<?php
/**
 * This file includes the theme functions.
 *
 * @package Organic Startup
 * @since Organic Startup 1.0
 */

/*
-------------------------------------------------------------------------------------------------------
	Theme Setup
-------------------------------------------------------------------------------------------------------
*/

if ( ! function_exists( 'organic_startup_setup' ) ) :

	/** Function organic_startup_setup */
	function organic_startup_setup() {
		/*
		* Enable support for translation.
		*/
		load_theme_textdomain( 'organic-startup', get_template_directory() . '/languages' );

		/*
		* Enable support for RSS feed links to head.
		*/
		add_theme_support( 'automatic-feed-links' );

		/*
		* Enable support for wide alignment class for Gutenberg blocks.
		*/
		add_theme_support( 'align-wide' );

		/*
		* Enable selective refresh for widgets.
		*/
		add_theme_support( 'customize-selective-refresh-widgets' );

		/*
		* Enable support for post thumbnails.
		*/
		add_theme_support( 'post-thumbnails' );

		add_image_size( 'startup-featured-large', 2400, 1800, true ); // Large Featured Image.
		add_image_size( 'startup-featured-medium', 1200, 800, true ); // Medium Featured Image.
		add_image_size( 'startup-featured-square', 1200, 1200, true ); // Square Featured Image.

		/*
		* Enable support for site title tag.
		*/
		add_theme_support( 'title-tag' );

		/*
		* Enable support for custom logo.
		*/
		add_theme_support(
			'custom-logo',
			array(
				'height'      => 360,
				'width'       => 640,
				'flex-height' => true,
				'flex-width'  => true,
			)
		);

		/*
		* Enable support for custom menus.
		*/
		register_nav_menus(
			array(
				'main-menu'   => esc_html__( 'Main Menu', 'organic-startup' ),
				'top-menu'    => esc_html__( 'Top Secondary Menu', 'organic-startup' ),
				'social-menu' => esc_html__( 'Social Menu', 'organic-startup' ),
				'mobile-menu' => esc_html__( 'Mobile Menu', 'organic-startup' ),
			)
		);

		/*
		* Enable support for custom header.
		*/
		register_default_headers(
			array(
				'default' => array(
					'url'           => get_template_directory_uri() . '/images/default-header.jpg',
					'thumbnail_url' => get_template_directory_uri() . '/images/default-header.jpg',
					'description'   => esc_html__( 'Default Custom Header', 'organic-startup' ),
				),
			)
		);
		$defaults = array(
			'video'         => true,
			'width'         => 1800,
			'height'        => 480,
			'flex-height'   => true,
			'flex-width'    => true,
			'default-image' => get_template_directory_uri() . '/images/default-header.jpg',
			'header-text'   => false,
			'uploads'       => true,
		);
		add_theme_support( 'custom-header', $defaults );

		/*
		* Enable support for custom background.
		*/
		$defaults = array(
			'default-color' => 'ffffff',
		);
		add_theme_support( 'custom-background', $defaults );

		/*
		* Enable theme starter content.
		*/
		add_theme_support(
			'starter-content',
			array(

				// Starter theme options.
				'theme_mods'  => array(
					'organic_startup_sticky_nav'         => '1',
					'organic_startup_header_transparent' => '1',
				),

				// Set default theme logo and title.
				'options'     => array(
					'custom_logo'     => '{{logo}}',
					'blogname'        => __( 'StartUp', 'organic-startup' ),
					'blogdescription' => __( 'My <b>Awesome</b> Organic Theme', 'organic-startup' ),
					'show_on_front'   => 'page',
					'page_on_front'   => '{{get-started}}',
					'page_for_posts'  => '{{blog}}',
				),

				// Starter pages to include.
				'posts'       => array(
					'get-started' => array(
						'post_type'    => 'page',
						'post_title'   => __( 'Getting Started', 'organic-startup' ),
						'post_content' => __( '<p>Welcome to the <b>StartUp Theme</b>. To get started, install and activate the <a href="https://github.com/Invulu/organic-widgets">Organic Customizer Widgets</a> plugin. Then apply the "Organic Custom" page template to this page, and enter the WordPress Customizer to begin building your page.</p>', 'organic-startup' ),
						'thumbnail'    => '{{image-home}}',
						'template'     => 'template-full.php',
					),
					'about'       => array(
						'thumbnail' => '{{image-about}}',
					),
					'services'    => array(
						'post_type'    => 'page',
						'post_title'   => __( 'Services', 'organic-startup' ),
						'post_content' => __( '<p>This is an example services page. You may want to write about the various services your company provides.</p>', 'organic-startup' ),
						'thumbnail'    => '{{image-services}}',
					),
					'blog',
					'contact'     => array(
						'thumbnail' => '{{image-contact}}',
					),
				),

				// Starter attachments for default images.
				'attachments' => array(
					'logo'           => array(
						'post_title' => __( 'Logo', 'organic-startup' ),
						'file'       => 'images/logo.png',
					),
					'image-home'     => array(
						'post_title' => __( 'Home Image', 'organic-startup' ),
						'file'       => 'images/image-home.jpg',
					),
					'image-about'    => array(
						'post_title' => __( 'About Image', 'organic-startup' ),
						'file'       => 'images/image-about.jpg',
					),
					'image-services' => array(
						'post_title' => __( 'Services Image', 'organic-startup' ),
						'file'       => 'images/image-services.jpg',
					),
					'image-contact'  => array(
						'post_title' => __( 'Contact Image', 'organic-startup' ),
						'file'       => 'images/image-contact.jpg',
					),
				),

				// Add pages to primary navigation menu.
				'nav_menus'   => array(
					'main-menu' => array(
						'name'  => __( 'Primary Navigation', 'organic-startup' ),
						'items' => array(
							'page_started'  => array(
								'type'      => 'post_type',
								'object'    => 'page',
								'title'     => __( 'Home', 'organic-startup' ),
								'object_id' => '{{get-started}}',
							),
							'page_about',
							'page_services' => array(
								'type'      => 'post_type',
								'object'    => 'page',
								'object_id' => '{{services}}',
							),
							'page_blog',
							'page_contact',
						),
					),
				),

				// Add test widgets to footer.
				'widgets'     => array(
					'footer' => array(
						'meta',
						'recent-posts',
						'text_about',
						'text_business_info',
					),
				),

			)
		);

	}
