Version Description
- Fix: Optimized API calls to reduce requests.
- Fix: Minor bug fixes.
Download this release
Release Info
Developer | smashballoon |
Plugin | Feeds for YouTube (YouTube video, channel, and gallery plugin) |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.0.1
- README.txt +5 -5
- img/pro.png +0 -0
- inc/admin/admin-functions.php +6 -1
- inc/admin/class-sbspf-admin.php +1 -1
- inc/admin/class-sby-admin.php +9 -3
- inc/admin/templates/configure.php +7 -5
- inc/admin/templates/main.php +3 -0
- inc/class-sby-api-connect.php +2 -14
- inc/class-sby-cron-update.php +1 -6
- inc/class-sby-feed.php +26 -0
- inc/class-sby-settings.php +3 -1
- inc/sby-functions.php +2 -2
- youtube-feed.php +14 -4
README.txt
CHANGED
@@ -5,7 +5,7 @@ Support Website: http://smashballoon/youtube-feed/
|
|
5 |
Tags: YouTube, YouTube feed, YouTube widget, YouTube channel, YouTube gallery
|
6 |
Requires at least: 3.4
|
7 |
Tested up to: 5.3
|
8 |
-
Stable tag: 1.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -133,10 +133,6 @@ This free plugin has several layout options built into it. Use the settings in t
|
|
133 |
|
134 |
Yep, you can choose to display between 1-50 YouTube videos in your feed by using the following setting: Feeds for YouTube > Customize > Layout > Number of Videos. The plugin also contains a "Load More" button to allow you to infinitely load more YouTube videos into your feed.
|
135 |
|
136 |
-
= How often will the plugin check YouTube for new content? =
|
137 |
-
|
138 |
-
The short answer is; as often as you'd like! Use the "Check for new posts" setting on the "Feeds for YouTube" settings page to set the plugin to check YouTube for new YouTube videos as often as you'd like. The recommended setting is once per hour.
|
139 |
-
|
140 |
== Screenshots ==
|
141 |
|
142 |
1. By default the plugin inherits styles from your theme
|
@@ -148,5 +144,9 @@ The short answer is; as often as you'd like! Use the "Check for new posts" setti
|
|
148 |
7. To display a YouTube feed just copy and paste the [youtube-feed] shortcode into a widget or page
|
149 |
|
150 |
== Changelog ==
|
|
|
|
|
|
|
|
|
151 |
= 1.0 =
|
152 |
* Launched the Feeds for YouTube plugin!
|
5 |
Tags: YouTube, YouTube feed, YouTube widget, YouTube channel, YouTube gallery
|
6 |
Requires at least: 3.4
|
7 |
Tested up to: 5.3
|
8 |
+
Stable tag: 1.0.1
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
133 |
|
134 |
Yep, you can choose to display between 1-50 YouTube videos in your feed by using the following setting: Feeds for YouTube > Customize > Layout > Number of Videos. The plugin also contains a "Load More" button to allow you to infinitely load more YouTube videos into your feed.
|
135 |
|
|
|
|
|
|
|
|
|
136 |
== Screenshots ==
|
137 |
|
138 |
1. By default the plugin inherits styles from your theme
|
144 |
7. To display a YouTube feed just copy and paste the [youtube-feed] shortcode into a widget or page
|
145 |
|
146 |
== Changelog ==
|
147 |
+
= 1.0.1 =
|
148 |
+
* Fix: Optimized API calls to reduce requests.
|
149 |
+
* Fix: Minor bug fixes.
|
150 |
+
|
151 |
= 1.0 =
|
152 |
* Launched the Feeds for YouTube plugin!
|
img/pro.png
ADDED
Binary file
|
inc/admin/admin-functions.php
CHANGED
@@ -52,11 +52,15 @@ function sby_admin_init() {
|
|
52 |
$admin = new SBY_Admin( $vars, $base_path, $slug, $plugin_name, $capability, $icon, $position, $tabs, $sby_settings, $active_tab, 'sby_settings' );
|
53 |
$admin->access_token_listener();
|
54 |
|
|
|
|
|
|
|
55 |
$types = array(
|
56 |
array(
|
57 |
'slug' => 'channel',
|
58 |
'label' => __( 'Channel', SBY_TEXT_DOMAIN ),
|
59 |
'input_type' => 'text',
|
|
|
60 |
'note' => __( 'Eg: UCNrD5PWitIbhVK8ID or smashballoon.', SBY_TEXT_DOMAIN ),
|
61 |
'tooltip' => '<p><ul>
|
62 |
<li><b>' . __( 'Channel ID or User Name', SBY_TEXT_DOMAIN ).'</b><br>
|
@@ -345,7 +349,7 @@ function sby_attempt_connection() {
|
|
345 |
$account_info['username'] = $data['items'][0]['snippet']['title'];
|
346 |
$account_info['channel_id'] = $data['items'][0]['id'];
|
347 |
$account_info['profile_picture'] = $data['items'][0]['snippet']['thumbnails']['default']['url'];
|
348 |
-
$account_info['privacy'] =
|
349 |
$account_info['expires'] = $expires;
|
350 |
//privacyStatus
|
351 |
SBY_Admin::connect_account( $account_info );
|
@@ -403,6 +407,7 @@ add_action( 'wp_ajax_sbspf_account_search', 'sbspf_account_search' );
|
|
403 |
function sby_reset_cron( $settings ) {
|
404 |
$sbi_caching_type = isset( $settings['caching_type'] ) ? $settings['caching_type'] : '';
|
405 |
$sbi_cache_cron_interval = isset( $settings['cache_cron_interval'] ) ? $settings['cache_cron_interval'] : '';
|
|
|
406 |
$sbi_cache_cron_time = isset( $settings['cache_cron_time'] ) ? $settings['cache_cron_time'] : '';
|
407 |
$sbi_cache_cron_am_pm = isset( $settings['cache_cron_am_pm'] ) ? $settings['cache_cron_am_pm'] : '';
|
408 |
|
52 |
$admin = new SBY_Admin( $vars, $base_path, $slug, $plugin_name, $capability, $icon, $position, $tabs, $sby_settings, $active_tab, 'sby_settings' );
|
53 |
$admin->access_token_listener();
|
54 |
|
55 |
+
$first_connected = sby_get_first_connected_account();
|
56 |
+
$first_channel_id = isset( $first_connected['channel_id'] ) ? $first_connected['channel_id'] : '';
|
57 |
+
|
58 |
$types = array(
|
59 |
array(
|
60 |
'slug' => 'channel',
|
61 |
'label' => __( 'Channel', SBY_TEXT_DOMAIN ),
|
62 |
'input_type' => 'text',
|
63 |
+
'default' => $first_channel_id,
|
64 |
'note' => __( 'Eg: UCNrD5PWitIbhVK8ID or smashballoon.', SBY_TEXT_DOMAIN ),
|
65 |
'tooltip' => '<p><ul>
|
66 |
<li><b>' . __( 'Channel ID or User Name', SBY_TEXT_DOMAIN ).'</b><br>
|
349 |
$account_info['username'] = $data['items'][0]['snippet']['title'];
|
350 |
$account_info['channel_id'] = $data['items'][0]['id'];
|
351 |
$account_info['profile_picture'] = $data['items'][0]['snippet']['thumbnails']['default']['url'];
|
352 |
+
$account_info['privacy'] = '';
|
353 |
$account_info['expires'] = $expires;
|
354 |
//privacyStatus
|
355 |
SBY_Admin::connect_account( $account_info );
|
407 |
function sby_reset_cron( $settings ) {
|
408 |
$sbi_caching_type = isset( $settings['caching_type'] ) ? $settings['caching_type'] : '';
|
409 |
$sbi_cache_cron_interval = isset( $settings['cache_cron_interval'] ) ? $settings['cache_cron_interval'] : '';
|
410 |
+
$sbi_cache_cron_interval = $sbi_cache_cron_interval === '30mins' ? '1hour' : $sbi_cache_cron_interval;
|
411 |
$sbi_cache_cron_time = isset( $settings['cache_cron_time'] ) ? $settings['cache_cron_time'] : '';
|
412 |
$sbi_cache_cron_am_pm = isset( $settings['cache_cron_am_pm'] ) ? $settings['cache_cron_am_pm'] : '';
|
413 |
|
inc/admin/class-sbspf-admin.php
CHANGED
@@ -508,7 +508,7 @@ class SB_YOUTUBE_Admin {
|
|
508 |
|
509 |
foreach ( $args['types'] as $type ) :
|
510 |
$input_type = isset( $type['input_type'] ) ? $type['input_type'] : 'connected_account';
|
511 |
-
$selected =
|
512 |
if ( $input_type === 'connected_account' ) {
|
513 |
$selected = isset( $this->settings[ $type['slug'] . '_ids' ] ) ? $this->settings[ $type['slug'] . '_ids' ] : array();
|
514 |
}
|
508 |
|
509 |
foreach ( $args['types'] as $type ) :
|
510 |
$input_type = isset( $type['input_type'] ) ? $type['input_type'] : 'connected_account';
|
511 |
+
$selected = ! empty( $this->settings[ $type['slug'] ] ) ? $this->settings[ $type['slug'] ] : $type['default'];
|
512 |
if ( $input_type === 'connected_account' ) {
|
513 |
$selected = isset( $this->settings[ $type['slug'] . '_ids' ] ) ? $this->settings[ $type['slug'] . '_ids' ] : array();
|
514 |
}
|
inc/admin/class-sby-admin.php
CHANGED
@@ -342,11 +342,19 @@ class SBY_Admin extends SB_YOUTUBE_Admin {
|
|
342 |
$social_network = $this->vars->social_network();
|
343 |
$type_selected = isset( $this->settings['caching_type'] ) ? $this->settings['caching_type'] : 'page';
|
344 |
$caching_time = isset( $this->settings['caching_time'] ) ? $this->settings['caching_time'] : 1;
|
345 |
-
$cache_time_unit_selected = isset( $this->settings['
|
346 |
$cache_cron_interval_selected = isset( $this->settings['cache_cron_interval'] ) ? $this->settings['cache_cron_interval'] : '';
|
347 |
$cache_cron_time = isset( $this->settings['cache_cron_time'] ) ? $this->settings['cache_cron_time'] : '';
|
348 |
$cache_cron_am_pm = isset( $this->settings['cache_cron_am_pm'] ) ? $this->settings['cache_cron_am_pm'] : '';
|
349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
?>
|
351 |
<div class="sbspf_cache_settings_wrap">
|
352 |
<div class="sbspf_row">
|
@@ -362,7 +370,6 @@ class SBY_Admin extends SB_YOUTUBE_Admin {
|
|
362 |
<?php _e ( 'Every', $this->vars->text_domain() ); ?>:
|
363 |
<input name="<?php echo $this->option_name.'[caching_time]'; ?>" type="text" value="<?php echo esc_attr( $caching_time ); ?>" size="4">
|
364 |
<select name="<?php echo $this->option_name.'[caching_time_unit]'; ?>">
|
365 |
-
<option value="minutes"<?php if ( $cache_time_unit_selected === 'minutes' ) echo ' selected'?>><?php _e ( 'Minutes', $this->vars->text_domain() ); ?></option>
|
366 |
<option value="hours"<?php if ( $cache_time_unit_selected === 'hours' ) echo ' selected'?>><?php _e ( 'Hours', $this->vars->text_domain() ); ?></option>
|
367 |
<option value="days"<?php if ( $cache_time_unit_selected === 'days' ) echo ' selected'?>><?php _e ( 'Days', $this->vars->text_domain() ); ?></option>
|
368 |
</select>
|
@@ -377,7 +384,6 @@ class SBY_Admin extends SB_YOUTUBE_Admin {
|
|
377 |
<div class="sbspf_row sbspf-caching-cron-options" style="display: block;">
|
378 |
|
379 |
<select name="<?php echo $this->option_name.'[cache_cron_interval]'; ?>" id="sbspf_cache_cron_interval">
|
380 |
-
<option value="30mins"<?php if ( $cache_cron_interval_selected === '30mins' ) echo ' selected'?>><?php _e ( 'Every 30 minutes', $this->vars->text_domain() ); ?></option>
|
381 |
<option value="1hour"<?php if ( $cache_cron_interval_selected === '1hour' ) echo ' selected'?>><?php _e ( 'Every hour', $this->vars->text_domain() ); ?></option>
|
382 |
<option value="12hours"<?php if ( $cache_cron_interval_selected === '12hours' ) echo ' selected'?>><?php _e ( 'Every 12 hours', $this->vars->text_domain() ); ?></option>
|
383 |
<option value="24hours"<?php if ( $cache_cron_interval_selected === '24hours' ) echo ' selected'?>><?php _e ( 'Every 24 hours', $this->vars->text_domain() ); ?></option>
|
342 |
$social_network = $this->vars->social_network();
|
343 |
$type_selected = isset( $this->settings['caching_type'] ) ? $this->settings['caching_type'] : 'page';
|
344 |
$caching_time = isset( $this->settings['caching_time'] ) ? $this->settings['caching_time'] : 1;
|
345 |
+
$cache_time_unit_selected = isset( $this->settings['caching_time_unit'] ) ? $this->settings['caching_time_unit'] : 'hours';
|
346 |
$cache_cron_interval_selected = isset( $this->settings['cache_cron_interval'] ) ? $this->settings['cache_cron_interval'] : '';
|
347 |
$cache_cron_time = isset( $this->settings['cache_cron_time'] ) ? $this->settings['cache_cron_time'] : '';
|
348 |
$cache_cron_am_pm = isset( $this->settings['cache_cron_am_pm'] ) ? $this->settings['cache_cron_am_pm'] : '';
|
349 |
|
350 |
+
if ( $cache_time_unit_selected === 'minutes' ) {
|
351 |
+
$cache_time_unit_selected = 'hours';
|
352 |
+
$caching_time = 1;
|
353 |
+
}
|
354 |
+
if ( $cache_cron_interval_selected === '30mins' ) {
|
355 |
+
$cache_cron_interval_selected = '1hour';
|
356 |
+
}
|
357 |
+
|
358 |
?>
|
359 |
<div class="sbspf_cache_settings_wrap">
|
360 |
<div class="sbspf_row">
|
370 |
<?php _e ( 'Every', $this->vars->text_domain() ); ?>:
|
371 |
<input name="<?php echo $this->option_name.'[caching_time]'; ?>" type="text" value="<?php echo esc_attr( $caching_time ); ?>" size="4">
|
372 |
<select name="<?php echo $this->option_name.'[caching_time_unit]'; ?>">
|
|
|
373 |
<option value="hours"<?php if ( $cache_time_unit_selected === 'hours' ) echo ' selected'?>><?php _e ( 'Hours', $this->vars->text_domain() ); ?></option>
|
374 |
<option value="days"<?php if ( $cache_time_unit_selected === 'days' ) echo ' selected'?>><?php _e ( 'Days', $this->vars->text_domain() ); ?></option>
|
375 |
</select>
|
384 |
<div class="sbspf_row sbspf-caching-cron-options" style="display: block;">
|
385 |
|
386 |
<select name="<?php echo $this->option_name.'[cache_cron_interval]'; ?>" id="sbspf_cache_cron_interval">
|
|
|
387 |
<option value="1hour"<?php if ( $cache_cron_interval_selected === '1hour' ) echo ' selected'?>><?php _e ( 'Every hour', $this->vars->text_domain() ); ?></option>
|
388 |
<option value="12hours"<?php if ( $cache_cron_interval_selected === '12hours' ) echo ' selected'?>><?php _e ( 'Every 12 hours', $this->vars->text_domain() ); ?></option>
|
389 |
<option value="24hours"<?php if ( $cache_cron_interval_selected === '24hours' ) echo ' selected'?>><?php _e ( 'Every 24 hours', $this->vars->text_domain() ); ?></option>
|
inc/admin/templates/configure.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<h3><?php _e( 'Configure', $text_domain ); ?></h3>
|
2 |
-
<div id="sbspf_config">
|
3 |
<a href="<?php echo $oauth_processor_url . admin_url( 'admin.php?page=' . esc_attr( $slug ) ); ?>" id="sbspf_get_token"><?php echo sby_icon( $slug, 'sbspf_small_svg' ); ?> <?php echo sprintf( __( 'Log in to %s and connect an account', $text_domain ), $social_network ); ?></a>
|
4 |
<a class="sbspf_not_working" href="https://smashballoon.com/<?php echo esc_attr( $slug ); ?>/token/" target="_blank"><?php _e( "Button not working?", $text_domain ); ?></a>
|
5 |
</div>
|
@@ -7,13 +7,14 @@
|
|
7 |
<form method="post" action="">
|
8 |
<?php
|
9 |
$settings = $this->settings;
|
10 |
-
|
|
|
11 |
$api_key = isset( $settings['api_key'] ) ? $settings['api_key'] : '';
|
12 |
?>
|
13 |
<input name="<?php echo $this->get_option_name(); ?>[have_own_tokens]" type="hidden" value="0">
|
14 |
|
15 |
-
<input name="<?php echo $this->get_option_name(); ?>[have_own_tokens]" id="sbspf_have_own_tokens" type="checkbox"<?php if ( $have_own_tokens === 'on' ) echo ' checked'; ?>><label for="sbspf_have_own_tokens"><?php echo sprintf( __( "Or, manually enter my own %s API key", $text_domain ), $social_network ); ?></label>
|
16 |
-
<span class="sbspf_tooltip_wrap">
|
17 |
<a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $this->default_tooltip_text(); ?></a>
|
18 |
<p class="sbspf_tooltip sbspf_more_info"><?php echo __( 'Check this box if you would like to manually enter your own API key. To generate an API key use <a href="https://smashballoon.com/youtube-api-key/" target="_blank" rel="noopener">these instructions.</a>', $text_domain ); ?></p>
|
19 |
</span>
|
@@ -25,13 +26,14 @@
|
|
25 |
</th>
|
26 |
<td>
|
27 |
<input name="<?php echo $this->get_option_name(); ?>[api_key]" id="sby_api_key" type="text" value="<?php echo esc_attr( $api_key ); ?>" size="64" minlength="15" maxlength="200" />
|
|
|
28 |
</td>
|
29 |
</tr>
|
30 |
|
31 |
</tbody>
|
32 |
</table>
|
33 |
<?php $this->hidden_fields_for_tab( 'configure' ); ?>
|
34 |
-
<?php include_once $this->get_path( 'connected-accounts' ); ?>
|
35 |
|
36 |
<?php foreach ( $this->get_sections( 'configure' ) as $section ) : ?>
|
37 |
|
1 |
<h3><?php _e( 'Configure', $text_domain ); ?></h3>
|
2 |
+
<div id="sbspf_config" style="display: none;">
|
3 |
<a href="<?php echo $oauth_processor_url . admin_url( 'admin.php?page=' . esc_attr( $slug ) ); ?>" id="sbspf_get_token"><?php echo sby_icon( $slug, 'sbspf_small_svg' ); ?> <?php echo sprintf( __( 'Log in to %s and connect an account', $text_domain ), $social_network ); ?></a>
|
4 |
<a class="sbspf_not_working" href="https://smashballoon.com/<?php echo esc_attr( $slug ); ?>/token/" target="_blank"><?php _e( "Button not working?", $text_domain ); ?></a>
|
5 |
</div>
|
7 |
<form method="post" action="">
|
8 |
<?php
|
9 |
$settings = $this->settings;
|
10 |
+
//$have_own_tokens = isset( $settings['have_own_tokens'] ) ? $settings['have_own_tokens'] : 0;
|
11 |
+
$have_own_tokens = 'on';
|
12 |
$api_key = isset( $settings['api_key'] ) ? $settings['api_key'] : '';
|
13 |
?>
|
14 |
<input name="<?php echo $this->get_option_name(); ?>[have_own_tokens]" type="hidden" value="0">
|
15 |
|
16 |
+
<input style="display: none;" name="<?php echo $this->get_option_name(); ?>[have_own_tokens]" id="sbspf_have_own_tokens" type="checkbox"<?php if ( $have_own_tokens === 'on' ) echo ' checked'; ?>><label for="sbspf_have_own_tokens" style="display: none;"><?php echo sprintf( __( "Or, manually enter my own %s API key", $text_domain ), $social_network ); ?></label>
|
17 |
+
<span class="sbspf_tooltip_wrap" style="display: none;">
|
18 |
<a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $this->default_tooltip_text(); ?></a>
|
19 |
<p class="sbspf_tooltip sbspf_more_info"><?php echo __( 'Check this box if you would like to manually enter your own API key. To generate an API key use <a href="https://smashballoon.com/youtube-api-key/" target="_blank" rel="noopener">these instructions.</a>', $text_domain ); ?></p>
|
20 |
</span>
|
26 |
</th>
|
27 |
<td>
|
28 |
<input name="<?php echo $this->get_option_name(); ?>[api_key]" id="sby_api_key" type="text" value="<?php echo esc_attr( $api_key ); ?>" size="64" minlength="15" maxlength="200" />
|
29 |
+
<p><?php echo __( 'Get started by entering your own YouTube API key. To generate an API key use <a href="https://smashballoon.com/youtube-api-key/" target="_blank" rel="noopener">these instructions.</a>', $text_domain ); ?></p>
|
30 |
</td>
|
31 |
</tr>
|
32 |
|
33 |
</tbody>
|
34 |
</table>
|
35 |
<?php $this->hidden_fields_for_tab( 'configure' ); ?>
|
36 |
+
<?php //include_once $this->get_path( 'connected-accounts' ); ?>
|
37 |
|
38 |
<?php foreach ( $this->get_sections( 'configure' ) as $section ) : ?>
|
39 |
|
inc/admin/templates/main.php
CHANGED
@@ -60,5 +60,8 @@ $tabs = $this->get_tabs();
|
|
60 |
<p><?php _e( "Find out how to display <a href='?page=".$slug."&tab=display'>multiple feeds</a>.", $text_domain ); ?></p>
|
61 |
</div>
|
62 |
|
|
|
|
|
|
|
63 |
</div>
|
64 |
<div class="wp-clearfix"></div>
|
60 |
<p><?php _e( "Find out how to display <a href='?page=".$slug."&tab=display'>multiple feeds</a>.", $text_domain ); ?></p>
|
61 |
</div>
|
62 |
|
63 |
+
<a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby" target="_blank" class="sbspf-pro-notice"><img src="<?php echo SBY_PLUGIN_URL . 'img/pro.png' ?>" alt="Pro" /></a>
|
64 |
+
|
65 |
+
|
66 |
</div>
|
67 |
<div class="wp-clearfix"></div>
|
inc/class-sby-api-connect.php
CHANGED
@@ -147,23 +147,11 @@ class SBY_API_Connect
|
|
147 |
}
|
148 |
$access_credentials = isset( $connected_account['api_key'] ) ? 'key=' . $connected_account['api_key'] : 'access_token=' . $connected_account['access_token'];
|
149 |
|
150 |
-
$url = 'https://www.googleapis.com/youtube/v3/channels?part=id,snippet,
|
151 |
-
} elseif ( $endpoint_slug === 'search' ) {
|
152 |
-
$q_param = '';
|
153 |
-
if ( isset( $params['q'] ) ) {
|
154 |
-
$q_param = $params['q'];
|
155 |
-
}
|
156 |
-
$type = '';
|
157 |
-
if ( isset( $params['type'] ) ) {
|
158 |
-
$type = '&type='. $params['type'];
|
159 |
-
}
|
160 |
-
$access_credentials = isset( $connected_account['api_key'] ) ? 'key=' . $connected_account['api_key'] : 'access_token=' . $connected_account['access_token'];
|
161 |
-
|
162 |
-
$url = 'https://www.googleapis.com/youtube/v3/search?part=snippet&q='.$q_param.'&maxResults='.$num.$type.'&'.$access_credentials;
|
163 |
} elseif ( $endpoint_slug === 'playlistItems' ) {
|
164 |
$access_credentials = isset( $connected_account['api_key'] ) ? 'key=' . $connected_account['api_key'] : 'access_token=' . $connected_account['access_token'];
|
165 |
|
166 |
-
$url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=id,snippet
|
167 |
} else {
|
168 |
$channel_param = 'mine=true';
|
169 |
if ( isset( $params['username'] ) ) {
|
147 |
}
|
148 |
$access_credentials = isset( $connected_account['api_key'] ) ? 'key=' . $connected_account['api_key'] : 'access_token=' . $connected_account['access_token'];
|
149 |
|
150 |
+
$url = 'https://www.googleapis.com/youtube/v3/channels?part=id,snippet,contentDetails&'.$channel_param.'&' . $access_credentials . $next_page;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
} elseif ( $endpoint_slug === 'playlistItems' ) {
|
152 |
$access_credentials = isset( $connected_account['api_key'] ) ? 'key=' . $connected_account['api_key'] : 'access_token=' . $connected_account['access_token'];
|
153 |
|
154 |
+
$url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=id,snippet&maxResults='.$num.'&playlistId='.$params['playlist_id'].'&' . $access_credentials;
|
155 |
} else {
|
156 |
$channel_param = 'mine=true';
|
157 |
if ( isset( $params['username'] ) ) {
|
inc/class-sby-cron-update.php
CHANGED
@@ -199,12 +199,7 @@ class SBY_Cron_Updater
|
|
199 |
}
|
200 |
|
201 |
} else {
|
202 |
-
|
203 |
-
if ( $sby_cache_cron_interval === '30mins' ) {
|
204 |
-
wp_schedule_event( time(), 'sby30mins', 'sby_feed_update' );
|
205 |
-
} else {
|
206 |
-
wp_schedule_event( time(), 'hourly', 'sby_feed_update' );
|
207 |
-
}
|
208 |
}
|
209 |
|
210 |
}
|
199 |
}
|
200 |
|
201 |
} else {
|
202 |
+
wp_schedule_event( time(), 'hourly', 'sby_feed_update' );
|
|
|
|
|
|
|
|
|
|
|
203 |
}
|
204 |
|
205 |
}
|
inc/class-sby-feed.php
CHANGED
@@ -174,6 +174,23 @@ class SBY_Feed
|
|
174 |
return $header_transient;
|
175 |
}
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
/**
|
178 |
* @return bool
|
179 |
*
|
@@ -446,6 +463,12 @@ class SBY_Feed
|
|
446 |
if ( ! $api_requests_delayed
|
447 |
&& (! isset( $next_pages[ $term . '_' . $type ] ) || $next_pages[ $term . '_' . $type ] !== false) ) {
|
448 |
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
if ( empty( $this->channels_data[ $term ] ) ) {
|
450 |
$channel_data = array();
|
451 |
$api_connect_channels = new SBY_API_Connect( $connected_account_for_term, 'channels', $params );
|
@@ -455,6 +478,8 @@ class SBY_Feed
|
|
455 |
$api_connect_channels->connect();
|
456 |
if ( ! $api_connect_channels->is_wp_error() && ! $api_connect_channels->is_youtube_error() ) {
|
457 |
$channel_data = $api_connect_channels->get_data();
|
|
|
|
|
458 |
} else {
|
459 |
if ( ! $api_connect_channels->is_wp_error() ) {
|
460 |
$return = SBY_API_Connect::handle_youtube_error( $api_connect_channels->get_data(), $connected_account_for_term );
|
@@ -493,6 +518,7 @@ class SBY_Feed
|
|
493 |
}
|
494 |
|
495 |
$api_connect_playlist_items = new SBY_API_Connect( $connected_account_for_term, 'playlistItems', $params );
|
|
|
496 |
$api_connect_playlist_items->connect();
|
497 |
if ( ! $api_connect_playlist_items->is_wp_error() && ! $api_connect_playlist_items->is_youtube_error() ) {
|
498 |
$one_successful_connection = true;
|
174 |
return $header_transient;
|
175 |
}
|
176 |
|
177 |
+
public function get_channel_cache( $channel ) {
|
178 |
+
$maybe_cache = get_option( SBY_CHANNEL_CACHE_PREFIX . $channel );
|
179 |
+
if ( $maybe_cache !== false ) {
|
180 |
+
$maybe_cache = json_decode( $maybe_cache, true );
|
181 |
+
}
|
182 |
+
|
183 |
+
return $maybe_cache;
|
184 |
+
}
|
185 |
+
|
186 |
+
public function set_channel_cache( $channel, $cache ) {
|
187 |
+
if ( is_array( $cache ) ) {
|
188 |
+
$cache = wp_json_encode( $cache );
|
189 |
+
}
|
190 |
+
|
191 |
+
update_option( SBY_CHANNEL_CACHE_PREFIX . $channel, $cache, false );
|
192 |
+
}
|
193 |
+
|
194 |
/**
|
195 |
* @return bool
|
196 |
*
|
463 |
if ( ! $api_requests_delayed
|
464 |
&& (! isset( $next_pages[ $term . '_' . $type ] ) || $next_pages[ $term . '_' . $type ] !== false) ) {
|
465 |
|
466 |
+
$existing_channel_cache = $this->get_channel_cache( $term );
|
467 |
+
|
468 |
+
if ( $existing_channel_cache ) {
|
469 |
+
$this->channels_data[ $term ] = $existing_channel_cache;
|
470 |
+
}
|
471 |
+
|
472 |
if ( empty( $this->channels_data[ $term ] ) ) {
|
473 |
$channel_data = array();
|
474 |
$api_connect_channels = new SBY_API_Connect( $connected_account_for_term, 'channels', $params );
|
478 |
$api_connect_channels->connect();
|
479 |
if ( ! $api_connect_channels->is_wp_error() && ! $api_connect_channels->is_youtube_error() ) {
|
480 |
$channel_data = $api_connect_channels->get_data();
|
481 |
+
$this->set_channel_cache( $term, $channel_data );
|
482 |
+
|
483 |
} else {
|
484 |
if ( ! $api_connect_channels->is_wp_error() ) {
|
485 |
$return = SBY_API_Connect::handle_youtube_error( $api_connect_channels->get_data(), $connected_account_for_term );
|
518 |
}
|
519 |
|
520 |
$api_connect_playlist_items = new SBY_API_Connect( $connected_account_for_term, 'playlistItems', $params );
|
521 |
+
|
522 |
$api_connect_playlist_items->connect();
|
523 |
if ( ! $api_connect_playlist_items->is_wp_error() && ! $api_connect_playlist_items->is_youtube_error() ) {
|
524 |
$one_successful_connection = true;
|
inc/class-sby-settings.php
CHANGED
@@ -320,7 +320,9 @@ class SBY_Settings {
|
|
320 |
if ( $cache_time_unit == 'hours' ) $cache_time_unit = 60*60;
|
321 |
if ( $cache_time_unit == 'days' ) $cache_time_unit = 60*60*24;
|
322 |
|
323 |
-
|
|
|
|
|
324 |
}
|
325 |
}
|
326 |
}
|
320 |
if ( $cache_time_unit == 'hours' ) $cache_time_unit = 60*60;
|
321 |
if ( $cache_time_unit == 'days' ) $cache_time_unit = 60*60*24;
|
322 |
|
323 |
+
$cache_time = max( 3600, $cache_time * $cache_time_unit );
|
324 |
+
|
325 |
+
return $cache_time;
|
326 |
}
|
327 |
}
|
328 |
}
|
inc/sby-functions.php
CHANGED
@@ -19,8 +19,8 @@ function sby_youtube_feed( $atts = array() ) {
|
|
19 |
ob_start(); ?>
|
20 |
<div id="sbi_mod_error" <?php echo $style; ?>>
|
21 |
<span><?php _e('This error message is only visible to WordPress admins', 'youtube-feed' ); ?></span><br />
|
22 |
-
<p><b><?php _e( 'Error: No
|
23 |
-
<p><?php _e( 'Please go to the YouTube Feed settings page to
|
24 |
</div>
|
25 |
<?php
|
26 |
$html = ob_get_contents();
|
19 |
ob_start(); ?>
|
20 |
<div id="sbi_mod_error" <?php echo $style; ?>>
|
21 |
<span><?php _e('This error message is only visible to WordPress admins', 'youtube-feed' ); ?></span><br />
|
22 |
+
<p><b><?php _e( 'Error: No API key.', 'youtube-feed' ); ?></b>
|
23 |
+
<p><?php _e( 'Please go to the YouTube Feed settings page to enter an API key.', 'youtube-feed' ); ?></p>
|
24 |
</div>
|
25 |
<?php
|
26 |
$html = ob_get_contents();
|
youtube-feed.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Feeds for YouTube
|
4 |
Plugin URI: http://smashballoon.com/youtube-feed
|
5 |
Description: The Feeds for YouTube plugin allows you to display completely customizable YouTube feeds from any channel.
|
6 |
-
Version: 1.0
|
7 |
Author: Smash Balloon
|
8 |
Author URI: http://smashballoon.com/
|
9 |
Text Domain: feeds-for-youtube
|
@@ -26,10 +26,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
26 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
27 |
|
28 |
if ( ! defined( 'SBYVER' ) ) {
|
29 |
-
define( 'SBYVER', 1.0 );
|
30 |
}
|
31 |
if ( ! defined( 'SBY_DBVERSION' ) ) {
|
32 |
-
define( 'SBY_DBVERSION', 1.
|
33 |
}
|
34 |
// Upload folder name for local image files for posts
|
35 |
if ( ! defined( 'SBY_UPLOADS_NAME' ) ) {
|
@@ -80,6 +80,9 @@ if ( function_exists( 'sby_init' ) ) {
|
|
80 |
if ( ! defined( 'SBY_USE_BACKUP_PREFIX' ) ) {
|
81 |
define( 'SBY_USE_BACKUP_PREFIX', '&' );
|
82 |
}
|
|
|
|
|
|
|
83 |
// Max Records in Database for Image Resizing
|
84 |
if ( ! defined( 'SBY_MAX_RECORDS' ) ) {
|
85 |
define( 'SBY_MAX_RECORDS', 100 );
|
@@ -272,7 +275,7 @@ if ( function_exists( 'sby_init' ) ) {
|
|
272 |
|
273 |
if ( ! isset( $sby_statuses_option['first_install'] ) ) {
|
274 |
|
275 |
-
$options_set = get_option( '
|
276 |
|
277 |
if ( $options_set ) {
|
278 |
$sby_statuses_option['first_install'] = 'from_update';
|
@@ -302,6 +305,13 @@ if ( function_exists( 'sby_init' ) ) {
|
|
302 |
update_option( 'sby_db_version', SBY_DBVERSION );
|
303 |
}
|
304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
}
|
306 |
add_action( 'wp_loaded', 'sby_check_for_db_updates' );
|
307 |
|
3 |
Plugin Name: Feeds for YouTube
|
4 |
Plugin URI: http://smashballoon.com/youtube-feed
|
5 |
Description: The Feeds for YouTube plugin allows you to display completely customizable YouTube feeds from any channel.
|
6 |
+
Version: 1.0.1
|
7 |
Author: Smash Balloon
|
8 |
Author URI: http://smashballoon.com/
|
9 |
Text Domain: feeds-for-youtube
|
26 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
27 |
|
28 |
if ( ! defined( 'SBYVER' ) ) {
|
29 |
+
define( 'SBYVER', '1.0.1' );
|
30 |
}
|
31 |
if ( ! defined( 'SBY_DBVERSION' ) ) {
|
32 |
+
define( 'SBY_DBVERSION', 1.2 );
|
33 |
}
|
34 |
// Upload folder name for local image files for posts
|
35 |
if ( ! defined( 'SBY_UPLOADS_NAME' ) ) {
|
80 |
if ( ! defined( 'SBY_USE_BACKUP_PREFIX' ) ) {
|
81 |
define( 'SBY_USE_BACKUP_PREFIX', '&' );
|
82 |
}
|
83 |
+
if ( ! defined( 'SBY_CHANNEL_CACHE_PREFIX' ) ) {
|
84 |
+
define( 'SBY_CHANNEL_CACHE_PREFIX', '~sby_' );
|
85 |
+
}
|
86 |
// Max Records in Database for Image Resizing
|
87 |
if ( ! defined( 'SBY_MAX_RECORDS' ) ) {
|
88 |
define( 'SBY_MAX_RECORDS', 100 );
|
275 |
|
276 |
if ( ! isset( $sby_statuses_option['first_install'] ) ) {
|
277 |
|
278 |
+
$options_set = get_option( 'sby_settings', false );
|
279 |
|
280 |
if ( $options_set ) {
|
281 |
$sby_statuses_option['first_install'] = 'from_update';
|
305 |
update_option( 'sby_db_version', SBY_DBVERSION );
|
306 |
}
|
307 |
|
308 |
+
if ( (float) $db_ver < 1.2 ) {
|
309 |
+
$options = get_option( 'sby_settings', false );
|
310 |
+
sby_reset_cron( $options );
|
311 |
+
|
312 |
+
update_option( 'sby_db_version', SBY_DBVERSION );
|
313 |
+
}
|
314 |
+
|
315 |
}
|
316 |
add_action( 'wp_loaded', 'sby_check_for_db_updates' );
|
317 |
|