Documentation.", 'siteorigin'), ucfirst($theme), 'http://siteorigin.com/doc/'.$theme.'/' ); ?>
add_help_tab(array( 'id' => 'theme_settings_documentation', 'title' => __('Theme Documentation', 'siteorigin'), 'content' => $content )); } /** * Initialize admin settings in the admin * * @action admin_init */ function so_settings_admin_init(){ register_setting('theme_settings', $GLOBALS['so_settings_name'], 'so_settings_validate'); } /** * Set up the theme settings page. * * @action admin_menu */ function so_settings_admin_menu(){ add_theme_page(__('Theme Settings','siteorigin'), __('Theme Settings', 'siteorigin'), 'edit_theme_options', 'theme_settings_page', 'so_settings_render'); } /** * Render the theme settings page */ function so_settings_render(){ locate_template('extras/settings/page.php', true, false); } function so_settings_enqueue_scripts($prefix){ if($prefix != 'appearance_page_theme_settings_page') return; wp_enqueue_script( 'siteorigin-settings', get_template_directory_uri().'/extras/settings/settings.js', array('jquery'), SO_THEME_VERSION ); wp_enqueue_style( 'siteorigin-settings', get_template_directory_uri().'/extras/settings/settings.css', array(), SO_THEME_VERSION ); wp_enqueue_style( 'farbtastic' ); wp_enqueue_script( 'farbtastic' ); } function so_settings_adminbar($bar){ $screen = get_current_screen(); if($screen->id == 'appearance_page_theme_settings_page'){ $bar = (object) array('id' => $GLOBALS['so_settings_name'], 'message' => array('extras/settings/message')); } return $bar; } /** * Add a settings section. * * @param $id * @param $name */ function so_settings_add_section($id, $name){ add_settings_section($id, $name, '__return_false', 'theme_settings'); } /** * Add a setting * * @param string $section * @param string $id * @param string $type * @param string $name * @param array $args */ function so_settings_add_field($section, $id, $type, $name, $args = array()){ if(isset($wp_settings_fields['theme_settings'][$section][$id])){ if(isset($wp_settings_fields['theme_settings'][$section][$id]['args']['type']) && $wp_settings_fields['theme_settings'][$section][$id]['args']['type'] == 'teaser') unset($wp_settings_fields['theme_settings'][$section][$id]); else return; } $args = wp_parse_args($args, array( 'section' => $section, 'field' => $id, 'type' => $type, )); add_settings_field($id, $name, 'so_settings_field', 'theme_settings', $section, $args); } /** * Adds a field that might only be available in another version of the theme. * * @param $section * @param $id * @param $type * @param $name * @param array $args */ function so_settings_add_teaser($section, $id, $name, $args = array()){ global $wp_settings_fields; if(isset($wp_settings_fields['theme_settings'][$section][$id])) return; $args = wp_parse_args($args, array( 'section' => $section, 'field' => $id, 'type' => 'teaser', )); add_settings_field($id, $name, 'so_settings_field', 'theme_settings', $section, $args); } /** * Get the value of a setting, or the default value. * * @param string $name The setting name * @return mixed */ function so_setting($name){ if(!isset($GLOBALS['so_settings'][$name])) return null; else return $GLOBALS['so_settings'][$name]; } /** * Render a settings field * @param $args */ function so_settings_field($args){ $field_name = $GLOBALS['so_settings_name'].'['.$args['section'].'_'.$args['field'].']'; $field_id = $args['section'].'_'.$args['field']; $current = isset($GLOBALS['so_settings'][$field_id]) ? $GLOBALS['so_settings'][$field_id] : null; switch($args['type']){ case 'checkbox' : ?> />