endif; // End function organic_startup_setup.
add_action( 'after_setup_theme', 'organic_startup_setup' );

/*
-------------------------------------------------------------------------------------------------------
	License Admin Notice
-------------------------------------------------------------------------------------------------------
*/

/** Function organic_startup_admin_notice */
function organic_startup_admin_notice_license() {

	$license = get_option( 'organic-startup_license_key' );
	$status  = get_option( 'organic-startup_license_key_status' );

	if ( ! PAnD::is_admin_notice_active( 'notice-organic-startup-license-forever' ) ) {
		return;
	}

	if ( 'valid' !== $status ) {
		?>

		<div data-dismissible="notice-organic-startup-license-forever" class="notice error">
				<p style="margin-bottom: 6px;"><?php /* translators: 1: admin link to license page, 2: link to account page */ printf( esc_html__( 'It appears your Organic Themes License has not been activated. Please %1$s your theme license. Your license is located within your Organic Themes %2$s.', 'organic-startup' ), sprintf( '<a href="%1$s"><strong>activate</strong></a>', esc_url( admin_url( 'themes.php?page=organic-startup-license' ) ) ), sprintf( '<a href="%1$s" target="_blank"><strong>account</strong></a>', esc_url( 'https://organicthemes.com/account/account-licenses/' ) ) ); ?></p>
				<p><a class="button button-primary" href="<?php echo esc_url( admin_url( 'themes.php?page=organic-startup-license' ) ); ?>"><?php esc_html_e( 'Activate Your License', 'organic-startup' ); ?></a></p>
			</div>

		<?php
	}
}
if ( ! function_exists( 'organic_startup_admin_notice_help' ) ) {

	/** Function organic_startup_admin_notice_help */
	function organic_startup_admin_notice_help() {
		if ( ! PAnD::is_admin_notice_active( 'notice-organic-startup-help' ) ) {
			return;
		}
		?>

		<div data-dismissible="notice-organic-startup-help" class="notice updated is-dismissible">
			<p><?php printf( wp_kses_post( 'Thanks for choosing an <b>Organic Theme</b>! View our <a href="%1$s" target="_blank">Theme Documentation</a> and <a href="%2$s" target="_blank">Support Forums</a> for help getting started.', 'organic-startup' ), 'https://organicthemes.com/documentation/', 'https://organicthemes.com/forums/forum/theme-support/' ); ?></p>
		</div>

		<?php
	}
}
add_action( 'admin_init', array( 'PAnD', 'init' ) );
add_action( 'admin_notices', 'organic_startup_admin_notice_license' );
add_action( 'admin_notices', 'organic_startup_admin_notice_help' );

