Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created an custom admin menu page called FCC Youtube with add_menu_page function which has some custom fields I manually generated via HTML and PHP:

code ( just the part how I created this custom admin menu page )

// creat admin menu page 
add_action("admin_menu","youtube_menu");
function youtube_menu() {
        add_menu_page('Youtube Channel Settings', 'FCC Youtube', 'edit_pages', 'youtube_channel_settings', 'youtube_channel_render_page','http://fcc.sportingpulse.com/wp-content/uploads/2013/04/youtube_icon16x16.png');
        add_action('admin_init','youtube_regsettings');
    }

see image

I want to create many admin menu pages like the FCC Youtube page I've created. ( FCC Vimeo, FCC Buttons etc.)

I wish these pages have ACF field groups. , means I can create ACF field groups and assign the group to my custom admin menu pages It will work exactly like ACF Option-addon page.

ACF Option-addon doesn't allow me to create multiple top level Options page. I understand I can create multiple second-level option page but I wish to have many TOP Level ones, but I still can't figure out how to do this!

I have purchased the Option add-on but it doesn't allow me to create multiple "top level" Option page, I only have a parent page called "Options" then lots of sub pages under it, I wish to have other "Top Level" pages have other names than "Options" , but it seems very difficult to do : s,

see this enter image description here

I have all these bunch of options page under the Parent 'Options', I can't move them outside of the parent

enter image description here

share|improve this question
    
Why not use the Settings API? codex.wordpress.org/Settings_API –  Andrew Bartel Apr 16 '13 at 6:17
    
thanks for the idea man I will have a read ! –  Ray Tsai Apr 16 '13 at 6:24
    
I just wished I can have a page that can go into editing content straight away, like this:ray-tsai.com/fcc_custom_bt.png, instead of seeing this page first :ray-tsai.com/fcc_custom_bt2.png, and then going into the editing page, I don't need my clients to see the multiple posts page. –  Ray Tsai Apr 16 '13 at 6:30
    
hi man I've put in more details hopefully it is now more clear ! –  Ray Tsai Apr 17 '13 at 4:35
    
So, you want an ACF Options Page premium add-on without premium? –  brasofilo Apr 17 '13 at 4:41
show 5 more comments

1 Answer

Interesting exercise, a one page plugin that believes it deserves a first level menu page is wrong, IMO. I use the same technique with Jetpack.

To create sub-pages in the Options Page add-on, read the documentation.

The logic of this menu/sub-menu swapping is:

  1. Add multiple ACF Options Pages
  2. Create our menu first level page
  3. Remove (hide) our plugin page
  4. Add (move) our plugin page into ACF's

Steps 1 and 2 are to make this example generic.
To use it with any other plugin, only steps 3 and 4 are necessary, adjusting the slugs.
To move it into a default WP menu, for example, use add_theme_page (Appearance) or add_options_page (Settings).

<?php
/**
 * Plugin Name: Swap Menus and Sub-menus
 * Plugin URI: http://wordpress.stackexchange.com/q/95981/12615
 * Author: brasofilo
 * Author URI: http://wordpress.stackexchange.com/users/12615/brasofilo
 * Licence: GPLv2 or later
 */

class Swap_Menus_WPSE_95981 {

    function __construct()
    {
        add_action( 'plugins_loaded', array( $this, 'modify_menus' ) );
    }

    function modify_menus() 
    {
        // 1) Add ACF Options pages
        if( function_exists( "register_options_page" ) )
        {
            register_options_page( 'Header' );
            register_options_page( 'Footer' );
        }

        // 2) Create this plugin page
        add_action( 'admin_menu', array( $this, 'add_aux_menu' ) );

        // 3) Remove (hide) this plugin page
        add_action( 'admin_init', array( $this, 'remove_aux_menu' ) );

        // 4) Move this plugin page into ACF Options page
        // Priority here (9999) is to put the submenu at last postition
        // If the priority is removed, the submenu is put at first position
        add_action( 'admin_menu', array( $this, 'add_aux_menu_again'), 9999 );
    }

    function add_aux_menu() 
    {
        add_menu_page(
            'Dummy Page First Level', 
            'Dummy Title', 
            'edit_posts', 
            'dummy-page-slug', 
            array( $this, 'menu_page_content' )
        );
    }

    function menu_page_content() 
    {
        ?>
            <div id="icon-post" class="icon32"></div>
            <h2>Dummy Page</h2>
            <p> Lorem ipsum</p>
        <?php
    }

    function remove_aux_menu() 
    {
        remove_menu_page( 'dummy-page-slug' ); 
    }


    function add_aux_menu_again() 
    {
        // To move into default pages, f.ex., use add_theme_page or add_options_page
        add_submenu_page(
            'acf-options-header', // <---- Destination menu slug
            'Dummy Page Second Level', 
            'Dummy Page Second Level', 
            'edit_posts', 
            'dummy-page-slug', 
            array( $this, 'menu_page_content' )
        );
    }
}

new Swap_Menus_WPSE_95981();
share|improve this answer
    
this is cool thanks a lot man ! but I still can't use the field group I have created via ACF in my custom admin menu page .. –  Ray Tsai Apr 17 '13 at 3:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.