awesomemotive / one-click-demo-import

One Click Demo Import plugin
https://www.awesomemotive.com/
195 stars 83 forks source link

Changing Plugin Page Location Throws 404 Not Found #224

Closed zamanq closed 3 years ago

zamanq commented 3 years ago

Hi again,

I tried to include the Demo Import admin page under my theme's admin page as subpage. It displays the menu title under my theme just fine but when clicked, it returns a 404 error and the url becomes http://mysite.com/wp-admin/my-custom-menu-slug, which should be something like http://mysite.com/wp-admin/admin.php?page=my-custom-menu-slug.

Please note that I followed this provided instruction to implement it:

function ocdi_plugin_page_setup( $default_settings ) { $default_settings['parent_slug'] = 'my-theme-slug'; $default_settings['page_title'] = esc_html__( 'One Click Demo Import' , 'pt-ocdi' ); $default_settings['menu_title'] = esc_html__( 'Import Demo Data' , 'pt-ocdi' ); $default_settings['capability'] = 'import'; $default_settings['menu_slug'] = 'my-custom-menu-slug';

return $default_settings;

} add_filter( 'pt-ocdi/plugin_page_setup', 'ocdi_plugin_page_setup' );

Any help is greatly appreciated!

capuderg commented 3 years ago

Hi,

I think the key is to use a "lower" priority number, in order for your WP custom menu to be added before our plugin tries to use that parent slug.

Please use this example: https://github.com/awesomemotive/one-click-demo-import/issues/53#issuecomment-253258096

I just tested and it works OK! Set the priority of your admin page action hook to 9, this is the relevant line from the example above: add_action( 'admin_menu', 'ocdi_add_menu_item', 9 );

Take care!