function widget($args, $instance)
    {
        $WidgetHTML = null;
        extract($args);
        //wp_reset_postdata();
        global $post;
        $title = apply_filters('widget_title', $instance['title']);
        $video_category = isset($instance['video_category']) ? $instance['video_category'] : null;
        $video_tag = isset($instance['video_tag']) ? $instance['video_tag'] : null;
        $video_orderby = isset($instance['video_orderby']) ? $instance['video_orderby'] : 'ID';
        $video_order = isset($instance['video_order']) ? $instance['video_order'] : 'DESC';
        $widget_column = isset($instance['widget_column']) ? $instance['widget_column'] : 2;
        $video_shows = isset($instance['video_shows']) ? (int) $instance['video_shows'] : 4;
        print $before_widget;
        print $before_title . $title . $after_title;
        $videos_query = array('post_type' => 'video', 'showposts' => $video_shows);
        if ($video_category) {
            $videos_query['tax_query'] = array(array('taxonomy' => 'categories', 'field' => 'id', 'terms' => $video_category));
        }
        if ($video_tag) {
            $videos_query['tax_query'][] = array('taxonomy' => 'video_tag', 'field' => 'slug', 'terms' => explode(",", $video_tag));
        }
        if ($video_orderby) {
            if ($video_orderby == 'views') {
                $videos_query['meta_key'] = 'count_viewed';
                $videos_query['orderby'] = 'meta_value_num';
            } elseif ($video_orderby == 'likes') {
                $videos_query['meta_key'] = 'like_key';
                $videos_query['orderby'] = 'meta_value_num';
            } else {
                $videos_query['orderby'] = $video_orderby;
            }
        }
        if ($video_order) {
            $videos_query['order'] = $video_order;
        }
        if ($post->ID) {
            $videos_query['post__not_in'] = array($post->ID);
        }
        $wp_query = new WP_Query($videos_query);
        ?>
			<?php 
        if ($widget_column == 2) {
            ?>
	        <div class="row">
	        	<?php 
            if ($wp_query->have_posts()) {
                while ($wp_query->have_posts()) {
                    $wp_query->the_post();
                    ?>
	        	<?php 
                    $postdata = mars_get_post_data(get_the_ID());
                    ?>
	            <div class="col-xs-6 item <?php 
                    print $this->id;
                    ?>
-<?php 
                    print get_the_ID();
                    ?>
">
	            	<div class="item-img">
	            	<?php 
                    if (has_post_thumbnail()) {
                        print '<a title="' . get_the_title() . '" href="' . get_permalink(get_the_ID()) . '">' . get_the_post_thumbnail(null, 'most-video-2col', array('class' => 'img-responsive')) . '</a>';
                    }
                    ?>
						<a href="<?php 
                    echo get_permalink(get_the_ID());
                    ?>
"><div class="img-hover"></div></a>
					</div>	            	
	                <h3><a title="<?php 
                    the_title();
                    ?>
" href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h3>
					<?php 
                    print apply_filters('mars_video_meta', null);
                    ?>
	       		</div>
	       		<?php 
                }
            }
            ?>
	        </div>
	        <?php 
        } else {
            ?>
	        	<?php 
            if ($wp_query->have_posts()) {
                while ($wp_query->have_posts()) {
                    $wp_query->the_post();
                    ?>
	        	<?php 
                    $postdata = mars_get_post_data(get_the_ID());
                    ?>
	        	
			        <div class="item <?php 
                    print $this->id;
                    ?>
-<?php 
                    print get_the_ID();
                    ?>
">
			        	<div class="item-img">
		            	<?php 
                    if (has_post_thumbnail()) {
                        print '<a title="' . get_the_title() . '" href="' . get_permalink(get_the_ID()) . '">' . get_the_post_thumbnail(null, 'video-featured', array('class' => 'img-responsive')) . '</a>';
                    }
                    ?>
							<a href="<?php 
                    echo get_permalink(get_the_ID());
                    ?>
"><div class="img-hover"></div></a>
						</div>		            	
		                <h3><a title="<?php 
                    the_title();
                    ?>
" href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h3>
						<?php 
                    print apply_filters('mars_video_meta', null);
                    ?>
			        </div>	
		        <?php 
                }
            }
            ?>
        
	        <?php 
        }
        ?>
	    <?php 
        print $after_widget;
    }
