diff --git a/class/MainWPChild.class.php b/class/MainWPChild.class.php index eae3350..076a7d0 100644 --- a/class/MainWPChild.class.php +++ b/class/MainWPChild.class.php @@ -154,28 +154,52 @@ class MainWPChild function admin_menu() { - // hide menu + if (get_option('mainwp_branding_remove_wp_tools')) { + remove_menu_page( 'tools.php' ); + $pos = stripos($_SERVER['REQUEST_URI'], 'tools.php') || + stripos($_SERVER['REQUEST_URI'], 'import.php') || + stripos($_SERVER['REQUEST_URI'], 'export.php'); + if ($pos !== false) + wp_redirect(get_option('siteurl') . '/wp-admin/index.php'); + } + + if (get_option('mainwp_branding_remove_wp_setting')) { + remove_menu_page( 'options-general.php' ); + $pos = stripos($_SERVER['REQUEST_URI'], 'options-general.php') || + stripos($_SERVER['REQUEST_URI'], 'options-writing.php') || + stripos($_SERVER['REQUEST_URI'], 'options-reading.php') || + stripos($_SERVER['REQUEST_URI'], 'options-discussion.php') || + stripos($_SERVER['REQUEST_URI'], 'options-media.php') || + stripos($_SERVER['REQUEST_URI'], 'options-permalink.php'); + if ($pos !== false) + wp_redirect(get_option('siteurl') . '/wp-admin/index.php'); + } + + // hide menu if (get_option('mainwp_branding_child_hide') == 'T') return; $branding_header = get_option('mainwp_branding_plugin_header'); if (is_array($branding_header) && !empty($branding_header['name'])) - $this->branding = $branding_header['name']; + $this->branding = stripslashes($branding_header['name']); - add_options_page('MainWPSettings', __($this->branding . ' Settings','mainwp-child'), 'manage_options', 'MainWPSettings', array(&$this, 'settings')); + if (!get_option('mainwp_branding_remove_setting')) + add_options_page('MainWPSettings', __($this->branding . ' Settings','mainwp-child'), 'manage_options', 'MainWPSettings', array(&$this, 'settings')); + + if (!get_option('mainwp_branding_remove_restore')) { + $restorePage = add_submenu_page('tools.php', $this->branding . ' Restore', '', 'read', 'mainwp-child-restore', array('MainWPClone', 'renderRestore')); + add_action('admin_print_scripts-'.$restorePage, array('MainWPClone', 'print_scripts')); - $restorePage = add_submenu_page('tools.php', $this->branding . ' Restore', '', 'read', 'mainwp-child-restore', array('MainWPClone', 'renderRestore')); - add_action('admin_print_scripts-'.$restorePage, array('MainWPClone', 'print_scripts')); - - $sitesToClone = get_option('mainwp_child_clone_sites'); - if ($sitesToClone != '0') - { - MainWPClone::init_menu($this->branding); - } - else - { - MainWPClone::init_restore_menu($this->branding); + $sitesToClone = get_option('mainwp_child_clone_sites'); + if ($sitesToClone != '0') + { + MainWPClone::init_menu($this->branding); + } + else + { + MainWPClone::init_restore_menu($this->branding); + } } } diff --git a/class/MainWPChildBranding.class.php b/class/MainWPChildBranding.class.php index b05c12c..231006b 100644 --- a/class/MainWPChildBranding.class.php +++ b/class/MainWPChildBranding.class.php @@ -16,20 +16,7 @@ class MainWPChildBranding public function __construct() { - $this->child_plugin_dir = dirname(dirname(__FILE__)); - $default_header = get_option('mainwp_branding_default_header', false); - if (empty($default_header)) - { - $info = get_plugin_data($this->child_plugin_dir . '/mainwp-child.php'); - if (is_array($info)) - { - $default_header = array('name' => $info['Name'], - 'description' => $info['Description'], - 'authoruri' => $info['AuthorURI'], - 'author' => $info['Author']); - update_option('mainwp_branding_default_header', $default_header); - } - } + $this->child_plugin_dir = dirname(dirname(__FILE__)); add_action('mainwp_child_deactivation', array($this, 'child_deactivation')); } @@ -50,6 +37,10 @@ class MainWPChildBranding 'mainwp_branding_show_support', 'mainwp_branding_support_email', 'mainwp_branding_support_message', + 'mainwp_branding_remove_restore', + 'mainwp_branding_remove_setting', + 'mainwp_branding_remove_wp_tools', + 'mainwp_branding_remove_wp_setting', 'mainwp_branding_plugin_header'); foreach ($dell_all as $opt) { @@ -85,6 +76,10 @@ class MainWPChildBranding update_option('mainwp_branding_plugin_header', $header); update_option('mainwp_branding_support_email', $settings['child_support_email']); update_option('mainwp_branding_support_message', $settings['child_support_message']); + update_option('mainwp_branding_remove_restore', $settings['child_remove_restore']); + update_option('mainwp_branding_remove_setting', $settings['child_remove_setting']); + update_option('mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools']); + update_option('mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting']); if ($settings['child_plugin_hide']) { @@ -119,7 +114,7 @@ class MainWPChildBranding public function branding_init() { - add_filter('map_meta_cap', array($this, 'theme_plugin_disable_change'), 10, 5); + add_filter('map_meta_cap', array($this, 'branding_map_meta_cap'), 10, 5); add_filter('all_plugins', array($this, 'branding_child_plugin')); add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2); @@ -210,7 +205,7 @@ class MainWPChildBranding