Code Monkey home page Code Monkey logo

acf-migrations's People

Contributors

jamiewarb avatar olivertappin avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

acf-migrations's Issues

Missing functionality when compared to ACF

As shown in #7, there is some missing functionality that this plugin does not support, and instead provides hard-coded, default values for.

This issue aims to collect that information, and record the progress of implementing it.

The following functionality has been identified as missing:

Field [addField()]

  • group - Does not get added to the field object (does work when added to a subfield though).

Field Group [addFieldGroup()]

  • position - currently hard-coded as 'normal'
  • menu_order - currently hard-coded as '0'

Layout [addLayout()]

  • label - currently the name prettified, and is not overridable (but gives an error if not specified)

Locations parameter in addFieldGroup function does not support multiple arrays

When creating a new field group with multiple locations, the exported code is in the wrong format. For example:

$migrations->addFieldGroup( 'global', [
        [
            'param' => 'post_type',
            'operator' => '==',
            'value' => 'page'
        ],
        [
            'param' => 'post_type',
            'operator' => '==',
            'value' => 'portfolio'
        ]
    ], [
        'hide_on_screen' => ['content_editor']
    ] )
    ->addField( 'image', 'Hero image' );

produces the following code within the export file:

...
"location" => [
    [
        [
            "param" => "post_type",
            "operator" => "==",
            "value" => "page"
        ],
        [
            "param" => "post_type",
            "operator" => "==",
            "value" => "portfolio"
        ]
    ]
],
...

when the arrays should be one level back, like so:

...
"location" => [
    [
        [
            "param" => "post_type",
            "operator" => "==",
            "value" => "page"
        ]
    ],
    [
        [
            "param" => "post_type",
            "operator" => "==",
            "value" => "portfolio"
        ]
    ]
],
...

Executable returns error when migrations class is empty

When you have a blank migrations file, with just:

<?php
$migrations = new Migrations;

and run the executable, the script returns a PHP error:

PHP Warning:  Invalid argument supplied for foreach() in phar:///Users/oliver/Sites/test/acf-migrations.phar/generate.php on line 484

Warning: Invalid argument supplied for foreach() in phar:///Users/oliver/Sites/test/acf-migrations.phar/generate.php on line 484
--> Successfully generated migrations export file

Phar unable to run on servers

The compiled phar, with the new repeater in repeater functionality, is unable to run on our servers. A Segmentation Fault is given. Likely to do with compilation of file

Potential repeater in repeater bug

Hi,

I'm using a repeater inside of a repeater in flexible content, and it's working just fine.

However, when I come to use it inside a field group for a page template, the second repeater isn't having it's subfields added inside of it, and no errors are flagged in the terminal on export.

Below is an isolated snippet to test:

<?php

$migrations = new Migrations;
$migrations->addFieldGroup( 'courses', [
        'page_template',
        '==',
        'templates/courses.php'
    ], [
        'hide_on_screen' => [ 'content_editor' ]
    ] )
    ->addField( 'repeater', 'Foo', [
        'layout' => 'block',
        'button_label' => 'Add Category',
        'min' => 1
    ] )
        ->addSubField( 'repeater', 'Bar', 1, [
            'layout' => 'block',
            'button_label' => 'Add Category',
            'min' => 1
        ] )
            ->addSubField( 'text', 'Group Title', 2 );

The exported snippet can be viewed in the following screenshot. The first set, with repeaters 'Foo' and 'Bar' are generated from the code above. The set beneath that are generated inside the 'Custom Fields' plugin on the site, to highlight that it should be possible, and therefore is most likely a bug in this generator plugin.

image

Cheers

Position is not able to be changed

When using the position attribute to move a group to the sidebar of the edit page, I've encountered an error with the migrations script.

It appears that the option is added always as position => normal, even when position => side is declared, as shown below.

The expected outcome as created in Custom Fields plugin:

acf_add_local_field_group(array (
    ...
    'menu_order' => 0,
    'position' => 'side',
    'style' => 'default',
    'label_placement' => 'top',
    'instruction_placement' => 'label',
    'hide_on_screen' => '',
    'active' => 1,
    'description' => '',
));

The actual outcome in export.php:

...
"options" => [
    "position" => "normal",
    "hide_on_screen" => ""
],
"menu_order" => 0,
"position" => "side",
"style" => "default",
"label_placement" => "top",
"instruction_placement" => "label",
"hide_on_screen" => "",
"active" => 1,
"description" => ""

The problem persists even when explicitly defining the options array in migrations:

'position' => 'side',
'options' => [
    'position' => 'side',
],

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.