Child Theme Settings. * * @package BE Genesis Child * @author Bill Erickson * @copyright Copyright (c) 2011, Bill Erickson * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later) * @link https://github.com/billerickson/BE-Genesis-Child */ /** * Registers a new admin page, providing content and corresponding menu item * for the Child Theme Settings page. * * @package BE Genesis Child * @subpackage Admin * * @since 1.0.0 */ class Child_Theme_Settings extends Genesis_Admin_Boxes { /** * Create an admin menu item and settings page. * * @since 1.0.0 */ function __construct() { // Specify a unique page ID. $page_id = 'child'; // Set it as a child to genesis, and define the menu and page titles $menu_ops = array( 'submenu' => array( 'parent_slug' => 'genesis', 'page_title' => 'Genesis - Child Theme Settings', 'menu_title' => 'Child Theme Settings', ) ); // Set up page options. These are optional, so only uncomment if you want to change the defaults $page_ops = array( // 'screen_icon' => 'options-general', // 'save_button_text' => 'Save Settings', // 'reset_button_text' => 'Reset Settings', // 'save_notice_text' => 'Settings saved.', // 'reset_notice_text' => 'Settings reset.', ); // Give it a unique settings field. // You'll access them from genesis_get_option( 'option_name', 'child-settings' ); $settings_field = 'child-settings'; // Set the default values $default_settings = array( 'phone' => '', 'address' => '', ); // Create the Admin Page $this->create( $page_id, $menu_ops, $page_ops, $settings_field, $default_settings ); // Initialize the Sanitization Filter add_action( 'genesis_settings_sanitizer_init', array( $this, 'sanitization_filters' ) ); } /** * Set up Sanitization Filters * * See /lib/classes/sanitization.php for all available filters. * * @since 1.0.0 */ function sanitization_filters() { genesis_add_option_filter( 'no_html', $this->settings_field, array( 'phone', 'address', ) ); } /** * Set up Help Tab * Genesis automatically looks for a help() function, and if provided uses it for the help tabs * @link http://wpdevel.wordpress.com/2011/12/06/help-and-screen-api-changes-in-3-3/ * * @since 1.0.0 */ function help() { $screen = get_current_screen(); $screen->add_help_tab( array( 'id' => 'sample-help', 'title' => 'Sample Help', 'content' => '

Help content goes here.

', ) ); } /** * Register metaboxes on Child Theme Settings page * * @since 1.0.0 * * @see Child_Theme_Settings::contact_information() Callback for contact information */ function metaboxes() { add_meta_box('contact-information', 'Contact Information', array( $this, 'contact_information' ), $this->pagehook, 'main', 'high'); } /** * Callback for Contact Information metabox * * @since 1.0.0 * * @see Child_Theme_Settings::metaboxes() */ function contact_information() { echo '

Phone:
'; echo ''; echo '

'; echo '

Address

'; echo '

'; } } add_action( 'genesis_admin_menu', 'be_add_child_theme_settings' ); /** * Add the Theme Settings Page * * @since 1.0.0 */ function be_add_child_theme_settings() { global $_child_theme_settings; $_child_theme_settings = new Child_Theme_Settings; }