PHP code example of log1x / modern-acf-options

1. Go to this page and download the library: Download log1x/modern-acf-options library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

log1x / modern-acf-options example snippets


use StoutLogic\AcfBuilder\FieldsBuilder;

acf_add_options_page([
    'page_title' => get_bloginfo('name'),
    'menu_title' => 'Theme Options',
    'menu_slug' => 'theme-options',
    'update_button' => 'Update Options',
    'capability' => 'edit_theme_options',
    'position' => '999',
    'autoload' => true,
]);

$options = new FieldsBuilder('theme_options', [
    'style' => 'seamless',
]);

$options
    ->setLocation('options_page', '==', 'theme-options');

$options
    ->addTab('general')
        ->setConfig('placement', 'left')

        ->addAccordion('customization')
          ->addImage('logo')

        ->addAccordion('tracking')
            ->addText('gtm')
                ->setConfig('label', 'Google Tag Manager')
        ->addAccordion('tracking_end')->endpoint()

    ->addTab('advanced')
        ->setConfig('placement', 'left')

        ->addTrueFalse('debug')
          ->setConfig('ui', '1');

acf_add_local_field_group($options->build());

add_filter('acf_color_palette', function () {
    return [
        'brand' => '#0073aa',
        'trim' => '#181818',
    ];
});

use Illuminate\Support\Str;

/**
 * Disable Screen Options on the theme options page.
 *
 * @param  bool       $show
 * @param  \WP_Screen $screen
 * @return bool
 */
add_filter('screen_options_show_screen', function ($show, $screen) {
    if (is_a($screen, 'WP_Screen') && Str::contains($screen->base, 'theme-options')) {
        return false;
    }
}, 1, 2);

/**
 * Remove admin footer text.
 *
 * @return bool
 */
add_filter('admin_footer_text', '__return_false', 100);