/*
-------------------------------------------------------------------------------------------------------
	Register Scripts
-------------------------------------------------------------------------------------------------------
*/

if ( ! function_exists( 'organic_startup_enqueue_scripts' ) ) {

	/** Function organic_startup_enqueue_scripts */
	function organic_startup_enqueue_scripts() {

		// Enqueue Styles.
		wp_enqueue_style( 'organic-startup-style', get_stylesheet_uri(), '', '1.0' );
		wp_enqueue_style( 'organic-startup-style-conditionals', get_template_directory_uri() . '/css/style-conditionals.css', array( 'organic-startup-style' ), '1.0' );
		wp_enqueue_style( 'organic-startup-style-mobile', get_template_directory_uri() . '/css/style-mobile.css', array( 'organic-startup-style' ), '1.0' );
		wp_enqueue_style( 'organic-startup-font-awesome', get_template_directory_uri() . '/css/font-awesome.css', array( 'organic-startup-style' ), '5.15.2' );
		wp_add_inline_style( 'organic_startup_custom_styles', 'organic_startup_custom_styles' );

		// Resgister Scripts.
		wp_register_script( 'jquery-sidr', get_template_directory_uri() . '/js/jquery.sidr.js', array( 'jquery' ), '1.0', true );
		wp_register_script( 'jquery-fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), '1.0', true );
		wp_register_script( 'jquery-bg-brightness', get_template_directory_uri() . '/js/jquery.brightness.js', array( 'jquery' ), '1.0', true );

		// Enqueue Scripts.
		wp_enqueue_script( 'organic-startup-custom', get_template_directory_uri() . '/js/jquery.custom.js', array( 'jquery', 'jquery-sidr', 'jquery-fitvids', 'jquery-bg-brightness', 'masonry' ), '1.0', true );

		// Load Flexslider on front page and slideshow page template.
		if ( is_page_template( 'template-slideshow.php' ) ) {
			wp_enqueue_script( 'jquery-flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array( 'jquery' ), '1.0', true );
		}

		// Load single scripts only on single pages.
		if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
			wp_enqueue_script( 'comment-reply' );
		}
	}
}
add_action( 'wp_enqueue_scripts', 'organic_startup_enqueue_scripts' );

/*
-------------------------------------------------------------------------------------------------------
	Gutenberg Editor Styles
-------------------------------------------------------------------------------------------------------
*/

/**
 * Enqueue WordPress theme styles within Gutenberg.
 */
function organic_startup_gutenberg_styles() {
	// Load the theme styles within Gutenberg.
	wp_enqueue_style(
		'organic-startup-gutenberg',
		get_theme_file_uri( '/css/gutenberg.css' ),
		false,
		'1.0',
		'all'
	);
}
add_action( 'enqueue_block_editor_assets', 'organic_startup_gutenberg_styles' );

/*
-------------------------------------------------------------------------------------------------------
	Theme Updater
-------------------------------------------------------------------------------------------------------
*/

/** Function organic_startup_theme_updater */
function organic_startup_theme_updater() {
	require get_template_directory() . '/updater/theme-updater.php';
}
add_action( 'after_setup_theme', 'organic_startup_theme_updater' );

/*
-------------------------------------------------------------------------------------------------------
	Category ID to Name
-------------------------------------------------------------------------------------------------------
*/

if ( ! function_exists( 'organic_startup_cat_id_to_name' ) ) :

	/**
	 * Changes category IDs to names.
	 *
	 * @param array $id IDs for categories.
	 * @return array
	 */
	function organic_startup_cat_id_to_name( $id ) {
		$cat = get_category( $id );
		if ( is_wp_error( $cat ) ) {
			return false; }
		return $cat->cat_name;
	}

endif;

/*
-------------------------------------------------------------------------------------------------------
	Add Class To Custom Logo
-------------------------------------------------------------------------------------------------------
*/

/** Function organic_startup_add_logo_class */
function organic_startup_add_logo_class( $html ) {
	$html = str_replace( 'custom-logo-link', 'custom-logo-link light-logo', $html );
	return $html;
}
add_filter( 'get_custom_logo', 'organic_startup_add_logo_class' );

/*
-------------------------------------------------------------------------------------------------------
	Register Sidebars
-------------------------------------------------------------------------------------------------------
*/

if ( ! function_exists( 'organic_startup_widgets_init' ) ) :

	/** Function organic_startup_widgets_init */
	function organic_startup_widgets_init() {
		register_sidebar(
			array(
				'name'          => esc_html__( 'Default Sidebar', 'organic-startup' ),
				'id'            => 'sidebar-1',
				'before_widget' => '<aside id="%1$s" class="widget %2$s">',
				'after_widget'  => '</aside>',
				'before_title'  => '<h6>',
				'after_title'   => '</h6>',
			)
		);
		register_sidebar(
			array(
				'name'          => esc_html__( 'Blog Sidebar', 'organic-startup' ),
				'id'            => 'sidebar-blog',
				'before_widget' => '<aside id="%1$s" class="widget %2$s">',
				'after_widget'  => '</aside>',
				'before_title'  => '<h6>',
				'after_title'   => '</h6>',
			)
		);
		register_sidebar(
			array(
				'name'          => esc_html__( 'Left Sidebar', 'organic-startup' ),
				'id'            => 'sidebar-left',
				'before_widget' => '<aside id="%1$s" class="widget %2$s">',
				'after_widget'  => '</aside>',
				'before_title'  => '<h6>',
				'after_title'   => '</h6>',
			)
		);
		register_sidebar(
			array(
				'name'          => esc_html__( 'Footer Widgets', 'organic-startup' ),
				'id'            => 'footer',
				'before_widget' => '<aside id="%1$s" class="widget %2$s"><div class="footer-widget">',
				'after_widget'  => '</div></aside>',
				'before_title'  => '<h6>',
				'after_title'   => '</h6>',
			)
		);
	}

endif;
add_action( 'widgets_init', 'organic_startup_widgets_init' );

/*
-------------------------------------------------------------------------------------------------------
	Posted On Function
-------------------------------------------------------------------------------------------------------
*/

if ( ! function_exists( 'organic_startup_posted_on' ) ) :

	/** Function organic_startup_posted_on */
	function organic_startup_posted_on() {
		printf(
			/* translators: 1: posted wrapper, 2: date and time permalink */
			__( '<span class="%1$s">Posted:</span> %2$s', 'organic-startup' ),
			'meta-prep meta-prep-author',
			sprintf(
				'<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
				esc_url( get_permalink() ),
				esc_attr( get_the_time() ),
				get_the_date( get_option( 'date_format' ) )
			)
		);
	}
endif;

/*
------------------------------------------------------------------------------------------------------
	Content Width
------------------------------------------------------------------------------------------------------
*/

if ( ! isset( $content_width ) ) {
	$content_width = 840; }

if ( ! function_exists( 'organic_startup_content_width' ) ) :

	/** Function organic_startup_content_width */
	function organic_startup_content_width() {
		$GLOBALS['content_width'] = apply_filters( 'organic_startup_content_width', 840 );
	}
endif;
add_action( 'after_setup_theme', 'organic_startup_content_width', 0 );

/*
-------------------------------------------------------------------------------------------------------
	Comments Function
-------------------------------------------------------------------------------------------------------
*/

if ( ! function_exists( 'organic_startup_comment' ) ) :

	/**
	 * Setup our comments for the theme.
	 *
	 * @param array $comment IDs for categories.
	 * @param array $args Comment arguments.
	 * @param array $depth Level of replies.
	 */
	function organic_startup_comment( $comment, $args, $depth ) {
		switch ( $comment->comment_type ) :
			case 'pingback':
			case 'trackback':
				?>
		<li class="post pingback">
			<p><?php esc_html_e( 'Pingback:', 'organic-startup' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( esc_html__( 'Edit', 'organic-startup' ), '<span class="edit-link">', '</span>' ); ?></p>
				<?php
				break;
			default:
				?>
			<li <?php comment_class(); ?> id="<?php echo esc_attr( 'li-comment-' . get_comment_ID() ); ?>">

				<article id="<?php echo esc_attr( 'comment-' . get_comment_ID() ); ?>" class="comment">
					<footer class="comment-meta">
						<div class="comment-author vcard">
							<?php
								$avatar_size = 48;
							if ( '0' !== $comment->comment_parent ) {
								$avatar_size = 48; }

								echo get_avatar( $comment, $avatar_size );

								printf(
									/* translators: 1: comment author, 2: date and time */
									esc_html__( '%1$s %2$s', 'organic-startup' ),
									sprintf( '<span class="comment-name">%s</span><br />', wp_kses_post( get_comment_author_link() ) ),
									sprintf(
										'<a class="comment-time" href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a><br />',
										esc_url( get_comment_link( $comment->comment_ID ) ),
										esc_html( get_comment_time( 'c' ) ),
										/* translators: 1: date, 2: time */
										sprintf( esc_html__( '%1$s, %2$s', 'organic-startup' ), esc_html( get_comment_date() ), esc_html( get_comment_time() ) )
									)
								);
							?>
						</div><!-- END .comment-author .vcard -->
					</footer>

					<div class="comment-content">
						<?php if ( '0' === $comment->comment_approved ) : ?>
						<em class="comment-awaiting-moderation"><?php esc_html_e( 'Your comment is awaiting moderation.', 'organic-startup' ); ?></em>
						<br />
					<?php endif; ?>
						<?php comment_text(); ?>
						<div class="reply">
						<?php
						comment_reply_link(
							array_merge(
								$args,
								array(
									'reply_text' => esc_html__( 'Reply', 'organic-startup' ),
									'depth'      => $depth,
									'max_depth'  => $args['max_depth'],
								)
							)
						);
						?>
						</div><!-- .reply -->
						<?php edit_comment_link( esc_html__( 'Edit', 'organic-startup' ), '<span class="edit-link">', '</span>' ); ?>
					</div>

				</article><!-- #comment-## -->

				<?php
		endswitch;
	}
endif; // Ends check for organic_startup_comment().

/*
-------------------------------------------------------------------------------------------------------
	Custom Excerpt
-------------------------------------------------------------------------------------------------------
*/

/**
 * Replaces "[...]" (appended to automatically generated excerpts) with ... and
 * a 'Continue reading' link.
 *
 * @since Startup 1.0
 *
 * @param string $more_link 'Continue reading' link prepended with an ellipsis.
 */
function organic_startup_excerpt_more( $more_link ) {
	if ( is_admin() ) {
		return $more_link;
	}

	$more_link = sprintf(
		'<p class="more-link-wrapper"><a href="%1$s" class="more-link">%2$s</a></p>',
		esc_url( get_permalink( get_the_ID() ) ),
		/* translators: %s: Name of current post */
		sprintf( __( 'Continue Reading<span class="screen-reader-text"> "%s"</span>', 'organic-startup' ), get_the_title( get_the_ID() ) )
	);
	return $more_link;
}
add_filter( 'excerpt_more', 'organic_startup_excerpt_more' );

/**
 * Adds paragraph wrapper to more tags.
 *
 * @since Startup 1.0
 *
 * @param string $more_link 'Continue reading' link prepended with an ellipsis.
 */
function organic_startup_more_link( $more_link ) {
	if ( is_admin() ) {
		return $more_link;
	}

	$more_link = sprintf(
		'<p class="more-link-wrapper"><a href="%1$s" class="more-link">%2$s</a></p>',
		esc_url( get_permalink( get_the_ID() ) ),
		/* translators: %s: Name of current post */
		sprintf( __( 'Continue Reading<span class="screen-reader-text"> "%s"</span>', 'organic-startup' ), get_the_title( get_the_ID() ) )
	);
	return $more_link;
}
add_filter( 'the_content_more_link', 'organic_startup_more_link', 10, 2 );

/*
-------------------------------------------------------------------------------------------------------
	Add Excerpt To Pages
-------------------------------------------------------------------------------------------------------
*/

/**
 * Add excerpt to pages.
 */
function organic_startup_page_excerpts() {
	add_post_type_support( 'page', 'excerpt' );
}
add_action( 'init', 'organic_startup_page_excerpts' );

/*
-------------------------------------------------------------------------------------------------------
	Custom Page Links
-------------------------------------------------------------------------------------------------------
*/

if ( ! function_exists( 'organic_startup_wp_link_pages_args_prevnext_add' ) ) :

	/**
	 * Adds custom page links to pages.
	 *
	 * @param array $args for page links.
	 * @return array
	 */
	function organic_startup_wp_link_pages_args_prevnext_add( $args ) {
		global $page, $numpages, $more, $pagenow;

		if ( ! $args['next_or_number'] == 'next_and_number' ) {
			return $args; }

		$args['next_or_number'] = 'number'; // Keep numbering for the main part.
		if ( ! $more ) {
			return $args; }

		if ( $page - 1 ) { // There is a previous page.
			$args['before'] .= _wp_link_page( $page - 1 )
			. $args['link_before'] . $args['previouspagelink'] . $args['link_after'] . '</a>'; }

		if ( $page < $numpages ) { // There is a next page.
			$args['after'] = _wp_link_page( $page + 1 )
			. $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '</a>'
			. $args['after']; }

		return $args;
	}
endif;
add_filter( 'wp_link_pages_args', 'organic_startup_wp_link_pages_args_prevnext_add' );

/*
-----------------------------------------------------------------------------------------------------//
	First Featured Video
-------------------------------------------------------------------------------------------------------
*/

function organic_startup_first_embed_media() {
	global $post, $posts;
	$first_vid = '';
	$content   = do_shortcode( apply_filters( 'the_content', $post->post_content ) );
	$embeds    = get_media_embedded_in_content( $content );

	if ( ! empty( $embeds ) ) {
		foreach ( $embeds as $embed ) {
			if ( strpos( $embed, 'video' ) || strpos( $embed, 'youtube' ) || strpos( $embed, 'vimeo' ) ) {
				return $embed;
			}
		}
	} else {
		return false;
	}
}

/*
-------------------------------------------------------------------------------------------------------
	Remove First Gallery
-------------------------------------------------------------------------------------------------------
*/

if ( ! function_exists( 'organic_startup_remove_gallery' ) ) :

	/**
	 * Removes first gallery shortcode from slideshow page template.
	 *
	 * @param array $content Content output on slideshow page template.
	 * @return array
	 */
	function organic_startup_remove_gallery( $content ) {
		if ( is_page_template( 'template-slideshow.php' ) ) {
			$regex   = get_shortcode_regex( array( 'gallery' ) );
			$content = preg_replace( '/' . $regex . '/s', '', $content, 1 );
			$content = wp_kses_post( $content );
		}
		return $content;
	}
endif;
add_filter( 'the_content', 'organic_startup_remove_gallery' );

/*
-------------------------------------------------------------------------------------------------------
	Body Class
-------------------------------------------------------------------------------------------------------
*/

if ( ! function_exists( 'organic_startup_body_class' ) ) :

	/**
	 * Adds custom classes to the array of body classes.
	 *
	 * @param array $classes Classes for the body element.
	 * @return array
	 */
	function organic_startup_body_class( $classes ) {

		global $post;

		if ( $post ) {
			$page_template = get_page_template_slug( $post->ID );
		} else {
			$page_template = false;
		}

		$header_image = get_header_image();

		$archive_pages = is_home() || is_category() || is_archive() || is_search();

		$woocommerce_pages = class_exists( 'Woocommerce' ) && ( is_woocommerce() || is_cart() || is_checkout() );

		if ( is_customize_preview() ) {
			$classes[] = 'startup-customizer'; }

		if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
			$classes[] = 'startup-has-logo';
		} else {
			$classes[] = 'startup-no-logo';
		}

		if ( is_page_template( 'template-landing.php' ) ) {
			$classes[] = 'startup-landing-page'; }

		if ( is_page_template( 'template-slideshow.php' ) ) {
			$classes[] = 'startup-slideshow'; }

		if ( '1' == get_theme_mod( 'organic_startup_sticky_nav', '' ) ) {
			$classes[] = 'startup-sticky-nav';
		} else {
			$classes[] = 'startup-scroll-nav';
		}

		if ( '1' == get_theme_mod( 'organic_startup_header_transparent', '' ) ) {
			$classes[] = 'startup-header-transparent';
		} else {
			$classes[] = 'startup-header-solid';
		}

		if ( '' == get_theme_mod( 'organic_startup_sticky_nav', '' ) && '' == get_theme_mod( 'organic_startup_header_transparent', '' ) ) {
			$classes[] = 'startup-header-static';
		}

		if ( 'top' == get_theme_mod( 'organic_startup_nav_position', 'top' ) ) {
			$classes[] = 'startup-nav-top'; }

		if ( 'left' == get_theme_mod( 'organic_startup_nav_position', 'top' ) ) {
			$classes[] = 'startup-nav-left'; }

		if ( 'right' == get_theme_mod( 'organic_startup_nav_position', 'top' ) ) {
			$classes[] = 'startup-nav-right'; }

		if ( 'left' == get_theme_mod( 'organic_startup_logo_align', 'left' ) ) {
			$classes[] = 'startup-logo-left'; }

		if ( 'center' == get_theme_mod( 'organic_startup_logo_align', 'left' ) ) {
			$classes[] = 'startup-logo-center'; }

		if ( 'right' == get_theme_mod( 'organic_startup_logo_align', 'left' ) ) {
			$classes[] = 'startup-logo-right'; }

		if ( get_theme_mod( 'organic_startup_logo_dark' ) ) {
			$classes[] = 'startup-logo-dark'; }

		if ( 'blank' != get_theme_mod( 'organic_startup_site_tagline' ) ) {
			$classes[] = 'startup-desc-active';
		} else {
			$classes[] = 'startup-desc-inactive';
		}

		if ( class_exists( 'Organic_Widgets' ) && $page_template == 'templates/organic-custom-template.php'
		|| class_exists( 'Organic_Widgets_Pro' ) && $page_template == 'templates/organic-custom-template.php'
		|| class_exists( 'Woocommerce' ) && is_singular() && ! is_product() && has_post_thumbnail()
		|| ! class_exists( 'Woocommerce' ) && is_singular() && has_post_thumbnail()
		|| $archive_pages && has_custom_header() || is_home() && is_front_page() && has_custom_header() || is_page_template( 'template-slideshow.php' ) && get_post_gallery() ) {
			$classes[] = 'startup-has-img';
		} else {
			$classes[] = 'startup-no-img';
		}

		if ( class_exists( 'Organic_Widgets' ) && $page_template == 'templates/organic-custom-template.php'
		|| class_exists( 'Organic_Widgets_Pro' ) && $page_template == 'templates/organic-custom-template.php' ) {
			$classes[] = 'organic-custom-template';
		} else {
			$classes[] = 'not-organic-custom-template';
		}

		if ( $archive_pages && ! empty( $header_image ) || is_page() && ! has_post_thumbnail() && ! empty( $header_image ) ) {
			$classes[] = 'startup-header-active';
		} else {
			$classes[] = 'startup-header-inactive';
		}

		if ( is_header_video_active() && has_header_video() ) {
			$classes[] = 'startup-header-video-active';
		} else {
			$classes[] = 'startup-header-video-inactive';
		}

		if ( is_singular() ) {
			$classes[] = 'startup-singular';
		}

		if ( is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-blog' ) || is_active_sidebar( 'sidebar-left' ) ) {
			$classes[] = 'startup-sidebar';
		}

		if ( is_active_sidebar( 'sidebar-1' ) && ! is_page_template( 'template-full.php' ) && ! $woocommerce_pages || class_exists( 'Woocommerce' ) && is_shop() && is_active_sidebar( 'shop-sidebar' ) ) {
			$classes[] = 'startup-sidebar-active';
		} else {
			$classes[] = 'startup-sidebar-inactive';
		}

		if ( '' !== get_theme_mod( 'background_image' ) ) {
			// This class will render when a background image is set
			// regardless of whether the user has set a color as well.
			$classes[] = 'startup-background-image';
		} elseif ( ! in_array( get_background_color(), array( '', get_theme_support( 'custom-background', 'default-color' ) ), true ) ) {
			// This class will render when a background color is set
			// but no image is set. In the case the content text will
			// Adjust relative to the background color.
			$classes[] = 'startup-relative-text';
		}

		return $classes;

	}
endif;
add_action( 'body_class', 'organic_startup_body_class' );

/*
-------------------------------------------------------------------------------------------------------
	Includes
-------------------------------------------------------------------------------------------------------
*/

require_once get_template_directory() . '/customizer/customizer.php';
require_once get_template_directory() . '/includes/style-options.php';
require_once get_template_directory() . '/includes/typefaces.php';
require_once get_template_directory() . '/includes/demo-import.php';
require_once get_template_directory() . '/includes/plugin-activation.php';
require_once get_template_directory() . '/includes/plugin-activation-class.php';
require_once get_template_directory() . '/includes/aria-walker-nav-menu.php';
require_once get_template_directory() . '/includes/persist-admin-notices-dismissal/persist-admin-notices-dismissal.php';

/*
-------------------------------------------------------------------------------------------------------
	Load Jetpack File
-------------------------------------------------------------------------------------------------------
*/

if ( class_exists( 'Jetpack' ) ) {
	require get_template_directory() . '/jetpack/jetpack-setup.php';
}

/*
-------------------------------------------------------------------------------------------------------
	Load WooCommerce File
-------------------------------------------------------------------------------------------------------
*/

if ( class_exists( 'Woocommerce' ) ) {
	require get_template_directory() . '/includes/woocommerce-setup.php';
}