Example #2
0
        function enable_seo()
        {
            global $post;
            global $wp_query;
            $post_datas = mars_get_post_data($post->ID);
            $meta = NULL;
            $layout = get_post_meta($post->ID, 'layout', true) ? get_post_meta($post->ID, 'layout', true) : 'small';
            if ($layout == 'large') {
                ### Fullwidth Video
                $width = 1140;
                $height = 641;
            } else {
                ### Right sidebar Video
                $width = 750;
                $height = 442;
            }
            ### meta title
            $meta .= '<meta name="title" content="' . get_wp_title_rss() . '">';
            ### meta description, keywords
            if (is_home() || is_front_page() || is_archive() || is_category()) {
                $meta .= '<meta name="description" content="' . get_bloginfo('description') . '">';
                $meta .= '<meta name="keywords" content="' . get_bloginfo('name') . '">';
            } elseif (get_post_type($post->ID) == 'video') {
                $meta .= '<meta name="description" content="' . mars_seo_limit_leng_titlewords(wp_filter_nohtml_kses($post_datas->post_content, 30)) . '">';
                $meta .= '<meta name="keywords" content="' . $this->wp_get_post_terms_string($post->ID, 'video_tag') . '">';
            } else {
                $meta .= '<meta name="description" content="' . mars_seo_limit_leng_titlewords(wp_filter_nohtml_kses($post_datas->post_content, 30)) . '">';
                $meta .= '<meta name="keywords" content="' . $this->wp_get_post_terms_string($post->ID, 'post_tag') . '">';
            }
            ### og tag.
            $meta .= '<meta property="og:site_name" content="' . get_wp_title_rss() . '">';
            if (is_home() && !is_front_page()) {
                $meta .= '<meta property="og:url" content="' . home_url() . '">';
                $meta .= '<meta property="og:title" content="' . get_bloginfo('name') . '">';
                $meta .= '<meta property="og:description" content="' . get_bloginfo('description') . '">';
            }
            if (is_archive()) {
                $meta .= '<meta property="og:url" content="' . get_post_type_archive_link(get_post_type()) . '">';
                $meta .= '<meta property="og:title" content="' . $wp_query->get_queried_object()->name . '">';
                $meta .= '<meta property="og:description" content="' . $wp_query->get_queried_object()->name . '">';
            }
            if (is_tax() || is_category() || is_tag()) {
                $meta .= '<meta property="og:url" content="' . get_term_link($wp_query->get_queried_object()->term_id, $wp_query->get_queried_object()->taxonomy) . '">';
                $meta .= '<meta property="og:title" content="' . $wp_query->get_queried_object()->name . '">';
                $meta .= '<meta property="og:description" content="' . $wp_query->get_queried_object()->name . '">';
            }
            if (is_single() || is_singular('video') || is_page()) {
                $meta .= '<meta property="og:url" content="' . get_permalink($post->ID) . '">';
                $meta .= '<meta property="og:title" content="' . $post_datas->post_title . '">';
                if (is_singular('video')) {
                    $meta .= '<meta property="og:type" content="video">';
                }
                if (has_post_thumbnail($post->ID)) {
                    $thumb_id = get_post_thumbnail_id($post->ID);
                    $thumb_url = wp_get_attachment_image_src($thumb_id, 'full', true);
                    $meta .= '<meta property="og:image" content="' . $thumb_url[0] . '">';
                }
                $meta .= '<meta property="og:description" content="' . $post_datas->post_title . '">';
                if (get_post_type($post->ID) == 'video') {
                    $video_file_url = wp_get_attachment_url(get_post_meta($post->ID, 'video_file', true));
                    if ($video_file_url) {
                        $meta .= '<meta property="og:video" content="' . $video_file_url . '">';
                    } else {
                        $meta .= '<meta property="og:video" content="' . get_permalink($post->ID) . '">';
                    }
                    $meta .= '
						<meta property="og:video:type" content="application/x-shockwave-flash">
						<meta property="og:video:width" content="' . $width . '">
						<meta property="og:video:height" content="' . $height . '">
					';
                }
            }
            print $meta;
        }
Example #3
0
?>
                    </div>
                    <div class="col-xs-3">
						<!-- LIGHT SWITCH -->
						<a href="javascript:void(0)" class="option switch-button">
                            <i class="fa fa-lightbulb-o"></i>
							<span class="option-text"><?php 
_e('Turn off Light', 'mars');
?>
</span>
                        </a>	
                    </div>
                </div>	
				<!-- IF SHARE BUTTON IS CLICKED SHOW THIS -->
				<?php 
$post_data = mars_get_post_data($post->ID);
$url_image = has_post_thumbnail() ? wp_get_attachment_url(get_post_thumbnail_id($post->ID)) : null;
$current_url = get_permalink($post->ID);
$current_title = $post_data->post_title;
$current_trimHTML_Content = esc_html($post_data->post_content);
?>
				<div class="row social-share-buttons">
					<div class="col-xs-12">
						<a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php 
