settings_page = add_theme_page( sprintf( __( '%1$s Theme Settings', $domain ), $theme_data['Name'] ), sprintf( __( '%1$s Settings', $domain ), $theme_data['Name'] ), apply_filters( "{$prefix}_settings_capability", 'edit_theme_options' ), 'theme-settings', 'Easy_settings_page' ); /* Register the default theme settings meta boxes. */ add_action( "load-{$Easy->settings_page}", 'Easy_create_settings_meta_boxes' ); /* Make sure the settings are saved. */ add_action( "load-{$Easy->settings_page}", 'Easy_load_settings_page' ); /* Load the JavaScript and stylehsheets needed for the theme settings. */ add_action( "load-{$Easy->settings_page}", 'Easy_settings_page_enqueue_script' ); add_action( "load-{$Easy->settings_page}", 'Easy_admin_enqueue_style' ); add_action( "admin_head-{$Easy->settings_page}", 'Easy_settings_page_load_scripts' ); } /** * Validation/Sanitization callback function for theme settings. This just returns the data passed to it. Theme * developers should validate/sanitize their theme settings on the "sanitize_option_{$prefix}_theme_settings" * hook. This function merely exists for backwards compatibility. * * @since 0.7.0 */ function Easy_save_theme_settings( $settings ) { $prefix = Easy_get_prefix(); /* Make sure we kill evil scripts from users without the 'unfiltered_html' cap. */ if ( current_theme_supports( 'Easy-core-meta-box-footer' ) && isset( $settings['footer_insert'] ) && !current_user_can( 'unfiltered_html' ) ) $settings['footer_insert'] = stripslashes( wp_filter_post_kses( addslashes( $settings['footer_insert'] ) ) ); /* Allow developers to futher validate/sanitize the data. */ /* @deprecated 1.0.0. Developers should filter "sanitize_option_{$prefix}_theme_settings" instead. */ $settings = apply_filters( "{$prefix}_validate_theme_settings", $settings ); /* Return the validated settings. */ return $settings; } /** * Creates an empty array of the default theme settings. If the theme adds support for the * 'Easy-core-meta-box-footer' feature, it'll automatically add that setting to the $settings array. * * @since 1.0.0 */ function Easy_get_default_theme_settings() { /* Set up some default variables. */ $settings = array(); $domain = Easy_get_textdomain(); $prefix = Easy_get_prefix(); /* If the current theme supports the footer meta box and shortcodes, add default footer settings. */ if ( current_theme_supports( 'Easy-core-meta-box-footer' ) && current_theme_supports( 'Easy-core-shortcodes' ) ) { /* If there is a child theme active, add the [child-link] shortcode to the $footer_insert. */ if ( STYLESHEETPATH !== TEMPLATEPATH ) $settings['footer_insert'] = '' . "\n\n" . '

' . __( 'Powered by [wp-link], [theme-link], and [child-link].', $domain ) . '

'; /* If no child theme is active, leave out the [child-link] shortcode. */ else $settings['footer_insert'] = '' . "\n\n" . '

' . __( 'Powered by [wp-link] and [theme-link].', $domain ) . '

'; } /* Backwards compatibility hook. @deprecated 1.0.0. */ $settings = apply_filters( "{$prefix}_settings_args", $settings ); /* Return the $settings array and provide a hook for overwriting the default settings. */ return apply_filters( "{$prefix}_default_theme_settings", $settings ); } /** * Saves the default theme settings in the {$wpdb->prefix}_options if none have been added. The * settings are given a unique name depending on the theme directory. They are always saved as * {$prefix}_theme_settings in the database. * * @since 0.7.0 */ function Easy_load_settings_page() { $prefix = Easy_get_prefix(); /* Get theme settings from the database. */ $settings = get_option( "{$prefix}_theme_settings" ); /* If no settings are available, add the default settings to the database. */ if ( false === $settings ) { $settings = Easy_get_default_theme_settings(); add_option( "{$prefix}_theme_settings", $settings, '', 'yes' ); /* Redirect the page so that the settings are reflected on the settings page. */ wp_redirect( admin_url( 'themes.php?page=theme-settings' ) ); exit; } } /** * Creates the default meta boxes for the theme settings page. Parent/child theme and plugin developers * should use add_meta_box() to create additional meta boxes. * * @since 0.7.0 * @global string $Easy The global theme object. */ function Easy_create_settings_meta_boxes() { global $Easy; /* Get theme information. */ $prefix = Easy_get_prefix(); $domain = Easy_get_textdomain(); $theme_data = get_theme_data( trailingslashit( TEMPLATEPATH ) . 'style.css' ); /* Adds the About box for the parent theme. */ add_meta_box( "{$prefix}-about-theme-meta-box", sprintf( __( 'About %1$s', $domain ), $theme_data['Title'] ), 'Easy_about_theme_meta_box', $Easy->settings_page, 'normal', 'high' ); /* If the user is using a child theme, add an About box for it. */ if ( TEMPLATEPATH != STYLESHEETPATH ) { $child_data = get_theme_data( trailingslashit( STYLESHEETPATH ) . 'style.css' ); add_meta_box( "{$prefix}-about-child-meta-box", sprintf( __( 'About %1$s', $domain ), $child_data['Title'] ), 'Easy_about_theme_meta_box', $Easy->settings_page, 'normal', 'high' ); } /* Creates a meta box for the footer settings. */ if ( current_theme_supports( 'Easy-core-meta-box-footer' ) ) add_meta_box( "{$prefix}-footer-settings-meta-box", __( 'Footer settings', $domain ), 'Easy_footer_settings_meta_box', $Easy->settings_page, 'normal', 'high' ); } /** * Creates an information meta box with no settings about the theme. The meta box will display * information about both the parent theme and child theme. If a child theme is active, this function * will be called a second time. * * @since 0.7.0 * @param $object Variable passed through the do_meta_boxes() call. * @param array $box Specific information about the meta box being loaded. */ function Easy_about_theme_meta_box( $object, $box ) { /* Get theme information. */ $prefix = Easy_get_prefix(); $domain = Easy_get_textdomain(); /* Grab theme information for the parent theme. */ if ( "{$prefix}-about-theme-meta-box" == $box['id'] ) $theme_data = get_theme_data( trailingslashit( TEMPLATEPATH ) . 'style.css' ); /* Grab theme information for the child theme. */ elseif ( "{$prefix}-about-child-meta-box" == $box['id'] ) $theme_data = get_theme_data( trailingslashit( STYLESHEETPATH ) . 'style.css' ); ?>

HTML and/or shortcodes, which will be automatically inserted into your theme.', $domain ); ?>

[the-year], [site-link], [wp-link], [theme-link], [child-link], [loginout-link], [query-counter]' ); ?>

' . __( 'Settings saved.', $domain ) . '

'; ?>
settings_page, 'normal', null ); ?>
settings_page, 'advanced', null ); ?>
settings_page, 'side', null ); ?>