-
Notifications
You must be signed in to change notification settings - Fork 0
/
sidebar.php
executable file
·144 lines (116 loc) · 4.41 KB
/
sidebar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* The sidebar containing the main widget area.
*
* @package Looptroop Rockers v5
*/
?>
<div id="secondary" class="widget-area" role="complementary">
<div class="widget-area__yt">
<?php /* hacky solution to get the latest video(s) on top, for now,
need to redo this video solution some day... */ ?>
<?php
/* start looping the videos properly now... */
error_reporting(E_ALL);
$feedURL = 'https://www.youtube.com/feeds/videos.xml?channel_id=UCPwK_VC6WK9HMrQAwmSMk8g';
$sxml = simplexml_load_file($feedURL);
$i=0;
$len = count($sxml->entry);
foreach ($sxml->entry as $entry) {
$media = $entry->children('media', true);
$watch = (string)$media->group->content->attributes()->url;
$watch2 = str_replace('/v/', '/embed/', $watch);
$watch3 = str_replace('?version=3', '', $watch2);
$thumbnail = (string)$media->group->thumbnail[0]->attributes()->url;
if ($i==0) {
echo apply_filters('the_content', '<iframe width="390" height="219" src="' . $watch3 . '" frameborder="0" allowfullscreen ></iframe>');
}
?>
<div class="videoitem<?php if ($i==0) { ?> active<?php } ?>">
<div class="videothumb"><a href="<?php echo $watch3; ?>" class="watchvideo"><img src="<?php echo $thumbnail;?>" alt="<?php echo $media->group->title; ?>" /></a></div>
</div>
<?php
$i++;
// Continue loop, unless we're at the last
// item and we're not at 16 videos yet.
if ($i == $len) {
if ($i < 16) {
error_reporting(E_ALL);
$videosLeft = 16 - $i;
$feedURL = 'https://www.youtube.com/feeds/videos.xml?user=LooptroopRockersVEVO';
$sxml = simplexml_load_file($feedURL);
foreach ($sxml->entry as $entry) {
$media = $entry->children('media', true);
$watch = (string)$media->group->content->attributes()->url;
$watch2 = str_replace('/v/', '/embed/', $watch);
$watch3 = str_replace('?version=3', '', $watch2);
$thumbnail = (string)$media->group->thumbnail[0]->attributes()->url;
if ($i < 16) {
?>
<div class="videoitem">
<div class="videothumb"><a href="<?php echo $watch3; ?>" class="watchvideo"><img src="<?php echo $thumbnail;?>" alt="<?php echo $media->group->title; ?>" /></a></div>
</div>
<?php
}
$i++;
}
}
if ($i < 16) {
error_reporting(E_ALL);
$videosLeft = 16 - $i;
$feedURL = 'https://www.youtube.com/feeds/videos.xml?user=dvsgee';
$sxml = simplexml_load_file($feedURL);
foreach ($sxml->entry as $entry) {
$media = $entry->children('media', true);
$watch = (string)$media->group->content->attributes()->url;
$watch2 = str_replace('/v/', '/embed/', $watch);
$watch3 = str_replace('?version=3', '', $watch2);
$thumbnail = (string)$media->group->thumbnail[0]->attributes()->url;
if ($i < 16) {
?>
<div class="videoitem">
<div class="videothumb"><a href="<?php echo $watch3; ?>" class="watchvideo"><img src="<?php echo $thumbnail;?>" alt="<?php echo $media->group->title; ?>" /></a></div>
</div>
<?php
}
$i++;
}
}
}
}
?>
</div>
<div class="widget-area__one">
<aside class="widget">
<h3 class="widget-title">Latest News</h3>
<?php
$args = array(
'category_name' => 'news',
'posts_per_page' => 3
);
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<div class="news-item">
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'thumbnail' ); ?>
<?php } ?>
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<?php the_excerpt(); ?>
</div>
<hr>
<?php
endwhile;
endif;
// Reset Post Data
wp_reset_postdata();
?>
</aside>
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div>
<div class="widget-area__two">
<?php dynamic_sidebar( 'sidebar-2' ); ?>
</div>
</div><!-- #secondary -->