print $current_url;
?>
"><img src="<?php 
echo get_template_directory_uri();
?>
/img/facebook.png" alt="" /></a>
						<a target="_blank" href="https://twitter.com/home?status=<?php 
    function widget($args, $instance)
    {
        $WidgetHTML = null;
        extract($args);
        wp_reset_postdata();
        wp_reset_query();
        global $post;
        $title = apply_filters('widget_title', $instance['title']);
        $post_category = isset($instance['post_category']) ? $instance['post_category'] : null;
        $post_tag = isset($instance['post_tag']) ? $instance['post_tag'] : null;
        $post_orderby = isset($instance['post_orderby']) ? $instance['post_orderby'] : 'ID';
        $post_order = isset($instance['post_order']) ? $instance['post_order'] : 'DESC';
        $widget_column = isset($instance['widget_column']) ? $instance['widget_column'] : 2;
        $post_shows = isset($instance['post_shows']) ? (int) $instance['post_shows'] : 4;
        print $before_widget;
        print $before_title . $title . $after_title;
        $posts_query = array('post_type' => 'post', 'showposts' => $post_shows, 'ignore_sticky_posts' => true);
        if ($post_category) {
            $posts_query['tax_query'] = array(array('taxonomy' => 'category', 'field' => 'id', 'terms' => $post_category));
        }
        if ($post_tag) {
            $posts_query['tax_query'][] = array('taxonomy' => 'post_tag', 'field' => 'slug', 'terms' => explode(",", $post_tag));
        }
        if ($post_orderby) {
            $posts_query['orderby'] = $post_orderby;
        }
        if ($post_order) {
            $posts_query['order'] = $post_order;
        }
        if (isset($post->ID)) {
            $posts_query['post__not_in'] = array($post->ID);
        }
        $wp_query = new WP_Query($posts_query);
        ?>
			<?php 
        if ($widget_column == 2) {
            ?>
	        <div class="row">
	        	<?php 
            if ($wp_query->have_posts()) {
                while ($wp_query->have_posts()) {
                    $wp_query->the_post();
                    ?>
	        	<?php 
                    $postdata = mars_get_post_data(get_the_ID());
                    ?>
	            <div id="post-right-<?php 
                    print $this->id;
                    ?>
-<?php 
                    the_ID();
                    ?>
" <?php 
                    post_class('col-xs-6 item');
                    ?>
>
	            	<?php 
                    if (has_post_thumbnail()) {
                        print '<a title="' . get_the_title() . '" href="' . get_permalink(get_the_ID()) . '">' . get_the_post_thumbnail(null, 'most-video-2col', array('class' => 'img-responsive')) . '</a>';
                    }
                    ?>
                    <div class="post-header">              	         	
	                	<h3><a title="<?php 
                    the_title();
                    ?>
" href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h3>
						<span class="post-meta">
							<i class="fa fa-clock-o"></i> <?php 
                    print get_the_date('F j ,Y');
                    ?>
						</span>	                	
	                </div>
	       		</div>
	       		<?php 
                }
            }
            ?>
	        </div>
	        <?php 
        } else {
            ?>
	        	<?php 
            if ($wp_query->have_posts()) {
                while ($wp_query->have_posts()) {
                    $wp_query->the_post();
                    ?>
	        	<?php 
                    $postdata = mars_get_post_data(get_the_ID());
                    ?>
	        	
			        <div id="post-right-<?php 
                    print $this->id;
                    ?>
-<?php 
                    the_ID();
                    ?>
" <?php 
                    post_class('item');
                    ?>
>
		            	<?php 
                    if (has_post_thumbnail()) {
                        print '<a title="' . get_the_title() . '" href="' . get_permalink(get_the_ID()) . '">' . get_the_post_thumbnail(null, 'video-featured', array('class' => 'img-responsive')) . '</a>';
                    }
                    ?>
	            	
	                    <div class="post-header">              	         	
		                	<h3><a title="<?php 
                    the_title();
                    ?>
" href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h3>
							<span class="post-meta">
								<i class="fa fa-clock-o"></i> <?php 
                    print get_the_date('F j ,Y');
                    ?>
							</span>	                	
		                </div>
			        </div>	
		        <?php 
                }
            }
            ?>
        
	        <?php 
        }
        ?>
	    <?php 
        wp_reset_postdata();
        wp_reset_query();
        print $after_widget;
    }