Give editors access to particular plugin – turn “admin.php” into “edit.php”

I’m using the Business Opening Hours plugin. I made it appear in the sidebar using the Client Dash plugin, but when the Editor clicks it, they cannot access it, only the Admins, how can I change that?

I found some code snippets in the plugin, can I change something here?

if( is_admin() )
$bizohours_settings_page = new BizoHoursSettingPage();

public function __construct()
    {
        add_action( 'admin_menu', array( $this, 'bizohours_plugin_page' ) );
        add_action( 'admin_init', array( $this, 'bizohours_page_init' ) );
    }

/**
 * Add plugin page
 */
public function bizohours_plugin_page()
{
    // This page will be in "Dashboard Menu"
    add_menu_page(
        __('Settings Admin', 'bizo-hours'), 
        __('Öffnungszeiten', 'bizo-hours'), 
        'manage_options', 
        'bizohours-setting-admin', 
        array( $this, 'bizohours_admin_page' ),
        plugins_url( 'images/icon.png',__FILE__)
    );
}

1 Answer
1

As I mentioned, it’s not the best practice to edit the plugin’s source codes because this will be overwritten if you were to get the latest update from the author.

Nonetheless, to allow the Business Opening Hours plugin to show for your Editors open /business-opening-hours/bizo-hours.php and tweak the following lines. At the time of this writing, the current version for this plugin is v1.0.7:

Line 614-616

Replace

/**** Instantiate Class ****/
if( is_admin() )
    $bizohours_settings_page = new BizoHoursSettingPage();

With

/**** Instantiate Class ****/
$bizohours_settings_page = new BizoHoursSettingPage();

Lines 26-40

Replace

/**
 * Add plugin page
 */
public function bizohours_plugin_page()
{
    // This page will be in "Dashboard Menu"
    add_menu_page(
        __('Settings Admin', 'bizo-hours'), 
        __('Business Hours', 'bizo-hours'), 
        'manage_options', 
        'bizohours-setting-admin', 
        array( $this, 'bizohours_admin_page' ),
        plugins_url( 'images/icon.png',__FILE__)
    );
}

With

/**
 * Add plugin page
 */
public function bizohours_plugin_page()
{
    // This page will be in "Dashboard Menu"
    add_menu_page(
        __('Settings Admin', 'bizo-hours'), 
        __('Business Hours', 'bizo-hours'), 
        'edit_others_pages', 
        'bizohours-setting-admin', 
        array( $this, 'bizohours_admin_page' ),
        plugins_url( 'images/icon.png',__FILE__)
    );
}

Leave a Comment