plugin_name = $plugin_name; $this->version = $version; } /** * This function introduces the theme options into the 'Appearance' menu and into a top-level * 'HMP' menu. */ public function setup_plugin_options_menu() { //Add the menu to the Plugins set of menu items add_options_page( 'Admin block', // The title to be displayed in the browser window for this page. 'Admin block', // The text to be displayed for this menu item 'manage_options', // Which type of users can see this menu item 'abbi_options', // The unique ID - that is, the slug - for this menu item array( $this, 'render_settings_page_content'), // The name of the function to call when rendering this menu's page 'dashicons-lock' ); } /** * Provides default values for the Display Options. * * @return array */ public function default_advanced_options() { $defaults = array( 'hide_wplogins' => '127.0.0.1', 'enable_devmode' => '', 'maintenance' => '/maintenance.html' ); return $defaults; } /** * Provide default values for the Social Options. * * @return array */ public function default_abbi_help() { $defaults = array( ); return $defaults; } /** * Renders a simple page to display for the theme menu defined above. */ public function render_settings_page_content( $active_tab = '' ) { ?>
' . __('Enter which IPs wish to display wp-admin.', 'admin-allow-by-ip') . ''; } // end general_options_callback /** * Initializes the theme's display options page by registering the Sections, * Fields, and Settings. * * This function is registered with the 'admin_init' hook. */ public function initialize_advanced_options() { // If the theme options don't exist, create them. if ( false == get_option('abbi_options_advanced_options') ) { $default_array = $this->default_advanced_options(); add_option('abbi_options_advanced_options', $default_array); } add_settings_section( 'general_settings_section', // ID used to identify this section and with which to register options __('Development mode', 'admin-allow-by-ip'), // Title to be displayed on the administration page array( $this, 'general_options_callback'), // Callback used to render the description of the section 'abbi_options_advanced_options' // Page on which to add this section of options ); add_settings_field( 'enable_devmode', __('Enable Development', 'admin-allow-by-ip'), array( $this, 'toggle_block_callback'), 'abbi_options_advanced_options', 'general_settings_section', array( __('Enable developing mode for below IP(s).', 'admin-allow-by-ip'), ) ); // Next, we'll introduce the fields for toggling the visibility of content elements. add_settings_field( 'hide_wplogins', // ID used to identify the field throughout the theme __('Hide wp logins', 'admin-allow-by-ip'), // The label to the left of the option interface element array( $this, 'toggle_ips_callback'), // The name of the function responsible for rendering the option interface 'abbi_options_advanced_options', // The page on which this option will be displayed 'general_settings_section', // The name of the section to which this field belongs array( // The array of arguments to pass to the callback. In this case, just a description. __('ex - 192.168.1.2,192.168.1.3', 'admin-allow-by-ip'), ) ); add_settings_field( 'redirect_location', __('Redirect location', 'dmin-allow-by-ip'), array( $this, 'select_direction_callback'), 'abbi_options_advanced_options', 'general_settings_section' ); // Finally, we register the fields with WordPress register_setting( 'abbi_options_advanced_options', 'abbi_options_advanced_options', array( $this, 'validate_input_examples') ); } // end wppb-demo_initialize_theme_options public function initialize_help_options() { // add_settings_section( // 'general_settings_section', // ID used to identify this section and with which to register options // __('Development mode', 'admin-allow-by-ip'), // Title to be displayed on the administration page // array( $this, 'general_options_callback'), // Callback used to render the description of the section // 'abbi_options_help_options' // Page on which to add this section of options // ); // add_settings_field( // 'enable_devmode', // __( 'Enable Development', 'admin-allow-by-ip' ), // array( $this, 'toggle_block_callback'), // 'abbi_options_help_options', // 'general_settings_section', // array( // __( 'Enable developing mode for below IP(s).', 'admin-allow-by-ip' ), // ) // ); } public function toggle_block_callback($args) { $options = get_option('abbi_options_advanced_options'); $devmode = "enable_devmode"; $checked = checked(1, isset($options['enable_devmode']) ? $options['enable_devmode'] : 0, false); $html = ''; $html .= ""; $allowed_html = array( 'input' => array( 'type' => array(), 'id' => array(), 'name' => array(), 'value' => array(), 'checked' => array() ), ); echo wp_kses($html, $allowed_html); } public function select_direction_callback() { $options = get_option('abbi_options_advanced_options'); $url = get_site_url().'/maintenance.html'; $page_status = $this->check_404($url); $html = '