option_defaults = $this->get_sds_theme_option_defaults(); $this->theme = $this->get_parent_theme(); add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); // Enqueue Theme Options Stylesheet add_action( 'admin_menu', array( $this, 'admin_menu' ) ); // Register Appearance Menu Item add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ),999 ); // Add Theme Options Menu to Toolbar add_action( 'admin_init', array( $this, 'admin_init' ) ); // Register Settings, Settings Sections, and Settings Fields add_filter( 'wp_redirect', array( $this, 'wp_redirect' ) ); // Add "hash" (tab) to URL before re-direct } /** * This function enqueues our theme options stylesheet, WordPress media upload scripts, and our custom upload script only on our options page in admin. */ function admin_enqueue_scripts( $hook ) { if ( $hook === 'appearance_page_sds-theme-options' ) { $protocol = is_ssl() ? 'https' : 'http'; wp_enqueue_style( 'sds-theme-options', get_template_directory_uri() . '/includes/css/sds-theme-options.css', false, self::VERSION ); wp_enqueue_media(); // Enqueue media scripts wp_enqueue_script( 'sds-theme-options', get_template_directory_uri() . '/includes/js/sds-theme-options.js', array( 'jquery' ), self::VERSION ); // Web Fonts if ( function_exists( 'sds_web_fonts' ) ) { $google_families = $this->get_google_font_families_list(); wp_enqueue_style( 'google-web-fonts', $protocol . '://fonts.googleapis.com/css?family=' . $google_families, false, self::VERSION ); } } } /** * This function adds a menu item under "Appearance" in the Dashboard. */ function admin_menu() { add_theme_page( __( 'Theme Options', 'capture' ), __( 'Theme Options', 'capture' ), 'edit_theme_options', 'sds-theme-options', array( $this, 'sds_theme_options_page' ) ); } /** * This function adds a new menu to the Toolbar under the appearance parent group on the front-end. */ function admin_bar_menu( $wp_admin_bar ) { // Make sure we're on the front end and that the current user can either switch_themes or edit_theme_options if ( ! is_admin() && ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) ) $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'sds-theme-options', 'title' => __( 'Theme Options', 'capture' ), 'href' => admin_url( 'themes.php?page=sds-theme-options' ), 'meta' => array( 'class' => 'sds-theme-options' ) ) ); } /** * This function registers our setting, settings sections, and settings fields. */ function admin_init() { //Register Setting register_setting( 'sds_theme_options', 'sds_theme_options', array( $this, 'sds_theme_options_sanitize' ) ); /* * General Settings (belong to the sds-theme-options[general] "page", used during page render to display section in tab format) */ // Logo add_settings_section( 'sds_theme_options_logo_section', __( 'Upload A Logo', 'capture'), array( $this, 'sds_theme_options_logo_section' ), 'sds-theme-options[general]' ); add_settings_field( 'sds_theme_options_logo_field', __( 'Logo:', 'capture'), array( $this, 'sds_theme_options_logo_field' ), 'sds-theme-options[general]', 'sds_theme_options_logo_section' ); // Hide Tagline add_settings_section( 'sds_theme_options_hide_tagline_section', __( 'Show/Hide Site Tagline', 'capture'), array( $this, 'sds_theme_options_hide_tagline_section' ), 'sds-theme-options[general]' ); add_settings_field( 'sds_theme_options_hide_tagline_field', __( 'Show or Hide Site Tagline:', 'capture'), array( $this, 'sds_theme_options_hide_tagline_field' ), 'sds-theme-options[general]', 'sds_theme_options_hide_tagline_section' ); // Color Schemes (if specified by theme) if ( function_exists( 'sds_color_schemes' ) ) { add_settings_section( 'sds_theme_options_color_schemes_section', __( 'Color Scheme', 'capture'), array( $this, 'sds_theme_options_color_schemes_section' ), 'sds-theme-options[general]' ); add_settings_field( 'sds_theme_options_color_schemes_field', __( 'Select A Color Scheme:', 'capture'), array( $this, 'sds_theme_options_color_schemes_field' ), 'sds-theme-options[general]', 'sds_theme_options_color_schemes_section' ); } // Google Web Fonts (if specified by theme) if ( function_exists( 'sds_web_fonts' ) ) { add_settings_section( 'sds_theme_options_web_fonts_section', __( 'Web Fonts', 'capture'), array( $this, 'sds_theme_options_web_fonts_section' ), 'sds-theme-options[general]' ); add_settings_field( 'sds_theme_options_web_fonts_field', __( 'Select A Web Font:', 'capture'), array( $this, 'sds_theme_options_web_fonts_field' ), 'sds-theme-options[general]', 'sds_theme_options_web_fonts_section' ); } /* * Content Layout Settings (belong to the sds-theme-options[content-layout] "page", used during page render to display section in tab format) */ if ( function_exists( 'sds_content_layouts' ) ) { add_settings_section( 'sds_theme_options_content_layout_section', __( 'Content Layout', 'capture'), array( $this, 'sds_theme_options_content_layout_section' ), 'sds-theme-options[content-layout]' ); add_settings_field( 'sds_theme_options_content_layout_global_field', __( 'Global', 'capture'), array( $this, 'sds_theme_options_content_layout_global_field' ), 'sds-theme-options[content-layout]', 'sds_theme_options_content_layout_section' ); add_settings_field( 'sds_theme_options_content_layout_front_page_field', __( 'Front Page', 'capture'), array( $this, 'sds_theme_options_content_layout_front_page_field' ), 'sds-theme-options[content-layout]', 'sds_theme_options_content_layout_section' ); add_settings_field( 'sds_theme_options_content_layout_home_field', __( 'Home (Blog)', 'capture'), array( $this, 'sds_theme_options_content_layout_home_field' ), 'sds-theme-options[content-layout]', 'sds_theme_options_content_layout_section' ); add_settings_field( 'sds_theme_options_content_layout_single_field', __( 'Single Post', 'capture'), array( $this, 'sds_theme_options_content_layout_single_field' ), 'sds-theme-options[content-layout]', 'sds_theme_options_content_layout_section' ); add_settings_field( 'sds_theme_options_content_layout_page_field', __( 'Single Page', 'capture'), array( $this, 'sds_theme_options_content_layout_page_field' ), 'sds-theme-options[content-layout]', 'sds_theme_options_content_layout_section' ); add_settings_field( 'sds_theme_options_content_layout_archive_field', __( 'Archive', 'capture'), array( $this, 'sds_theme_options_content_layout_archive_field' ), 'sds-theme-options[content-layout]', 'sds_theme_options_content_layout_section' ); add_settings_field( 'sds_theme_options_content_layout_category_field', __( 'Category', 'capture'), array( $this, 'sds_theme_options_content_layout_category_field' ), 'sds-theme-options[content-layout]', 'sds_theme_options_content_layout_section' ); add_settings_field( 'sds_theme_options_content_layout_tag_field', __( 'Tag', 'capture'), array( $this, 'sds_theme_options_content_layout_tag_field' ), 'sds-theme-options[content-layout]', 'sds_theme_options_content_layout_section' ); add_settings_field( 'sds_theme_options_content_layout_404_field', __( '404 Error', 'capture'), array( $this, 'sds_theme_options_content_layout_404_field' ), 'sds-theme-options[content-layout]', 'sds_theme_options_content_layout_section' ); } /* * Social Media Settings (belong to the sds-theme-options[social-media] "page", used during page render to display section in tab format) */ add_settings_section( 'sds_theme_options_social_media_section', __( 'Social Media', 'capture'), array( $this, 'sds_theme_options_social_media_section' ), 'sds-theme-options[social-media]' ); add_settings_field( 'sds_theme_options_social_media_facebook_url_field', __( 'Facebook:', 'capture'), array( $this, 'sds_theme_options_social_media_facebook_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); add_settings_field( 'sds_theme_options_social_media_twitter_url_field', __( 'Twitter:', 'capture'), array( $this, 'sds_theme_options_social_media_twitter_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); add_settings_field( 'sds_theme_options_social_media_linkedin_url_field', __( 'LinkedIn:', 'capture'), array( $this, 'sds_theme_options_social_media_linkedin_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); add_settings_field( 'sds_theme_options_social_media_google_plus_url_field', __( 'Google+:', 'capture'), array( $this, 'sds_theme_options_social_media_google_plus_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); add_settings_field( 'sds_theme_options_social_media_youtube_url_field', __( 'YouTube:', 'capture'), array( $this, 'sds_theme_options_social_media_youtube_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); add_settings_field( 'sds_theme_options_social_media_vimeo_url_field', __( 'Vimeo:', 'capture'), array( $this, 'sds_theme_options_social_media_vimeo_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); add_settings_field( 'sds_theme_options_social_media_instagram_url_field', __( 'Instagram:', 'capture'), array( $this, 'sds_theme_options_social_media_instagram_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); add_settings_field( 'sds_theme_options_social_media_pinterest_url_field', __( 'Pinterest:', 'capture'), array( $this, 'sds_theme_options_social_media_pinterest_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); add_settings_field( 'sds_theme_options_social_media_flickr_url_field', __( 'Flickr:', 'capture'), array( $this, 'sds_theme_options_social_media_flickr_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); //add_settings_field( 'sds_theme_options_social_media_yelp_url_field', __( 'Yelp:', 'capture'), array( $this, 'sds_theme_options_social_media_yelp_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); add_settings_field( 'sds_theme_options_social_media_foursquare_url_field', __( 'Foursquare:', 'capture'), array( $this, 'sds_theme_options_social_media_foursquare_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); add_settings_field( 'sds_theme_options_social_media_rss_url_field', __( 'RSS:', 'capture'), array( $this, 'sds_theme_options_social_media_rss_url_field' ), 'sds-theme-options[social-media]', 'sds_theme_options_social_media_section' ); } /** * This function is the callback for the logo settings section. */ function sds_theme_options_logo_section() { ?>

