<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div class="container">
 *
 * @package Creator World
 */
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php
	//wp_body_open hook from WordPress 5.2
	if ( function_exists( 'wp_body_open' ) ) {
	    wp_body_open();
	}
?>
<?php
$disabled_slides 	  	= esc_attr( get_theme_mod('disabled_slides', false) );
?>
<a class="skip-link screen-reader-text" href="#page_content">
<?php esc_html_e( 'Skip to content', 'creator-world' ); ?>
</a>
<div id="pagewrap">
<div class="headertop">
 <div class="container">
      <?php if ( ! dynamic_sidebar( 'header-info' ) ) : ?>
      <?php endif; // end header widget area ?>
 </div><!-- .container -->  
</div><!-- .headertop -->  


<div class="header">
  <div class="container">
    <div class="logo">
           <?php creator_world_the_custom_logo(); ?>
          <h1><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo('name'); ?></a></h1>
            <?php $description = get_bloginfo( 'description', 'display' );
            if ( $description || is_customize_preview() ) : ?>
                <p><?php echo esc_html($description); ?></p>
            <?php endif; ?>
    </div><!-- logo -->
    <div class="toggle"> <a class="toggleMenu" href="#">
      <?php esc_html_e('Menu','creator-world'); ?>
      </a> </div> <!-- toggle -->
    <div class="sitenav">
      <?php wp_nav_menu(array('theme_location' => 'primary')); ?>
    </div>
    <!-- site-nav -->
    <div class="clear"></div>
  </div><!-- container -->
</div><!--.header -->

<?php 
if ( is_front_page() && !is_home() ) {
if($disabled_slides != '') {
	for($i=7; $i<=10; $i++) {
	  if( get_theme_mod('page-setting'.$i,false)) {
		$slider_Arr[] = absint( get_theme_mod('page-setting'.$i,true));
	  }
	}
?> 
<div class="slider_wrapper">                
<?php if(!empty($slider_Arr)){ ?>
<div id="slider" class="nivoSlider">
<?php 
$i=1;
$slidequery = new WP_Query( array( 'post_type' => 'page', 'post__in' => $slider_Arr, 'orderby' => 'post__in' ) );
while( $slidequery->have_posts() ) : $slidequery->the_post();
$image = wp_get_attachment_url( get_post_thumbnail_id($post->ID)); 
$thumbnail_id = get_post_thumbnail_id( $post->ID );
$alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true); 
?>
<?php if(!empty($image)){ ?>
<img src="<?php echo esc_url( $image ); ?>" title="#slidecaption<?php echo esc_attr( $i ); ?>" alt="<?php echo esc_attr($alt); ?>" />
<?php }else{ ?>
<img src="<?php echo esc_url( get_template_directory_uri() ) ; ?>/images/slides/slider-default.jpg" title="#slidecaption<?php echo esc_attr( $i ); ?>" alt="<?php echo esc_attr($alt); ?>" />
<?php } ?>
<?php $i++; endwhile; ?>
</div>   

<?php 
$j=1;
$slidequery->rewind_posts();
while( $slidequery->have_posts() ) : $slidequery->the_post(); ?>                 
    <div id="slidecaption<?php echo esc_attr( $j ); ?>" class="nivo-html-caption">         
    	<h2><?php the_title(); ?></h2>
    	<?php the_excerpt(); ?>		               
    </div>   
<?php $j++; 
endwhile;
wp_reset_postdata(); ?>   
<?php } ?>
<?php } } ?>


<?php if ( is_front_page() && ! is_home() ) { ?>
 <?php $hidewelcome = get_theme_mod('disabled_welcome', '1'); ?>
		<?php if($hidewelcome == ''){ ?>  
<section id="welcomesection">
  <div class="container">
    <div class="welcomebx">
      <?php if( get_theme_mod('page-setting1')) { ?>
      <?php $queryvar = new WP_query('page_id='.get_theme_mod('page-setting1' ,true)); ?>
      <?php while( $queryvar->have_posts() ) : $queryvar->the_post();?>     
     <h2 class="headingtitle">
        <?php the_title(); ?>
      </h2>
      <?php the_content(); ?>
      <div class="clear"></div>
      <?php endwhile;
			wp_reset_postdata(); ?>                            
       <?php } ?>
    </div> <!-- welcomewrap-->
    <div class="clear"></div>
  </div> <!-- container -->
</section>
<?php } ?> 


 <?php $hidepgbxes = get_theme_mod('disabled_pageboxes', '1'); ?>
		<?php if($hidepgbxes == ''){ ?>  
<section id="wrapsecond">
  <div class="container">
    <div class="services-wrap">
      <?php for($p=1; $p<5; $p++) { ?>
      <?php if( get_theme_mod('page-column'.$p,false)) { ?>
      <?php $querymy = new WP_query('page_id='.get_theme_mod('page-column'.$p,true)); ?>
      <?php while( $querymy->have_posts() ) : $querymy->the_post(); ?>
      <div class="fourbox <?php if($p % 4 == 0) { echo "last_column"; } ?>">           
            <?php if(has_post_thumbnail() ) { ?>
                  <div class="thumbbx"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail();?></a> </div>
            <?php } ?>
           <div class="pagecontent">          
                <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 
               <?php the_excerpt(); ?>        
                <a class="pagemore" href="<?php the_permalink(); ?>">
                 <?php esc_html_e('Read More','creator-world'); ?>
                </a>
           </div>
        </div>
       <?php endwhile;
             wp_reset_postdata(); ?>
        <?php } } ?>      
      <div class="clear"></div>
    </div>   <!-- services-wrap-->
  </div> <!-- container -->
</section>
<?php } ?>
<?php } ?>