/** * Generates semantic classes for BODY element * * @param array $classes body classes */ function thematic_body_class($classes) { /** * Filter to control the theme layout * * Accepts any string that is part of thematic_available_theme_layouts(). Note that * the filter overrides the layout defined in the Theme Customizer. Any invalid * layout string will be ignored and the theme's default layout will be used. * * @see thematic_available_theme_layouts() * * @since 2.0.0 * * @param string $current_layout */ $current_layout = apply_filters('thematic_current_theme_layout', thematic_get_theme_opt('layout')); if (is_page_template('template-page-fullwidth.php')) { $classes[] = 'full-width'; } elseif (in_array($current_layout, thematic_available_layout_slugs())) { $classes[] = $current_layout; } else { $classes[] = thematic_default_theme_layout(); } if (thematic_is_legacy_xhtml()) { $classes[] = 'thematic-xhtml'; } /** * Filter the body classes * * @param array $classes */ return apply_filters('thematic_body_class', $classes); }
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); }
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()); }