Change all wordpress theme options page to same url?

Okay so im running a wordpress multisite installtion, with different themes, and i want to add a new tab to easy blogging which would go to the theme options page for the theme being used. Problem is each theme has a different url, one has “/wp-admin/admin.php?page=am_general” another has “/wp-admin/admin.php?page=website” another has “/wp-admin/admin.php?page=themepanel”, how can i change or add somesort of hack/plugin to make each url the same?

  • PC
    • WPMU DEV Initiate

    Hiya @aphects

    Greetings and thanks for posting on the forums.

    That is certainly gonna be a good level of custom work required to achieve that. While I can not comment on how easy is it to do, you can try posting a Job requirement here : https://premium.wpmudev.org/wpmu-jobs/

    If the theme options for the themes are appearing under the Appearance menu, then you can try and add that menu to the navigation so that it can be accessed via it.

    I have however tagged our lead developer @vladislav on this post to see if he has got some quick advice about the same.

    Cheers, PC

  • Vladislav
    • Dead Eye Dev

    Hi,

    Although this is certainly possible, perhaps there’s an easier way to achieve this – adding a custom Easy Blogging menu entry with the proper theme settings URL, based on the active theme. The basic idea would be to use something like “wp_get_theme” (http://codex.wordpress.org/Function_Reference/wp_get_theme ) to get the currently active theme, then use the Easy Blogging API to add a menu link. This could look a bit like in this generic example: https://premium.wpmudev.org/forums/topic/add-menu-items-to-easy-blogging#post-230384 Alternatively, a similar approach could be used to edit the existing theme settings menu item too. Do you think this approach could work for your scenario?

  • PC
    • WPMU DEV Initiate

    Hiya,

    While it has not been asked for before so I am not quite sure if @vladislav has got an example handy however as I suggested before, you can use the Job board link above to post a custom work requirement.

    Also what do you mean “edit the existing theme settings menu item too” ?

    He is referring to the Theme settings menu in Easy blogging plugin.

    Cheers, PC

  • Vladislav
    • Dead Eye Dev

    Hello,

    Of course, here is a working example that will work with our WP Nelo theme – if it’s activated on the current site, this example will add a link to its Gallery page (which normally wouldn’t be available in Easy mode):

    function wdeb_add_my_site_theme_custom_settings_page ($items) {
    $theme = wp_get_theme();
    $directory = !empty($theme->stylesheet) ? $theme->stylesheet : false;
    switch ($directory) {
    case "wpmu-nelo":
    $items[] = array(
    'check_callback' => false, // Custom callback function for access checking.
    'capability' => 'edit_theme_options', // User capability needed to access this page. Can be set to "false".
    'url' => 'themes.php?page=gallery.php', // The path to your page
    'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/edit-themes.png', // Full URL to your icon
    'title' => __('Upload Images', 'wdeb'),
    'help' => __('Upload images here - only jpg, gif and png allowed.', 'wdeb'),
    );
    break;
    }
    return $items;
    }
    add_filter('wdeb_menu_items', 'wdeb_add_my_site_theme_custom_settings_page');

    For sites that don’t have Nelo theme as their current theme, it’ll do nothing. As you see from the example, the $items that get passed to “wdeb_menu_items” filter is an array of menu items that will be shown in your Easy Blogging menu. Each menu item is represented as an associative array with several keys: check_callback, capability, url, icon, title and help, The idea here is to check the current theme and create a new menu item that links to that theme’s settings page.

    Since the menu items are simply an array, you can also easily remove all the links you wish removed, and/or edit the default ones to better suite your scenario. I hope this can get you started in the right direction.

  • aphects
    • Flash Drive

    Thank you so much, that looks very promising! Should i just add this as a plugin in “easyblogging/lib/plugins/” ? would i need to add more code to the new plugin .php file i make for this code? of would what you provided be enough?

  • Vladislav
    • Dead Eye Dev

    Hello,

    The code I added can go in a plugin, or a mu-plugin – which is basically just a .php file in your wp-content/mu-plugins directory, and it will be executed automatically, always, no activation needed. If you go with the mu-plugin approach, the code in the post above should be enough (just don’t forget to add the opening <?php tag at the beginning of the file).

  • aphects
    • Flash Drive

    @vladislav I added this code

    function wdeb_add_my_site_theme_custom_settings_page ($items) {
    $theme = wp_get_theme();
    $directory = !empty($theme->stylesheet) ? $theme->stylesheet : false;
    switch ($directory) {
    case "BasicKloud":
    $items[] = array(
    'check_callback' => false, // Custom callback function for access checking.
    'capability' => 'edit_theme_options', // User capability needed to access this page. Can be set to "false".
    'url' => 'themes.php?page=website.php', // The path to your page
    'icon' => WDEB_PLUGIN_THEME_URL . '/assets/icons/theme_icons/edit-themes.png', // Full URL to your icon
    'title' => __('Upload Images', 'wdeb'),
    'help' => __('Upload images here - only jpg, gif and png allowed.', 'wdeb'),
    );
    break;
    }
    return $items;
    }
    add_filter('wdeb_menu_items', 'wdeb_add_my_site_theme_custom_settings_page');

    To my mu-plugin approach and it does nothing :disappointed:, no new tab added whatsoever, using the theme “BasicKloud”. I do also have the <?php opening and closing tags.

  • Vladislav
    • Dead Eye Dev

    Hi,

    One thing I forgot to mention is that this snippet will check for the theme agains the directory where its stylesheet file is – in the case of WP Nelo, that’s “wpmu-nelo” (it’s also case sensitive). Is it perhaps possible that your theme isn’t in the directory named exactly “BasicKloud”?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.