0

I have been working in a wordpress multisite installation. Where I am using upPrev plugin that has an option page under Appearance ->> upPrev

Now what I need is to move this menu under Settings ->> upPrev without editing the core plugin file. Here is the code used to register the menu in upPrev.php :

          add_action( 'admin_menu',                 'iworks_upprev_add_pages' );

    function iworks_upprev_add_pages()
    {
    $dir = explode('/', dirname(__FILE__));
    $dir = $dir[ count( $dir ) - 1 ];
    if (current_user_can( 'manage_options' ) && function_exists('add_theme_page') ) {
        add_theme_page(
            __('upPrev', 'upprev'),
            __('upPrev', 'upprev'),
            'manage_options',
            $dir.'/admin/index.php'
        );
    }
}

I've tried using the code below to update menu :

  add_action( 'admin_menu', 'my_remove_tp', 999 );

function my_remove_tp() {
    remove_submenu_page( 'themes.php', 'upprev/admin/index.php' );
}


add_action('admin_menu', 'upprev_menu');
function upprev_menu(){
        //add_options_page('upPrev Menu', 'upPrev', 'manage_options', 'upprev/admin/index.php', 'upprev');  
        if (current_user_can( 'manage_options' ) && function_exists('add_options_page') ) {
    add_options_page(
        __('upPrev', 'upprev'),
        __('upPrev', 'upprev'),
        'edit_page', 'options-general.php?page=upprev/admin/index.php');
    }
}

Result : The menu is showing under settings but leads to an empty page... Any idea how it can be fixed ??

4
  • I am using the code in wp-content/mu-plugins/custom-plugin/cplugin.php
    – Abdul Awal
    Commented Jul 1, 2013 at 22:40
  • Please use the edit link instead of comments. And please also rework your post as the code styling didn't work out. There're WYSIWYG buttons for that.
    – kaiser
    Commented Jul 1, 2013 at 23:03
  • My site is in maintenance mode... And as it is an admin side issue, so I thunk posting code is perfect thing..
    – Abdul Awal
    Commented Jul 1, 2013 at 23:33
  • I meant the WYSIWYG editor here on this site - to format your question properly.
    – kaiser
    Commented Jul 1, 2013 at 23:43

1 Answer 1

0

I've fixed it... Posting the solution here if it helps someone... Here is the final code that fixed my problem :

/** Remove the Menu registered by Plugin **/
    add_action( 'admin_menu', 'my_remove_tp', 999 );

function my_remove_tp() {
    remove_submenu_page( 'themes.php', 'upprev/admin/index.php' );
}

/** Re-Register the menu from here **/ add_action('admin_menu', 'upprev_menu2');

function upprev_menu2(){ add_options_page('upPrev Menu', 'upPrev', 'manage_options', 'upprev/admin/index.php', '');
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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