function thematic_validate_opt($input) { $output = thematic_get_wp_opt('thematic_theme_opt', thematic_default_opt()); // Index Insert position must be a non-negative number if (!is_numeric($input['index_insert']) || $input['index_insert'] < 0) { add_settings_error('thematic_theme_opt', 'thematic_insert_opt', __('The index insert position value must be a number equal to or greater than zero. This setting has been reverted to the previous value.', 'thematic'), 'error'); } else { // A sanitize numeric value to ensure a whole number $output['index_insert'] = intval($input['index_insert']); } // Author Info CheckBox value either 1(yes) or 0(no) $output['author_info'] = isset($input['author_info']) && 1 == $input['author_info'] ? 1 : 0; // Footer Text sanitized allowing HTML and WP shortcodes if (isset($input['footer_txt'])) { $output['footer_txt'] = wp_kses_post($input['footer_txt']); } // Remove Legacy XHTML CheckBox value either 1(yes) or 0(no) $output['legacy_xhtml'] = isset($input['legacy_xhtml']) && 1 == $input['legacy_xhtml'] ? 1 : 0; // Check and set layout if (isset($input['layout'])) { $available_layouts = thematic_available_layout_slugs(); if (in_array($input['layout'], $available_layouts)) { $output['layout'] = $input['layout']; } else { $output['layout'] = thematic_default_theme_layout(); } } // Remove Legacy Options CheckBox value either 1(yes) or 0(no) $output['del_legacy_opt'] = isset($input['del_legacy_opt']) && 1 == $input['del_legacy_opt'] ? 1 : 0; if (1 == $output['del_legacy_opt']) { // Remove options if the choice is yes delete_option('thm_insert_position'); delete_option('thm_authorinfo'); delete_option('thm_footertext'); // Reset checkbox value to unchecked in case a legacy set of options is ever saved to database again $output['del_legacy_opt'] = 0; } return apply_filters('thematic_theme_opt_validation', $output, $input); }
<textarea rows="5" style="width:100%;" <?php $this->link(); ?> ><?php echo esc_textarea($this->value()); ?> </textarea> </label> <?php } } // Add postMessage support for site title and description. $wp_customize->get_setting('blogname')->transport = 'postMessage'; $wp_customize->get_setting('blogdescription')->transport = 'postMessage'; // Get the default thematic footer text $thematic_defaults = thematic_default_opt(); $thematic_default_footertext = $thematic_defaults['footer_txt']; $thematic_default_layout = $thematic_defaults['layout']; // Only show the layout section if the theme supports it if (current_theme_supports('thematic_customizer_layout')) { $wp_customize->add_section('thematic_layout', array('title' => __('Layout', 'thematic'), 'description' => __('Choose the main layout of your theme', 'thematic'), 'capability' => 'edit_theme_options', 'priority' => '90')); $wp_customize->add_setting('thematic_theme_opt[layout]', array('default' => $thematic_default_layout, 'type' => 'option')); $possible_layouts = thematic_available_theme_layouts(); $available_layouts = array(); foreach ($possible_layouts as $layout) { $available_layouts[$layout['slug']] = $layout['title']; } $wp_customize->add_control('thematic_layout_control', array('type' => 'radio', 'label' => __('Theme layout', 'thematic'), 'section' => 'thematic_layout', 'choices' => $available_layouts, 'settings' => 'thematic_theme_opt[layout]')); } // Add section for thematic footer options $wp_customize->add_section('thematic_footer_text', array('title' => __('Footer', 'thematic'), 'description' => sprintf(_x('You can use HTML and shortcodes in your footer text. Shortcode examples: %s', '%s are shortcode tags', 'thematic'), '[wp-link] [theme-link] [loginout-link] [blog-title] [blog-link] [the-year]'), 'priority' => 135));
function test_thematic_default_opt() { $expected_ops = array('index_insert' => 2, 'author_info' => 0, 'footer_txt' => 'Powered by [wp-link]. Built on the [theme-link].', 'del_legacy_opt' => 0, 'legacy_xhtml' => 0, 'layout' => thematic_default_theme_layout()); $this->assertEquals($expected_ops, thematic_default_opt()); }
function set_xhtml_theme_option() { $options = thematic_default_opt(); $options['legacy_xhtml'] = 1; $this->update_theme_option($options); }