/** * 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); }
/** * Get the standard sidebar * * This includes the primary and secondary widget areas. * The sidebar can be switched on or off using thematic_sidebar. <br> * Default: ON <br> * * Filter: thematic_sidebar */ function thematic_sidebar() { $current_layout = apply_filters('thematic_current_theme_layout', thematic_get_theme_opt('layout')); if (in_array($current_layout, thematic_available_layout_slugs()) && 'full-width' == $current_layout) { $show = false; } else { $show = true; } $show = apply_filters('thematic_sidebar', $show); if ($show) { get_sidebar(); } return; }
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); }
/** * Decide the default layout of the theme * * @since 2.0.0 * * @return string $default_layout */ function thematic_default_theme_layout() { $options = thematic_get_wp_opt('thematic_theme_opt'); // use a default layout of right-sidebar if no theme option has been set $thematic_default_layout = isset($options['layout']) ? $options['layout'] : 'right-sidebar'; /** * Filter for the default layout * * Specifies the theme layout upon first setup. The returned string need to match * one of the available layout slugs. Any invalid slug will be ignored. * * @since 2.0.0 * * @see thematic_available_layout_slugs() * * @param string $thematic_default_layout */ $thematic_possible_default_layout = apply_filters('thematic_default_theme_layout', $thematic_default_layout); // only use the filtered layout if it is a valid layout if (in_array($thematic_possible_default_layout, thematic_available_layout_slugs())) { $thematic_default_layout = $thematic_possible_default_layout; } return $thematic_default_layout; }