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 CSS/JS add_action( 'admin_menu', array( $this, 'admin_menu' ) ); // Register Menu Item } /** * 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 ) { // SDS Theme Options CSS wp_enqueue_style( 'sds-theme-options', SDS_Theme_Options::sds_core_url() . '/css/sds-theme-options.css', false, self::VERSION ); // SDS Theme Options JS wp_enqueue_script( 'sds-theme-options', get_template_directory_uri() . '/includes/js/sds-theme-options.js', array( 'jquery' ), self::VERSION ); // About Page if ( $hook === 'appearance_page_about-baton' ) // Font Awesome wp_enqueue_style( 'font-awesome-css-min', SDS_Theme_Options::sds_core_url() . '/css/font-awesome.min.css' ); } /** * This function adds a menu item under "Appearance" in the Dashboard. */ function admin_menu() { // About add_theme_page( sprintf( __( 'About %1$s', 'baton' ), $this->theme->get( 'Name' ) ), sprintf( __( 'About %1$s', 'baton' ), $this->theme->get( 'Name' ) ), 'edit_theme_options', 'about-baton', array( $this, 'sds_about_theme_page' ) ); } /** * This function handles the rendering of the about page. */ function sds_about_theme_page() { ?>

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

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

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

Customizer to get started.', 'baton' ), $this->theme->get( 'Name' ), esc_url( wp_customize_url() ) ); ?>

General Documentation for helpful guides.', 'baton' ), esc_url( 'https://slocumthemes.com/docs/section/general/' ) ); ?>

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

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

0 && $pro_color_schemes_count > 0 ) printf( __( 'Both %1$s and %1$s Pro have color schemes.', 'baton' ), $this->theme->get( 'Name' ) ); // Pro color schemes only else if ( $free_color_schemes_count === 0 && $pro_color_schemes_count > 0 ) printf( __( '%1$s Pro has color schemes.', 'baton' ), $this->theme->get( 'Name' ) ); // Free color schemes only else if ( $free_color_schemes_count > 0 && $pro_color_schemes_count === 0 ) printf( __( '%1$s has color schemes.', 'baton' ), $this->theme->get( 'Name' ) ); // Free vs Pro color scheme count if ( $free_color_schemes_count < $pro_color_schemes_count ) printf( __( ' %1$s Pro offers more color schemes for you to choose from.', 'baton' ), $this->theme->get( 'Name' ) ); ?>

0 ) : ?>

0 ) : ?>

0 && $pro_web_fonts_count > 0 ) printf( __( 'Both %1$s and %1$s Pro have web fonts.', 'baton' ), $this->theme->get( 'Name' ) ); // Pro web fonts only else if ( $free_web_fonts_count === 0 && $pro_web_fonts_count > 0 ) printf( __( '%1$s Pro has web fonts.', 'baton' ), $this->theme->get( 'Name' ) ); // Free web fonts only else if ( $free_web_fonts_count > 0 && $pro_web_fonts_count === 0 ) printf( __( '%1$s has web fonts.', 'baton' ), $this->theme->get( 'Name' ) ); // Free vs Pro web font count if ( $free_web_fonts_count < $pro_web_fonts_count ) printf( __( ' %1$s Pro offers more web fonts for you to choose from.', 'baton' ), $this->theme->get( 'Name' ) ); ?>

0 ) : ?>

0 ) : ?>

0 && $pro_content_layouts_count > 0 ) printf( __( 'Both %1$s and %1$s Pro have content layouts.', 'baton' ), $this->theme->get( 'Name' ) ); // Pro content layouts only else if ( $free_content_layouts_count === 0 && $pro_content_layouts_count > 0 ) printf( __( '%1$s Pro has content layouts.', 'baton' ), $this->theme->get( 'Name' ) ); // Free content layouts only else if ( $free_content_layouts_count > 0 && $pro_content_layouts_count === 0 ) printf( __( '%1$s has content layouts.', 'baton' ), $this->theme->get( 'Name' ) ); // Free vs Pro content layout count if ( $free_content_layouts_count < $pro_content_layouts_count ) printf( __( ' %1$s Pro offers more content layouts for you to choose from.', 'baton' ), $this->theme->get( 'Name' ) ); ?>

0 ) : ?>

0 ) : ?>

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

get_sds_theme_option_defaults(); // Remove Logo if ( isset( $input['remove-logo'] ) ) { unset( $input['remove-logo'] ); // We don't want to store this value in the options array $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'] !== 'default' ) ? sanitize_text_field( $input['web_font'] ) : false; $input['hide_tagline'] = ( $input['hide_tagline'] ) ? true : false; // Color Scheme (remove content/background colors if they match another color scheme's default values) if ( ! empty( $input['color_scheme'] ) ) { // Get color schemes $color_schemes = ( function_exists( 'sds_color_schemes' ) ) ? sds_color_schemes() : array(); if ( ! empty( $color_schemes ) ) { unset( $color_schemes[$input['color_scheme']]); // Remove current color scheme // Get current theme mods $theme_mod_content_color = get_theme_mod( 'content_color' ); $theme_mod_background_color = get_theme_mod( 'background_color' ); // Loop through color schemes foreach( $color_schemes as $color_scheme_id => $color_scheme ) { // Check to see if the current content color theme mod matches this color scheme's default value if ( $color_scheme['content_color'] === $theme_mod_content_color ) remove_theme_mod( 'content_color' ); // Check to see if the current background color theme mod matches this color scheme's default value if ( isset( $color_scheme['background_color'] ) && ltrim( $color_scheme['background_color'], '#' ) === $theme_mod_background_color ) remove_theme_mod( 'background_color' ); } } } // 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; } /********************** * Internal Functions * **********************/ /** * This function returns default values for SDS Theme Options */ public static function get_sds_theme_option_defaults() { $defaults = array( // General 'logo_attachment_id' => 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; } return false; } /** * This function returns the details of the current parent theme. */ public 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(); } /******************** * Helper Functions * ********************/ /** * This function returns the current option values. */ public static function get_sds_theme_options() { global $sds_theme_options; $sds_theme_options = wp_parse_args( get_option( self::$option_name ), SDS_Theme_Options::get_sds_theme_option_defaults() ); return $sds_theme_options; } /** * This function returns the current option name. */ public static function get_option_name() { return self::$option_name; } /** * This function returns the directory for SDS Core without a trailing slash. A relative directory * can be returned by passing true for the $relative parameter. */ public static function sds_core_dir( $relative = false ) { // Replace backslashes on Windows machines $template_dir = str_replace( array( '\\\\', '\\' ), '/', get_template_directory() ); $file_dir = str_replace( array( '\\\\', '\\' ), '/', dirname( __FILE__ ) ); return untrailingslashit( ( $relative ) ? str_replace( $template_dir, '', $file_dir ) : $file_dir ); } /** * This function returns the url for SDS Core without a trailing slash. */ public static function sds_core_url() { return untrailingslashit( get_template_directory_uri() . self::sds_core_dir( true ) ); } } function SDS_Theme_Options_Instance() { return SDS_Theme_Options::instance(); } // Instantiate SDS_Theme_Options SDS_Theme_Options_Instance(); }