StoutLogic / acf-builder

An Advanced Custom Field Configuration Builder
GNU General Public License v2.0
793 stars 62 forks source link

display => seamless not working for option page #106

Open thomasjulienalain opened 4 years ago

thomasjulienalain commented 4 years ago

Hello !

I created an option page and I want to enable the seamless style. It's not working as expected and still display the metabox.

Seamless is working fine for my other pages, but not for the theme options page. I'm using ACF Builder 1.9 and ACF Pro 5.8.7.

image

namespace App;

use StoutLogic\AcfBuilder\FieldsBuilder;

acf_add_options_page( array(
    'page_title'    => 'Gérer les options du site',
    'menu_title'    => 'Options du site',
    'menu_slug'     => 'theme-options',
    'capability'    => 'edit_others_pages',
    'position'      => 21
) );

$theme_options = new FieldsBuilder('theme_options ', [
    'label' => 'Options du thème',
    'style' => 'seamless'
]);

[...]

return $theme_options;
stevep commented 4 years ago

When you do print_r($theme_options->build()); what is the output?

thomasjulienalain commented 4 years ago
Array
(
    [key] => group_theme_options 
    [title] => Theme Options 
    [label] => Options du thème
    [style] => seamless
    [fields] => Array
        (
            [0] => Array
                (
                    [type] => accordion
                    [name] => accordion_1_accordion
                    [label] => Coordonnées
                    [key] => field_theme_options__accordion_1_accordion
                    [open] => 1
                )

            [1] => Array
                (
                    [type] => textarea
                    [name] => address
                    [label] => Adresse postale
                    [key] => field_theme_options__address
                    [required] => 1
                    [new_lines] => br
                )

            [2] => Array
                (
                    [type] => url
                    [name] => address_gmap
                    [label] => Lien Google Map
                    [key] => field_theme_options__address_gmap
                    [required] => 1
                )

            [3] => Array
                (
                    [type] => text
                    [name] => telephone
                    [label] => Numéro de téléphone
                    [key] => field_theme_options__telephone
                    [required] => 1
                )

            [4] => Array
                (
                    [type] => email
                    [name] => email
                    [label] => Adresse courriel
                    [key] => field_theme_options__email
                    [required] => 1
                )

            [5] => Array
                (
                    [type] => text
                    [name] => fax
                    [label] => Numéro de télécopieur
                    [key] => field_theme_options__fax
                    [required] => 1
                )

            [6] => Array
                (
                    [type] => url
                    [name] => facebook
                    [label] => Lien facebook
                    [key] => field_theme_options__facebook
                    [required] => 1
                )

            [7] => Array
                (
                    [type] => accordion
                    [name] => accordion_1_end_accordion
                    [label] => Accordion 1 End
                    [key] => field_theme_options__accordion_1_end_accordion
                    [endpoint] => 1
                )

            [8] => Array
                (
                    [type] => accordion
                    [name] => accordion_2_accordion
                    [label] => Pied de page
                    [key] => field_theme_options__accordion_2_accordion
                )

            [9] => Array
                (
                    [type] => text
                    [name] => telephone_label
                    [label] => Libellé pour le téléphone
                    [key] => field_theme_options__telephone_label
                    [required] => 1
                    [default_value] => Téléphone
                )

            [10] => Array
                (
                    [type] => text
                    [name] => email_label
                    [label] => Libellé pour le courriel
                    [key] => field_theme_options__email_label
                    [required] => 1
                    [default_value] => Courriel
                )

            [11] => Array
                (
                    [type] => text
                    [name] => address_label
                    [label] => Libellé pour l'adresse postale
                    [key] => field_theme_options__address_label
                    [required] => 1
                    [default_value] => Adresse
                )

            [12] => Array
                (
                    [type] => text
                    [name] => fax_label
                    [label] => Libellé pour le télécopieur
                    [key] => field_theme_options__fax_label
                    [required] => 1
                    [default_value] => Télécopieur
                )

            [13] => Array
                (
                    [type] => text
                    [name] => social_label
                    [label] => Libellé pour les réseaux sociaux
                    [key] => field_theme_options__social_label
                    [required] => 1
                    [default_value] => Nous suivre
                )

            [14] => Array
                (
                    [type] => textarea
                    [name] => company_excerpt
                    [label] => Résumé de l'entreprise
                    [key] => field_theme_options__company_excerpt
                    [required] => 1
                    [new_lines] => br
                )

            [15] => Array
                (
                    [type] => accordion
                    [name] => accordion_2_end_accordion
                    [label] => Accordion 2 End
                    [key] => field_theme_options__accordion_2_end_accordion
                    [endpoint] => 1
                )

        )

    [location] => Array
        (
            [0] => Array
                (
                    [0] => Array
                        (
                            [param] => options_page
                            [operator] => ==
                            [value] => theme-options
                        )

                )

        )

)
stevep commented 4 years ago

@thomasjulienalain Hm I'm not sure, it should be working. If you try with the ACF UI, does it work?

thomasjulienalain commented 4 years ago

@stevep Yes it's working with ACF UI. It's really weird.

wpsmith commented 4 years ago

I assume you are doing this, right?

acf_add_local_field_group($theme_options->build());
wpsmith commented 4 years ago

Recommend closing as this works @stevep.

thomasjulienalain commented 4 years ago

Hello ! Yes I use acf_add_local_field_group($theme_options->build()); to load the filds. I am using sage theme.

/**
 * Initialize ACF Builder
 */
add_action('init', function () {
    collect(glob(config('theme.dir').'/app/fields/*.php'))->map(function ($field) {
        return require_once($field);
    })->map(function ($field) {
        if ($field instanceof FieldsBuilder) {
            acf_add_local_field_group($field->build());
        }
    });
});

What I wanted to say is that when I use the ACF plugin in UI mode, the custom group option's title display correctely.

But I still can't make it work with ACF Builder.