• Resolved looking3

    (@looking3)


    Hi.

    I want to change demo menu location theme.php to custom menu.
    So I changed ‘parent_slug’ which is themes.php to my-custom-menu.
    The menu change to my custom menu but it is not working.
    When I click the demo menu at my custom menu, link to 404 page.
    I want to know, what shoud I do.

    Help~

    thank you….

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    did you follow the instructions in the FAQ: https://wordpress.org/plugins/one-click-demo-import/#faq for the question “How to change the location, title and other parameters of the plugin page?” ?

    Take care!

    Thread Starter looking3

    (@looking3)

    Hi,

    I tried that already but it is not working…..

    My codes are..

    
    ******************************************************************
    function ocdi_plugin_page_setup( $default_settings ) {
    	$default_settings['parent_slug'] = 'mytheme-builder-demo';
    	$default_settings['page_title']  = esc_html__( 'Demo Import' , 'sonnet' );
    	$default_settings['menu_title']  = esc_html__( 'Import Demo Data' , 'sonnet' );
    	$default_settings['capability']  = 'manage_options';
    //	$default_settings['menu_slug']   = 'admin.php?page=theme-sonnet-demo-import';
    	$default_settings['menu_slug']   = 'theme-sonnet-demo-import';
    
    	return $default_settings;
    }
    add_filter( 'pt-ocdi/plugin_page_setup', 'ocdi_plugin_page_setup' );
    *************************************************************************
    

    I need your help….

    I look forward to your reply.

    Thank you.

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    I think the parent_slug parameter has to be one of the main WP menu sections. Please look at this comment: https://developer.wordpress.org/reference/functions/add_submenu_page/#user-contributed-notes

    Take care!

    Thread Starter looking3

    (@looking3)

    Hi,
    Thank you for your reply.
    but I have still problem.

    Do you know how can add demo import at custom menu page which is I made it?

    when I make menu page, the menu page url is ~admin.php.

    I wana to konw how demo importer add the admin.php.

    I need your help….

    I look forward to your reply.

    Thank you.

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    can you please show me the code you used to create the new top level custom wp-admin menu item?

    Take care!

    Thread Starter looking3

    (@looking3)

    Hi,

    Here is my code…

    
    //////////   menu-resister.php   /////////////
    
    function welcome_screen() {
    	require_once 'admin-screens/welcome-test.php';
    }
    function sub_screen() {
    	require_once 'admin-screens/sub-test-2.php';
    }
    
    add_action( 'admin_menu', 'sonnet_options_menu');
    
    function sonnet_options_menu(){
    	add_menu_page (
    		'Welcome',             
    		'MY CUSTOM THEME',        
    		'switch_themes',       
    		'custom-builder-demo',   
    		'',                    
    		'',                    
    		'2.111111'             
    	);
    
    	add_submenu_page(
    		'custom-builder-demo',            
    		esc_attr__('Welcome', 'shin'),  
    		esc_attr__('Welcome', 'shin'),  
    		'edit_theme_options',           
    		'custom-builder-demo',            
    		'welcome_screen'                
    	);
    
    	add_submenu_page(
    		'custom-builder-demo',
    		esc_attr__('sub 2', 'shin'),
    		esc_attr__('sub 2', 'shin'),
    		'manage_options',
    		'sonnet-sub2',
    		'sub_screen'
    	);
    }  
    ////////////////////////////////////////////////////
    
    //////////   demo-import.php   /////////////
    
    function ocdi_plugin_page_setup( $settings ) {
    	$settings['parent_slug'] = 'custom-builder-demo'; 
    	$settings['page_title']  = esc_html__( 'Demo Import' , 'pt-ocdi' );
    	$settings['menu_title']  = esc_html__( 'Import Demo Data' , 'pt-ocdi' );
    	$settings['capability']  = 'edit_theme_options';
    	$settings['menu_slug']   = 'custom-one-click-demo-import';
    
    	return $settings;
    }
    add_filter( 'pt-ocdi/plugin_page_setup', 'ocdi_plugin_page_setup' );
    
    //////////////////////////////////////////////////////////
    

    I made 2 php files and the codes are up there…..

    Please Help…

    I look foward to your reply.

    Thank you….

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Please wrap your code using the code button. If you don’t then all you are sharing is an unreadable mess.

    Thread Starter looking3

    (@looking3)

    
    /////////   menu-resister.php   /////////////
    
    function welcome_screen() {
    	require_once 'admin-screens/welcome-test.php';
    }
    function sub_screen() {
    	require_once 'admin-screens/sub-test-2.php';
    }
    
    add_action( 'admin_menu', 'sonnet_options_menu');
    
    function sonnet_options_menu(){
    	add_menu_page (
    		'Welcome',             
    		'MY CUSTOM THEME',        
    		'switch_themes',       
    		'custom-builder-demo',   
    		'',                    
    		'',                    
    		'2.111111'             
    	);
    
    	add_submenu_page(
    		'custom-builder-demo',            
    		esc_attr__('Welcome', 'shin'),  
    		esc_attr__('Welcome', 'shin'),  
    		'edit_theme_options',           
    		'custom-builder-demo',            
    		'welcome_screen'                
    	);
    
    	add_submenu_page(
    		'custom-builder-demo',
    		esc_attr__('sub 2', 'shin'),
    		esc_attr__('sub 2', 'shin'),
    		'manage_options',
    		'sonnet-sub2',
    		'sub_screen'
    	);
    }  
    
    
    //////////   demo-import.php   /////////////
    
    function ocdi_plugin_page_setup( $settings ) {
    	$settings['parent_slug'] = 'custom-builder-demo'; 
    	$settings['page_title']  = esc_html__( 'Demo Import' , 'pt-ocdi' );
    	$settings['menu_title']  = esc_html__( 'Import Demo Data' , 'pt-ocdi' );
    	$settings['capability']  = 'edit_theme_options';
    	$settings['menu_slug']   = 'custom-one-click-demo-import';
    
    	return $settings;
    }
    add_filter( 'pt-ocdi/plugin_page_setup', 'ocdi_plugin_page_setup' );
    

    I made 2 php files and the codes are up there…..

    Please Help…

    I look foward to your reply.

    Thank you….

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    the issue in your case was that the OCDI plugin add_submenu_page call was triggered before your custom wp-admin page was even created.

    You can solve that, but setting the priority for this line:
    add_action( 'admin_menu', 'sonnet_options_menu');

    change it to:
    add_action( 'admin_menu', 'sonnet_options_menu', 9);

    Take care!

    Thread Starter looking3

    (@looking3)

    Hi,

    Thank you!
    It is working now~!

    Thank you~~~!

    Plugin Author Gregor Capuder

    (@capuderg)

    No problem.

    Have a nice day!

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Change the menu location’ is closed to new replies.