<?php
/**
 *
 * WARNING: Please do not edit this file.
 * @see http://codex.wordpress.org/Child_Themes
 *
 * Load the theme function files (options panel, theme functions, widgets, etc...).
 */

include_once get_template_directory() . '/includes/ModernEstate.php'; // Modern Estate Class (main functionality, actions/filters)

include_once get_template_directory() . '/includes/class-tgm-plugin-activation.php'; // TGM Activation

include_once get_template_directory() . '/includes/theme-options.php'; // SDS Theme Options
include_once get_template_directory() . '/includes/theme-functions.php'; // SDS Theme Options Functions
include_once get_template_directory() . '/includes/widget-social-media.php'; // SDS Social Media Widget

include_once get_template_directory() . '/includes/tha-theme-hooks.php'; // Theme Hook Alliance


/**
 * ---------------
 * Theme Specifics
 * ---------------
 */

/**
 * Set the Content Width for embeded items.
 */
if ( ! isset( $content_width ) )
	$content_width = 685;

/**
 * This function outputs the Footer Sidebar.
 */
function me_footer_left_sidebar() {
	if ( is_active_sidebar( 'footer-left-sidebar' ) )
		dynamic_sidebar( 'footer-left-sidebar' );
}

/**
 * This function registers all color schemes available in this theme.
 */
if ( ! function_exists( 'sds_color_schemes' ) ) {
	function sds_color_schemes() {
		$color_schemes = array(
			'default' => array( // Name used in saved option
				'label' => 'Blue', // Label on options panel (required)
				'stylesheet' => false, // Stylesheet URL, relative to theme directory (required)
				'preview' => '#36506a', // Preview color on options panel (required)
				'default' => true
			),
			'gray' => array(
				'label' => 'Gray',
				'stylesheet' => '/css/gray.css',
				'preview' => '#acacac',
				'deps' => 'modern-estate'
			)
		);

		return apply_filters( 'sds_theme_options_color_schemes', $color_schemes );
	}
}

/**
 * This function registers all web fonts available in this theme.
 */
if ( ! function_exists( 'sds_web_fonts' ) ) {
	function sds_web_fonts() {
		$web_fonts = array(
			// Lato
			'Lato:400' => array(
				'label' => 'Lato',
				'css' => 'font-family: \'Lato\', sans-serif;'
			)
		);

		return apply_filters( 'sds_theme_options_web_fonts', $web_fonts );
	}
}

/**
 * This function sets a default featured image size for use in this theme.
 */
if ( ! function_exists( 'sds_theme_options_default_featured_image_size' ) ) {
	add_filter( 'sds_theme_options_default_featured_image_size', 'sds_theme_options_default_featured_image_size' );

	function sds_theme_options_default_featured_image_size( $default ) {
		return 'me-200x300';
	}
}

/**
 * This function adds the custom Theme Customizer styles to the <head> tag.
 */
if ( ! function_exists( 'me_wp_head' ) ) {
	add_filter( 'wp_head', 'me_wp_head', 20 );

	function me_wp_head() {
		$sds_theme_options_instance = SDS_Theme_Options_Instance();
	?>
		<style type="text/css" id="<?php echo $sds_theme_options_instance->get_parent_theme()->get_template(); ?>-theme-customizer">
			/* Content Color */
			.blog-post, .inner-block, .news-block, footer.post-footer, #post-author, .post-content {
				color: <?php echo get_theme_mod( 'content_color' ); ?>;
			}
		</style>
	<?php
	}
}

if ( ! function_exists( 'sds_theme_options_ads' ) ) {
	add_action( 'sds_theme_options_ads', 'sds_theme_options_ads' );

	function sds_theme_options_ads() {
	?>
		<div class="sds-theme-options-ad">
			<a href="<?php echo esc_url( __( 'http://slocumthemes.com/wordpress-themes/modern-estate-theme/', 'modern-estate' ) ); ?>" target="_blank" class="sds-theme-options-upgrade-ad">
				<h3><?php _e( 'Upgrade to Modern Estate Pro!', 'modern-estate' ); ?></h3>
				<ul>
					<li><?php _e( 'Priority Ticketing Support', 'modern-estate' ); ?></li>
					<li><?php _e( 'More Color Schemes', 'modern-estate' ); ?></li>
					<li><?php _e( 'More Web Fonts', 'modern-estate' ); ?></li>
					<li><?php _e( 'Adjust Featured Image Sizes', 'modern-estate' ); ?></li>
					<li><?php _e( 'Easily Add Custom Scripts/Styles', 'modern-estate' ); ?></li>
					<li><?php _e( 'and More!', 'modern-estate' ); ?></li>
				</ul>

				<span class="sds-theme-options-btn-green"><?php _e( 'Upgrade Now!', 'modern-estate' ); ?></span>
			</a>
		</div>
	<?php
	}
}

if ( ! function_exists( 'sds_theme_options_upgrade_cta' ) ) {
	add_action( 'sds_theme_options_upgrade_cta', 'sds_theme_options_upgrade_cta' );

	function sds_theme_options_upgrade_cta( $type ) {
		switch( $type ) :
			case 'color-schemes':
			?>
				<p><?php printf( __( '<a href="%1$s">Upgrade to Modern Estate Pro</a> and receive more color schemes!', 'modern-estate' ), esc_url( 'http://slocumthemes.com/wordpress-themes/modern-estate-theme/' ) ); ?></p>
			<?php
			break;
			case 'web-fonts':
			?>
				<p><?php printf( __( '<a href="%1$s">Upgrade to Modern Estate Pro</a> to use more web fonts!', 'modern-estate' ), esc_url( 'http://slocumthemes.com/wordpress-themes/modern-estate-theme/' ) ); ?></p>
			<?php
			break;
			case 'help-support':
			?>
				<p><?php printf( __( '<a href="%1$s">Upgrade to Modern Estate Pro</a> to receive priority ticketing support!', 'modern-estate' ), esc_url( 'http://slocumthemes.com/wordpress-themes/modern-estate-theme/' ) ); ?></p>
			<?php
			break;
		endswitch;
	}
}

if ( ! function_exists( 'sds_theme_options_help_support_tab_content' ) ) {
	add_action( 'sds_theme_options_help_support_tab_content', 'sds_theme_options_help_support_tab_content' );

	function sds_theme_options_help_support_tab_content( ) {
	?>
		<p><?php printf( __( 'If you\'d like to create a support request, please visit the <a href="%1$s">Modern Estate Forums on WordPress.org</a>.', 'modern-estate' ), esc_url( 'http://wordpress.org/support/theme/modern-estate/' ) ); ?></p>
	<?php
	}
}

if ( ! function_exists( 'sds_copyright_branding' ) ) {
	add_filter( 'sds_copyright_branding', 'sds_copyright_branding', 10, 2 );

	function sds_copyright_branding( $text, $theme_name ) {
		return sprintf( __( '<a href="%1$s">%2$s by Slocum Studio</a>', 'modern-estate' ), esc_url( 'http://slocumthemes.com/wordpress-themes/modern-estate-free/' ), $theme_name );
	}
}