Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Radio Theme for Genesis
- * Requires Genesis 1.8 or later
- *
- * This file is the engine for the Radio Theme. It defines required parameters, registers
- * all of this child theme's specific Theme Settings, accessible from Genesis > Radio Settings,
- * and executes required functions.
- *
- * @package Radio
- * @author Greg Rickaby <greg@gregrickaby.com>
- * @copyright Copyright (c) 2012
- * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
- * @link http://radio.gregrickaby.com
- * @thanks Bill Erickson for BE-Genesis-Child
- */
- /** Child theme (do not remove) */
- define( 'CHILD_THEME_NAME', 'Radio Theme for Genesis' );
- define( 'CHILD_THEME_URL', 'http://radio.gregrickaby.com' );
- /**
- * Registers a new admin page, providing content and corresponding menu item
- * for the Radio Settings page.
- *
- * @package Radio
- * @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' => 'Radio Theme for Genesis',
- 'menu_title' => 'Radio Settings',
- )
- );
- function settings_init() {
- parent::settings_init();
- add_action( 'genesis_meta', array( &$this, 'add_viewport_meta_tag' ) );
- }
- // 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(
- 'jflow_speed' => '400',
- );
- // 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(
- 'style_box',
- 'custom_stylesheet',
- 'jflow_category',
- 'jflow_limit',
- 'jflow_sort',
- 'jflow_order',
- 'jflow_speed',
- ) );
- }
- /**
- * Register metaboxes on Child Theme Settings page
- *
- * @since 1.0.0
- *
- * @see Child_Theme_Settings::style_box() Callback for style information
- */
- function metaboxes() {
- add_meta_box( 'style-box', 'Color Style', array ($this, 'style_box' ), $this->pagehook, 'main', 'high' );
- add_meta_box( 'custom-stylesheet', 'Custom Stylesheet', array( $this, 'custom_stylesheet' ), $this->pagehook, 'main', 'high' );
- add_meta_box( 'jflow-settings', 'Featured Content Slider', array( $this, 'jflow_settings' ), $this->pagehook, 'main', 'high' );
- }
- /**
- * Callback for setting(s) metaboxes
- *
- * @since 1.0.0
- *
- * @see Child_Theme_Settings::metaboxes()
- */
- function style_box() {
- $current_style = $this->get_field_value( 'style_selection' );
- $styles = get_theme_support( 'child-style-selector' );
- echo '<p><label for="' . $this->get_field_id( 'style_selection' ) . '">Color Style: </label>';
- echo '<select name="' . $this->get_field_name( 'style_selection' ) . '" id="' . $this->get_field_id( 'style_selection' ) . '">';
- echo '<option value="">Default</option>';
- if ( ! empty( $styles ) ) {
- $styles = array_shift( $styles );
- foreach ( (array) $styles as $style => $title ) {
- echo '<option value="' . esc_attr( $style ) . '"' . selected( $current_style, $style ) . '>' . esc_html( $title ) . '</option>';
- }
- }
- echo '</select></p>';
- echo '<p><span class="description">Please select the color style from the drop down list and save your settings.</span></p>';
- }
- function custom_stylesheet() {
- echo '<input type="checkbox" name="' . $this->get_field_name( 'custom_stylesheet' ) . '" value="checked" '. esc_attr( $this->get_field_value( 'custom_stylesheet' ) ) . ' />';
- echo '<label> Load <span class="description"><code>custom.css</code></span>?</label>';
- echo '<p><span class="description">The use of this stylesheet will prevent your customizations from disappearing after a theme update.</span></p>';
- }
- function jflow_settings() {
- $jflow_category = get_categories( 'type=post&orderby=name&hide_empty=0' );
- $jflow_current_category = $this->get_field_value( 'jflow_category' );
- $jflow_current_limit = $this->get_field_value( 'jflow_limit' );
- $jflow_current_sort = $this->get_field_value( 'jflow_sort' );
- $jflow_current_order = $this->get_field_value( 'jflow_order' );
- $jflow_post_limit = array(
- '10' => '10',
- '9' => '9',
- '8' => '8',
- '7' => '7',
- '6' => '6',
- '5' => '5',
- '4' => '4',
- '3' => '3',
- '2' => '2',
- '1' => '1',
- );
- $jflow_display_sort = apply_filters( 'child_display_sort', array(
- 'date' => __( 'Date', 'child' ),
- 'title' => __( 'Title', 'child' ),
- 'author' => __( 'Author', 'child' ),
- 'ID' => __( 'Post ID', 'child' ),
- 'rand' => __( 'Random', 'child' ),
- 'parent' => __( 'Parent ID', 'child' ),
- 'menu_order' => __( 'Menu Order', 'child' ),
- 'modified' => __( 'Date Modified', 'child' ),
- 'comment_count' => __( 'Comment Count', 'child' ),
- ));
- $jflow_display_order = apply_filters( 'child_display_order', array(
- 'ASC' => __( 'Oldest', 'child' ),
- 'DESC' => __( 'Newest', 'child' ),
- ));
- echo '<label>Featured Category: </label>';
- echo '<select name="' . $this->get_field_name( 'jflow_category' ) . '" id="' . $this->get_field_id( 'jflow_category' ) . '">';
- foreach( $jflow_category as $jflow_cat ) {
- echo '<option value="' . $jflow_cat->cat_ID . '"' . selected( $jflow_current_category, $jflow_cat->cat_ID ) . '>' . $jflow_cat->cat_name. '</option>';
- }
- echo '</select></p>';
- echo '<p><span class="description">Selected the featured category.</span></p>';
- echo '<label>Story Count: </label>';
- echo '<select name="' . $this->get_field_name( 'jflow_limit' ) . '" id="' . $this->get_field_id( 'jflow_limit' ) . '">';
- foreach ( $jflow_post_limit as $jflow_limit ) {
- echo '<option value="' . esc_attr( $jflow_limit ) . '"' . selected( $jflow_current_limit, $jflow_limit ) . '>' . esc_html( $jflow_limit ) . '</option>';
- }
- echo '</select>';
- echo '<p><span class="description">Select the number of stories to be displayed.</p>';
- echo '<label>Sort Stories: </label>';
- echo '<select name="' . $this->get_field_name( 'jflow_sort' ) . '" id="' . $this->get_field_id( 'jflow_sort' ) . '">';
- foreach ( $jflow_display_sort as $jflow_d_sort => $sort_label ) {
- printf( '<option value="%s" %s>%s</option>', $jflow_d_sort, selected( $jflow_d_sort, genesis_get_option( 'jflow_sort' , $this->settings_field ), 0 ), $sort_label );
- }
- echo '</select>';
- echo '<p><span class="description">Select how to sort stories.</span></p>';
- echo '<label>Order Stories: </label>';
- echo '<select name="' . $this->get_field_name( 'jflow_order' ) . '" id="' . $this->get_field_id( 'jflow_order' ) . '">';
- foreach ( $jflow_display_order as $jflow_d_order => $order_label ) {
- printf( '<option value="%s" %s>%s</option>', $jflow_d_order, selected( $jflow_d_order, genesis_get_option( 'jflow_order' , $this->settings_field ), 0 ), $order_label );
- }
- echo '</select>';
- echo '<p><span class="description">Select the story order.</span></p>';
- echo '<label>Speed: </label><input type="text" name="' . $this->get_field_name( 'jflow_speed' ) . '" id="' . $this->get_field_id( 'jflow_speed' ) . '" value="' . esc_attr( $this->get_field_value( 'jflow_speed' ) ) . '" class="small-text" />';
- echo 'Default: <code class="description">400</code>';
- echo '<p><span class="description">This sets the transition speed of the featured content slider in milliseconds.</span></p>';
- }
- /**
- * Add viewport meta-tag to <head> for responsive design in mobile browsers.
- *
- * @author Greg Rickaby
- * @since 1.0.0
- * @required Genesis
- */
- function add_viewport_meta_tag() {
- echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>' . "\n";
- }
- }
- add_action( 'admin_menu', 'child_add_child_theme_settings', 2 );
- /**
- * Add the Theme Settings Page
- *
- * @since 1.0.0
- * @required Genesis
- */
- function child_add_child_theme_settings() {
- global $_child_theme_settings;
- $_child_theme_settings = new Child_Theme_Settings;
- }
- add_action( 'wp_enqueue_scripts', 'child_scripts' );
- /**
- * Load theme scripts and move jQuery to Google CDN.
- *
- * @author Greg Rickaby
- * @since 1.0.0
- */
- function child_scripts() {
- wp_deregister_script( 'jquery' );
- wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' );
- wp_enqueue_script( 'jflow', CHILD_URL . '/lib/js/jflow.plus.min.js', array('jquery'), '1.0', true );
- }
- add_action( 'wp_head', 'child_custom_stylesheet', 99 );
- /**
- * Check for and load custom.css immediately before the </head> tag.
- *
- * @author Greg Rickaby
- * @since 1.0.0
- */
- function child_custom_stylesheet() {
- if ( genesis_get_option( 'custom_stylesheet', 'child-settings' ) )
- echo '<link rel="stylesheet" href="'. CHILD_URL.'/custom/custom.css" type="text/css" media="screen" />' . "\n";
- }
- add_filter( 'body_class', 'child_style_body_class' );
- /**
- * Filters the <body> class to add "custom".
- *
- * @since 1.0.0
- */
- function child_style_body_class( $classes ) {
- if ( $style = genesis_get_option( 'style_selection', 'child-settings' ) ) {
- $classes[] = esc_attr( sanitize_html_class( $style ) );
- }
- if ( genesis_get_option( 'custom_stylesheet', 'child-settings' ) ) {
- $classes[] = 'custom';
- }
- return $classes;
- }
- add_action( 'genesis_after', 'child_jflow_script', 99 );
- /**
- * Check if homepage, then add jFlow javascript to footer.
- *
- * @author Greg Rickaby
- * @since 1.0.0
- * @requires jFlow script -> jflow.plus.min.js
- * @requires jQuery 1.7 or later
- */
- function child_jflow_script() {
- if ( is_front_page() ) {
- echo '<script type="text/javascript">';
- echo '$(document).ready(function(){';
- echo '$("#myController").jFlow({';
- echo 'controller: ".jFlowControl",';
- echo 'slideWrapper : "#jFlowSlider",';
- echo 'slides: "#mySlides",';
- echo 'selectedWrapper: "jFlowSelected",';
- echo 'effect: "flow",';
- echo 'width: "970px",';
- echo 'height: "300px",';
- echo 'pause: 5000,';
- echo 'prev: ".jFlowPrev",';
- echo 'next: ".jFlowNext",';
- echo 'auto: true,';
- $jflow = genesis_get_option( 'jflow_speed', 'child-settings' );
- echo 'duration: '. $jflow . '';
- echo '});';
- echo '});';
- echo '</script>';
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement