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; }