array( 'value' => 'frankie', 'label' => __( 'Frankie', 'monster' ) ), 'vampire' => array( 'value' => 'vampire', 'label' => __( 'Vampire', 'monster' ) ), 'spider' => array( 'value' => 'spider', 'label' => __( 'Spider', 'monster' ) ), 'jack' => array( 'value' => 'jack', 'label' => __( 'Jack-o-lantern', 'monster' ) ), 'demon' => array( 'value' => 'demon', 'label' => __( 'Demon', 'monster' ) ), 'skull' => array( 'value' => 'skull', 'label' => __( 'Skull', 'monster' ) ) ); /** * Check the number of daily posts in the last week * If it's greater than or equal to 7 add the zombie monster */ $daily_posts_last_week = monster_daily_posts_in_last_week(); if ( 7 <= $daily_posts_last_week ) { $style['zombie']['value'] = 'zombie'; $style['zombie']['label'] = __( 'Zombie', 'monster' ); } /** * Check to see if the user has ever made a post on Oct. 31. * If so, add a new monster! */ if ( 'true' == monster_halloween_post_date() ) { $style['eyes']['value'] = 'eyes'; $style['eyes']['label'] = __( 'Monster Eyes', 'monster' ); } return apply_filters( 'monster_style', $style ); } /** * Returns the options array for Monster Theme. * * @since Monster 1.0 */ function monster_get_theme_options() { $saved = (array) get_option( 'monster_theme_options' ); $defaults = array( 'style' => 'frankie', ); $defaults = apply_filters( 'monster_theme_default_theme_options', $defaults ); $options = wp_parse_args( $saved, $defaults ); $options = array_intersect_key( $options, $defaults ); return $options; } /** * Renders the style setting field. */ function monster_settings_field_style() { $options = monster_get_theme_options(); foreach ( monster_style() as $button ) { ?>

add_section( 'monster_theme_options', array( 'title' => __( 'Theme Options', 'monster' ), 'priority' => 35, ) ); $wp_customize->add_setting( 'monster_theme_options[style]', array( 'default' => 'frankie', 'type' => 'option', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'monster_sanitize_style', ) ); $wp_customize->add_control( 'monster_theme_style', array( 'label' => 'Select your monster:', 'section' => 'monster_theme_options', 'settings' => 'monster_theme_options[style]', 'type' => 'select', 'choices' => array( 'frankie' => __( 'Frankie', 'monster' ), 'vampire' => __( 'Vampire', 'monster' ), 'spider' => __( 'Spider', 'monster' ), 'jack' => __( 'Jack-o-lantern', 'monster' ), 'demon' => __( 'Demon', 'monster' ), 'skull' => __( 'Skull', 'monster' ), ) ) ); } add_action( 'customize_register', 'monster_customize_register' ); //Sanitization function for Theme Style function monster_sanitize_style( $input ) { $choices = array( 'frankie', 'vampire', 'spider', 'jack', 'demon', 'skull', 'zombie', 'eyes', ); if ( ! in_array( $input, $choices ) ) $input = 'frankie'; return $input; }