__( 'All Feeds', 'feeds-for-youtube' ),
'slug' => 'allfeeds',
'capability' => $capability,
'numbered_tab' => false,
'has_nav_tab' => false
)
);
$active_tab = $tabs[0]['slug'];
if ( isset( $_GET['tab'] ) ) {
$active_tab = sanitize_text_field( $_GET['tab'] ); $tabs[0]['slug'];
} elseif ( isset( $_GET['page'] ) ) {
foreach ( $tabs as $tab ) {
if ( $_GET['page'] === $slug . '_' . $tab['slug'] ) {
$active_tab = $tab['slug'];
}
}
}
$vars = new SBY_Vars();
$admin = new SBY_Admin( $vars, $base_path, $slug, $plugin_name, $capability, $icon, $position, $tabs, $sby_settings, $active_tab, 'sby_settings' );
$admin->access_token_listener();
$first_connected = sby_get_first_connected_account();
$first_channel_id = isset( $first_connected['channel_id'] ) ? $first_connected['channel_id'] : '';
$types = array(
array(
'slug' => 'channel',
'label' => __( 'Channel', 'feeds-for-youtube' ),
'input_type' => 'text',
'default' => $first_channel_id,
'note' => __( 'Eg: Channel ID or User Name', 'feeds-for-youtube' ),
'example' => 'smashballoon',
'description' => __( 'Display videos from a YouTube channel (channel)', 'feeds-for-youtube' ),
'tooltip' => '
' . __( 'Enter any channel ID or user name to display all of an accounts latest videos starting with the most recently published.', 'feeds-for-youtube' ) . '
' . __( 'Channel ID or User Name', 'feeds-for-youtube' ).'
' . __( 'You can find the ID or User Name of your YouTube Channel from the URL. In each URL format, the text you need to use is highlighted below:', 'feeds-for-youtube' ).'
' . __( 'URL Format 1:', 'feeds-for-youtube' ).' https://www.youtube.com/channel/UC1a2b3c4D5F6g7i8j9k
' . __( 'URL Format 2:', 'feeds-for-youtube' ).' https://www.youtube.com/user/your_user_name
'
),
array(
'slug' => 'playlist',
'label' => __( 'Playlist', 'feeds-for-youtube' ),
'input_type' => 'text',
'default' => '',
'note' => __( 'Eg: Playlist ID', 'feeds-for-youtube' ),
'example' => 'PLLLm1a2b3c4D6g7i8j9k_1a',
'description' => __( 'Display videos from a specific playlist (playlist)', 'feeds-for-youtube' ),
'tooltip' => '' . __( 'Enter any playlist ID to display videos from a playlist starting with the most recently published.', 'feeds-for-youtube' ) . '
' . __( 'Playlist ID', 'feeds-for-youtube' ).'
' . __( 'You can find the ID of your YouTube playlist from the URL. The text you need to use is highlighted below:', 'feeds-for-youtube' ).'
https://www.youtube.com/playlist?list=PLLLm1a2b3c4D6g7i8j9k_1a2b3c4D57i8j9k
'
),
array(
'slug' => 'favorites',
'label' => __( 'Favorites', 'feeds-for-youtube' ),
'input_type' => 'text',
'default' => '',
'note' => __( 'Eg: Channel ID or User Name', 'feeds-for-youtube' ),
'example' => 'smashballoon',
'description' => __( 'Display the "favorites" playlist for a channel (favorites)', 'feeds-for-youtube' ),
'tooltip' => '' . __( 'Displays all videos marked as "favorites" by a YouTube account starting with the most recently published.', 'feeds-for-youtube' ) . '
' . __( 'Channel ID or User Name', 'feeds-for-youtube' ).'
' . __( 'You can find the ID or User Name of your YouTube Channel from the URL. In each URL format, the text you need to use is highlighted below:', 'feeds-for-youtube' ).'
' . __( 'URL Format 1:', 'feeds-for-youtube' ).' https://www.youtube.com/channel/UC1a2b3c4D5F6g7i8j9k
' . __( 'URL Format 2:', 'feeds-for-youtube' ).' https://www.youtube.com/user/your_user_name
'
),
array(
'slug' => 'search',
'label' => __( 'Search', 'feeds-for-youtube' ),
'input_type' => 'text',
'default' => '',
'note' => __( 'Eg: Search Term', 'feeds-for-youtube' ),
'example' => 'cats',
'description' => __( 'Display a feed of matching search results (search)', 'feeds-for-youtube' ),
'tooltip' => '' . __( 'Enter any search term or phrase. Separate multiple terms with commas. You can add your own additional query vars using the guide on our website and the input field above.', 'feeds-for-youtube' ) . '
',
'onselect' => 'search_query_string'
),
array(
'slug' => 'live',
'label' => __( 'Live Streams', 'feeds-for-youtube' ),
'input_type' => 'text',
'default' => '',
'note' => __( 'Eg: Channel ID', 'feeds-for-youtube' ),
'example' => 'UC1a2b3c4D5F6g7i8j9k',
'description' => __( 'Display upcoming and currently playing live streams (live)', 'feeds-for-youtube' ),
'tooltip' => '' . __( 'Displays a single upcoming or currently playing live streaming video from a channel.', 'feeds-for-youtube' ) . '
' . __( 'Channel ID', 'feeds-for-youtube' ).'
' . __( 'You can find the ID of your YouTube Channel from the URL. The text you need to use is highlighted below:', 'feeds-for-youtube' ).'
https://www.youtube.com/channel/UC1a2b3c4D5F6g7i8j9k
',
'onselect' => 'live_options'
),
array(
'slug' => 'single',
'label' => __( 'Single Videos', 'feeds-for-youtube' ),
'input_type' => 'text',
'default' => '',
'note' => __( 'Eg: Video ID 1, Video ID 2', 'feeds-for-youtube' ),
'example' => 'ahL3sbPK1U8',
'description' => __( 'Display a feed of individual videos', 'feeds-for-youtube' ),
'tooltip' => '' . __( 'Displays individual videos sorted in order here. Display multiple single videos by using a comma separated list.', 'feeds-for-youtube' ) . '
' . __( 'Video ID', 'feeds-for-youtube' ).'
' . __( 'You can find the Video ID of your individual videos from the URL. The text you need to use is highlighted below:', 'feeds-for-youtube' ).'
https://www.youtube.com/watch?v=ahL3sbPK1U8
'
)
);
$admin->set_feed_types( $types );
$admin->add_false_field( 'usecustomsearch', 'configure' );
$admin->add_false_field( 'showpast', 'configure' );
/* Layout */
$layouts = array(
array(
'slug' => 'grid',
'label' => __( 'Grid', 'feeds-for-youtube' ),
'image' => 'img/grid.png',
'note' => __( 'Video thumbnails are displayed in columns and play in a lightbox when clicked.', 'feeds-for-youtube' ),
'options' => array(
array(
'name' => 'cols',
'callback' => 'select',
'label' => __( 'Columns', 'feeds-for-youtube' ),
'min' => 1,
'max' => 7,
'default' => 3,
'shortcode' => array(
'example' => '3',
'description' => __( 'Videos in carousel when 480px screen width or less.', 'feeds-for-youtube' ),
)
),
array(
'name' => 'colsmobile',
'callback' => 'select',
'label' => __( 'Mobile Columns', 'feeds-for-youtube' ),
'min' => 1,
'max' => 2,
'default' => 2,
'shortcode' => array(
'example' => '2',
'description' => __( 'Columns when 480px screen width or less.', 'feeds-for-youtube' ),
)
),
)
),
array(
'slug' => 'gallery',
'label' => __( 'Gallery', 'feeds-for-youtube' ),
'image' => 'img/gallery.png',
'note' => __( 'One large video that plays when clicked with thumbnails underneath to play more.', 'feeds-for-youtube' ),
'options' => array(
array(
'name' => 'cols',
'callback' => 'select',
'label' => __( 'Columns', 'feeds-for-youtube' ),
'min' => 1,
'max' => 7,
'default' => 3,
'shortcode' => array(
'example' => '3',
'description' => __( 'Videos in carousel when 480px screen width or less.', 'feeds-for-youtube' ),
)
),
array(
'name' => 'colsmobile',
'callback' => 'select',
'label' => __( 'Mobile Columns', 'feeds-for-youtube' ),
'min' => 1,
'max' => 2,
'default' => 2,
'shortcode' => array(
'example' => '2',
'description' => __( 'Columns when 480px screen width or less.', 'feeds-for-youtube' ),
)
),
)
),
array(
'slug' => 'list',
'label' => __( 'List', 'feeds-for-youtube' ),
'image' => 'img/list.png',
'note' => __( 'A single columns of videos that play when clicked.', 'feeds-for-youtube' ),
),
array(
'slug' => 'carousel',
'label' => __( 'Carousel', 'feeds-for-youtube' ),
'image' => 'img/carousel.png',
'note' => __( 'Posts are displayed in a slideshow carousel.', 'feeds-for-youtube' ),
'options' => array(
array(
'name' => 'cols',
'callback' => 'select',
'label' => __( 'Columns', 'feeds-for-youtube' ),
'min' => 1,
'max' => 7,
'default' => 3,
'shortcode' => array(
'example' => '3',
'description' => __( 'Videos in carousel when 480px screen width or less.', 'feeds-for-youtube' ),
)
),
array(
'name' => 'colsmobile',
'callback' => 'select',
'label' => __( 'Mobile Columns', 'feeds-for-youtube' ),
'min' => 1,
'max' => 2,
'default' => 2,
'shortcode' => array(
'example' => '2',
'description' => __( 'Columns when 480px screen width or less.', 'feeds-for-youtube' ),
) ),
array(
'name' => 'rows',
'callback' => 'select',
'label' => __( 'Number of Rows', 'feeds-for-youtube' ),
'min' => 1,
'max' => 2,
'default' => 1,
'shortcode' => array(
'example' => '2',
'description' => __( 'Choose 2 rows to show two posts in a single slide.', 'feeds-for-youtube' ),
)
),
array(
'name' => 'loop',
'callback' => 'select',
'label' => __( 'Loop Type', 'feeds-for-youtube' ),
'options' => array(
array(
'label' => __( 'Rewind', 'feeds-for-youtube' ),
'value' => 'rewind'
),
array(
'label' => __( 'Infinity', 'feeds-for-youtube' ),
'value' => 'infinity'
)
),
'default' => 'rewind',
'shortcode' => array(
'example' => 'infinity',
'description' => __( 'What happens when the last slide is reached.', 'feeds-for-youtube' ),
)
),
array(
'name' => 'arrows',
'callback' => 'checkbox',
'label' => __( 'Show Navigation Arrows', 'feeds-for-youtube' ),
'default' => true,
'shortcode' => array(
'example' => 'false',
'description' => __( 'Show arrows on the sides to navigate posts.', 'feeds-for-youtube' ),
)
),
array(
'name' => 'pag',
'callback' => 'checkbox',
'label' => __( 'Show Pagination', 'feeds-for-youtube' ),
'default' => true,
'shortcode' => array(
'example' => 'false',
'description' => __( 'Show dots below carousel for an ordinal indication of which slide is being shown.', 'feeds-for-youtube' ),
)
),
array(
'name' => 'autoplay',
'callback' => 'checkbox',
'label' => __( 'Enable Autoplay', 'feeds-for-youtube' ),
'default' => false,
'shortcode' => array(
'example' => 'true',
'description' => __( 'Whether or not to change slides automatically on an interval.', 'feeds-for-youtube' ),
)
),
array(
'name' => 'time',
'callback' => 'text',
'label' => __( 'Interval Time', 'feeds-for-youtube' ),
'default' => 5000,
'shortcode' => array(
'example' => '3000',
'description' => __( 'Duration in milliseconds before the slide changes.', 'feeds-for-youtube' ),
)
),
)
),
);
$admin->set_feed_layouts( $layouts );
$display_your_feed_table_headings = array(
array(
'slug' => 'configure',
'label' => __( 'Configure Options', 'feeds-for-youtube' ),
),
array(
'slug' => 'customize',
'label' => __( 'Customize Options', 'feeds-for-youtube' ),
),
array(
'slug' => 'layout',
'label' => __( 'Layout Options', 'feeds-for-youtube' ),
),
array(
'slug' => 'experience',
'label' => __( 'Video Experience Options', 'feeds-for-youtube' ),
),
array(
'slug' => 'text',
'label' => __( 'Custom Text/Translations', 'feeds-for-youtube' ),
),
array(
'slug' => 'header',
'label' => __( 'Header Options', 'feeds-for-youtube' ),
),
array(
'slug' => 'button',
'label' => __( '"Load More" Button Options', 'feeds-for-youtube' ),
),
array(
'slug' => 'subscribe',
'label' => __( '"Subscribe" Button Options', 'feeds-for-youtube' ),
)
);
$admin->set_display_table_sections( $display_your_feed_table_headings );
$admin->init();
}
function sby_is_admin_page() {
if ( isset( $_GET['action'] ) && $_GET['action'] === 'edit' ) {
global $post;
if ( isset( $post->post_type ) && $post->post_type === SBY_CPT ) {
return true;
}
} elseif ( isset( $_GET['page'] ) && $_GET['page'] === 'sby-feed-builder' ) {
return true;
} elseif ( isset( $_GET['post_type'] ) && $_GET['post_type'] === SBY_CPT ) {
return true;
} elseif ( ! isset( $_GET['page'] ) ) {
return false;
} elseif ( strpos( sanitize_text_field( $_GET['page'] ), SBY_SLUG ) !== false || strpos( sanitize_text_field( $_GET['page'] ), 'sby-' ) !== false) {
return true;
} elseif ( strpos( sanitize_text_field( $_GET['page'] ), 'sby_single' ) !== false ) {
return true;
}
return false;
}
function sby_admin_icon( $icon, $class = '' ) {
$class = ! empty( $class ) ? ' ' . $class : '';
if ( $icon === 'question-circle' ) {
return ' ';
} elseif ( $icon === 'info-circle' ) {
return ' ';
} elseif ( $icon === 'life-ring' ) {
return ' ';
} elseif ( $icon === 'envelope' ) {
return ' ';
} elseif ( $icon === 'chevron-right' ) {
return ' ';
} elseif ( $icon === 'rocket' ) {
return ' ';
} elseif ( $icon === 'minus-circle' ) {
return ' ';
} elseif ( $icon === 'times' ) {
return ' ';
} elseif ( $icon === 'cog' ) {
return ' ';
} elseif ( $icon === 'ellipsis' ) {
return ' ';
} else {
sby_icon( $icon );
}
}
function sby_get_current_time() {
// where to do tests
//$current_time = strtotime( 'November 25, 2020' ) + 1;
return time();
}
function sby_attempt_connection() {
if ( ! current_user_can( 'manage_youtube_feed_options' ) ) {
return false;
}
$nonce = !empty($_GET['nonce']) ? sanitize_key($_GET['nonce']) :
(!empty($_POST['nonce']) ? sanitize_key($_POST['nonce']) : '');
if (wp_verify_nonce($nonce, 'sby_con') || wp_verify_nonce($nonce, 'sby-admin') ) {
if ( isset( $_GET['sby_access_token'] ) ) {
$access_token = sanitize_text_field( urldecode( $_GET['sby_access_token'] ) );
$refresh_token = '';
} else {
$access_token = sanitize_text_field( $_POST['sby_access_token'] );
$refresh_token = '';
}
$account_info = array(
'access_token' => $access_token,
'refresh_token' => $refresh_token
);
$sby_api_connect = new SBY_API_Connect( $account_info, 'tokeninfo' );
$sby_api_connect->connect();
$data = $sby_api_connect->get_data();
if ( isset( $data['audience'] ) ) {
$expires = $data['expires_in'] + time();
$sby_api_connect = new SBY_API_Connect( $account_info, 'channels' );
$sby_api_connect->connect();
$data = $sby_api_connect->get_data();
if ( isset( $data['items'] ) ) {
$account_info['username'] = $data['items'][0]['snippet']['title'];
$account_info['channel_id'] = $data['items'][0]['id'];
$account_info['profile_picture'] = $data['items'][0]['snippet']['thumbnails']['default']['url'];
$account_info['privacy'] = '';
$account_info['expires'] = $expires;
//privacyStatus
SBY_Admin::connect_account( $account_info );
return $account_info;
} else {
$account_info['username'] = '(No Channel)';
$account_info['channel_id'] = '';
$account_info['profile_picture'] = SBY_PLUGIN_URL . 'img/person-avatar.png';
$account_info['privacy'] = '';
$account_info['expires'] = $expires;
//privacyStatus
SBY_Admin::connect_account( $account_info );
return $account_info;
}
}
}
return false;
}
function sby_api_key_notice_not_dismissed() {
return (string)get_user_meta( get_current_user_id(), 'sby_api_key_notice', true ) !== 'dismissed';
}
function sby_notice_not_dismissed( $key = 'sby_at_warning_notice' ) {
$meta = get_user_meta( get_current_user_id(), $key, true );
return (int)$meta + DAY_IN_SECONDS < time();
}
function sby_clear_wp_posts() {
global $wpdb;
$youtube_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type = '".SBY_CPT."';" );
$id_string = implode( ', ', $youtube_ids );
if ( ! empty( $id_string ) ) {
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE post_id IN ($id_string);" );
$wpdb->query( "DELETE FROM $wpdb->posts WHERE post_type = '".SBY_CPT."';" );
}
}
function youtube_feed_social_wall_page() {
( is_plugin_active( 'social-wall/social-wall.php' ) ) ? $sbi_sw_active = true : $sbi_sw_active = false;
?>
'; ?>
Combine all your social media channels into one single wall.
Maximize your social content and get more followers.
A dash of Instagram Add posts from your profile, public hashtag posts, or posts you're tagged in.
A sprinkle of Facebook Include posts from your page or group timeline, or from your photos, videos, albums, and events pages.
A spoonful of Twitter Add Tweets from any Twitter account, hashtag Tweets, mentions, and more.
And a dollop of YouTube Embed videos from any public YouTube channel, playlists, searches, and more.
All in the same feed Combine feeds from all of our Smash Balloon Pro plugins into one single wall feed, and show off all your social media content in one place.
View Demo