0

I cant get Redux Options Framework working for my plugin. I was trying to add the settings as submenu to my plugin.

I created a simplified demo plugin and could also approve this behaviour.

<?php
/**
 * Plugin Name: Redux sample plugin
 * Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
 * Description: A brief description of the Plugin.
 * Version: The Plugin's Version Number, e.g.: 1.0
 * Author: Name Of The Plugin Author
 * Author URI: http://URI_Of_The_Plugin_Author
 * License: A "Slug" license name e.g. GPL2
 */

require_once(plugin_dir_path(__FILE__) . 'inc/admin/admin-init.php'); 

function redux_sample_plugin_log() {
}

function createSettingsMenue() {

        $pluginSlug = 'redux_sample_plugin';
        //create new top-level menu
        add_menu_page('Redux Sample Plugin'),
                        'Redux Sample Plugin',
                        'administrator',
                        $pluginSlug . '_log',
                        'LogMenu'
                                );

        /*add_submenu_page( $pluginSlug . '_log',
                        null,
                        'Im a silly dummy entry',
                        'administrator',
                        'dummy',
                        '__return_null'  );*/
}
add_action( 'admin_menu', 'createSettingsMenue', 9 );

I changed the config to this:

...
    'page_slug' => 'my_plugin_settings',
    'page_title' => 'Settings'
    'menu_type' => 'submenu',
    'page_parent' => 'redux_sample_plugin_log',
...

The Menu is not shown with the code above (case 1 illustration). If you comment in the submenu function call the redux options are shown properely (case 2 illustration). I spent a lot of time but can't get it working. I was that sure it must be a bug that I opened a case at the github issue tracker (#1745) and also provided some additional details. They said I'm likely doing it wrong. Can somebody help me out?

//Edit Added screenshot for both cases

Cases

//Edit This behaviour is fixed in Redux 3.3.9.35. No need for adding another page as workaround any more.

Clarkie
  • 6,818
  • 8
  • 33
  • 52
No3x
  • 401
  • 1
  • 7
  • 23

3 Answers3

1

Trying adding lower priority for "admin_menu" hook. Priority 9 is working for me.

add_action( 'admin_menu', 'register_my_custom_menu_page', 9);

function register_my_custom_menu_page(){
    add_menu_page( "Options", "Options", 'manage_options', "slug_options", 'function_to_call', '', 81 );
    add_submenu_page( 'slug_options', 'My Custom Page', 'My Custom Page', 'manage_options', 'sub-menu-slug', 'function_to_call_sub');
}

Redux configuration:

'menu_type'            => 'submenu',
'allow_sub_menu'       => true,
'page_parent'          => "slug_options",
'page_permissions'     => 'manage_options',

Working fine for me.

Mrky
  • 11
  • 1
  • Well that's what I'm doing, isn't it? Please look at my sample plugin code above. The priority is 9. You just confirmed the behaviour that you need a submenu entry first! Otherwise the menu is not shown - and that's actually the issue here. – No3x Nov 20 '14 at 17:12
0

So Redux creates it's own menu. Are you trying to make it a sub-menu of a menu then?

Page parent is usually a php file...

Dovy
  • 1,210
  • 9
  • 18
  • Yes I try making it a submenu of a (registered top level) menu. Special case: there is no submenu in the menu yet -> redux doesn't appear. If I add at least one submenu also redux appears. (see added illustration) – No3x Oct 20 '14 at 19:38
0

This behaviour is fixed in Redux 3.3.9.35. No need for adding another page as workaround any more.

No3x
  • 401
  • 1
  • 7
  • 23