. */ //define('WP_DEBUG', true); class YouTubePrefs { public static $folder_name = 'youtube-embed-plus'; public static $curltimeout = 30; public static $version = '13.4.2'; public static $opt_version = 'version'; public static $optembedwidth = null; public static $optembedheight = null; public static $defaultheight = null; public static $defaultwidth = null; public static $oembeddata = null; public static $opt_center = 'centervid'; public static $opt_glance = 'glance'; public static $opt_autoplay = 'autoplay'; public static $opt_debugmode = 'debugmode'; public static $opt_old_script_method = 'old_script_method'; public static $opt_cc_load_policy = 'cc_load_policy'; public static $opt_cc_lang_pref = 'cc_lang_pref'; public static $opt_iv_load_policy = 'iv_load_policy'; public static $opt_loop = 'loop'; public static $opt_modestbranding = 'modestbranding'; public static $opt_rel = 'rel'; public static $opt_fs = 'fs'; public static $opt_playsinline = 'playsinline'; public static $opt_autohide = 'autohide'; public static $opt_controls = 'controls'; public static $opt_theme = 'theme'; public static $opt_color = 'color'; public static $opt_listType = 'listType'; public static $opt_dohl = 'dohl'; public static $opt_hl = 'hl'; public static $opt_nocookie = 'nocookie'; public static $opt_gb_compat = 'gb_compat'; public static $opt_gdpr_consent = 'gdpr_consent'; public static $opt_gdpr_consent_message = 'gdpr_consent_message'; public static $opt_gdpr_consent_button = 'gdpr_consent_button'; public static $gdpr_cookie_name = 'ytprefs_gdpr_consent'; public static $opt_playlistorder = 'playlistorder'; public static $opt_acctitle = 'acctitle'; public static $opt_pro = 'pro'; public static $opt_oldspacing = 'oldspacing'; public static $opt_frontend_only = 'frontend_only'; public static $opt_responsive = 'responsive'; public static $opt_responsive_all = 'responsive_all'; public static $opt_origin = 'origin'; public static $opt_widgetfit = 'widgetfit'; public static $opt_evselector_light = 'evselector_light'; public static $opt_stop_mobile_buffer = 'stop_mobile_buffer'; public static $opt_restrict_wizard = 'restrict_wizard'; public static $opt_restrict_wizard_roles = 'restrict_wizard_roles'; public static $opt_ajax_compat = 'ajax_compat'; public static $opt_ytapi_load = 'ytapi_load'; public static $opt_defaultdims = 'defaultdims'; public static $opt_defaultwidth = 'width'; public static $opt_defaultheight = 'height'; public static $opt_pause_others = 'pause_others'; public static $opt_defaultvol = 'defaultvol'; public static $opt_vol = 'vol'; public static $opt_apikey = 'apikey'; public static $opt_migrate = 'migrate'; public static $opt_migrate_youtube = 'migrate_youtube'; public static $opt_migrate_embedplusvideo = 'migrate_embedplusvideo'; public static $opt_gallery_pagesize = 'gallery_pagesize'; public static $opt_gallery_columns = 'gallery_columns'; public static $opt_gallery_collapse_grid = 'gallery_collapse_grid'; public static $opt_gallery_collapse_grid_breaks = 'gallery_collapse_grid_breaks'; public static $opt_gallery_scrolloffset = 'gallery_scrolloffset'; public static $opt_gallery_hideprivate = 'gallery_hideprivate'; public static $opt_gallery_showtitle = 'gallery_showtitle'; public static $opt_gallery_showpaging = 'gallery_showpaging'; public static $opt_gallery_thumbplay = 'gallery_thumbplay'; public static $opt_gallery_autonext = 'gallery_autonext'; public static $opt_gallery_channelsub = 'gallery_channelsub'; public static $opt_gallery_channelsublink = 'gallery_channelsublink'; public static $opt_gallery_channelsubtext = 'gallery_channelsubtext'; public static $opt_gallery_customarrows = 'gallery_customarrows'; public static $opt_gallery_customprev = 'gallery_customprev'; public static $opt_gallery_customnext = 'gallery_customnext'; public static $opt_not_live_content = 'not_live_content'; public static $opt_not_live_on = 'not_live_on'; public static $opt_admin_off_scripts = 'admin_off_scripts'; public static $opt_defer_js = 'defer_js'; public static $opt_defer_jquery = 'defer_jquery'; public static $opt_ajax_save = 'ajax_save'; public static $opt_onboarded = 'onboarded'; public static $opt_show_pointer = 'show_pointer'; public static $opt_alloptions = 'youtubeprefs_alloptions'; public static $alloptions = null; public static $yt_options = array(); public static $dft_bpts = array(array('bp' => array('min' => 0, 'max' => 767), 'cols' => 1)); public static $dft_roles = array('administrator', 'editor', 'author', 'contributor', 'subscriber'); public static $epbase = 'https://www.embedplus.com'; public static $double_plugin = false; public static $scriptsprinted = 0; public static $min = '.min'; public static $badentities = array('×', '×', '–', '–', '&', '&', '&'); public static $goodliterals = array('x', 'x', '--', '--', '&', '&', '&'); public static $wizard_hook = ''; public static $onboarding_hook = ''; public static $admin_page_hooks = array(); public static $the_content_filters = array( 'wptexturize', 'wpautop', 'shortcode_unautop', 'prepend_attachment', 'wp_make_content_images_responsive', 'wp_filter_content_tags', 'do_shortcode', 'convert_smilies' ); public static $get_api_key_msg = 'The ### feature now requires a (free) YouTube API key from Google. Please follow the easy steps in this video to create and save your API key.'; public static $boilerplate_api_error_message = ' Please make sure you performed the steps in this video to create and save a proper server API key.'; public static $dft_gdpr_consent_message = '

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