'disabled', 'data-init-empty' => 'true' ) : false ); ?>

/>

$atts ) : ?>

$atts ) : $css_name = strtolower( str_replace( array( '+'. ':' ), '-', $name) ); ?>

content_layouts_field( 'global', 'Select a content layout that will be applied globally on your site. Select more specific content layouts below.' ); } /** * This function is the callback for the front page content layout settings field. */ function sds_theme_options_content_layout_front_page_field() { $this->content_layouts_field( 'front_page', 'Select a content layout that will be applied to the front page on your site (if selected in Settings > General).' ); } /** * This function is the callback for the home (blog) page content layout settings field. */ function sds_theme_options_content_layout_home_field() { $this->content_layouts_field( 'home', 'Select a content layout that will be applied to the blog on your site.' ); } /** * This function is the callback for the single post content layout settings field. */ function sds_theme_options_content_layout_single_field() { $this->content_layouts_field( 'single', 'Select a content layout that will be applied to single posts on your site.' ); } /** * This function is the callback for the single page content layout settings field. */ function sds_theme_options_content_layout_page_field() { $this->content_layouts_field( 'page', 'Select a content layout that will be applied to single pages on your site.' ); } /** * This function is the callback for the archive content layout settings field. */ function sds_theme_options_content_layout_archive_field() { $this->content_layouts_field( 'archive', 'Select a content layout that will be applied to archives on your site.' ); } /** * This function is the callback for the category content layout settings field. */ function sds_theme_options_content_layout_category_field() { $this->content_layouts_field( 'category', 'Select a content layout that will be applied to category archives on your site.' ); } /** * This function is the callback for the tag content layout settings field. */ function sds_theme_options_content_layout_tag_field() { $this->content_layouts_field( 'tag', 'Select a content layout that will be applied to tag archives on your site.' ); } /** * This function is the callback for the 404 (error) content layout settings field. */ function sds_theme_options_content_layout_404_field() { $this->content_layouts_field( '404', 'Select a content layout that will be applied to the 404 error page on your site.' ); } /** * This function is the callback for the social media settings section. */ function sds_theme_options_social_media_section() { ?>

social_media_field( 'facebook_url' ); } /** * This function is the callback for the twitter url settings field. */ function sds_theme_options_social_media_twitter_url_field() { $this->social_media_field( 'twitter_url' ); } /** * This function is the callback for the linkedin url settings field. */ function sds_theme_options_social_media_linkedin_url_field() { $this->social_media_field( 'linkedin_url' ); } /** * This function is the callback for the google_plus url settings field. */ function sds_theme_options_social_media_google_plus_url_field() { $this->social_media_field( 'google_plus_url' ); } /** * This function is the callback for the youtube url settings field. */ function sds_theme_options_social_media_youtube_url_field() { $this->social_media_field( 'youtube_url' ); } /** * This function is the callback for the vimeo url settings field. */ function sds_theme_options_social_media_vimeo_url_field() { $this->social_media_field( 'vimeo_url' ); } /** * This function is the callback for the instagram url settings field. */ function sds_theme_options_social_media_instagram_url_field() { $this->social_media_field( 'instagram_url' ); } /** * This function is the callback for the pinterest url settings field. */ function sds_theme_options_social_media_pinterest_url_field() { $this->social_media_field( 'pinterest_url' ); } /** * This function is the callback for the flickr url settings field. */ function sds_theme_options_social_media_flickr_url_field() { $this->social_media_field( 'flickr_url' ); } /** * This function is the callback for the yelp url settings field. */ function sds_theme_options_social_media_yelp_url_field() { $this->social_media_field( 'yelp_url' ); } /** * This function is the callback for the foursquare url settings field. */ function sds_theme_options_social_media_foursquare_url_field() { $this->social_media_field( 'foursquare_url' ); } /** * This function is the callback for the rss url settings field. */ function sds_theme_options_social_media_rss_url_field() { global $sds_theme_options; ?>
/>
get_sds_theme_option_defaults(); // Remove Logo if ( isset( $input['remove-logo'] ) ) $input['logo_attachment_id'] = false; // Parse arguments, replacing defaults with user input $input = wp_parse_args( $input, $this->get_sds_theme_option_defaults() ); // General $input['logo_attachment_id'] = ( ! empty( $input['logo_attachment_id'] ) ) ? ( int ) $input['logo_attachment_id'] : ''; $input['color_scheme'] = sanitize_text_field( $input['color_scheme'] ); $input['web_font'] = ( ! empty( $input['web_font'] ) && $input['web_font'] !== 'none' ) ? sanitize_text_field( $input['web_font'] ) : false; $input['hide_tagline'] = ( $input['hide_tagline'] ) ? true : false; // Content Layouts foreach ( $input['content_layouts'] as $key => &$value ) $value = ( $value !== 'default' ) ? sanitize_text_field( $value ) : false; // Social media foreach ( $input['social_media'] as $key => &$value ) { // RSS Feed (use site feed) if ( $key === 'rss_url_use_site_feed' && $value ) { $value = true; $input['social_media']['rss_url'] = ''; } else $value = esc_url( $value ); } // Ensure the 'rss_url_use_site_feed' key is set in social media if ( ! isset( $input['social_media']['rss_url_use_site_feed'] ) ) $input['social_media']['rss_url_use_site_feed'] = false; return $input; } /** * This function handles the rendering of the options page. */ function sds_theme_options_page() { global $_wp_admin_css_colors; $user_admin_color = get_user_meta( get_current_user_id(), 'admin_color', true ); ?>

theme->get( 'Name' ); ?>

false, 'color_scheme' => false, 'hide_tagline' => false, 'web_font' => false, // Content Layouts 'content_layouts' => array( 'global' => false, 'front_page'=> false, 'home' => false, 'single' => false, 'page' => false, 'archive' => false, 'category' => false, 'tag' => false, '404' => false ), // Social Media 'social_media' => array( 'facebook_url' => '', 'twitter_url' => '', 'linkedin_url' => '', 'google_plus_url' => '', 'youtube_url' => '', 'vimeo_url' => '', 'instagram_url' => '', 'pinterest_url' => '', 'flickr_url' => '', //'yelp_url' => '', 'foursquare_url' => '', 'rss_url' => '', 'rss_url_use_site_feed' => false ) ); return apply_filters( 'sds_theme_options_defaults', $defaults ); } /** * This function returns a formatted list of Google Web Font families for use when enqueuing styles. */ function get_google_font_families_list() { if ( function_exists( 'sds_web_fonts' ) ) { $web_fonts = sds_web_fonts(); $web_fonts_count = count( $web_fonts ); $google_families = ''; if ( ! empty( $web_fonts ) && is_array( $web_fonts ) ) { foreach( $web_fonts as $name => $atts ) { // Google Font Name $google_families .= $name; if ( $web_fonts_count > 1 ) $google_families .= '|'; } // Trim last | when multiple fonts are set if ( $web_fonts_count > 1 ) $google_families = substr( $google_families, 0, -1 ); } return $google_families; } } /** * This function returns the details of the current parent theme. */ function get_parent_theme() { if ( is_a( $this->theme, 'WP_Theme' ) ) return $this->theme; return ( is_child_theme() ) ? wp_get_theme()->parent() : wp_get_theme(); } /** * This function returns the HTML output of a social media field. */ function social_media_field( $field_id ) { global $sds_theme_options; ?>
$atts ) : ?>