cleverington / elegant

An OOP + ACF + Timber / TWIG based WordPress theme.
4 stars 0 forks source link

Rebuild the usage of acf_add_options_page() in ACF.php #8

Open cleverington opened 2 years ago

cleverington commented 2 years ago

Not happy with it.

Its not OOP. You've got 'functional' code sitting alongside 'config' settings in a dumb way.

Not to mention that we shoe-horned the function altogether into the run() on ACF.php. It should be a stand-alone static function which, possibly, pulls from a 'config only' chunk of code.

In addition, there's no example and/or usage of acf_add_options_sub_page(), which is possibly one of the most useful features of the options pages.

Same for adding an example of adding a c-type specific options page:

<?php
       /**
     * Custom Post Type Options Pages
     */
    acf_add_options_page(
        // Add 'Example' Post Type Options Page.
        array(
            'page_title'  => 'Example Options',
            'menu_title'  => 'ExampleOptions',
            'menu_slug'   => 'options_example',
            'capability'  => 'edit_posts',
            'parent_slug' => 'edit.php?post_type=example',
            'position'    => false,
            'icon_url'    => 'dashicons-images-alt2',
            'redirect'    => false,
        ),
    );

Same for "theme" level ACF Settings:

<?php
      /**
     * Example: Default '404' options page
     *
     * @note: This could also be accomplished as a theme setting.
     */
    acf_add_options_page(
        array(
            'page_title'  => '404 Page Options',
            'parent_slug' => 'themes.php',
        )
    );