'; /////////////////////////////////////////////////////////////////////////////////////////////////// public static $vi_default_date = ''; // date('Y-m-d H:i:s', strtotime('2000-01-01')); public static $vi_last_category_update_interval = '1 hour'; public static $vi_script_tag_done = false; public static $vi_dft_js_settings = array( //"adUnitType" => "NATIVE_VIDEO_UNIT", "divId" => "ytvi_story_container", "language" => "en-us", "iabCategory" => "", "font" => "Arial", "fontSize" => 12, "keywords" => "", "textColor" => "#000000", "backgroundColor" => "#ffffff", "vioptional1" => "", "vioptional2" => "", "vioptional3" => "", "float" => true, //"logoUrl" => "", "dfpSupport" => true, "sponsoredText" => "", "poweredByText" => "" ); public static $opt_vi_active = 'vi_active'; public static $opt_vi_hide_monetize_tab = 'vi_hide_monetize_tab'; public static $opt_vi_endpoints = 'vi_endpoints'; public static $opt_vi_token = 'vi_token'; public static $opt_vi_last_login = 'vi_last_login'; public static $opt_vi_last_category_update = 'vi_last_category_update'; public static $opt_vi_adstxt = 'vi_adstxt'; public static $opt_vi_js_settings = 'vi_js_settings'; public static $opt_vi_js_script = 'vi_js_script'; public static $opt_vi_js_posttypes = 'vi_js_posttypes'; public static $opt_vi_js_position = 'vi_js_position'; public static $opt_vi_show_gdpr_authorization = 'vi_show_gdpr_authorization'; public static $opt_vi_show_privacy_button = 'vi_show_privacy_button'; /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// public static $oldytregex = '@^\s*https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))(?:/live_stream){0,1}/{0,1}\?)|(?:youtu.be/))([^\s"]+)\s*$@im'; public static $ytregex = '@^[\r\t ]*https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))(?:/live_stream){0,1}/{0,1}\?)|(?:youtu.be/))([^\s"]+)[\r\t ]*$@im'; public static $justurlregex = '@https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))(?:/live_stream){0,1}/{0,1}\?)|(?:youtu.be/))([^\[\s"]+)@i'; /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// public function __construct() { if (defined('EMBEDPLUS_BASE_URL')) { self::$epbase = EMBEDPLUS_BASE_URL; } self::$vi_default_date = date('Y-m-d H:i:s', strtotime('2000-01-01')); register_deactivation_hook(__FILE__, array(get_class(), 'on_deactivation')); add_action('admin_init', array(get_class(), 'check_double_plugin_warning')); add_action('admin_notices', array(get_class(), 'separate_version_message')); self::$alloptions = get_option(self::$opt_alloptions); if (self::$alloptions == false || version_compare(self::$alloptions[self::$opt_version], self::$version, '<')) { self::initoptions(); } if ((defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) || self::$alloptions[self::$opt_debugmode] == 1) { self::$min = ''; } if (self::$alloptions[self::$opt_oldspacing] == 1) { self::$ytregex = self::$oldytregex; } self::$optembedwidth = intval(get_option('embed_size_w')); self::$optembedheight = intval(get_option('embed_size_h')); self::$yt_options = array( self::$opt_autoplay, self::$opt_cc_load_policy, self::$opt_cc_lang_pref, self::$opt_iv_load_policy, self::$opt_loop, self::$opt_modestbranding, self::$opt_rel, self::$opt_fs, self::$opt_playsinline, self::$opt_autohide, self::$opt_controls, self::$opt_hl, self::$opt_theme, self::$opt_color, self::$opt_listType, 'index', 'list', 'start', 'end', 'channel' ); add_action('media_buttons', array(get_class(), 'media_button_wizard'), 11); self::do_ytprefs(); add_action('admin_menu', array(get_class(), 'ytprefs_plugin_menu')); add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(get_class(), 'my_plugin_action_links')); if (!is_admin()) { if (self::$alloptions[self::$opt_old_script_method] == 1) { add_action('wp_print_scripts', array(get_class(), 'jsvars')); add_action('wp_enqueue_scripts', array(get_class(), 'jsvars')); } add_action('wp_enqueue_scripts', array(get_class(), 'ytprefsscript'), 100); add_action('wp_enqueue_scripts', array(get_class(), 'fitvids'), 101); } add_filter('ytprefs_filter_the_content_light', array(get_class(), 'filter_the_content_light')); add_action("wp_ajax_my_embedplus_onboarding_save_ajax", array(get_class(), 'onboarding_save_ajax')); add_action("wp_ajax_my_embedplus_settings_save_ajax", array(get_class(), 'settings_save_ajax')); add_action("wp_ajax_my_embedplus_onboarding_save_apikey_ajax", array(get_class(), 'onboarding_save_apikey_ajax')); add_action("wp_ajax_my_embedplus_glance_vids", array(get_class(), 'my_embedplus_glance_vids')); add_action("wp_ajax_my_embedplus_glance_count", array(get_class(), 'my_embedplus_glance_count')); add_action("wp_ajax_my_embedplus_dismiss_double_plugin_warning", array(get_class(), 'my_embedplus_dismiss_double_plugin_warning')); add_action("wp_ajax_my_embedplus_gallery_page", array(get_class(), 'my_embedplus_gallery_page')); add_action("wp_ajax_nopriv_my_embedplus_gallery_page", array(get_class(), 'my_embedplus_gallery_page')); add_action('admin_enqueue_scripts', array(get_class(), 'admin_enqueue_scripts'), 10, 1); ///////////////////////////////////// include_once(EPYTVI_INCLUDES_PATH . 'vi_actions.php'); include_once(EPYTGB_INCLUDES_PATH . 'gutenberg_hooks.php'); } public static function separate_version_message() { if (current_user_can('manage_options') && self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 10) { $class = 'notice notice-error is-dismissible'; $message = 'Important message to YouTube Pro users: From version 11.7 onward, you must download the separate plugin here to regain your Pro features. All your settings will automatically migrate after installing the separate Pro download. Thank you for your support and patience during this transition.'; printf('

%2$s

', esc_attr($class), wp_kses_post($message)); } } public static function defer_scripts($tag, $handle, $src) { $defer = array( '__dispload__', '__ytprefs__', '__dynload__', '__ytprefs__bar', '__ytprefsfitvids__', '__jquery_cookie__' ); if (self::$alloptions[self::$opt_defer_jquery] == 1 && !is_admin()) { array_push($defer, 'jquery', 'jquery-core', 'jquery-migrate'); } if (in_array($handle, $defer) && stripos($tag, ' defer') === false) { $tag = str_replace(' src', ' defer src', $tag); } return $tag; } public static function my_plugin_action_links($links) { if (is_array($links)) { $links[] = 'Settings'; $links[] = 'Pro Version'; } return $links; } public static function show_glance_list() { $glancehref = self::show_glance(); $cnt = self::get_glance_count(); //display via list return '
  • ' . number_format_i18n($cnt) . ' With YouTube
  • '; } public static function show_glance_table() { $glancehref = self::show_glance(); $cnt = self::get_glance_count(); return ' ' . number_format_i18n($cnt) . ' With YouTube '; } public static function get_glance_count() { global $wpdb; $query_sql = " SELECT count(*) as mytotal FROM $wpdb->posts WHERE (post_content LIKE '%youtube.com/%' OR post_content LIKE '%youtu.be/%') AND post_status = 'publish'"; $query_result = $wpdb->get_results($query_sql, OBJECT); return intval($query_result[0]->mytotal); } public static function show_glance() { $glancehref = admin_url('admin.php?page=youtube-ep-glance') . '&random=' . rand(1, 1000) . '&TB_iframe=true&width=780&height=800'; return $glancehref; } public static function glance_page() { ?>
    posts WHERE (post_content LIKE '%youtube.com/%' OR post_content LIKE '%youtu.be/%') AND post_status = 'publish' order by post_date DESC LIMIT 0, 10"; $query_result = $wpdb->get_results($query_sql, OBJECT); if ($query_result !== null) { $total = $wpdb->get_var("SELECT FOUND_ROWS();"); global $post; echo '

    10 Latest Posts/Pages with YouTube Videos (' . intval($total) . ' Total)

    '; ?> We recommend using this page as an easy way to check the results of the global default settings you make (e.g. hide annotations) on your recent embeds. Or, simply use it as an index to jump right to your posts that contain YouTube embeds. 0) { echo ''; } else { echo '

    You currently do not have any YouTube embeds yet.

    '; } } wp_reset_postdata(); ?> To remove this feature from your dashboard, simply uncheck Show "At a Glance" Embed Links in the plugin settings page ».
    '; $matches = array(); $ismatch = preg_match_all(self::$justurlregex, $currpost->post_content, $matches); if ($ismatch) { foreach ($matches[0] as $match) { $link = trim(preg_replace('/&/i', '&', $match)); $link = preg_replace('/\s/', '', $link); $link = trim(str_replace(self::$badentities, self::$goodliterals, $link)); $linkparamstemp = explode('?', $link); $linkparams = array(); if (count($linkparamstemp) > 1) { $linkparams = self::keyvalue($linkparamstemp[1], true); } if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v'])) { $vtemp = explode('/', $linkparamstemp[0]); $linkparams['v'] = array_pop($vtemp); } $vidid = $linkparams['v']; if ($vidid != null) { try { $odata = self::get_oembed('https://youtube.com/watch?v=' . $vidid, 1920, 1280); $postlink = get_permalink($postid); if ($odata != null && !is_wp_error($odata)) { $_name = esc_attr(sanitize_text_field($odata->title)); $_description = esc_attr(sanitize_text_field($odata->author_name)); $_thumbnailUrl = esc_url("https://i.ytimg.com/vi/" . $vidid . "/0.jpg"); $thehtml .= 'YouTube Video'; $thehtml .= '
    '; $thehtml .= '' . $_name . ''; $thehtml .= '
    ' . (strlen($_description) > 400 ? substr($_description, 0, 400) . "..." : $_description) . '
    '; $thehtml .= '
    '; $thehtml .= '
    '; } else { $thehtml .= '

    This post/page contains a video that has been removed from YouTube.'; $thehtml .= '
    Activate delete video tracking to catch these cases »'; $thehtml .= ''; } } catch (Exception $ex) { } } else if (isset($linkparams['list'])) { // if playlist try { $odata = self::get_oembed('https://youtube.com/playlist?list=' . $linkparams['list'], 1920, 1280); $postlink = get_permalink($postid); if ($odata != null && !is_wp_error($odata)) { $_name = esc_attr(sanitize_text_field($odata->title)); $_description = esc_attr(sanitize_text_field($odata->author_name)); $_thumbnailUrl = esc_url($odata->thumbnail_url); $thehtml .= 'YouTube Video'; $thehtml .= '

    '; $thehtml .= '' . $_name . ''; $thehtml .= '
    ' . (strlen($_description) > 400 ? substr($_description, 0, 400) . "..." : $_description) . '
    '; $thehtml .= '
    '; $thehtml .= '
    '; } else { $thehtml .= '

    This post/page contains a video that has been removed from YouTube.'; $thehtml .= '
    Activate delete video tracking to catch these cases »'; $thehtml .= ''; } } catch (Exception $ex) { } } } } if ($currpost != null) { $result['type'] = 'success'; $result['data'] = $thehtml; } else { $result['type'] = 'error'; } echo json_encode($result); } else { $result['type'] = 'error'; header("Location: " . $_SERVER["HTTP_REFERER"]); } die(); } public static function my_embedplus_glance_count() { $result = array(); if (self::is_ajax()) { $thehtml = ''; try { if (version_compare(get_bloginfo('version'), '3.8', '>=')) { $result['container'] = '#dashboard_right_now ul'; $thehtml .= self::show_glance_list(); } else { $result['container'] = '#dashboard_right_now .table_content table tbody'; $thehtml .= self::show_glance_table(); } $result['type'] = 'success'; $result['data'] = $thehtml; } catch (Exception $e) { $result['type'] = 'error'; } echo json_encode($result); } else { $result['type'] = 'error'; header("Location: " . $_SERVER["HTTP_REFERER"]); } die(); } public static function try_get_ytid($url) { $theytid = null; if (strpos($url, 'v=') !== false) { $url_params = explode('?', $url); $kvp = self::keyvalue($url_params[1], true); $theytid = $kvp['v']; } else if (strpos($url, "youtu.be") !== false) { $shortpath = explode('/', parse_url($url, PHP_URL_PATH)); $theytid = $shortpath[1]; } return $theytid; } public static function wizard() { ?>

    Please periodically check the YouTube plugin tab on your admin panel to review the latest options.
    the owner of the video allowed embed sharing permissions (otherwise, contact the owner of the video to allow embedding). Then copy that full link in your address bar to paste here. If you are sure your link is correct, then (1) your API key may be too restrictive (check here) or (2) you have reached your Google quota (check here). You can apply to Google for a quota increase here.'; $step1_video_errors = ''; $step1_video_error_invalid = 'Sorry, that does not seem to be a link to an existing video. Please confirm that the link works in your browser, and that the owner of the video allowed embed sharing permissions (otherwise, contact the owner of the video to allow embedding). Then copy that full link in your address bar to paste here.'; $step1_playlist_errors = ''; $step1_playlist_error_invalid = 'Sorry, that does not seem to be a link to an existing playlist. Please confirm that the link works in your browser, and that the owner of the playlist allowed embed sharing permissions (otherwise, contact the owner of the video to allow embedding). Then copy that full link in your address bar to paste here.'; $step1_channel_errors = ''; $step1_channel_error_invalid = 'Sorry, that does not seem to be a link to an existing video. ' . $step1_api_error_msg; $step1_live_errors = ''; $step1_live_error_invalid = 'Sorry, that does not seem to be a valid link to an existing live video. ' . $step1_api_error_msg; $step1_livechannel_errors = ''; $step1_livechannel_error_invalid = 'Sorry, that does not seem to be a link to an existing channel.'; $if_live_preview = false; $theytid = null; $theplaylistid = null; $submit_type = null; if (isset($_POST['wizform_submit'])) { check_admin_referer('_epyt_wiz', '_epyt_nonce'); $submit_type = sanitize_text_field($_POST['wizform_submit']); if ($submit_type === 'step1_video') { // validate $search = sanitize_text_field(trim($_POST['txtUrl'])); try { if (empty($search)) { throw new Exception(); } if (preg_match(self::$justurlregex, $search)) { //$search = esc_url($search); try { $theytid = self::try_get_ytid($search); if ($theytid == null) { $form_valid = false; $step1_video_errors = $step1_video_error_invalid; $acc_expand = 'h3_video'; } else { $odata = self::get_oembed('http://youtube.com/watch?v=' . $theytid, 1920, 1280); if (is_object($odata)) { ?>

    title)) { echo sanitize_text_field($odata->title); } ?>

    Customize (PRO)   Insert Into Editor

      Or Copy Code: [embedyt] https://www.youtube.com/watch?v=[/embedyt]
    q = $search; $search_options->pageToken = null; ?>

    title)) { echo 'Playlist: ' . sanitize_text_field($odata->title); } ?>

    Insert as Playlist   Insert as Gallery   Customize (PRO)

    Or Copy Code:

    Playlist Layout: [embedyt] [/embedyt]

    Gallery Layout: [embedyt] [/embedyt]

    snippet->channelId); } } else { // channel id $chanmatch = array(); preg_match('@/channel/(.+)@', $search, $chanmatch); if (!empty($chanmatch)) { $thechannel = self::get_channel_snippet($chanmatch[1]); } } if ($thechannel) { $theplaylistid = $thechannel->contentDetails->relatedPlaylists->uploads; $rel = 'https://www.youtube.com/embed?listType=playlist&list=' . (esc_attr($theplaylistid)); ?>

    snippet->title); ?>

    Insert as Playlist   Insert as Gallery   Customize (PRO)

    Or Copy Code:

    Playlist Layout: [embedyt] [/embedyt]

    Gallery Layout: [embedyt] [/embedyt]

    Insert Into Editor   Customize (PRO)

      Or Copy Code: [embedyt] https://www.youtube.com/embed/live_stream?channel=[/embedyt]

    id; $final_title = sanitize_text_field($live_attempt->snippet->title); $final_title_prefix = 'Live Stream'; } $rel = 'https://www.youtube.com/watch?v=' . (esc_attr($theytid)) . '&live=1'; $doing_live = true; ?>

    snippet->title); ?>

    Insert Into Editor   Customize (PRO)

    Or Copy Code:

    [embedyt] [/embedyt]

    Is your live stream not working? According to Google/YouTube rules, there must be an active AdSense account that's connected to the live stream's channel (for monetization) in order embed the stream. If you own the channel, we suggest that you attach an AdSense account. Otherwise, you will likely just see a blank screen when you embed your stream, even if it is visible on YouTube.com. Read more here: https://support.google.com/youtube/answer/2474026?hl=en

    Check my general YouTube embedding instructions and settings.

    Embed a single video.

    Single video directions

    Paste the url of a single video below (example: https://www.youtube.com/watch?v=YVvn8dpSAt0 )

    ' . $step1_video_errors . '

    ' : ''; ?>

    Note: You can also search YouTube videos by title in the text box above (example: TED talks). However, searching will use a significant amount of your YouTube API quota.

    Embed a playlist.

    Playlist directions

    1. Go to the page for the playlist that lists all of its videos (Example »).
    2. You may then click on the video that you want the playlist to start with (this step only applies to self-contained playlists. You cannot pick a starter for gallery layout directions).
    3. Copy the URL in your browser and paste it in the textbox below. You'll notice that a playlist URL contains the playlist ID (e.g. "PL...")
    4. Click "Get Playlist" to continue.
    1. Go to the page for the playlist that lists all of its videos (Example »).
    2. Copy the URL in your browser and paste it in the textbox below. You'll notice that a playlist URL contains the playlist ID (e.g. "PL...")
    3. Click "Get Playlist" to continue.
    ' . $step1_playlist_errors . '

    ' : ''; ?>

    Embed a channel.

    Channel directions

    If you already know the direct link to the channel ID, enter it below.
    Example: https://www.youtube.com/channel/UCnM5iMGiKsZg-iOlIO2ZkdQ

    Note: the following format will not work: https://www.youtube.com/c/customchannelname If you cannot locate the proper channel ID format above, then try the other method below.

    Or, simply enter a link to any single video that belongs to the user's channel, and the plugin will find the channel for you.
    Example: https://www.youtube.com/watch?v=YVvn8dpSAt0

    ' . $step1_channel_errors . '

    ' : ''; ?>

    Embed a live stream or premiere video.

    Live stream or premiere directions

    Important: You can embed any public livestreams or premieres from any channel that YouTube/Google has approved to be Eligible and Enabled. If you're trying to embed a livestream from your own channel, you can check make sure it is Eligible and Enabled by visiting here. You are verified if you see the word "Enabled" at the bottom of the box that is labeled "Embed live streams." Note that verification can only be done directly through YouTube/Google with the link above, and this plugin cannot automatically do that. YouTube/Google also requires Monetization enabled. You can read more here »

    This will embed a specific live stream or premiere video.

    1. Paste in the direct URL of the live stream or premiere below and click Submit. Example: https://www.youtube.com/watch?v=5qap5aO4i9A
    2. On the next screen, customize or insert your video.
    ' . $step1_live_errors . '

    ' : ''; ?>

    This will embed a video that will automatically display the next upcoming live stream from a channel.

    Enter the link to the channel page below (note the word "channel" should be in the link).
    Example: https://www.youtube.com/channel/UCL0iAkpqV5YaIVG7xkDtS4Q

    ' . $step1_livechannel_errors . '

    ' : ''; ?>

    Note: For now, the "Not Live" custom content feature is not available for channel-based embeds. YouTube's standard countdown will appear in the video until the scheduled stream goes live.

    Earn money embedding videos.

    Check my performance, blocked countries, deleted videos, etc. (PRO)

    0) { return true; } return false; } public static function get_live_snippet($channel) { $apiEndpoint = 'https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&maxResults=1&type=video&eventType=live&safeSearch=none&videoEmbeddable=true&key=' . self::$alloptions[self::$opt_apikey] . '&channelId=' . urlencode($channel); $apiResult = wp_remote_get($apiEndpoint, array('timeout' => self::$curltimeout)); if (is_wp_error($apiResult)) { return false; } $jsonResult = json_decode($apiResult['body']); if (isset($jsonResult->error)) { return false; } if (isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items) && count($jsonResult->items)) { return $jsonResult->items[0]; } return false; } public static function get_video_snippet($vid) { $apiEndpoint = 'https://www.googleapis.com/youtube/v3/videos?part=snippet&maxResults=1&key=' . self::$alloptions[self::$opt_apikey] . '&id=' . urlencode($vid); $apiResult = wp_remote_get($apiEndpoint, array('timeout' => self::$curltimeout)); if (is_wp_error($apiResult)) { return false; } $jsonResult = json_decode($apiResult['body']); if (isset($jsonResult->error)) { return false; } if (isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items) && count($jsonResult->items)) { return $jsonResult->items[0]; } return false; } public static function get_channel_snippet($channid) { $apiEndpoint = 'https://www.googleapis.com/youtube/v3/channels?part=contentDetails,snippet&key=' . self::$alloptions[self::$opt_apikey] . '&id=' . urlencode($channid); $apiResult = wp_remote_get($apiEndpoint, array('timeout' => self::$curltimeout)); if (is_wp_error($apiResult)) { return false; } $jsonResult = json_decode($apiResult['body']); if (isset($jsonResult->error)) { return false; } if (isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items) && count($jsonResult->items)) { return $jsonResult->items[0]; } return false; } public static function clean_api_error($raw_message) { return htmlspecialchars(strip_tags(preg_replace('@&key=[^& ]+@i', '&key=*******', $raw_message))); } public static function clean_api_error_html($raw_message, $add_boilerplate) { $clean_html = '
    Sorry, there was a YouTube error.
    '; if (current_user_can('manage_options')) { $clean_html = '
    Sorry, there was a YouTube API error: ' . self::clean_api_error($raw_message) . '' . ( $add_boilerplate ? self::$boilerplate_api_error_message : '' ) . '
    '; } return $clean_html; } public static function get_search_page($options) { $gallobj = new stdClass(); $pageSize = 30; if (!self::has_api_key()) { $gallobj->html = '
    ' . str_replace('###', 'search', self::$get_api_key_msg) . '
    '; return $gallobj; } $apiEndpoint = 'https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=' . $pageSize . '&type=video&safeSearch=none&videoEmbeddable=true&key=' . self::$alloptions[self::$opt_apikey] . '&q=' . urlencode($options->q); if (!empty($options->pageToken)) { $apiEndpoint .= '&pageToken=' . $options->pageToken; } $code = ''; $apiResult = wp_remote_get($apiEndpoint, array('timeout' => self::$curltimeout)); if (is_wp_error($apiResult)) { $gallobj->html = self::clean_api_error_html($apiResult->get_error_message(), true); return $gallobj; } $jsonResult = json_decode($apiResult['body']); if (isset($jsonResult->error)) { if (isset($jsonResult->error->message)) { $gallobj->html = self::clean_api_error_html($jsonResult->error->message, true); return $gallobj; } $gallobj->html = '
    Sorry, there may be an issue with your YouTube API key. ' . self::$boilerplate_api_error_message . '
    '; return $gallobj; } $totalResults = $jsonResult->pageInfo->totalResults; $nextPageToken = ''; $prevPageToken = ''; if (isset($jsonResult->nextPageToken)) { $nextPageToken = $jsonResult->nextPageToken; } if (isset($jsonResult->prevPageToken)) { $prevPageToken = $jsonResult->prevPageToken; } $cnt = 0; $code .= '
    '; if (isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items)) { foreach ($jsonResult->items as $item) { $thumb = new stdClass(); $thumb->id = isset($item->snippet->resourceId->videoId) ? $item->snippet->resourceId->videoId : null; $thumb->id = $thumb->id ? $thumb->id : (isset($item->id->videoId) ? $item->id->videoId : null); if ($thumb->id) { $thumb->title = $item->snippet->title; if (isset($item->snippet->thumbnails->high->url)) { $thumb->img = $item->snippet->thumbnails->high->url; $thumb->quality = 'high'; } elseif (isset($item->snippet->thumbnails->default->url)) { $thumb->img = $item->snippet->thumbnails->default->url; $thumb->quality = 'default'; } elseif (isset($item->snippet->thumbnails->medium->url)) { $thumb->img = $item->snippet->thumbnails->medium->url; $thumb->quality = 'medium'; } else { $thumb->img = plugins_url('/images/deleted-video-thumb.png', __FILE__); $thumb->quality = 'medium'; } $code .= self::get_search_result_html($thumb, $options); $cnt++; $code .= '
    '; } } } $code .= '
    '; $totalPages = ceil($totalResults / $pageSize); $pagination = '
    '; $txtprev = self::$alloptions[self::$opt_gallery_customarrows] ? self::$alloptions[self::$opt_gallery_customprev] : _('Prev'); $pagination .= '
    «
    ' . $txtprev . '
    '; $pagination .= '
    '; $pagination .= '
    1
    /
    ' . $totalPages . '
    '; $pagination .= '
    '; $txtnext = self::$alloptions[self::$opt_gallery_customarrows] ? self::$alloptions[self::$opt_gallery_customnext] : _('Next'); $pagination .= '
    ' . $txtnext . '
    »
    '; $pagination .= '
    loading
    '; $pagination .= '
    '; $code = $pagination . $code . $pagination; $gallobj->html = $code; return $gallobj; } public static function get_search_result_html($thumb, $options) { $get_pro_link = self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=searchresult'; $escId = esc_attr($thumb->id); $code = ''; $code .= '
    ' . sanitize_text_field($thumb->title) . '

    Customize (PRO)   Insert Into Editor

      Or Copy Code: [embedyt] https://www.youtube.com/watch?v=' . $escId . '[/embedyt]
    '; return $code; } public static function user_in_roles_any($user, $roles) { foreach ($user->roles as $idx => $r) { if (in_array($r, $roles)) { return true; } } return false; } public static function is_restrict_wizard() { $curr_user = wp_get_current_user(); if ( $curr_user->ID // logged in && isset(self::$alloptions[self::$opt_restrict_wizard]) && self::$alloptions[self::$opt_restrict_wizard] == 1 // restricting && is_array(self::$alloptions[self::$opt_restrict_wizard_roles]) && !self::user_in_roles_any($curr_user, self::$alloptions[self::$opt_restrict_wizard_roles]) ) { return true; } return false; } public static function media_button_wizard() { if (self::is_restrict_wizard()) { return; } add_thickbox(); $wizhref = admin_url('admin.php?page=youtube-ep-wizard') . '&random=' . rand(1, 1000) . '&TB_iframe=true&width=950&height=800'; ?> YouTube Video Ad ' . $_SERVER['QUERY_STRING'] .''; if ($pagenow == 'plugins.php' || strpos($_SERVER['QUERY_STRING'], 'youtube-my-preferences') !== false || strpos($_SERVER['QUERY_STRING'], 'embedplus-video-analytics-dashboard') !== false || strpos($_SERVER['QUERY_STRING'], 'youtube-ep-analytics-dashboard') !== false || strpos($_SERVER['QUERY_STRING'], 'embedplus-official-options') !== false) { ?>

    ×'; } ?> Seems like you have two different YouTube plugins by the EmbedPlus Team installed: YouTube and Advanced YouTube Embed. We strongly suggest keeping only the one you prefer, so that they don't conflict with each other while trying to create your embeds.

    options . " set autoload = 'no' where option_name like '" . self::$opt_alloptions . "\_backup\_%'"; $wpdb->query($sql); } // backup settings for migration if (isset($arroptions[self::$opt_pro]) && strlen(trim($arroptions[self::$opt_pro])) > 10) { add_option(self::$opt_alloptions . '_migrate', $arroptions); } //vanilla defaults $_center = 0; $_glance = 0; $_autoplay = 0; $_cc_load_policy = 0; $_cc_lang_pref = ''; $_iv_load_policy = 1; $_loop = 0; $_modestbranding = 0; $_rel = 1; $_fs = 1; $_theme = 'dark'; $_color = 'red'; $_autohide = 2; $_pro = ''; $_nocookie = 0; $_gb_compat = 1; $_gdpr_consent = 0; $_gdpr_consent_message = self::$dft_gdpr_consent_message; $_gdpr_consent_button = 'Accept YouTube Content'; $_playlistorder = 0; $_acctitle = 0; $_migrate = 0; $_migrate_youtube = 0; $_migrate_embedplusvideo = 0; $_controls = 1; $_oldspacing = 1; $_frontend_only = 1; $_responsive = 0; $_responsive_all = 1; $_widgetfit = 1; $_evselector_light = 0; $_stop_mobile_buffer = 1; $_restrict_wizard = 0; $_restrict_wizard_roles = self::$dft_roles; $_ajax_compat = 0; $_ytapi_load = 'light'; $_defaultdims = 0; $_defaultwidth = ''; $_defaultheight = ''; $_playsinline = 0; $_origin = 0; $_pause_others = 0; $_defaultvol = 0; $_vol = ''; $_apikey = ''; $_hl = ''; $_dohl = 0; $_gallery_columns = 3; $_gallery_collapse_grid = 0; $_gallery_collapse_grid_breaks = self::$dft_bpts; $_gallery_scrolloffset = 20; $_gallery_hideprivate = 1; $_gallery_showtitle = 1; $_gallery_showpaging = 1; $_gallery_autonext = 0; $_gallery_thumbplay = 1; $_gallery_channelsub = 0; $_gallery_channelsublink = ''; $_gallery_channelsubtext = 'Subscribe to my channel'; $_gallery_customarrows = 0; $_gallery_customprev = 'Prev'; $_gallery_customnext = 'Next'; $_gallery_pagesize = 15; $_not_live_content = ''; $_not_live_on = 0; $_debugmode = 0; $_admin_off_scripts = 0; $_defer_js = 0; $_defer_jquery = 0; $_ajax_save = 1; $_show_pointer = 1; $_onboarded = 0; $_old_script_method = 0; $_vi_active = 0; $_vi_hide_monetize_tab = 0; $_vi_endpoints = ''; $_vi_token = ''; $_vi_last_login = self::$vi_default_date; $_vi_last_category_update = self::$vi_default_date; $_vi_adstxt = ''; $_vi_js_settings = self::$vi_dft_js_settings; $_vi_js_script = ''; $_vi_js_posttypes = array(); $_vi_js_position = 'top'; $_vi_show_gdpr_authorization = 1; $_vi_show_privacy_button = 0; //update vanilla to previous settings if exists if ($arroptions !== false) { $_center = self::tryget($arroptions, self::$opt_center, 0); $_glance = self::tryget($arroptions, self::$opt_glance, $_glance); $_autoplay = self::tryget($arroptions, self::$opt_autoplay, 0); $_debugmode = self::tryget($arroptions, self::$opt_debugmode, 0); $_old_script_method = self::tryget($arroptions, self::$opt_old_script_method, 0); $_cc_load_policy = self::tryget($arroptions, self::$opt_cc_load_policy, 0); $_cc_lang_pref = self::tryget($arroptions, self::$opt_cc_lang_pref, $_cc_lang_pref); $_iv_load_policy = self::tryget($arroptions, self::$opt_iv_load_policy, 1); $_loop = self::tryget($arroptions, self::$opt_loop, 0); $_modestbranding = self::tryget($arroptions, self::$opt_modestbranding, 0); $_rel = self::tryget($arroptions, self::$opt_rel, 1); $_fs = self::tryget($arroptions, self::$opt_fs, 1); $_playsinline = self::tryget($arroptions, self::$opt_playsinline, 0); $_origin = self::tryget($arroptions, self::$opt_origin, 0); $_hl = self::tryget($arroptions, self::$opt_hl, ''); $_dohl = self::tryget($arroptions, self::$opt_dohl, 0); $_theme = self::tryget($arroptions, self::$opt_theme, 'dark'); $_color = self::tryget($arroptions, self::$opt_color, 'red'); $_autohide = self::tryget($arroptions, self::$opt_autohide, 2); $_pro = self::tryget($arroptions, self::$opt_pro, ''); $_nocookie = self::tryget($arroptions, self::$opt_nocookie, 0); $_gb_compat = self::tryget($arroptions, self::$opt_gb_compat, $_gb_compat); $_gdpr_consent = self::tryget($arroptions, self::$opt_gdpr_consent, $_gdpr_consent); $_gdpr_consent_message = self::tryget($arroptions, self::$opt_gdpr_consent_message, $_gdpr_consent_message); $_gdpr_consent_button = self::tryget($arroptions, self::$opt_gdpr_consent_button, $_gdpr_consent_button); $_playlistorder = self::tryget($arroptions, self::$opt_playlistorder, 0); $_acctitle = self::tryget($arroptions, self::$opt_acctitle, 0); $_migrate = self::tryget($arroptions, self::$opt_migrate, 0); $_migrate_youtube = self::tryget($arroptions, self::$opt_migrate_youtube, 0); $_migrate_embedplusvideo = self::tryget($arroptions, self::$opt_migrate_embedplusvideo, 0); $_controls = self::tryget($arroptions, self::$opt_controls, 1); $_controls = $_controls == 2 ? 1 : $_controls; $_oldspacing = self::tryget($arroptions, self::$opt_oldspacing, 1); $_frontend_only = self::tryget($arroptions, self::$opt_frontend_only, $_frontend_only); $_responsive = self::tryget($arroptions, self::$opt_responsive, $_responsive); $_responsive_all = self::tryget($arroptions, self::$opt_responsive_all, $_responsive_all); $_widgetfit = self::tryget($arroptions, self::$opt_widgetfit, 1); $_evselector_light = self::tryget($arroptions, self::$opt_evselector_light, 0); $_stop_mobile_buffer = self::tryget($arroptions, self::$opt_stop_mobile_buffer, 1); $_restrict_wizard = self::tryget($arroptions, self::$opt_restrict_wizard, 0); $_restrict_wizard_roles = self::tryget($arroptions, self::$opt_restrict_wizard_roles, self::$dft_roles); $_ajax_compat = self::tryget($arroptions, self::$opt_ajax_compat, 0); $_ytapi_load = self::tryget($arroptions, self::$opt_ytapi_load, $_ytapi_load); $_defaultdims = self::tryget($arroptions, self::$opt_defaultdims, 0); $_defaultwidth = self::tryget($arroptions, self::$opt_defaultwidth, ''); $_defaultheight = self::tryget($arroptions, self::$opt_defaultheight, ''); $_pause_others = self::tryget($arroptions, self::$opt_pause_others, $_pause_others); $_defaultvol = self::tryget($arroptions, self::$opt_defaultvol, 0); $_vol = self::tryget($arroptions, self::$opt_vol, ''); $_apikey = self::tryget($arroptions, self::$opt_apikey, ''); $_gallery_pagesize = self::tryget($arroptions, self::$opt_gallery_pagesize, 15); $_gallery_columns = self::tryget($arroptions, self::$opt_gallery_columns, 3); $_gallery_collapse_grid = self::tryget($arroptions, self::$opt_gallery_collapse_grid, 0); $_gallery_collapse_grid_breaks = self::tryget($arroptions, self::$opt_gallery_collapse_grid_breaks, self::$dft_bpts); $_gallery_scrolloffset = self::tryget($arroptions, self::$opt_gallery_scrolloffset, 20); $_gallery_hideprivate = self::tryget($arroptions, self::$opt_gallery_hideprivate, $_gallery_hideprivate); $_gallery_showtitle = self::tryget($arroptions, self::$opt_gallery_showtitle, 1); $_gallery_showpaging = self::tryget($arroptions, self::$opt_gallery_showpaging, 1); $_gallery_autonext = self::tryget($arroptions, self::$opt_gallery_autonext, 0); $_gallery_thumbplay = self::tryget($arroptions, self::$opt_gallery_thumbplay, 1); $_gallery_channelsub = self::tryget($arroptions, self::$opt_gallery_channelsub, $_gallery_channelsub); $_gallery_channelsublink = self::tryget($arroptions, self::$opt_gallery_channelsublink, $_gallery_channelsublink); $_gallery_channelsubtext = self::tryget($arroptions, self::$opt_gallery_channelsubtext, $_gallery_channelsubtext); $_gallery_customarrows = self::tryget($arroptions, self::$opt_gallery_customarrows, $_gallery_customarrows); $_gallery_customnext = self::tryget($arroptions, self::$opt_gallery_customnext, $_gallery_customnext); $_gallery_customprev = self::tryget($arroptions, self::$opt_gallery_customprev, $_gallery_customprev); $_not_live_content = self::tryget($arroptions, self::$opt_not_live_content, $_not_live_content); $_not_live_content = empty($_not_live_content) ? $_not_live_content : trim($_not_live_content); $_not_live_on = self::tryget($arroptions, self::$opt_not_live_on, empty($_not_live_content) ? 0 : $_not_live_on); $_admin_off_scripts = self::tryget($arroptions, self::$opt_admin_off_scripts, $_admin_off_scripts); $_defer_js = self::tryget($arroptions, self::$opt_defer_js, $_defer_js); $_defer_jquery = self::tryget($arroptions, self::$opt_defer_jquery, $_defer_jquery); $_ajax_save = self::tryget($arroptions, self::$opt_ajax_save, $_ajax_save); $_show_pointer = self::tryget($arroptions, self::$opt_show_pointer, $_show_pointer); $_onboarded = 0; // self::tryget($arroptions, self::$opt_onboarded, $_onboarded); $_vi_active = self::tryget($arroptions, self::$opt_vi_active, $_vi_active); $_vi_hide_monetize_tab = self::tryget($arroptions, self::$opt_vi_hide_monetize_tab, $_vi_hide_monetize_tab); $_vi_endpoints = self::tryget($arroptions, self::$opt_vi_endpoints, $_vi_endpoints); $_vi_token = self::tryget($arroptions, self::$opt_vi_token, $_vi_token); $_vi_last_login = self::tryget($arroptions, self::$opt_vi_last_login, $_vi_last_login); $_vi_last_category_update = self::tryget($arroptions, self::$opt_vi_last_category_update, $_vi_last_category_update); $_vi_adstxt = self::tryget($arroptions, self::$opt_vi_adstxt, $_vi_adstxt); $_vi_js_settings = self::tryget($arroptions, self::$opt_vi_js_settings, self::$vi_dft_js_settings); $_vi_js_script = self::tryget($arroptions, self::$opt_vi_js_script, $_vi_js_script); $_vi_js_posttypes = self::tryget($arroptions, self::$opt_vi_js_posttypes, $_vi_js_posttypes); $_vi_js_position = self::tryget($arroptions, self::$opt_vi_js_position, $_vi_js_position); $_vi_show_gdpr_authorization = self::tryget($arroptions, self::$opt_vi_show_gdpr_authorization, $_vi_show_gdpr_authorization); $_vi_show_privacy_button = self::tryget($arroptions, self::$opt_vi_show_privacy_button, $_vi_show_privacy_button); } else { $_oldspacing = 0; } $all = array( self::$opt_version => self::$version, self::$opt_center => $_center, self::$opt_glance => $_glance, self::$opt_autoplay => $_autoplay, self::$opt_cc_load_policy => $_cc_load_policy, self::$opt_cc_lang_pref => $_cc_lang_pref, self::$opt_iv_load_policy => $_iv_load_policy, self::$opt_loop => $_loop, self::$opt_modestbranding => $_modestbranding, self::$opt_rel => $_rel, self::$opt_fs => $_fs, self::$opt_playsinline => $_playsinline, self::$opt_origin => $_origin, self::$opt_autohide => $_autohide, self::$opt_hl => $_hl, self::$opt_dohl => $_dohl, self::$opt_theme => $_theme, self::$opt_color => $_color, self::$opt_pro => $_pro, self::$opt_nocookie => $_nocookie, self::$opt_gb_compat => $_gb_compat, self::$opt_gdpr_consent => $_gdpr_consent, self::$opt_gdpr_consent_message => $_gdpr_consent_message, self::$opt_gdpr_consent_button => $_gdpr_consent_button, self::$opt_playlistorder => $_playlistorder, self::$opt_acctitle => $_acctitle, self::$opt_migrate => $_migrate, self::$opt_migrate_youtube => $_migrate_youtube, self::$opt_migrate_embedplusvideo => $_migrate_embedplusvideo, self::$opt_controls => $_controls, self::$opt_oldspacing => $_oldspacing, self::$opt_frontend_only => $_frontend_only, self::$opt_responsive => $_responsive, self::$opt_responsive_all => $_responsive_all, self::$opt_widgetfit => $_widgetfit, self::$opt_evselector_light => $_evselector_light, self::$opt_stop_mobile_buffer => $_stop_mobile_buffer, self::$opt_restrict_wizard => $_restrict_wizard, self::$opt_restrict_wizard_roles => $_restrict_wizard_roles, self::$opt_ajax_compat => $_ajax_compat, self::$opt_ytapi_load => $_ytapi_load, self::$opt_defaultdims => $_defaultdims, self::$opt_defaultwidth => $_defaultwidth, self::$opt_defaultheight => $_defaultheight, self::$opt_pause_others => $_pause_others, self::$opt_defaultvol => $_defaultvol, self::$opt_vol => $_vol, self::$opt_apikey => $_apikey, self::$opt_gallery_columns => $_gallery_columns, self::$opt_gallery_collapse_grid => $_gallery_collapse_grid, self::$opt_gallery_collapse_grid_breaks => $_gallery_collapse_grid_breaks, self::$opt_gallery_scrolloffset => $_gallery_scrolloffset, self::$opt_gallery_hideprivate => $_gallery_hideprivate, self::$opt_gallery_showtitle => $_gallery_showtitle, self::$opt_gallery_showpaging => $_gallery_showpaging, self::$opt_gallery_autonext => $_gallery_autonext, self::$opt_gallery_thumbplay => $_gallery_thumbplay, self::$opt_gallery_channelsub => $_gallery_channelsub, self::$opt_gallery_channelsublink => $_gallery_channelsublink, self::$opt_gallery_channelsubtext => $_gallery_channelsubtext, self::$opt_gallery_customarrows => $_gallery_customarrows, self::$opt_gallery_customnext => $_gallery_customnext, self::$opt_gallery_customprev => $_gallery_customprev, self::$opt_gallery_pagesize => $_gallery_pagesize, self::$opt_not_live_content => $_not_live_content, self::$opt_not_live_on => $_not_live_on, self::$opt_debugmode => $_debugmode, self::$opt_admin_off_scripts => $_admin_off_scripts, self::$opt_defer_js => $_defer_js, self::$opt_defer_jquery => $_defer_jquery, self::$opt_ajax_save => $_ajax_save, self::$opt_show_pointer => $_show_pointer, self::$opt_onboarded => $_onboarded, self::$opt_old_script_method => $_old_script_method, self::$opt_vi_active => $_vi_active, self::$opt_vi_hide_monetize_tab => $_vi_hide_monetize_tab, self::$opt_vi_endpoints => $_vi_endpoints, self::$opt_vi_token => $_vi_token, self::$opt_vi_last_login => $_vi_last_login, self::$opt_vi_last_category_update => $_vi_last_category_update, self::$opt_vi_adstxt => $_vi_adstxt, self::$opt_vi_js_settings => $_vi_js_settings, self::$opt_vi_js_script => $_vi_js_script, self::$opt_vi_js_posttypes => $_vi_js_posttypes, self::$opt_vi_js_position => $_vi_js_position, self::$opt_vi_show_gdpr_authorization => $_vi_show_gdpr_authorization, self::$opt_vi_show_privacy_button => $_vi_show_privacy_button ); update_option(self::$opt_alloptions, $all); update_option('embed_autourls', 1); self::$alloptions = get_option(self::$opt_alloptions); } public static function tryget($array, $key, $default = null) { return isset($array[$key]) ? $array[$key] : $default; } public static function wp_above_version($ver) { global $wp_version; if (version_compare($wp_version, $ver, '>=')) { return true; } return false; } public static function do_ytprefs() { //add_filter('autoptimize_filter_js_exclude', array(get_class(), 'ao_override_jsexclude'), 10, 1); if ( !is_admin() || (self::$alloptions[self::$opt_frontend_only] != 1) //|| (function_exists('wp_doing_ajax') && wp_doing_ajax()) ) { add_filter('the_content', array(get_class(), 'apply_prefs_content'), 1); add_filter('widget_text', array(get_class(), 'apply_prefs_widget'), 1); //add_filter('bjll/skip_classes', array(get_class(), 'bjll_skip_classes'), 10, 2); add_filter('sgo_lazy_load_exclude_classes', array(get_class(), 'exclude_lazy_sgo')); add_shortcode('embedyt', array(get_class(), 'apply_prefs_shortcode')); if (self::$alloptions[self::$opt_migrate] == 1) { if (self::$alloptions[self::$opt_migrate_youtube] == 1) { add_shortcode('youtube', array(get_class(), 'apply_prefs_shortcode_youtube')); add_shortcode('youtube_video', array(get_class(), 'apply_prefs_shortcode_youtube')); } if (self::$alloptions[self::$opt_migrate_embedplusvideo] == 1) { add_shortcode('embedplusvideo', array(get_class(), 'apply_prefs_shortcode_embedplusvideo')); } } } if (self::$alloptions[self::$opt_defer_js] == 1) { add_filter('script_loader_tag', array(get_class(), 'defer_scripts'), 10, 3); } } public static function ao_override_jsexclude($exclude) { if (strpos($exclude, 'ytprefs' . self::$min . '.js') === false) { return $exclude . ',ytprefs' . self::$min . '.js,__ytprefs__'; } return $exclude; } public static function exclude_lazy_sgo($classes) { $classes[] = '__youtube_prefs__'; return $classes; } public static function apply_prefs_shortcode($atts, $content = null) { $content = trim($content); $currfilter = current_filter(); if (preg_match(self::$justurlregex, $content)) { return self::get_html(array($content), strpos($currfilter, 'widget_text') === 0 ? false : true, false); } return ''; } public static function apply_prefs_shortcode_youtube($atts, $content = null) { $content = 'https://www.youtube.com/watch?v=' . trim($content); $currfilter = current_filter(); if (preg_match(self::$justurlregex, $content)) { return self::get_html(array($content), $currfilter == 'widget_text' ? false : true, false); } return ''; } public static function apply_prefs_shortcode_embedplusvideo($atts, $content = null) { $atts = shortcode_atts(array( "height" => self::$defaultheight, "width" => self::$defaultwidth, "vars" => "", "standard" => "", "id" => "ep" . rand(10000, 99999) ), $atts); $epvars = $atts['vars']; $epvars = preg_replace('/\s/', '', $epvars); $epvars = preg_replace('/¬/', '¬', $epvars); $epvars = str_replace('&', '&', $epvars); $epparams = self::keyvalue($epvars, true); if (isset($epparams) && isset($epparams['ytid'])) { $start = isset($epparams['start']) && is_numeric($epparams['start']) ? '&start=' . intval($epparams['start']) : ''; $end = isset($epparams['end']) && is_numeric($epparams['end']) ? '&end=' . intval($epparams['end']) : ''; $end = isset($epparams['stop']) && is_numeric($epparams['stop']) ? '&end=' . intval($epparams['stop']) : ''; $url = 'https://www.youtube.com/watch?v=' . trim($epparams['ytid']) . $start . $end; $currfilter = current_filter(); if (preg_match(self::$justurlregex, $url)) { return self::get_html(array($url), $currfilter == 'widget_text' ? false : true, false); } } return ''; } public static function apply_prefs_content($content) { $content = preg_replace_callback(self::$ytregex, array(get_class(), "get_html_content"), $content); return $content; } public static function apply_prefs_widget($content) { $content = preg_replace_callback(self::$ytregex, array(get_class(), "get_html_widget"), $content); return $content; } public static function get_html_content($m) { return self::get_html($m, true, true); } public static function get_html_widget($m) { return self::get_html($m, false, true); } public static function get_gallery_page($options) { $gallobj = new stdClass(); $options->pageSize = min(intval($options->pageSize), 50); $options->columns = intval($options->columns) == 0 ? 3 : intval($options->columns); $options->showTitle = intval($options->showTitle); $options->showPaging = intval($options->showPaging); $options->autonext = intval($options->autonext); $options->thumbplay = intval($options->thumbplay); if (empty($options->apiKey)) { $gallobj->html = '
    Please enter your YouTube API key to embed galleries.
    '; return $gallobj; } $apiEndpoint = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,status&playlistId=' . $options->playlistId . '&maxResults=' . $options->pageSize . '&key=' . $options->apiKey; if ($options->pageToken != null) { $apiEndpoint .= '&pageToken=' . $options->pageToken; } $code = ''; $init_id = null; $apiResult = wp_remote_get($apiEndpoint, array('timeout' => self::$curltimeout)); if (is_wp_error($apiResult)) { $gallobj->html = self::clean_api_error_html($apiResult->get_error_message(), true); return $gallobj; } if (self::$alloptions[self::$opt_debugmode] == 1 && current_user_can('manage_options')) { $redactedEndpoint = preg_replace('@&key=[^&]+@i', '&key=PRIVATE', $apiEndpoint); $active_plugins = get_option('active_plugins'); $gallobj->html = '
    CLICK this debug text to auto-select all. Then, COPY the selection.' . "\n\n" .
                        'THIS IS DEBUG MODE OUTPUT. UNCHECK THE OPTION IN THE SETTINGS PAGE ONCE YOU ARE DONE DEBUGGING TO PUT THINGS BACK TO NORMAL.' . "\n\n" . $redactedEndpoint . "\n\n" . print_r($apiResult, true) . "\n\nActive Plugins\n\n" . print_r($active_plugins, true) . '
    '; return $gallobj; } $jsonResult = json_decode($apiResult['body']); if (isset($jsonResult->error)) { if (isset($jsonResult->error->message)) { $gallobj->html = self::clean_api_error_html($jsonResult->error->message, true); return $gallobj; } $gallobj->html = '
    Sorry, there may be an issue with your YouTube API key. ' . self::$boilerplate_api_error_message . '
    '; return $gallobj; } $resultsPerPage = $options->pageSize; // $jsonResult->pageInfo->resultsPerPage; $totalResults = $jsonResult->pageInfo->totalResults; $nextPageToken = ''; $prevPageToken = ''; if (isset($jsonResult->nextPageToken)) { $nextPageToken = $jsonResult->nextPageToken; } if (isset($jsonResult->prevPageToken)) { $prevPageToken = $jsonResult->prevPageToken; } $cnt = 0; $colclass = ' epyt-cols-' . $options->columns . ' '; $code .= ''; $totalPages = ceil($totalResults / $resultsPerPage); $pagination = '
    '; $txtprev = self::$alloptions[self::$opt_gallery_customarrows] ? self::$alloptions[self::$opt_gallery_customprev] : _('Prev'); $pagination .= '
    «
    ' . $txtprev . '
    '; $pagination .= '
    '; $pagination .= '
    1
    /
    ' . $totalPages . '
    '; $pagination .= '
    '; $txtnext = self::$alloptions[self::$opt_gallery_customarrows] ? self::$alloptions[self::$opt_gallery_customnext] : _('Next'); $pagination .= '
    ' . $txtnext . '
    »
    '; $pagination .= '
    loading
    '; $pagination .= '
    '; // if ($options->showPaging == 0) // { // $pagination = '
    '; // } $code = $pagination . $code . $pagination; $gallobj->html = $code; $gallobj->init_id = $init_id; return $gallobj; } public static function compare_vid_date($a, $b) { if ($a->snippet->publishedAt == $b->snippet->publishedAt) { return 0; } return ($a->snippet->publishedAt > $b->snippet->publishedAt) ? -1 : 1; } public static function get_thumbnail_html($thumb, $options) { $escId = esc_attr($thumb->id); $code = ''; $code .= '

    If you're using a separate caching plugin and you do not see your changes after saving, you need to reset your cache.

    $bpts) { $custom_css .= " @media (min-width:" . $bpts['bp']['min'] . "px) and (max-width: " . $bpts['bp']['max'] . "px) { .epyt-gallery-rowbreak { display: none; } .epyt-gallery-allthumbs[class*=\"epyt-cols\"] .epyt-gallery-thumb { width: " . round(100.0 / intval($bpts['cols']), 3) . "% !important; } }"; } } wp_add_inline_style('__EPYT__style', $custom_css); wp_enqueue_script('__ytprefs__', plugins_url('scripts/ytprefs' . self::$min . '.js', __FILE__), array('jquery'), self::$version); if (self::$alloptions[self::$opt_old_script_method] != 1) { $my_script_vars = array( 'ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('embedplus-nonce'), 'gallery_scrolloffset' => intval(self::$alloptions[self::$opt_gallery_scrolloffset]), 'eppathtoscripts' => plugins_url('scripts/', __FILE__), 'eppath' => plugins_url('/', __FILE__), 'epresponsiveselector' => self::get_responsiveselector(), 'epdovol' => true, 'version' => self::$alloptions[self::$opt_version], 'evselector' => self::get_evselector(), 'ajax_compat' => self::$alloptions[self::$opt_ajax_compat] == '1' ? true : false, 'ytapi_load' => self::$alloptions[self::$opt_ytapi_load], 'pause_others' => self::$alloptions[self::$opt_pause_others] == '1' ? true : false, 'stopMobileBuffer' => self::$alloptions[self::$opt_stop_mobile_buffer] == '1' ? true : false, 'vi_active' => false, // self::$alloptions[self::$opt_vi_active] == '1' ? true : false, 'vi_js_posttypes' => array() // self::$alloptions[self::$opt_vi_js_posttypes] ); wp_localize_script('__ytprefs__', '_EPYT_', $my_script_vars); } if ((bool) self::$alloptions[self::$opt_gdpr_consent]) { wp_enqueue_script('__jquery_cookie__', plugins_url('scripts/jquery.cookie' . self::$min . '.js', __FILE__), array('jquery'), self::$version); } ////////////////////// cloudflare accomodation //add_filter('script_loader_tag', array(get_class(), 'set_cfasync'), 10, 3); } } public static function set_cfasync($tag, $handle, $src) { if ('__ytprefs__' !== $handle) { return $tag; } return str_replace(' admin_url('admin-ajax.php'), 'wizhref' => admin_url('admin.php?page=youtube-ep-wizard') . '&random=' . rand(1, 1000) . '&TB_iframe=true&width=950&height=800', 'manage_options' => current_user_can('manage_options'), 'security' => wp_create_nonce('embedplus-nonce'), 'onboarded' => self::$alloptions[self::$opt_onboarded], 'vi_logged_in' => self::vi_logged_in(), 'epbase' => self::$epbase, 'admin_url' => admin_url(), 'vi_js_settings' => self::$alloptions[self::$opt_vi_js_settings], 'admin_url_ytprefs' => admin_url('admin.php?page=youtube-my-preferences'), 'admin_url_vi' => admin_url('admin.php?page=youtube-ep-vi') //'epblogwidth' => self::get_blogwidth(), //'epprokey' => self::$alloptions[self::$opt_pro], //'epbasesite' => self::$epbase, //'epversion' => self::$version, //'myytdefaults' => http_build_query(self::$alloptions), //'eppluginadminurl' => admin_url('admin.php?page=youtube-my-preferences') ); wp_localize_script('__ytprefs_admin__', '_EPYTA_', $admin_script_vars); if (function_exists('add_thickbox')) { add_thickbox(); } if ((get_bloginfo('version') >= '3.3') && self::custom_admin_pointers_check()) { add_action('admin_print_footer_scripts', array(get_class(), 'custom_admin_pointers_footer')); wp_enqueue_script('wp-pointer'); wp_enqueue_style('wp-pointer'); } if (self::$alloptions['glance'] == 1) { add_action('admin_print_footer_scripts', array(get_class(), 'glance_script')); } if ($hook == self::$wizard_hook) { wp_enqueue_style('__ytprefs_admin__wizard_ui', plugins_url('styles/jquery-ui' . self::$min . '.css', __FILE__), array(), self::$version); wp_enqueue_style('__ytprefs_admin__wizard', plugins_url('styles/ytprefs-wizard' . self::$min . '.css', __FILE__), array(), self::$version); wp_enqueue_script('__ytprefs_admin__wizard_script', plugins_url('scripts/ytprefs-wizard' . self::$min . '.js', __FILE__), array('jquery', 'jquery-ui-accordion', 'jquery-ui-tabs'), self::$version); } if ($hook == self::$onboarding_hook) { wp_enqueue_style('__ytprefs_admin__onboarding_animate', plugins_url('scripts/embdyn' . self::$min . '.css', __FILE__), array(), self::$version); wp_enqueue_style('__ytprefs_admin__onboarding_ui', plugins_url('styles/jquery-ui' . self::$min . '.css', __FILE__), array(), self::$version); wp_enqueue_style('__ytprefs_admin__onboarding', plugins_url('styles/ytprefs-onboarding' . self::$min . '.css', __FILE__), array(), self::$version); } } public static function get_blogwidth() { $blogwidth = null; try { $embed_size_w = intval(get_option('embed_size_w')); global $content_width; if (empty($content_width)) { $content_width = $GLOBALS['content_width']; } $blogwidth = $embed_size_w ? $embed_size_w : ($content_width ? $content_width : 450); } catch (Exception $ex) { } $blogwidth = preg_replace('/\D/', '', $blogwidth); //may have px return $blogwidth; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private static function ajax_referer() { return check_ajax_referer('embedplus-nonce', 'security', false); } public static function base_url() { $parsed = parse_url(site_url()); return $parsed['scheme'] . '://' . $parsed['host']; } public static function on_deactivation() { self::vi_cron_stop(); } private static function update_option_set($new_options) { $all = get_option(self::$opt_alloptions); $all = $new_options + $all; update_option(self::$opt_alloptions, $all); self::$alloptions = get_option(self::$opt_alloptions); } private static function vi_remote_get($endpoint, $options = array()) { $params = $options + array( 'headers' => array('Authorization' => self::$alloptions[self::$opt_vi_token]), 'timeout' => self::$curltimeout ); return wp_remote_get($endpoint, $params); } private static function vi_remote_post($endpoint, $options = array()) { $params = $options + array( 'headers' => array('Content-Type' => 'application/json', 'Authorization' => self::$alloptions[self::$opt_vi_token]), 'timeout' => self::$curltimeout ); // if (self::$alloptions[self::$opt_debugmode]) // { // echo $endpoint . '
    ' . self::vi_debug_json($params); // } return wp_remote_post($endpoint, $params); } private static function vi_remote_post_anon($endpoint, $options = array()) { $params = $options + array( 'headers' => array('Content-Type' => 'application/json'), 'timeout' => self::$curltimeout ); return wp_remote_post($endpoint, $params); } private static function vi_cache_endpoints_valid(&$apiResult) { $messages = array(); if (is_wp_error($apiResult)) { $messages[] = $apiResult->get_error_message(); } else { $jsonResult = json_decode($apiResult['body']); if (!empty($jsonResult->error)) { $messages[] = $jsonResult->error; } if (!filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)) { $messages[] = "Please enter a valid email address."; } if (isset($jsonResult->status) && strcasecmp($jsonResult->status, 'ok') == 0 && isset($jsonResult->data) && is_object($jsonResult->data)) { $apiResult = $jsonResult; } } if (empty($messages)) { return true; } return $messages; } public static function vi_cache_endpoints() { $result = array(); $apiResult = wp_remote_get(EPYTVI_ENDPOINTS_URL, array('timeout' => self::$curltimeout)); $valid = self::vi_cache_endpoints_valid($apiResult); if ($valid === true) { $new_options = array( self::$opt_vi_endpoints => $apiResult->data ); self::update_option_set($new_options); $post_email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL); if (!empty($post_email)) { $result['type'] = 'success'; $result['data'] = $apiResult->data; $result['signupURLParams'] = $apiResult->data->signupURL . '?aid=WP_embedplus&email=' . filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL) . '&domain=' . site_url(); } } else { $result['type'] = 'error'; $result['message'] = implode('
    ', $valid); } return $result; } public static function vi_cache_endpoints_ajax() { $result = array(); if (self::is_ajax() && self::ajax_referer() && current_user_can('manage_options')) { $result = self::vi_cache_endpoints(); } else { $result['type'] = 'error'; $result['message'] = 'Sorry, there was a problem submitting the data.'; } $result['message'] = wp_kses_post($result['message']); echo json_encode($result); die(); } public static function vi_notice_login_reminder() { if (filter_has_var(INPUT_COOKIE, 'vi_signup_attempt')) { $screen = get_current_screen(); $date_string = filter_input(INPUT_COOKIE, 'vi_signup_attempt', FILTER_SANITIZE_STRING); $date_attempt = strtotime($date_string); $date_wait = strtotime($date_string . ' + 7 days'); if (time() > $date_wait && !self::vi_logged_in() && in_array($screen->id, array('toplevel_page_youtube-my-preferences')) ) { ?>

    It looks like you may have signed up for the vi monetization feature, but haven't completed the settings to receive revenue. Click the "Monetize" tab below to login and continue.

    get_error_message(); } else { $jsonResult = json_decode($apiResult['body']); if (!empty($jsonResult->error)) { $messages[] = $jsonResult->error->message . ": " . (is_string($jsonResult->error->description) ? $jsonResult->error->description : json_encode($jsonResult->error->description)); } if (isset($jsonResult->status) && strcasecmp($jsonResult->status, 'ok') == 0 && isset($jsonResult->data) && strlen($jsonResult->data) > 0) { $apiResult = $jsonResult; } } if (empty($messages)) { return true; } return $messages; } private static function vi_adstxt_api_valid(&$apiResult) { $messages = array(); if (is_wp_error($apiResult)) { $messages[] = $apiResult->get_error_message(); } else { $jsonResult = json_decode($apiResult['body']); if (!empty($jsonResult->error)) { $messages[] = implode(': ', array($jsonResult->error->message, $jsonResult->error->description)); } if (isset($jsonResult->status) && strcasecmp($jsonResult->status, 'ok') == 0 && isset($jsonResult->data) && strlen($jsonResult->data) > 0) { $apiResult = $jsonResult; } } if (empty($messages)) { return true; } return $messages; } public static function vi_login() { $result = array(); $default = array( 'email' => '', 'password' => '' ); $input = shortcode_atts($default, stripslashes_deep($_POST)); $valid = self::vi_login_valid($input); if ($valid === true) { self::vi_cache_endpoints(); $loginAPI = self::$alloptions[self::$opt_vi_endpoints]->loginAPI . '?affiliateId=WP_embedplus'; $inputAuth = array( 'email' => $input['email'], 'password' => $input['password'] ); $apiResult = self::vi_remote_post_anon($loginAPI, array( 'body' => json_encode($inputAuth) )); $valid = self::vi_login_api_valid($apiResult); if ($valid === true) { $result['type'] = 'success'; $new_options = array( self::$opt_vi_token => $apiResult->data, self::$opt_vi_last_login => date('Y-m-d H:i:s') ); self::update_option_set($new_options); } else { $result['type'] = 'error'; $result['message'] = implode('
    ', $valid); } } else { $result['type'] = 'error'; $result['message'] = implode('
    ', $valid); } if ($result['type'] === 'success') { self::vi_db_init_schema(); } return $result; } public static function vi_login_ajax() { $result = array(); if (self::is_ajax() && self::ajax_referer() && current_user_can('manage_options')) { $result = self::vi_login(); } else { $result['type'] = 'error'; $result['message'] = 'Sorry, there was a problem submitting the data.'; } $result['message'] = wp_kses_post($result['message']); echo json_encode($result); die(); } public static function vi_logout_ajax() { $result = array(); if (self::is_ajax() && self::ajax_referer() && current_user_can('manage_options')) { self::vi_cron_stop(); $new_options = array( self::$opt_vi_token => '' ); self::update_option_set($new_options); $result['type'] = 'success'; $result['url'] = admin_url('admin.php?page=youtube-my-preferences'); } else { $result['type'] = 'error'; $result['message'] = 'Sorry, there was a problem submitting the data.'; } echo json_encode($result); die(); } public static function vi_toggle_ajax() { $result = array(); if (self::is_ajax() && self::ajax_referer() && current_user_can('manage_options')) { $new_options = array( self::$opt_vi_active => self::$alloptions[self::$opt_vi_active] ? 0 : 1 ); self::update_option_set($new_options); $result['type'] = 'success'; $result['button_text'] = self::$alloptions[self::$opt_vi_active] ? 'On' : 'Off'; } else { $result['type'] = 'error'; $result['message'] = 'Sorry, there was a problem submitting the data.'; } echo json_encode($result); die(); } public static function vi_hide_feature_ajax() { $result = array(); if (self::is_ajax() && self::ajax_referer() && current_user_can('manage_options')) { $new_options = array( self::$opt_vi_hide_monetize_tab => 1 ); self::update_option_set($new_options); $result['type'] = 'success'; $result['url'] = admin_url('admin.php?page=youtube-my-preferences'); } else { $result['type'] = 'error'; $result['message'] = 'Sorry, there was a network error. Please try again, or turn off this feature using the "Hide Monetize Feature" checkbox on the "Defaults" tab of the YouTube settings. If the issue persists, please contact ext@embedplus.com'; } echo json_encode($result); die(); } public static function vi_cover_prompt_yes() { return filter_input(INPUT_COOKIE, 'vi_cover_prompt_yes', FILTER_SANITIZE_NUMBER_INT) == 1; } public static function vi_cron_stop() { $timestamp = wp_next_scheduled('ytvi_cron_cache_js_hook'); if ($timestamp !== false) { wp_unschedule_event($timestamp, 'ytvi_cron_cache_js_hook'); } } private static function vi_reports_valid(&$apiResult) { $messages = array(); if (is_wp_error($apiResult)) { $messages[] = $apiResult->get_error_message(); } else { $jsonResult = json_decode($apiResult['body']); //$messages[] = $apiResult['body']; // COMMENT if (!empty($jsonResult->error)) { $messages[] = $jsonResult->error->message . ": " . $jsonResult->error->description; } if (isset($jsonResult->status) && strcasecmp($jsonResult->status, 'ok') == 0 && isset($jsonResult->data)) { $apiResult = $jsonResult; } } if (empty($messages)) { return true; } return $messages; } public static function vi_reports_ajax() { $result = array(); if (self::is_ajax() && self::ajax_referer() && current_user_can('manage_options')) { $revenueResult = self::vi_remote_get(self::$alloptions[self::$opt_vi_endpoints]->revenueAPI); $revenue_valid = self::vi_reports_valid($revenueResult); if ($revenue_valid === true) { $result['data'] = $revenueResult->data; $result['type'] = 'success'; } else { $result['type'] = 'error'; $result['message'] = wp_kses_post(implode('
    ', $revenue_valid)); } } else { $result['type'] = 'error'; $result['message'] = 'Sorry, there was a problem retrieving the data.'; } echo json_encode($result); die(); } private static function vi_cache_user_adstxt() { $adsTxtAPI = self::$alloptions[self::$opt_vi_endpoints]->adsTxtAPI; $iabResult = self::vi_remote_get($adsTxtAPI); $iab_valid = self::vi_adstxt_api_valid($iabResult); if ($iab_valid === true) { $new_options = array( self::$opt_vi_adstxt => $iabResult->data ); self::update_option_set($new_options); return $iabResult->data; } return false; } private static function vi_adstxt_status() { $user_adstxt = self::vi_cache_user_adstxt(); $current_adstxt = false; if ($user_adstxt === false) { return array( 'code' => -1, 'message' => 'Sorry, your publisher ads.txt info could not be retrieved. Please wait a few minutes and try again. Your ads.txt verification file will enable you to make money through vi. FAQ »' ); } else { $user_adstxt = preg_replace('~\R~u', PHP_EOL, $user_adstxt); } $adstxt_file = self::vi_get_home_path() . 'ads.txt'; $adstxt_url = self::base_url() . '/ads.txt'; $adstxt_http = wp_remote_get($adstxt_url, array('timeout' => self::$curltimeout)); if (!is_wp_error($adstxt_http) && in_array(wp_remote_retrieve_response_code($adstxt_http), array(200, 301, 302, 304))) { $current_adstxt = wp_remote_retrieve_body($adstxt_http); } if (empty($current_adstxt)) { $current_adstxt = file_get_contents($adstxt_file); } if (!empty($current_adstxt)) { $current_adstxt = preg_replace('~\R~u', PHP_EOL, $current_adstxt); // append if (is_writable($adstxt_file)) { if (stripos($current_adstxt, '# 41b5eef6') === false) { $to_write = PHP_EOL . $user_adstxt; file_put_contents($adstxt_file, $to_write, FILE_APPEND); return array( 'code' => 1, 'before_adstxt' => $current_adstxt, 'after_adstxt' => $current_adstxt . $to_write, 'message' => 'You successfully validated your account. Your ads.txt file has been updated, which enables you to make money through vi. FAQ »' ); } else if ($current_adstxt !== $user_adstxt) { $current_adstxt_lines = preg_split('/\r\n|\r|\n/', $current_adstxt); $current_adstxt_lines = array_filter($current_adstxt_lines, array(get_class(), 'vi_not_vi_adstxt_line')); $former_adstxt = implode(PHP_EOL, $current_adstxt_lines); $new_adstxt = $former_adstxt . (strlen($former_adstxt) > 0 ? PHP_EOL : '') . $user_adstxt; if ($current_adstxt === $new_adstxt) { return array( 'code' => 2, 'message' => 'You successfully validated your account.' ); } else { file_put_contents($adstxt_file, $new_adstxt); return array( 'code' => 1, 'before_adstxt' => $current_adstxt, 'after_adstxt' => $new_adstxt, 'message' => 'You successfully validated your account. Your ads.txt file has been updated, which enables you to make money through vi. FAQ »' ); } } else { return array( 'code' => 2, 'message' => 'You successfully validated your account.' ); } } else { if (stripos($current_adstxt, $user_adstxt) === false) // $user_adstxt { return array( 'code' => 0, 'message' => 'Sorry, your current ads.txt file could not be automatically be updated. Please first download this updated ads.txt file and upload it to your site root, then try logging in again. Your ads.txt verification file will enable you to make money through vi. FAQ »' ); } else { return array( 'code' => 2, 'message' => 'You successfully validated your account.' ); } } } else { // create if ((!file_exists($adstxt_file) && is_writable(self::vi_get_home_path())) || (file_exists($adstxt_file) && is_writable($adstxt_file))) { file_put_contents($adstxt_file, self::$alloptions[self::$opt_vi_adstxt], FILE_APPEND); return array( 'code' => 1, 'before_adstxt' => $current_adstxt, 'after_adstxt' => self::$alloptions[self::$opt_vi_adstxt], 'message' => 'You successfully validated your account. Your ads.txt file has been created, which enables you to make money through vi. FAQ »' ); } else { return array( 'code' => 0, 'message' => 'Sorry, your ads.txt verification file could not automatically be created. Please first download this ads.txt file and upload it to your site root, then try logging in again. Your ads.txt verification file will enable you to make money through vi. FAQ »' ); } } } public static function vi_adstxt_status_soft_ajax() { $result = array(); if (self::is_ajax() && self::ajax_referer() && current_user_can('manage_options')) { $default = array( 'current_adstxt' => '' ); $input = shortcode_atts($default, stripslashes_deep($_POST)); $result = self::vi_adstxt_status_soft($input['current_adstxt']); if (isset($result['code']) && intval($result['code']) < 0) { $result['token'] = self::$alloptions[self::$opt_vi_token]; } } else { $result['type'] = 'error'; $result['message'] = 'Sorry, there was a problem verifying your ads.txt file. Please try again.'; } $result['message'] = wp_kses_post($result['message']); echo json_encode($result); die(); } private static function vi_adstxt_status_soft($current_adstxt) { $adstxt_url = self::base_url() . '/ads.txt'; $adstxt_note = ' Note: If you already have an ads.txt file at ' . $adstxt_url . ', you will just need to add in the additional lines found in the download.'; $user_adstxt = self::vi_cache_user_adstxt(); $current_adstxt = empty($current_adstxt) ? false : $current_adstxt; if ($user_adstxt === false) { return array( 'code' => -1, 'message' => 'For your security, a quick reauthentication is needed to begin setting up your ads.txt file. First, log out of this Ads Settings page with the "Logout" button right above and then log back in with your vi login and password. Then come back to this tab for next steps. Your ads.txt verification file will enable you to make money through vi. FAQ »' ); } else { $user_adstxt = preg_replace('~\R~u', PHP_EOL, $user_adstxt); } if (!empty($current_adstxt)) { $current_adstxt = preg_replace('~\R~u', PHP_EOL, $current_adstxt); // append / update manually if (stripos($current_adstxt, $user_adstxt) === false) { if (stripos($current_adstxt, '# 41b5eef6') !== false) // update { return array( 'code' => 0, 'message' => 'Looks like video intelligence has just updated its ad delivery partners. To get the most revenue out of your ads, open up your ' . ' ads.txt file and replace the vi lines (ending in # 41b5eef6) with the new lines you see below. Then, refresh this page. ' . ' Please do not reorder or double space the below lines. ' . ' If we helped you with your ads.txt in the past, feel free to contact us to help out again with this update. ' . '# video intelligence (vi.ai) ads.txt lines begin here:' . PHP_EOL . $user_adstxt . PHP_EOL . '# video intelligence (vi.ai) ads.txt lines end' ); } else // add { return array( 'code' => 0, 'message' => 'In your current ads.txt file, just add in the additional lines you see below. Then, refresh this page.' . ' Please do not reorder or double space the below lines. ' . '# video intelligence (vi.ai) ads.txt lines begin here:' . PHP_EOL . $user_adstxt . PHP_EOL . '# video intelligence (vi.ai) ads.txt lines end' ); } } else { return array( 'code' => 2, 'message' => '

    You successfully validated your ads.txt file.

    ' ); } } else { // create manually return array( 'code' => 0, 'message' => 'You can download this ads.txt file and upload it to your site root (or copy the same text below). Then, refresh this page to verify.' . ' Please do not reorder or double space the below lines. ' . '# video intelligence (vi.ai) ads.txt lines begin here:' . PHP_EOL . $user_adstxt . PHP_EOL . '# video intelligence (vi.ai) ads.txt lines end' ); } } private static function vi_not_vi_adstxt_line($line) { return stripos($line, '# 41b5eef6') === false; } public static function vi_get_home_path() { $abs_root = get_home_path(); if (strlen($abs_root) <= 1) { $abs_root = trailingslashit(str_replace('\\', '/', ABSPATH)); $url_path = parse_url(site_url()); if (isset($url_path['path'])) { $relpath = trailingslashit($url_path['path']); $relpath_length = strlen($relpath); $path_intersect = substr($abs_root, -$relpath_length); if ($path_intersect === $relpath) { $abs_root = trailingslashit(substr($abs_root, 0, strlen($abs_root) - $relpath_length)); } } } return $abs_root; } public static function vi_adstxt_lookup() { $request = esc_url_raw(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); if ('/ads.txt' === $request) { if (function_exists('tenup_display_ads_txt')) { $post_id = get_option('adstxt_post'); if (!empty($post_id)) { $post = get_post($post_id); header('Content-Type: text/plain'); echo esc_html($post->post_content); die(); } } } } public static function vi_adstxt_download() { $inp_key = filter_input(INPUT_GET, 'key'); if (filter_input(INPUT_GET, 'ytvi_adstxt_download') == 1 && !empty($inp_key)) { $key = urldecode(filter_input(INPUT_GET, 'key', FILTER_DEFAULT)); self::$alloptions[self::$opt_vi_token] = $key; $user_adstxt = self::vi_cache_user_adstxt(); $adstxt_file = self::vi_get_home_path() . 'ads.txt'; $current_adstxt = file_exists($adstxt_file) ? file_get_contents($adstxt_file) : ''; $current_adstxt_lines = preg_split('/\r\n|\r|\n/', $current_adstxt); $current_adstxt_lines = array_filter($current_adstxt_lines, array(get_class(), 'vi_not_vi_adstxt_line')); $former_adstxt = implode(PHP_EOL, $current_adstxt_lines); $new_adstxt = $former_adstxt . (strlen($former_adstxt) > 0 ? PHP_EOL : '') . ($user_adstxt === false ? '' : $user_adstxt); $new_adstxt = '# video intelligence (vi.ai) ads.txt lines begin here:' . PHP_EOL . $new_adstxt . PHP_EOL . '# video intelligence (vi.ai) ads.txt lines end'; header("Expires: 0"); header("Cache-Control: no-cache, no-store, must-revalidate"); header('Cache-Control: pre-check=0, post-check=0, max-age=0', false); header("Pragma: no-cache"); header("Content-Disposition:attachment; filename=ads.txt"); header("Content-Type: application/force-download"); echo $new_adstxt; exit(); } } public static function vi_logged_in() { return !empty(self::$alloptions[self::$opt_vi_token]); } public static function vi_settings_nav() { ?> get_error_message(); } else { $jsonResult = json_decode($apiResult['body']); if (!empty($jsonResult->error)) { //$messages[] = implode(': ', array('vi API - ' . self::vi_debug_json($apiResult))); $messages[] = 'If the issue is not resolved, please contact support at ext@embedplus.com and we will get you going. (Error code ' . wp_remote_retrieve_response_code($apiResult) . ', v' . self::$version . ' - ' . implode(': ', array($jsonResult->error->message, is_string($jsonResult->error->description) ? $jsonResult->error->description : json_encode($jsonResult->error->description))) . ')'; } if (isset($jsonResult->status) && strcasecmp($jsonResult->status, 'ok') == 0 && isset($jsonResult->data) && strlen($jsonResult->data) > 0) { $apiResult = $jsonResult; } } if (empty($messages)) { return true; } return $messages; } private static function vi_cache_js($options) { $readonly = array( 'domain' => parse_url(site_url(), PHP_URL_HOST), 'adUnitType' => 'NATIVE_VIDEO_UNIT', 'logoUrl' => 'https://example.com/logo.jpg' ); $options = $readonly + $options; $jsTagAPI = self::$alloptions[self::$opt_vi_endpoints]->jsTagAPI; $iabCategoryList = explode(',', $options['iabCategory']); $matches = array(); if (isset(self::$alloptions[self::$opt_vi_js_script]) && preg_match('/IAB_Category[ ]*:([^,]+),/i', self::$alloptions[self::$opt_vi_js_script], $matches)) { $currCategory = array(trim($matches[1])); $iabCategoryList = array_diff($iabCategoryList, $currCategory); } $options['iabCategory'] = $iabCategoryList[array_rand($iabCategoryList)]; $apiResult = self::vi_remote_post($jsTagAPI, array( 'body' => json_encode($options) )); //$js_valid = array(self::vi_debug_json($options)); $js_valid = self::vi_cache_js_valid($apiResult); if ($js_valid === true) { $mod_data = $apiResult->data; $new_options = array( self::$opt_vi_js_script => $mod_data, self::$opt_vi_last_category_update => date('Y-m-d H:i:s') ); self::update_option_set($new_options); } return $js_valid; } public static function vi_debug_json($json) { return '
    ' . json_encode($json, JSON_PRETTY_PRINT) . '
    '; } public static function vi_script_setup_done() { if (empty(self::$alloptions[self::$opt_vi_js_script])) { return false; } return true; } public static function vi_admin_dashboard_valid(&$item) { $messages = array(); $all_post_types = get_post_types(array('public' => true), 'names'); foreach ($item[self::$opt_vi_js_posttypes] as $pt) { if (!in_array($pt, $all_post_types)) { $messages[] = 'Please choose only valid post types for your ad to appear in.'; } } if (!in_array($item[self::$opt_vi_js_position], array('top', 'bottom'))) { $messages[] = 'Please choose a valid placement position.'; } $item[self::$opt_vi_js_settings]['keywords'] = substr(sanitize_text_field(str_replace(array('\'', '"'), '', $item[self::$opt_vi_js_settings]['keywords'])), 0, 200); $item[self::$opt_vi_js_settings]['iabCategory'] = sanitize_text_field($item[self::$opt_vi_js_settings]['iabCategory']); if (empty($item[self::$opt_vi_js_settings]['iabCategory'])) { $messages[] = 'Please choose at least one IAB category under Video Categories.'; } $item[self::$opt_vi_js_settings]['language'] = sanitize_text_field($item[self::$opt_vi_js_settings]['language']); if (empty($item[self::$opt_vi_js_settings]['language'])) { $item[self::$opt_vi_js_settings]['language'] = 'en-us'; } $item[self::$opt_vi_js_settings]['backgroundColor'] = sanitize_hex_color($item[self::$opt_vi_js_settings]['backgroundColor']); if (empty($item[self::$opt_vi_js_settings]['backgroundColor'])) { $item[self::$opt_vi_js_settings]['backgroundColor'] = '#ffffff'; } $item[self::$opt_vi_js_settings]['textColor'] = sanitize_hex_color($item[self::$opt_vi_js_settings]['textColor']); if (empty($item[self::$opt_vi_js_settings]['textColor'])) { $item[self::$opt_vi_js_settings]['textColor'] = '#000000'; } $item[self::$opt_vi_js_settings]['font'] = sanitize_text_field($item[self::$opt_vi_js_settings]['font']); if (empty($item[self::$opt_vi_js_settings]['font'])) { $item[self::$opt_vi_js_settings]['font'] = 'Arial'; } if (!is_numeric($item[self::$opt_vi_js_settings]['fontSize']) || intval($item[self::$opt_vi_js_settings]['fontSize']) < 0) { $item[self::$opt_vi_js_settings]['fontSize'] = 12; } if (empty($messages)) { $js = self::vi_cache_js($item[self::$opt_vi_js_settings]); if ($js === true) { $item[self::$opt_vi_js_script] = self::$alloptions[self::$opt_vi_js_script]; } else { $messages[] = 'For your security, a quick re-authentication is required to save your most recent customizations. Simply log out of this Ads Settings page with the "Logout" button right above and then log back in with your vi login and password. '; $messages = array_merge($messages, $js); } } if (empty($messages)) { return true; } return $messages; } public static function vi_print_toggle_button() { ?> self::$alloptions[self::$opt_vi_js_settings], self::$opt_vi_js_script => self::$alloptions[self::$opt_vi_js_script], self::$opt_vi_js_posttypes => self::$alloptions[self::$opt_vi_js_posttypes], self::$opt_vi_js_position => self::$alloptions[self::$opt_vi_js_position], self::$opt_vi_show_gdpr_authorization => self::$alloptions[self::$opt_vi_show_gdpr_authorization], self::$opt_vi_show_privacy_button => self::$alloptions[self::$opt_vi_show_privacy_button] ); if (wp_verify_nonce(filter_input(INPUT_POST, 'nonce'), basename(__FILE__))) { $post_vars = stripslashes_deep($_POST); if (!array_key_exists(self::$opt_vi_js_posttypes, $post_vars)) { $post_vars[self::$opt_vi_js_posttypes] = array(); } $post_vars = shortcode_atts($item, $post_vars); $item[self::$opt_vi_js_settings] = $post_vars[self::$opt_vi_js_settings] + $item[self::$opt_vi_js_settings]; $item[self::$opt_vi_js_posttypes] = $post_vars[self::$opt_vi_js_posttypes]; $item[self::$opt_vi_js_position] = $post_vars[self::$opt_vi_js_position]; $item[self::$opt_vi_show_gdpr_authorization] = self::postchecked(self::$opt_vi_show_gdpr_authorization) ? 1 : 0; $item[self::$opt_vi_show_privacy_button] = self::postchecked(self::$opt_vi_show_privacy_button) ? 1 : 0; $item_valid = self::vi_admin_dashboard_valid($item); //$item_valid = array('
    _post: ' . print_r(stripslashes_deep($_POST), true) . '
    ', '
    item: ' . print_r($item, true) . '
    '); if ($item_valid === true) { self::update_option_set($item); $message = 'Settings were successfully saved. Now you can turn on vi ads above. Note: changes may take a few minutes to appear on your website. If you are using a separate caching plugin, you need to reset your cache to see any changes.'; } else { $notice = wp_kses_post(implode('
    ', $item_valid)); } } ?>

    Video Ad Settings Logout of vi settings

    This feature is being deprecated in the next version. Please contact ext@embedplus.com for questions.


    Congrats! Ads are now on. Here are some tips to maximize your fill rate and therefore revenue:

    • Visibility - The higher the player is placed, the greater the demand and fill rate. Inserting it near the top or middle of your pages are best.
    • Ad Unit Size - The recommended minimum width for the player is 336px
    • Give vi.ai about 2-3 weeks to optimize their inventory for your site
    • Contact us for help if you have any questions: ext@embedplus.com

    '; // print_r(_get_cron_array()); // echo ''; ?>

    How It Works

    Before you begin, please turn off any ad blocker extensions you may have, so that you will see how your ads look. Then follow the steps below:


    1

    Video Categories

    Categorize your site to help match with the right ads.

    2

    Appearance

    Customize how the ad player should look.

    3

    Placement

    Decide where the ad player should be placed.

    4

    Turn It On

    Click the colored button at the top right of this page to make the ad player visible.

    5

    Ads.txt Verification

    Verify your ads.txt file to start earning revenue.

    6

    Revenue Reporting

    View reports on your CPM, revenue, and more.

    7

    Profile Settings

    Collect your earnings in a few days via PayPal or bank transfer.

    Trouble getting content that fits your site, even with the proper settings above/below? Contact support at ext@embedplus.com

    1 Video Categories (Multiple Allowed)

    Your video ad will be optimized to relate to your site's content and the one or more categories you select below. Note that the quality of the matches improves over time.

    Tip: select more than one category to add variety to your video ads. If you select more than one, you must stay logged in to this settings page for your categories to automatically add variety to your ads.

    Select the categories that most fit your website. You can select up to 4. Filter by:

    Your Selected Categories:

    2 Appearance

    Customize your ad unit's visual appearance below.

    Appearance Demo

    AD + CONTENT
    Example vi Story Title Text
    featured by
    languages)) { ?>
    Select a background color that will enable the ad to blend in with your site's theme.
    Select a text color that will enable the ad to blend in with your site's theme.
    Select the font that matches your site's theme the most.
    Select the font size for your ad.
    Select from the available list of languages.

    Sizing Tips

    The video ad's player will be as large as the container it’s in. If you’d like to change the default size to something smaller, you’ll just need to add some CSS to your website's theme as follows:

    1. You'll be using your site's theme customizer. In the WordPress admin menu on the left, go to Appearance > Customize.
    2. On the customizer page, scroll down in the left menu to "Additional CSS" and click on it.
    3. You'll have a textbox to paste in the following CSS (change 480 to your desired max width in pixels):

    4. When done, click on the "Publish" button at the top to save your change, and then the X to close the theme customizer.

    3 Placement

    You can choose to place your ad automatically, or manually using a shortcode, or in a specific spot in your theme code. Each method is explained below.

    After you finish choosing your placement preferences below, 1) Click on "Save Changes", and 2) turn on the ads using the button at the top of this screen.

    Note: The ad player will auto-fit to its container when loaded.

    Automatic: Top or Bottom

    You can have your ad automatically placed at the top or bottom of your post content--right above your first paragraph (top), or right under your last paragraph (bottom). For optimal revenue, we recommend using the "Top" option:

    Next, just check which types of posts you desire to have the ad appear, and the plugin will take care of the rest. You'll start seeing the ads on your pages after pressing the "Save Changes" button on the bottom right, and turning "ON" vi ads with the top right button.

      true), 'objects'); foreach ($all_post_types as $pt) { ?>

    Note that only one ad can appear on a page, but if you'd like more control of exactly where it's placed, see the "Manual" or "Theme Code" directions in the next sections.

    Manual: Shortcode or Gutenberg Block

    If you didn't select any of the automatic options above, you can manually insert your ad in text widgets, and in specific posts or pages. See the below screenshot to find the button you can use to manually embed the ad code. (or, use this shortcode directly: [embed-vi-ad]). We're quite happy to help you if you aren't sure what to do, especially due the newness of the new Gutenberg editor. Just email us at ext@embedplus.com

    By the way, if you did make an automatic selection above, do not make any manual insertions. Skip the remaining options on this page, since only one ad code/script is allowed per page and the above has got you covered.

    Theme Code (advanced)

    You can also position the ad directly in your theme code. Copy the PHP code below and paste it where you would like it to appear in your theme.

    echo do_shortcode("[embed-vi-ad]");

    Trouble with your ads.txt verification? Contact support at ext@embedplus.com

    5 Ads.txt Verification

    In order for your ads to start generating revenue, verify your ads.txt file.

    Are you also running Google Adsense ads on your site? If so, also add the following line which is recommended by Google for ads.txt files (replace the 0000000000000000 with your actual publisher ID as provided by Google).

    google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0

    6 Revenue Reporting

    Total Earnings

    To view more detailed reports on your ad's performance and stats, click here to automatically login to your vi account. Then click on the "Reports" tab as shown below.

    Total Earnings

    No Data

    Monthly Earnings Graph



    No Data

    Trouble showing the reports? Please try again later, or contact support at ext@embedplus.com

    7 Profile Settings

    To enter where you would like to receive your payments, click here to automatically login to your dashboard on vi.ai. Your deposit options, which include bank transfer or PayPal, are found in the "Settings" tab:

    Trouble automatically logging in? Manually login here using the email you signed up with.

    Privacy

    FAQs

    • What kind of video ad unit am I embedding?

      It's a unique type of ad unit called a "vi story," which is essentially a video ad wrapped with engaging content related to your website. View a demo here (be sure to turn off ad-blocker to preview the demo).

      Your ad unit will display content from quality sources like:

    • Why embed an ad unit that also includes a story, rather than just an ad?

      Simply put, advertisers pay more for video advertising when it's matched with video content. With both, you'll increase your visitors' time-on-site and even command up to 10x higher CPM than regular display advertising.

    • What is my ads.txt file for?

      This is an industry standard (IAB-approved) text file that aims to prevent unauthorized inventory sales. Basically, it helps increase your revenue by verifying to ad buyers that you have a valid site that they are buying ad space for.

    • What is the best place to put my ad?

      To optimize your revenue, we strongly recommend embedding the ad "above the fold" when possible (lower placements tend to yield much less revenue). In general, the higher the placement, the better engagement and revenue. The automatic placement options place the ad at the top of your content area for you, but keep this tip in mind whenever you manually embed the ad.

    • Why are there no ads, even though I added the code (manually or automatically)?

      It's likely that you've added more than one ad script/code to your pages. Perhaps you selected the automatic placement on a post/page but also inserted a separate piece of code/script manually. At this time, only one ad is allowed per page. If you insert more, then no ads might be visible.

    • Is this video intelligence (vi) monetization feature compatible with Google Adsense?

      Yes. Many publishers are in fact running both Adsense and vi at the same time. Like vi, Google Adsense recommends that you have an ads.txt in your root folder. Therefore, you should also include the following line in your ads.txt -- either before or after the lines you inserted for vi (replace the 0000000000000000 with the actual publisher ID provided by Google):

      google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0

    • How do I resize the ad?

      The video ad's player will be as large as the container it’s in. If you’d like to change the default size to something smaller, you’ll just need to add some CSS to your website's theme as follows:

      1. You'll be using your site's theme customizer. In the WordPress admin menu on the left, go to Appearance > Customize.
      2. On the customizer page, scroll down in the left menu to "Additional CSS" and click on it.
      3. You'll have a textbox to paste in the following CSS (change 480 to your desired max width in pixels):

      4. When done, click on the "Publish" button at the top to save your change, and then the X to close the theme customizer.
    • I don't want my ad to follow me as I scroll.

      This is a feature that greatly increases your rate of revenue. If you would like to turn if off, please contact support.

    • When will I start seeing ads within the vi story?

      It can vary depending on which countries the bulk of your traffic is coming from. For most countries it takes about 1 to 2 days. If you have questions, email us at ext@embedplus.com

    • How do I change the number of ads that are shown for each vi story I embed?

      vi manages the maximum number of ads and time between them based on each publisher. This is to optimize the fill rates and monetization. If you would like some custom settings, please contact support.

    • Why am I seeing ads that do not match my site's topics?

      1. Wait for 24 hours to give the video intelligence service time to learn more about your site.
      2. Check each category and its subcategories to see if there is a better fit for your site’s topics than your initial selections.
      3. If you're still not seeing well-matched ads, it's likely that your site's topics are very specific or they are based on categories in which vi.ai is still building inventory. In the meantime, try and find other categories that you think will be of interest to your audience.
      4. If all else fails, please contact support.

    To see a comprehensive list of FAQs, please visit vi FAQs.

    Earnings & Payment Support

    For issues on the advertising program, your earnings, and vi: video intelligence: please contact ext@embedplus.com.

    Join over 40,000 publishers making money embedding high quality video ads
    '; self::vi_print_toggle_button(); echo ''; } ?>

    If you're using a separate caching plugin and you do not see your changes after saving, you need to reset your cache.

    0 && self::vi_logged_in()) { $last_category_update = strtotime(self::$alloptions[self::$opt_vi_last_category_update]); $last_category_update_plus = strtotime(self::$alloptions[self::$opt_vi_last_category_update] . ' + ' . self::$vi_last_category_update_interval); if ($last_category_update_plus < time()) { $success = self::vi_cache_js(self::$alloptions[self::$opt_vi_js_settings]); if ($success !== true) { self::vi_token_expire(); } } } self::$vi_script_tag_done = true; $scriptTag = '
    '; return $scriptTag; } return ''; } public static function vi_js_placement($content) { //$mainquery = is_main_query(); if (!self::$vi_script_tag_done && self::$alloptions[self::$opt_vi_active] && self::vi_script_setup_done()) { if (!empty(self::$alloptions[self::$opt_vi_js_posttypes])) { $singular = is_singular(self::$alloptions[self::$opt_vi_js_posttypes]); if ($singular && in_the_loop()) { return self::$alloptions[self::$opt_vi_js_position] == 'top' ? self::vi_script_tag() . $content : $content . self::vi_script_tag(); } } } return $content; } public static function vi_js_shortcode($atts, $content = null) { return self::vi_script_tag(); } public static function wp_insert_vi_api_is_eu() { $userIp = $_SERVER["REMOTE_ADDR"]; if (defined('VI_EU_TEST')) { $userIp = '185.216.33.82'; // force EU for testing } $isEU = get_transient('wp_insert_vi_api_is_eu_' . $userIp); if ($isEU === false) { try { $response = wp_remote_get( 'http://gdpr-check.net/gdpr/is-eu?ip=' . $userIp, array('timeout' => 15) ); if (!is_wp_error($response)) { if (200 == wp_remote_retrieve_response_code($response)) { $responseBody = json_decode($response['body']); if ((json_last_error() == JSON_ERROR_NONE)) { if ((isset($responseBody->is_eu)) && ($responseBody->is_eu == '1')) { delete_transient('wp_insert_vi_api_is_eu_' . $userIp); set_transient('wp_insert_vi_api_is_eu_' . $userIp, '1', WEEK_IN_SECONDS); return true; } else { delete_transient('wp_insert_vi_api_is_eu_' . $userIp); set_transient('wp_insert_vi_api_is_eu_' . $userIp, '0', WEEK_IN_SECONDS); return false; } } else { return false; } } else { return false; } } } catch (Exception $ex) { return false; } } else { if ($isEU == '1') { return true; } else { return false; } } } public static function wp_insert_vi_gdpr_popup_init() { if ((bool) self::$alloptions[self::$opt_vi_show_gdpr_authorization] || defined('VI_EU_TEST')) { add_action('init', array(get_class(), 'wp_insert_vi_gdpr_data_init')); add_action('wp_enqueue_scripts', array(get_class(), 'wp_insert_vi_gdpr_popup_wp_enqueue')); add_action('wp_footer', array(get_class(), 'wp_insert_vi_gdpr_popup_wp_footer')); } } public static function wp_insert_vi_gdpr_popup_wp_enqueue() { wp_enqueue_style('wp_insert_vi_gdpr_css', plugins_url('styles/ytvi-gdpr' . self::$min . '.css', __FILE__), array(), self::$version); wp_enqueue_script('wp_insert_vi_gdpr_js', plugins_url('scripts/ytvi-gdpr' . self::$min . '.js', __FILE__), array('jquery'), self::$version, true); } public static function wp_insert_vi_gdpr_popup_wp_footer() { $showViConsent = true; $isEU = self::wp_insert_vi_api_is_eu(); if (isset($_COOKIE['Viconsent'])) { $showViConsent = false; } $labels = array(); $viConsentPopupContent = isset(self::$alloptions[self::$opt_vi_endpoints]->consentPopupContent) ? self::$alloptions[self::$opt_vi_endpoints]->consentPopupContent : false; if ($viConsentPopupContent != false) { $lang = isset(self::$alloptions[self::$opt_vi_js_settings]['language']) ? self::$alloptions[self::$opt_vi_js_settings]['language'] : 'en-us'; switch ($lang) { case 'de-de': $labels['popupContent'] = $viConsentPopupContent->es; $labels['accept'] = 'acepto'; $labels['donotaccept'] = 'no acepto'; $labels['showPurposes'] = 'Mostrar propósitos'; $labels['showVendors'] = 'Mostrar vendedores'; break; case 'fr-fr': $labels['popupContent'] = $viConsentPopupContent->fr; $labels['accept'] = 'J’accepte'; $labels['donotaccept'] = 'Je n’accepte pas'; $labels['showPurposes'] = 'Plus de details'; $labels['showVendors'] = 'Montrez les vendeurs'; break; case 'en-us': default: $labels['popupContent'] = $viConsentPopupContent->en; $labels['accept'] = 'I accept'; $labels['donotaccept'] = 'I do not accept'; $labels['showPurposes'] = 'View purposes'; $labels['showVendors'] = 'View vendors'; break; } } ?> prefix . 'vi_consent_logs'; $query = $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($table_name)); if ($wpdb->get_var($query) != $table_name) { self::vi_db_init_schema(); } $viconsent = array( 'id' => 0, 'viconsent' => (isset($_COOKIE['Viconsent']) ? $_COOKIE['Viconsent'] : ''), 'date_created' => date('Y-m-d H:i:s') ); $result = $wpdb->insert($table_name, $viconsent); die(); } } public static function vi_db_init_schema() { try { global $wpdb; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE " . $wpdb->prefix . 'vi_consent_logs' . " ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, viconsent varchar(1000) NOT NULL DEFAULT '', date_created datetime NOT NULL, PRIMARY KEY (id) ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta($sql); } catch (Exception $ex) { } } public static function vi_cron_interval($schedules) { $schedules['ytvi_fifteen_days'] = array( 'interval' => 1296000, 'display' => esc_html__('Every 15 Days'), ); $schedules['ytvi_two_minutes'] = array( 'interval' => 120, 'display' => esc_html__('Every 2 Minutes'), ); return $schedules; } public static function vi_cron_cache_js() { } public static function vi_ever_logged_in() { return self::$alloptions[self::$opt_vi_last_login] != self::$vi_default_date; } public static function vi_last_login_valid() { $last_login = strtotime(self::$alloptions[self::$opt_vi_last_login]); $last_login_plus = strtotime(self::$alloptions[self::$opt_vi_last_login] . ' + 29 days'); //$last_login_plus = strtotime(self::$alloptions[self::$opt_vi_last_login] . ' + 2 minutes'); if ($last_login_plus < time()) { return false; } return true; } public static function vi_token_expire() { try { self::vi_cron_stop(); if (self::vi_logged_in() && !self::vi_last_login_valid()) { self::update_option_set(array( self::$opt_vi_token => '' )); } else if (self::vi_logged_in() && filter_input(INPUT_SERVER, 'REQUEST_METHOD') != 'POST' && ((is_admin() && filter_input(INPUT_GET, 'page') == 'youtube-ep-vi') || !is_admin()) ) // (&& not $_POSTing anything, && on monetize page) || NOT admin page...e.g. category randomization { $adsTxtAPI = self::$alloptions[self::$opt_vi_endpoints]->adsTxtAPI; $tokenCheck = self::vi_remote_get($adsTxtAPI); $tokenCheck_valid = self::vi_adstxt_api_valid($tokenCheck); if ($tokenCheck_valid !== true) // do a token check. if invalid, then: { self::update_option_set(array( self::$opt_vi_token => false )); if (is_admin()) { wp_safe_redirect(admin_url('admin.php?page=youtube-ep-vi')); exit; } } } } catch (Exception $ex) { } } ///////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////// public static function gb_block_assets() { // frontend+backend styles. wp_enqueue_style('epytgb-style-css', plugins_url('dist/blocks.style.build.css', __FILE__), array('wp-blocks'), self::$version); } public static function gb_editor_assets() { // backend styels self::ytprefsscript(); self::fitvids(); if (!self::is_restrict_wizard() && current_user_can('edit_posts')) { // Scripts. wp_enqueue_script( 'epytgb-block-js', // Handle. plugins_url('/dist/blocks.build.js', __FILE__), // Block.build.js: We register the block here. Built with Webpack. array('wp-blocks', 'wp-i18n', 'wp-element'), // Dependencies, defined above. self::$version, true // Enqueue the script in the footer. ); // Styles. wp_enqueue_style( 'epytgb-block-editor-css', // Handle. plugins_url('dist/blocks.editor.build.css', __FILE__), // Block editor CSS. array('wp-edit-blocks'), // Dependency to include the CSS after it. self::$version ); //wp_enqueue_style('__ytprefs_admin__vi_css', plugins_url('styles/ytvi-admin' . self::$min . '.css', __FILE__), array(), self::$version); // Tiny MCE wp_enqueue_style('__ytprefs_admin__tinymce_css', plugins_url('styles/epyt_mce_wizard_button' . self::$min . '.css', __FILE__), array(), self::$version); } } public static function gb_classic_block_setup() { if (!self::is_restrict_wizard() && current_user_can('edit_posts')) { add_thickbox(); add_filter("mce_external_plugins", array(get_class(), "gb_add_tinymce_plugin")); add_filter('mce_buttons_2', array(get_class(), 'gb_register_tinymce_button')); } } public static function gb_add_tinymce_plugin($plugin_array) { $plugin_array['epyt_mce_wizard_button'] = plugins_url('scripts/epyt_mce_wizard_button' . self::$min . '.js', __FILE__) . '?ver=' . self::$version; return $plugin_array; } public static function gb_register_tinymce_button($buttons) { array_push($buttons, "epyt_mce_wizard_button"); return $buttons; } public static function gb_svg_defs() { ?> array( 'shortcode' => array( 'type' => 'string' ) ), 'render_callback' => array(get_class(), 'gb_render_callback_youtube'), ) ); } } public static function gb_render_callback_youtube($attributes, $content) { if ($attributes && $attributes['shortcode'] && strpos($attributes['shortcode'], '[') === 0) { $render = do_shortcode($attributes['shortcode']); if (empty($render) && stripos($attributes['shortcode'], 'live=1') !== false) { $render = 'This is a live embed that is not currently streaming. You can optionally fill out the Not Live Content field in the YouTube plugin\'s Default Settings.'; } return $render; } return isset($attributes['shortcode']) ? $attributes['shortcode'] : ''; } } // constants define('EPYT_BASE_URL', rtrim(plugins_url('', __FILE__), "\\/") . '/'); define('EPYTVI_INCLUDES_PATH', rtrim(dirname(__FILE__), "\\/") . '/includes/vi/'); define('EPYTGB_INCLUDES_PATH', rtrim(dirname(__FILE__), "\\/") . '/includes/gutenberg/'); if (!defined('EPYTVI_ENDPOINTS_URL')) define('EPYTVI_ENDPOINTS_URL', 'https://dashboard-api.vidint.net/v1/api/widget/settings'); $youtubeplgplus = new YouTubePrefs();