Ejemplo n.º 1
0
/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously for simplecatch.
 * And flushes out all transient data on preview
 *
 * @since Simple Catch 1.6.3
 */
function simplecatch_customize_preview()
{
    //Remove transients on preview
    simplecatch_themeoption_invalidate_caches();
    global $simplecatch_options_defaults, $simplecatch_options_settings;
    $simplecatch_options_settings = simplecatch_options_set_defaults($simplecatch_options_defaults);
}
/**
 * Reset all settings to default
 * @param  $input entered value
 * @return sanitized output
 *
 * @since Simple Catch 3.0
 */
function simplecatch_reset_all_settings($input)
{
    if ($input == 1) {
        // Delete all theme options
        delete_option('simplecatch_options');
        // Flush out all transients	on reset
        simplecatch_themeoption_invalidate_caches();
    } else {
        return '';
    }
}
Ejemplo n.º 3
0
/**
 * Validate content options
 * @param array $options
 * @uses esc_url_raw, absint, esc_textarea, sanitize_text_field, simplecatch_invalidate_caches
 * @return array
 */
function simplecatch_theme_options_validate($options)
{
    global $simplecatch_options_settings;
    $input_validated = $simplecatch_options_settings;
    $input = array();
    $input = $options;
    // data validation for logo
    if (isset($input['featured_logo_header'])) {
        $input_validated['featured_logo_header'] = esc_url_raw($input['featured_logo_header']);
    }
    if (isset($input['remove_header_logo'])) {
        // Our checkbox value is either 0 or 1
        $input_validated['remove_header_logo'] = $input['remove_header_logo'];
    }
    if (isset($input['remove_site_title'])) {
        // Our checkbox value is either 0 or 1
        $input_validated['remove_site_title'] = $input['remove_site_title'];
    }
    if (isset($input['remove_site_description'])) {
        // Our checkbox value is either 0 or 1
        $input_validated['remove_site_description'] = $input['remove_site_description'];
    }
    if (isset($input['featured_logo_footer'])) {
        $input_validated['featured_logo_footer'] = esc_url_raw($input['featured_logo_footer']);
    }
    if (isset($input['remove_footer_logo'])) {
        // Our checkbox value is either 0 or 1
        $input_validated['remove_footer_logo'] = $input['remove_footer_logo'];
    }
    //Fav Icon URL
    if (isset($input['fav_icon'])) {
        $input_validated['fav_icon'] = esc_url_raw($input['fav_icon']);
    }
    if (isset($input['remove_fav_icon'])) {
        // Our checkbox value is either 0 or 1
        $input_validated['remove_fav_icon'] = $input['remove_fav_icon'];
    }
    //Web Clip Icon URL
    if (isset($input['web_clip'])) {
        $input_validated['web_clip'] = esc_url_raw($input['web_clip']);
    }
    // data validation for Color Scheme
    if (isset($input['color_scheme'])) {
        // Our checkbox value is either 0 or 1
        $input_validated['color_scheme'] = $input['color_scheme'];
    }
    //Color Options
    if (isset($input['heading_color'])) {
        $input_validated['heading_color'] = wp_filter_nohtml_kses($input['heading_color']);
    }
    if (isset($input['meta_color'])) {
        $input_validated['meta_color'] = wp_filter_nohtml_kses($input['meta_color']);
    }
    if (isset($input['text_color'])) {
        $input_validated['text_color'] = wp_filter_nohtml_kses($input['text_color']);
    }
    if (isset($input['link_color'])) {
        $input_validated['link_color'] = wp_filter_nohtml_kses($input['link_color']);
    }
    if (isset($input['widget_heading_color'])) {
        $input_validated['widget_heading_color'] = wp_filter_nohtml_kses($input['widget_heading_color']);
    }
    if (isset($input['widget_text_color'])) {
        $input_validated['widget_text_color'] = wp_filter_nohtml_kses($input['widget_text_color']);
    }
    if (isset($input['reset_color'])) {
        // Our checkbox value is either 0 or 1
        $input_validated['reset_color'] = $input['reset_color'];
    }
    //Reset Color Options
    if ($input['reset_color'] == 1) {
        global $simplecatch_options_defaults;
        $defaults = $simplecatch_options_defaults;
        $input_validated['color_scheme'] = $defaults['color_scheme'];
        $input_validated['heading_color'] = $defaults['heading_color'];
        $input_validated['meta_color'] = $defaults['meta_color'];
        $input_validated['text_color'] = $defaults['text_color'];
        $input_validated['link_color'] = $defaults['link_color'];
        $input_validated['widget_heading_color'] = $defaults['widget_heading_color'];
        $input_validated['widget_text_color'] = $defaults['widget_text_color'];
    }
    if (isset($input['exclude_slider_post'])) {
        // Our checkbox value is either 0 or 1
        $input_validated['exclude_slider_post'] = $input['exclude_slider_post'];
    }
    // Front page posts categories
    if (isset($input['front_page_category'])) {
        $input_validated['front_page_category'] = $input['front_page_category'];
    }
    //data validation for Featured Slider
    if (isset($input['slider_qty'])) {
        $input_validated['slider_qty'] = absint($input['slider_qty']) ? $input['slider_qty'] : 4;
    }
    if (isset($input['featured_slider'])) {
        $input_validated['featured_slider'] = array();
    }
    if (isset($input['slider_qty'])) {
        for ($i = 1; $i <= $input['slider_qty']; $i++) {
            if (!empty($input['featured_slider'][$i]) && intval($input['featured_slider'][$i])) {
                $input_validated['featured_slider'][$i] = absint($input['featured_slider'][$i]);
            }
        }
    }
    if (isset($input['remove_noise_effect'])) {
        // Our checkbox value is either 0 or 1
        $input_validated['remove_noise_effect'] = $input['remove_noise_effect'];
    }
    if (isset($input['transition_effect'])) {
        $input_validated['transition_effect'] = wp_filter_nohtml_kses($input['transition_effect']);
    }
    // data validation for transition delay
    if (isset($input['transition_delay']) && is_numeric($input['transition_delay'])) {
        $input_validated['transition_delay'] = $input['transition_delay'];
    }
    // data validation for transition length
    if (isset($input['transition_duration']) && is_numeric($input['transition_duration'])) {
        $input_validated['transition_duration'] = $input['transition_duration'];
    }
    // data validation for Social Icons
    if (isset($input['social_facebook'])) {
        $input_validated['social_facebook'] = esc_url_raw($input['social_facebook']);
    }
    if (isset($input['social_twitter'])) {
        $input_validated['social_twitter'] = esc_url_raw($input['social_twitter']);
    }
    if (isset($input['social_googleplus'])) {
        $input_validated['social_googleplus'] = esc_url_raw($input['social_googleplus']);
    }
    if (isset($input['social_pinterest'])) {
        $input_validated['social_pinterest'] = esc_url_raw($input['social_pinterest']);
    }
    if (isset($input['social_youtube'])) {
        $input_validated['social_youtube'] = esc_url_raw($input['social_youtube']);
    }
    if (isset($input['social_vimeo'])) {
        $input_validated['social_vimeo'] = esc_url_raw($input['social_vimeo']);
    }
    if (isset($input['social_linkedin'])) {
        $input_validated['social_linkedin'] = esc_url_raw($input['social_linkedin']);
    }
    if (isset($input['social_slideshare'])) {
        $input_validated['social_slideshare'] = esc_url_raw($input['social_slideshare']);
    }
    if (isset($input['social_foursquare'])) {
        $input_validated['social_foursquare'] = esc_url_raw($input['social_foursquare']);
    }
    if (isset($input['social_flickr'])) {
        $input_validated['social_flickr'] = esc_url_raw($input['social_flickr']);
    }
    if (isset($input['social_tumblr'])) {
        $input_validated['social_tumblr'] = esc_url_raw($input['social_tumblr']);
    }
    if (isset($input['social_deviantart'])) {
        $input_validated['social_deviantart'] = esc_url_raw($input['social_deviantart']);
    }
    if (isset($input['social_dribbble'])) {
        $input_validated['social_dribbble'] = esc_url_raw($input['social_dribbble']);
    }
    if (isset($input['social_myspace'])) {
        $input_validated['social_myspace'] = esc_url_raw($input['social_myspace']);
    }
    if (isset($input['social_wordpress'])) {
        $input_validated['social_wordpress'] = esc_url_raw($input['social_wordpress']);
    }
    if (isset($input['social_rss'])) {
        $input_validated['social_rss'] = esc_url_raw($input['social_rss']);
    }
    if (isset($input['social_delicious'])) {
        $input_validated['social_delicious'] = esc_url_raw($input['social_delicious']);
    }
    if (isset($input['social_lastfm'])) {
        $input_validated['social_lastfm'] = esc_url_raw($input['social_lastfm']);
    }
    if (isset($input['social_instagram'])) {
        $input_validated['social_instagram'] = esc_url_raw($input['social_instagram']);
    }
    if (isset($input['social_github'])) {
        $input_validated['social_github'] = esc_url_raw($input['social_github']);
    }
    if (isset($input['social_vkontakte'])) {
        $input_validated['social_vkontakte'] = esc_url_raw($input['social_vkontakte']);
    }
    if (isset($input['social_myworld'])) {
        $input_validated['social_myworld'] = esc_url_raw($input['social_myworld']);
    }
    if (isset($input['social_odnoklassniki'])) {
        $input_validated['social_odnoklassniki'] = esc_url_raw($input['social_odnoklassniki']);
    }
    if (isset($input['social_goodreads'])) {
        $input_validated['social_goodreads'] = esc_url_raw($input['social_goodreads']);
    }
    if (isset($input['social_skype'])) {
        $input_validated['social_skype'] = sanitize_text_field($input['social_skype']);
    }
    if (isset($input['social_soundcloud'])) {
        $input_validated['social_soundcloud'] = esc_url_raw($input['social_soundcloud']);
    }
    if (isset($input['social_email'])) {
        $input_validated['social_email'] = sanitize_email($input['social_email']);
    }
    //Custom CSS Style Validation
    if (isset($input['custom_css'])) {
        $input_validated['custom_css'] = wp_kses_stripslashes($input['custom_css']);
    }
    //Webmaster Tool Verification
    if (isset($input['google_verification'])) {
        $input_validated['google_verification'] = wp_filter_post_kses($input['google_verification']);
    }
    if (isset($input['yahoo_verification'])) {
        $input_validated['yahoo_verification'] = wp_filter_post_kses($input['yahoo_verification']);
    }
    if (isset($input['bing_verification'])) {
        $input_validated['bing_verification'] = wp_filter_post_kses($input['bing_verification']);
    }
    if (isset($input['analytic_header'])) {
        $input_validated['analytic_header'] = wp_kses_stripslashes($input['analytic_header']);
    }
    if (isset($input['analytic_footer'])) {
        $input_validated['analytic_footer'] = wp_kses_stripslashes($input['analytic_footer']);
    }
    // Layout settings verification
    if (isset($input['sidebar_layout'])) {
        $input_validated['sidebar_layout'] = $input['sidebar_layout'];
    }
    if (isset($input['more_tag_text'])) {
        $input_validated['more_tag_text'] = htmlentities(sanitize_text_field($input['more_tag_text']), ENT_QUOTES, 'UTF-8');
    }
    if (isset($input['search_display_text'])) {
        $input_validated['search_display_text'] = sanitize_text_field($input['search_display_text']);
    }
    if (isset($input['search_button_text'])) {
        $input_validated['search_button_text'] = sanitize_text_field($input['search_button_text']);
    }
    //data validation for excerpt length
    if (isset($input['excerpt_length'])) {
        $input_validated['excerpt_length'] = absint($input['excerpt_length']) ? $input['excerpt_length'] : 30;
    }
    //Feed Redirect
    if (isset($input['feed_url'])) {
        $input_validated['feed_url'] = esc_url_raw($input['feed_url']);
    }
    //Clearing the theme option cache
    if (function_exists('simplecatch_themeoption_invalidate_caches')) {
        simplecatch_themeoption_invalidate_caches();
    }
    return $input_validated;
}