. */ //define('WP_DEBUG', true); class YouTubePrefs { public static $version = '11.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_iv_load_policy = 'iv_load_policy'; public static $opt_loop = 'loop'; public static $opt_modestbranding = 'modestbranding'; public static $opt_rel = 'rel'; public static $opt_showinfo = 'showinfo'; 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_wmode = 'wmode'; public static $opt_vq = 'vq'; public static $opt_html5 = 'html5'; public static $opt_dohl = 'dohl'; public static $opt_hl = 'hl'; public static $opt_ssl = 'ssl'; public static $opt_ogvideo = 'ogvideo'; public static $opt_nocookie = 'nocookie'; public static $opt_playlistorder = 'playlistorder'; public static $opt_acctitle = 'acctitle'; public static $opt_pro = 'pro'; public static $opt_oldspacing = 'oldspacing'; 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_defaultdims = 'defaultdims'; public static $opt_defaultwidth = 'width'; public static $opt_defaultheight = 'height'; public static $opt_defaultvol = 'defaultvol'; public static $opt_vol = 'vol'; public static $opt_apikey = 'apikey'; public static $opt_schemaorg = 'schemaorg'; public static $opt_ftpostimg = 'ftpostimg'; public static $opt_spdc = 'spdc'; public static $opt_spdcexp = 'spdcexp'; public static $opt_migrate = 'migrate'; public static $opt_migrate_youtube = 'migrate_youtube'; public static $spdcprefix = 'ytpref'; public static $spdcall = 'youtubeprefs_spdcall'; public static $opt_dynload = 'dynload'; public static $opt_dyntype = 'dyntype'; public static $opt_gallery_pagesize = 'gallery_pagesize'; public static $opt_gallery_apikey = 'gallery_apikey'; public static $opt_gallery_columns = 'gallery_columns'; public static $opt_gallery_style = 'gallery_style'; public static $opt_gallery_scrolloffset = 'gallery_scrolloffset'; 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_gallery_showdsc = 'gallery_showdsc'; public static $opt_gallery_thumbcrop = 'gallery_thumbcrop'; public static $opt_admin_off_scripts = 'admin_off_scripts'; public static $opt_alloptions = 'youtubeprefs_alloptions'; public static $alloptions = null; public static $yt_options = array(); //public static $epbase = 'http://localhost:2346'; public static $epbase = '//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 $ytregex = '@^[\r\n]{0,1}[[:blank:]]*https?://(?:www\.)?(?:(?:youtube.com/watch\?)|(?:youtu.be/))([^\s"]+)[[:blank:]]*[\r\n]{0,1}$@im'; public static $oldytregex = '@^\s*https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))/{0,1}\?)|(?:youtu.be/))([^\s"]+)\s*$@im'; public static $ytregex = '@^[\r\t ]*https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))/{0,1}\?)|(?:youtu.be/))([^\s"]+)[\r\t ]*$@im'; public static $justurlregex = '@https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))/{0,1}\?)|(?:youtu.be/))([^\[\s"]+)@i'; /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// public function __construct() { add_action('admin_init', array("YouTubePrefs", 'check_double_plugin_warning')); self::$alloptions = get_option(self::$opt_alloptions); if (self::$alloptions == false || version_compare(self::$alloptions[self::$opt_version], self::$version, '<')) { self::initoptions(); } 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_iv_load_policy, self::$opt_loop, self::$opt_modestbranding, self::$opt_rel, self::$opt_showinfo, self::$opt_playsinline, self::$opt_autohide, self::$opt_controls, self::$opt_html5, self::$opt_hl, self::$opt_theme, self::$opt_color, self::$opt_listType, self::$opt_wmode, self::$opt_vq, 'index', 'list', 'start', 'end' ); add_action('media_buttons', 'YouTubePrefs::media_button_wizard', 11); self::do_ytprefs(); add_action('admin_menu', 'YouTubePrefs::ytprefs_plugin_menu'); if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 8) { add_action('admin_bar_menu', 'YouTubePrefs::ytprefs_admin_bar', 100); add_action('wp_enqueue_scripts', array('YouTubePrefs', 'ytprefs_admin_bar_scripts')); add_action('admin_enqueue_scripts', array('YouTubePrefs', 'ytprefs_admin_bar_scripts')); } if (!is_admin()) { if (self::$alloptions[self::$opt_old_script_method] == 1) { add_action('wp_print_scripts', array('YouTubePrefs', 'jsvars')); add_action('wp_enqueue_scripts', array('YouTubePrefs', 'jsvars')); } add_action('wp_enqueue_scripts', array('YouTubePrefs', 'ytprefsscript'), 100); add_action('wp_enqueue_scripts', array('YouTubePrefs', 'fitvids'), 101); if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && self::$alloptions[self::$opt_ogvideo] == 1) { add_action('wp_head', array('YouTubePrefs', 'do_ogvideo')); } } if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { self::$min = ''; } } public static function ytprefs_admin_bar_scripts() { if (current_user_can('edit_posts')) { wp_enqueue_script('__ytprefs__bar', plugins_url('scripts/ytprefs-bar' . self::$min . '.js', __FILE__), array('jquery')); wp_localize_script('__ytprefs__bar', '_EPYTA_', array( 'ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('embedplus-nonce'), 'pluginurl' => plugins_url('/', __FILE__) )); } } public static function ytprefs_admin_bar($wp_admin_bar) { $args = array( 'id' => 'ytprefs-bar-cache', 'title' => 'Clear YouTube Cache', 'href' => '#', 'meta' => array( 'class' => '' ) ); $wp_admin_bar->add_node($args); } 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 (' . $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 .= ''; $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.'; if (!(self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)) { $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 .= ''; $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.'; if (!(self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)) { $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 (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $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 media_button_wizard() { add_thickbox(); $wizhref = self::$epbase . '/wpembedcode-simple-search-' . YouTubePrefs::$version . '.aspx?pluginversion=' . YouTubePrefs::$version . '&wpversion=' . get_bloginfo('version') . '&settingsurl=' . urlencode(admin_url('admin.php?page=youtube-my-preferences#jumpdefaults')) . '&dashurl=' . urlencode(admin_url('admin.php?page=youtube-ep-analytics-dashboard')) . '&blogwidth=' . YouTubePrefs::get_blogwidth() . '&domain=' . urlencode(site_url()) . '&prokey=' . urlencode(YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro]) . '&myytdefaults=' . urlencode(http_build_query(YouTubePrefs::$alloptions)) . '&random=' . rand(1, 1000) . '&TB_iframe=true&width=950&height=800'; ?> YouTube ' . $_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.

    self::$version, self::$opt_center => $_center, self::$opt_glance => $_glance, self::$opt_autoplay => $_autoplay, self::$opt_cc_load_policy => $_cc_load_policy, self::$opt_iv_load_policy => $_iv_load_policy, self::$opt_loop => $_loop, self::$opt_modestbranding => $_modestbranding, self::$opt_rel => $_rel, self::$opt_showinfo => $_showinfo, self::$opt_playsinline => $_playsinline, self::$opt_origin => $_origin, self::$opt_autohide => $_autohide, self::$opt_html5 => $_html5, self::$opt_hl => $_hl, self::$opt_dohl => $_dohl, self::$opt_theme => $_theme, self::$opt_color => $_color, self::$opt_wmode => $_wmode, self::$opt_vq => $_vq, self::$opt_pro => $_pro, self::$opt_ssl => $_ssl, self::$opt_nocookie => $_nocookie, self::$opt_playlistorder => $_playlistorder, self::$opt_acctitle => $_acctitle, self::$opt_ogvideo => $_ogvideo, self::$opt_migrate => $_migrate, self::$opt_migrate_youtube => $_migrate_youtube, self::$opt_controls => $_controls, self::$opt_oldspacing => $_oldspacing, self::$opt_responsive => $_responsive, self::$opt_responsive_all => $_responsive_all, self::$opt_widgetfit => $_widgetfit, self::$opt_evselector_light => $_evselector_light, self::$opt_schemaorg => $_schemaorg, self::$opt_ftpostimg => $_ftpostimg, self::$opt_spdc => $_spdc, self::$opt_spdcexp => $_spdcexp, self::$opt_dynload => $_dynload, self::$opt_dyntype => $_dyntype, self::$opt_defaultdims => $_defaultdims, self::$opt_defaultwidth => $_defaultwidth, self::$opt_defaultheight => $_defaultheight, self::$opt_defaultvol => $_defaultvol, self::$opt_vol => $_vol, self::$opt_apikey => $_apikey, self::$opt_gallery_columns => $_gallery_columns, self::$opt_gallery_scrolloffset => $_gallery_scrolloffset, 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_showdsc => $_gallery_showdsc, self::$opt_gallery_style => $_gallery_style, self::$opt_gallery_thumbcrop => $_gallery_thumbcrop, self::$opt_gallery_pagesize => $_gallery_pagesize, self::$opt_debugmode => $_debugmode, self::$opt_admin_off_scripts => $_admin_off_scripts, self::$opt_old_script_method => $_old_script_method ); 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', 'YouTubePrefs::ao_override_jsexclude', 10, 1); if (!is_admin()) { add_filter('the_content', 'YouTubePrefs::apply_prefs_content', 1); add_filter('widget_text', 'YouTubePrefs::apply_prefs_widget', 1); add_shortcode('embedyt', array('YouTubePrefs', 'apply_prefs_shortcode')); if (self::$alloptions[self::$opt_migrate] == 1) { if (self::$alloptions[self::$opt_migrate_youtube] == 1) { add_shortcode('youtube', array('YouTubePrefs', 'apply_prefs_shortcode_youtube')); add_shortcode('youtube_video', array('YouTubePrefs', 'apply_prefs_shortcode_youtube')); } } } else { if (self::$alloptions[self::$opt_ftpostimg] == 1 && self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0) { add_action('save_post', array('YouTubePrefs', 'doftpostimg'), 110, 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 apply_prefs_shortcode($atts, $content = null) { $content = trim($content); $currfilter = current_filter(); if (preg_match(self::$justurlregex, $content)) { return self::get_html(array($content), $currfilter == 'widget_text' ? false : true); } 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); } return ''; } public static function apply_prefs_content($content) { $content = preg_replace_callback(self::$ytregex, "YouTubePrefs::get_html_content", $content); return $content; } public static function apply_prefs_widget($content) { $content = preg_replace_callback(self::$ytregex, "YouTubePrefs::get_html_widget", $content); return $content; } public static function get_html_content($m) { return self::get_html($m, true); } public static function get_html_widget($m) { return self::get_html($m, false); } public static function get_gallery_page($options) { $gallobj = new stdClass(); $options->pageSize = min(intval($options->pageSize), 50); $options->columns = intval($options->columns); $options->showTitle = intval($options->showTitle); $options->showPaging = intval($options->showPaging); $options->autonext = intval($options->autonext); $options->thumbplay = intval($options->thumbplay); $options->showDsc = intval($options->showDsc); $options->thumbcrop = sanitize_html_class($options->thumbcrop); $options->style = sanitize_html_class($options->style); 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; } $spdckey = ''; if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 9 && self::$alloptions[self::$opt_spdc] == 1) { try { $optionsstr = json_encode($options); $spdckey = self::$spdcprefix . '_' . md5($apiEndpoint . $optionsstr); $spdcval = get_transient($spdckey); if (!empty($spdcval)) { //self::debuglog((microtime(true) - $time_start) . "\t" . $spdckey . "\t" . $spdcval . "\r\n"); $gallobj->html = $spdcval; return $gallobj; } } catch (Exception $ex) { } } $code = ''; $init_id = null; $apiResult = wp_remote_get($apiEndpoint); if (is_wp_error($apiResult)) { $gallobj->html = '
    Sorry, there was a YouTube API error: ' . htmlspecialchars(strip_tags($apiResult->get_error_message())) . '' . ' Please make sure you performed the steps in this video to create and save a proper API key.' . '
    '; return $gallobj; } if (self::$alloptions[self::$opt_debugmode] == 1 && current_user_can('manage_options')) { $redactedEndpoint = preg_replace('@&key=[^&]+@i', '&key=PRIVATE', $apiEndpoint); $gallobj->html = '
    CLICK this debug text to auto-select all. Then, COPY the selection.' . "\n\n" . $redactedEndpoint . "\n\n" . print_r($apiResult, true) . '
    '; return $gallobj; } $jsonResult = json_decode($apiResult['body']); if (isset($jsonResult->error)) { if (isset($jsonResult->error->message)) { $gallobj->html = '
    Sorry, there was a YouTube API error: ' . htmlspecialchars(strip_tags($jsonResult->error->message)) . '' . ' Please make sure you performed the steps in this video to create and save a proper API key.' . '
    '; return $gallobj; } $gallobj->html = '
    Sorry, there may be an issue with your YouTube API key. Please make sure you performed the steps in this video to create and save a proper API key.
    '; 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 = ''; if (in_array($options->style, array('grid', ''))) { $colclass = ' epyt-cols-' . $options->columns . ' '; } $cropclass = ''; if (!in_array($options->thumbcrop, array('box', ''))) { $cropclass = ' epyt-thumb-' . $options->thumbcrop . ' '; } $code.= ''; if ($options->style === 'carousel' && $options->showTitle) { $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 .= '
    '; $pagination .= '
    '; if ($options->showPaging == 0) { $pagination = ''; } $code = $pagination . $code . $pagination; if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && self::$alloptions[self::$opt_spdc] == 1) { $daysecs = self::$alloptions[self::$opt_spdcexp] * 60 * 60; set_transient($spdckey, $code, $daysecs); $allk = get_option(self::$spdcall, array()); $allk[] = $spdckey; update_option(self::$spdcall, $allk); //self::debuglog((microtime(true) - $time_start) . "\t" . $spdckey . "\t" . $code . "\r\n"); } $gallobj->html = $code; $gallobj->init_id = $init_id; return $gallobj; } public static function get_thumbnail_html($thumb, $options) { $escId = esc_attr($thumb->id); $code = ''; $styleclass = ''; $rawstyle = ''; $dschtml = ''; if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0) { if ($options->style == 'listview') { $styleclass = 'epyt-listview'; $dschtml = isset($thumb->dsc) && !empty($thumb->dsc) ? '' : ''; } else if ($options->style == 'carousel') { $rawstyle = ' style="width: ' . (100.0 / floatval($options->pageSize)) . '%;" '; } } $code .= ''; return $code; } public static function my_embedplus_gallery_page() { if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { //check_ajax_referer('embedplus-nonce', 'security'); $options = (object) $_POST['options']; $options->apiKey = self::$alloptions[self::$opt_apikey]; echo self::get_gallery_page($options)->html; die(); } } public static function get_html($m, $iscontent) { //$time_start = microtime(true); $link = trim(str_replace(self::$badentities, self::$goodliterals, $m[0])); $link = preg_replace('/\s/', '', $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); } //$linkscheme = 'http'; $youtubebaseurl = 'youtube'; $schemaorgoutput = ''; $voloutput = ''; $dynsrc = ''; $dyntype = ''; $acctitle = ''; $videoseries = ''; $finalparams = $linkparams + self::$alloptions; $spdckey = ''; if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && self::$alloptions[self::$opt_spdc] == 1) { try { $kparams = $finalparams; $kparams['iscontent'] = $iscontent; ksort($kparams); $jparams = json_encode($kparams); $spdckey = self::$spdcprefix . '_' . md5($jparams); $spdcval = get_transient($spdckey); if (!empty($spdcval)) { //self::debuglog((microtime(true) - $time_start) . "\t" . $spdckey . "\t" . $spdcval . "\r\n"); return $spdcval; } } catch (Exception $ex) { } } self::init_dimensions($link, $linkparams, $finalparams); if (self::$alloptions[self::$opt_nocookie] == 1) { $youtubebaseurl = 'youtube-nocookie'; } // if (self::$alloptions[self::$opt_ssl] == 1) // { // $linkscheme = 'https'; // } if (self::$alloptions[self::$opt_defaultvol] == 1) { $voloutput = ' data-vol="' . self::$alloptions[self::$opt_vol] . '" '; } // if (!(self::$alloptions[self::$opt_dohl] == 1 && isset($finalparams[self::$opt_hl]) && strlen($finalparams[self::$opt_hl]) == 2)) // { // unset($finalparams[self::$opt_hl]); // } if (self::$alloptions[self::$opt_dohl] == 1) { $locale = get_locale(); $finalparams[self::$opt_hl] = $locale; } else { unset($finalparams[self::$opt_hl]); } if (isset($finalparams[self::$opt_html5]) && $finalparams[self::$opt_html5] == 0) { unset($finalparams[self::$opt_html5]); } if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0) { if (self::$alloptions[self::$opt_schemaorg] == 1 && isset($finalparams['v'])) { $schemaorgoutput = self::getschemaorgoutput($finalparams['v']); } if (self::$alloptions[self::$opt_dynload] == 1 //&& $finalparams[self::$opt_autoplay] != 1 ) { $dynsrc = 'data-ep-'; $dyntype = ' data-ep-a="' . self::$alloptions[self::$opt_dyntype] . '" '; } if (isset($linkparams[self::$opt_vol]) && is_numeric(trim($linkparams[self::$opt_vol]))) { $voloutput = ' data-vol="' . $linkparams[self::$opt_vol] . '" '; } } else { if (isset($finalparams[self::$opt_vol])) { unset($finalparams[self::$opt_vol]); } } $centercode = ''; if ($finalparams[self::$opt_center] == 1) { $centercode = ' style="display: block; margin: 0px auto;" '; } if (self::$alloptions[self::$opt_acctitle] == 1) { try { //attr escape if (self::$oembeddata) { $acctitle = self::$oembeddata->title; } else { if (isset($linkparams['list'])) { $odata = self::get_oembed('http://youtube.com/playlist?list=' . $linkparams['list'], 1920, 1280); $acctitle = $odata->title; } else { $odata = self::get_oembed('http://youtube.com/watch?v=' . $linkparams['v'], 1920, 1280); $acctitle = $odata->title; } } if ($acctitle) { $acctitle = ' title="' . esc_attr($acctitle) . '" '; } } catch (Exception $e) { } } // playlist cleanup $videoidoutput = isset($linkparams['v']) ? $linkparams['v'] : ''; if (!isset($finalparams['layout']) && isset($finalparams['list'])) { //$videoseries = 'videoseries/'; } if ((self::$alloptions[self::$opt_playlistorder] == 1 || isset($finalparams['plindex'])) && isset($finalparams['list'])) { try { $videoidoutput = ''; if (isset($finalparams['plindex'])) { $finalparams['index'] = intval($finalparams['plindex']); } } catch (Exception $ex) { } } $galleryWrapper1 = ''; $galleryWrapper2 = ''; $galleryCode = ''; if ( isset($finalparams['layout']) && strtolower($finalparams['layout']) == 'gallery' && isset($finalparams['list']) ) { $gallery_options = new stdClass(); $gallery_options->playlistId = $finalparams['list']; $gallery_options->pageToken = null; $gallery_options->pageSize = $finalparams[self::$opt_gallery_pagesize]; $gallery_options->columns = intval($finalparams[self::$opt_gallery_columns]); $gallery_options->showTitle = intval($finalparams[self::$opt_gallery_showtitle]); $gallery_options->showPaging = intval($finalparams[self::$opt_gallery_showpaging]); $gallery_options->autonext = intval($finalparams[self::$opt_gallery_autonext]); $gallery_options->thumbplay = intval($finalparams[self::$opt_gallery_thumbplay]); $gallery_options->showDsc = intval($finalparams[self::$opt_gallery_showdsc]); $gallery_options->style = $finalparams[self::$opt_gallery_style]; $gallery_options->thumbcrop = $finalparams[self::$opt_gallery_thumbcrop]; $gallery_options->apiKey = self::$alloptions[self::$opt_apikey]; $subbutton = ''; if (self::$alloptions[self::$opt_gallery_channelsub] == 1) { $subbutton = ''; } $gallery_page_obj = self::get_gallery_page($gallery_options); //$dynsrc = '';// 'data-ep-gallery'; $galleryWrapper1 = ''; $galleryCode = $subbutton . ''; $videoidoutput = isset($gallery_page_obj->init_id) ? $gallery_page_obj->init_id : ''; // 'GALLERYVIDEOID'; } $code1 = '' . $schemaorgoutput; $origin = ''; try { if (self::$alloptions[self::$opt_origin] == 1) { $url_parts = parse_url(site_url()); $origin = 'origin=' . $url_parts['scheme'] . '://' . $url_parts['host'] . '&'; } } catch (Exception $e) { $origin = ''; } $finalsrc = 'enablejsapi=1&' . $origin; if (count($finalparams) > 1) { foreach ($finalparams as $key => $value) { if (in_array($key, self::$yt_options)) { if (!empty($galleryCode) && ($key == 'listType' || $key == 'list')) { } else { $finalsrc .= htmlspecialchars($key) . '=' . htmlspecialchars($value) . '&'; if ($key == 'loop' && $value == 1 && !isset($finalparams['list'])) { $finalsrc .= 'playlist=' . $finalparams['v'] . '&'; } } } } } $code = $galleryWrapper1 . $code1 . $finalsrc . $code2 . $galleryCode . $galleryWrapper2; //. ''; // reset static vals for next embed self::$defaultheight = null; self::$defaultwidth = null; self::$oembeddata = null; if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && self::$alloptions[self::$opt_spdc] == 1) { $daysecs = self::$alloptions[self::$opt_spdcexp] * 60 * 60; set_transient($spdckey, $code, $daysecs); $allk = get_option(self::$spdcall, array()); $allk[] = $spdckey; update_option(self::$spdcall, $allk); //self::debuglog((microtime(true) - $time_start) . "\t" . $spdckey . "\t" . $code . "\r\n"); } return $code; } public static function debuglog($str) { $handle = fopen(__DIR__ . "\\debug.txt", "a+"); fwrite($handle, $str); fclose($handle); } public static function spdcpurge() { $allk = get_option(self::$spdcall, array()); if (is_array($allk)) { foreach ($allk as $t) { $success = delete_transient($t); } } update_option(self::$spdcall, array()); } public static function keyvalue($qry, $includev) { $ytvars = explode('&', $qry); $ytkvp = array(); foreach ($ytvars as $k => $v) { $kvp = explode('=', $v); if (count($kvp) == 2 && ($includev || strtolower($kvp[0]) != 'v')) { $ytkvp[$kvp[0]] = $kvp[1]; } } return $ytkvp; } public static function getschemaorgoutput($vidid) { $schemaorgcode = ''; try { $ytapilink = 'https://www.googleapis.com/youtube/v3/videos?id=' . $vidid . '&part=contentDetails,snippet&key=' . self::$alloptions[self::$opt_apikey]; $apidata = wp_remote_get($ytapilink); if (!is_wp_error($apidata)) { $raw = wp_remote_retrieve_body($apidata); if (!empty($raw)) { $json = json_decode($raw, true); if (is_array($json)) { $_name = esc_attr(sanitize_text_field(str_replace("@", "@", $json['items'][0]['snippet']['title']))); $_description = esc_attr(sanitize_text_field(str_replace("@", "@", $json['items'][0]['snippet']['description']))); $_thumbnailUrl = esc_url("https://i.ytimg.com/vi/" . $vidid . "/0.jpg"); $_duration = $json['items'][0]['contentDetails']['duration']; // "T0H9M35S" "PT9M35S" $_uploadDate = sanitize_text_field($json['items'][0]['snippet']['publishedAt']); // "2014-10-03T15:30:12.000Z" $schemaorgcode = ''; $schemaorgcode .= ''; $schemaorgcode .= ''; $schemaorgcode .= ''; $schemaorgcode .= ''; $schemaorgcode .= ''; $schemaorgcode .= ''; $schemaorgcode .= ''; } } } } catch (Exception $ex) { } return $schemaorgcode; } public static function secondsToDuration($seconds) { $remaining = $seconds; $parts = array(); $multipliers = array( 'hours' => 3600, 'minutes' => 60, 'seconds' => 1 ); foreach ($multipliers as $type => $m) { $parts[$type] = (int) ($remaining / $m); $remaining -= ($parts[$type] * $m); } return $parts; } public static function formatDuration($parts) { $default = array( 'hours' => 0, 'minutes' => 0, 'seconds' => 0 ); extract(array_merge($default, $parts)); return "T{$hours}H{$minutes}M{$seconds}S"; } public static function init_dimensions($url, $urlkvp, $finalparams) { // get default dimensions; try embed size in settings, then try theme's content width, then just 480px if (self::$defaultwidth == null) { global $content_width; if (empty($content_width)) { $content_width = $GLOBALS['content_width']; } if (isset($urlkvp['width']) && is_numeric($urlkvp['width'])) { self::$defaultwidth = $urlkvp['width']; } else if (self::$alloptions[self::$opt_defaultdims] == 1 && (isset(self::$alloptions[self::$opt_defaultwidth]) && is_numeric(self::$alloptions[self::$opt_defaultwidth]))) { self::$defaultwidth = self::$alloptions[self::$opt_defaultwidth]; } else if (self::$optembedwidth) { self::$defaultwidth = self::$optembedwidth; } else if ($content_width) { self::$defaultwidth = $content_width; } else { self::$defaultwidth = 480; } if (isset($urlkvp['height']) && is_numeric($urlkvp['height'])) { self::$defaultheight = $urlkvp['height']; } else if (self::$alloptions[self::$opt_defaultdims] == 1 && (isset(self::$alloptions[self::$opt_defaultheight]) && is_numeric(self::$alloptions[self::$opt_defaultheight]))) { self::$defaultheight = self::$alloptions[self::$opt_defaultheight]; } else { self::$defaultheight = self::get_aspect_height($url, $urlkvp, $finalparams); } } } public static function get_oembed($url, $height, $width) { require_once( ABSPATH . WPINC . '/class-oembed.php' ); $oembed = _wp_oembed_get_object(); $args = array(); $args['width'] = $width; $args['height'] = $height; $args['discover'] = false; self::$oembeddata = $oembed->fetch('https://www.youtube.com/oembed', $url, $args); return self::$oembeddata; } public static function get_aspect_height($url, $urlkvp, $finalparams) { // attempt to get aspect ratio correct height from oEmbed $aspectheight = round((self::$defaultwidth * 9) / 16, 0); if ($url) { $odata = self::get_oembed($url, self::$defaultwidth, self::$defaultwidth); if ($odata) { $aspectheight = $odata->height; } } if ($finalparams[self::$opt_controls] != 0 && $finalparams[self::$opt_autohide] != 1) { //add 28 for YouTube's own bar: DEPRECATED //$aspectheight += 28; } return $aspectheight; } public static function doftpostimg($postid, $post, $update) { if (current_user_can('edit_posts')) { if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || !in_array($post->post_status, array('publish', 'pending', 'draft', 'future', 'private'))) { return; } try { self::doftpostimgfor($post); } catch (Exception $ex) { // display error message } } } public static function doftpostimgfor($post) { $search_content = isset($post->post_content) ? $post->post_content : ''; $search_content = substr(wp_strip_all_tags($search_content), 0, 5000); $search_content = apply_filters('youtube_embedplus_video_content', $search_content); $vid_match = null; if ($search_content && $post->ID && !has_post_thumbnail($post->ID) && preg_match(self::$justurlregex, $search_content, $vid_match) ) { $first_vid_link = trim(str_replace(self::$badentities, self::$goodliterals, $vid_match[0])); $first_vid_link = preg_replace('/\s/', '', $first_vid_link); $linkparamstemp = explode('?', $first_vid_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); } $just_id = $linkparams['v']; if ($just_id == null && isset($linkparams['list'])) { $apiEndpoint = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,status&playlistId=' . $linkparams['list'] . '&maxResults=10&key=' . self::$alloptions[self::$opt_apikey]; try { $apiResult = wp_remote_get($apiEndpoint); if (!is_wp_error($apiResult)) { $jsonResult = json_decode($apiResult['body']); if (!isset($jsonResult->error) && isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items)) { $item = $jsonResult->items[0]; $just_id = isset($item->snippet->resourceId->videoId) ? $item->snippet->resourceId->videoId : null; $just_id = $just_id ? $just_id : $item->id->videoId; } } } catch (Exception $ex) { } } if ($just_id != null) { $ftimgurl = "https://img.youtube.com/vi/" . $just_id . "/maxresdefault.jpg"; $ftimgid = self::media_sideload($ftimgurl, $post->ID, sanitize_title(preg_replace("/[^a-zA-Z0-9\s]/", "-", $post->post_title))); if (!ftimgid || is_wp_error($ftimgid)) { $ftimgurl = null; $ftimgid = 0; if ($just_id) { require_once( ABSPATH . WPINC . '/class-oembed.php' ); $oembed = _wp_oembed_get_object(); $args = array(); $args['width'] = 1920; $args['height'] = 1080; $args['discover'] = false; $odata = $oembed->fetch('https://www.youtube.com/oembed', 'http://youtube.com/watch?v=' . $just_id, $args); if ($odata) { $ftimgurl = $odata->thumbnail_url; } } $ftimgid = $ftimgurl && !is_wp_error($ftimgurl) ? self::media_sideload($ftimgurl, $post->ID, sanitize_title(preg_replace("/[^a-zA-Z0-9\s]/", "-", $post->title))) : 0; if (!$ftimgid || is_wp_error($ftimgid)) { return; } } set_post_thumbnail($post->ID, $ftimgid); } } } public static function media_sideload($url, $post_id, $filename = null) { if (!$url || !$post_id) { return new WP_Error('missing', __('Please provide a valid URL and post ID', '')); } $post_title = get_the_title($post_id); require_once(ABSPATH . 'wp-admin/includes/file.php'); $tmp = download_url($url); if (is_wp_error($tmp)) { @unlink($file_array['tmp_name']); $file_array['tmp_name'] = ''; return $tmp; } preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches); $url_filename = basename($matches[0]); $url_type = wp_check_filetype($url_filename); if (!empty($filename)) { $filename = sanitize_file_name($filename); $tmppath = pathinfo($tmp); $new = $tmppath['dirname'] . '/' . $filename . '.' . $tmppath['extension']; rename($tmp, $new); $tmp = $new; } $file_array['tmp_name'] = $tmp; if (!empty($filename)) { $file_array['name'] = $filename . '.' . $url_type['ext']; } else { $file_array['name'] = $url_filename; } $post_data = array( 'post_title' => $post_title, 'post_parent' => $post_id, ); require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . 'wp-admin/includes/media.php' ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); $att_id = media_handle_sideload($file_array, $post_id, null, $post_data); if (is_wp_error($att_id)) { @unlink($file_array['tmp_name']); return $att_id; } return $att_id; } public static function do_ogvideo() { global $wp_query; $the_content = $wp_query->post->post_content; $matches = Array(); $ismatch = preg_match_all(self::$justurlregex, $the_content, $matches); if ($ismatch) { $match = $matches[0][0]; $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); } if (isset($linkparams['v'])) { ?> 0) { add_menu_page('YouTube Settings', 'YouTube PRO', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options', plugins_url('images/youtubeicon16.png', __FILE__), '10.000392854349'); add_submenu_page('youtube-my-preferences', '', '', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options'); add_submenu_page('youtube-my-preferences', 'YouTube Analytics Dashboard', '  PRO Analytics', 'manage_options', 'youtube-ep-analytics-dashboard', 'YouTubePrefs::epstats_show_options'); } else { add_menu_page('YouTube Settings', 'YouTube Free', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options', plugins_url('images/youtubeicon16.png', __FILE__), '10.000392854349'); add_submenu_page('youtube-my-preferences', '', '', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options'); add_submenu_page('youtube-my-preferences', 'YouTube PRO', '  YouTube PRO', 'manage_options', 'youtube-ep-analytics-dashboard', 'YouTubePrefs::epstats_show_options'); } add_submenu_page(null, 'YouTube Posts', 'YouTube Posts', 'manage_options', 'youtube-ep-glance', 'YouTubePrefs::glance_page'); } public static function epstats_show_options() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } if (self::$double_plugin) { //add_action('admin_notices', array("YouTubePrefs", "double_plugin_warning")); self::double_plugin_warning(); } // Now display the settings editing screen ?>

    0) { //// header echo "

    " . ' ' . __('YouTube Analytics Dashboard') . "

    "; echo '

    Logging you in below... (You can also click here to launch your dashboard in a new tab)

    '; } else { //// header echo "

    " . ' ' . __('YouTube Plugin PRO') . "

    This tab is here to provide direct access to analytics. Graphs and other data about your site will show below after you activate PRO.


    "; } ?>

    type="checkbox" class="checkbox">
    Animation:

    type="checkbox" class="checkbox">

    type="checkbox" class="checkbox">

    Below are PRO features for enhanced SEO and performance (works for even past embed links).

    Activate the above and several other features »


    ▲ top

    Suppose you have a few videos that need to be different from the above defaults. You can add options to the end of a link as displayed below to override the above defaults. Each option should begin with '&'.
    PRO users: You can use the big blue customize buttons that you will see inside the wizard, instead of memorizing the following. '); _e("

  • width - Sets the width of your player. If omitted, the default width will be the width of your theme's content. Example: http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350
  • "); _e("
  • height - Sets the height of your player. Example: http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350
  • "); _e("
  • autoplay - Set this to 1 to autoplay the video (or 0 to play the video once). Example: http://www.youtube.com/watch?v=quwebVjAEJA&autoplay=1
  • "); _e("
  • cc_load_policy - Set this to 1 to turn on closed captioning (or 0 to leave them off). Example: http://www.youtube.com/watch?v=quwebVjAEJA&cc_load_policy=1
  • "); _e("
  • iv_load_policy - Set this to 3 to turn off annotations (or 1 to show them). Example: http://www.youtube.com/watch?v=quwebVjAEJA&iv_load_policy=3
  • "); _e("
  • loop - Set this to 1 to loop the video (or 0 to not loop). Example: http://www.youtube.com/watch?v=quwebVjAEJA&loop=1
  • "); _e("
  • modestbranding - Set this to 1 to remove the YouTube logo while playing (or 0 to show the logo). Example: http://www.youtube.com/watch?v=quwebVjAEJA&modestbranding=1
  • "); _e("
  • rel - Set this to 0 to not show related videos at the end of playing (or 1 to show them). Example: http://www.youtube.com/watch?v=quwebVjAEJA&rel=0
  • "); _e("
  • showinfo - Set this to 0 to hide the video title and other info (or 1 to show it). Example: http://www.youtube.com/watch?v=quwebVjAEJA&showinfo=0
  • "); _e("
  • theme - Set this to 'light' to make the player have the light-colored theme (or 'dark' for the dark theme). Example: http://www.youtube.com/watch?v=quwebVjAEJA&theme=light
  • "); _e("
  • color - Set this to 'white' to make the player have a white progress bar (or 'red' for a red progress bar). Note: Using white will disable the modestbranding option. Example: http://www.youtube.com/watch?v=quwebVjAEJA&color=white
  • "); _e("
  • vq - Set this to 'hd720' or 'hd1080' to force the video to have HD quality. Leave blank to let YouTube decide. Example: http://www.youtube.com/watch?v=quwebVjAEJA&vq=hd720
  • "); _e("
  • controls - Set this to 0 to completely hide the video controls (or 2 to show it). Example: http://www.youtube.com/watch?v=quwebVjAEJA&controls=0
  • "); _e("
  • autohide - Set this to 1 to slide away the control bar after the video starts playing. It will automatically slide back in again if you mouse over the video. (Set to 2 to always show it). Example: http://www.youtube.com/watch?v=quwebVjAEJA&autohide=1
  • "); _e("
  • playsinline - Set this to 1 to allow videos play inline with the page on iOS browsers. (Set to 0 to have iOS launch videos in fullscreen instead). Example: http://www.youtube.com/watch?v=quwebVjAEJA&playsinline=1
  • "); _e("
  • origin - Set this to 1 to add the 'origin' parameter for extra JavaScript security. Example: http://www.youtube.com/watch?v=quwebVjAEJA&origin=1
  • "); _e(''); _e("

    You can also start and end each individual video at particular times. Like the above, each option should begin with '&'

    "); _e(''); ?>
    0) { echo "

    " . __('Thank you for going PRO.'); echo '  '; echo "

    "; ?>

    Want to go PRO? (Low Prices) »   PRO users help keep new features coming and our coffee cups filled. Go PRO and get these perks in return:


    Enter and save your PRO key (emailed to you):

    0) { echo 'style="display: none;"'; } ?>> 0)) { ?>       |       Click here to go PRO »

    Support tips for all users (Free and PRO)

    We've found that a common support request has been from users that are pasting video links on single lines, as required, but are not seeing the video embed show up. One of these suggestions is usually the fix:

    Deactivating the No Cookies option has also been proven to solve player errors.

    We also have a YouTube channel. We use it to provide users with some helper videos and a way to keep updated on new features as they are introduced. Subscribe for tips and updates here »


    Priority Support (PRO Users »)▲ top

    PRO users: Below, We've enabled the ability to have priority support with our team. Use this to get one-on-one help with any issues you might have or to send us suggestions for future features. We typically respond within minutes during normal work hours. We're always happy to accept any testimonials you might have as well.

    0)) { ?>

    How To Embed Visual Wizard Defaults Compatibility Gallery Settings Override Defaults " style="border-color: #888888;">Upgrade? Support

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

    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__), 'epresponsiveselector' => self::get_responsiveselector(), 'epdovol' => true, 'version' => self::$alloptions[self::$opt_version], 'evselector' => self::get_evselector() )); } ////////////////////// cloudflare accomodation //add_filter('script_loader_tag', 'YouTubePrefs::set_cfasync', 10, 3); if (!is_admin() && (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0) && self::$alloptions[self::$opt_dynload] == 1) { wp_enqueue_style('__dyntype__', plugins_url('scripts/embdyn.min.css', __FILE__)); wp_enqueue_script('__dynload__', plugins_url('scripts/embdyn' . self::$min . '.js', __FILE__), array('jquery')); } } } public static function set_cfasync($tag, $handle, $src) { if ('__ytprefs__' !== $handle) { return $tag; } return str_replace('btn_arr = array("Seperator" => $seperator, "Name" => $btn_name); $this->js_file = $javascrip_location; add_action('init', array($this, 'add_tinymce_button')); add_filter('tiny_mce_version', array($this, 'refresh_mce_version')); } /* * create the buttons only if the user has editing privs. * If so we create the button and add it to the tinymce button array */ function add_tinymce_button() { if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) return; if (get_user_option('rich_editing') == 'true') { //the function that adds the javascript add_filter('mce_external_plugins', array($this, 'add_new_tinymce_plugin')); //adds the button to the tinymce button array add_filter('mce_buttons', array($this, 'register_new_button')); } } /* * add the new button to the tinymce array */ function register_new_button($buttons) { array_push($buttons, $this->btn_arr["Seperator"], $this->btn_arr["Name"]); return $buttons; } /* * Call the javascript file that loads the * instructions for the new button */ function add_new_tinymce_plugin($plugin_array) { $plugin_array[$this->btn_arr['Name']] = $this->js_file; return $plugin_array; } /* * This function tricks tinymce in thinking * it needs to refresh the buttons */ function refresh_mce_version($ver) { $ver += 3; return $ver; } } //class end register_activation_hook(__FILE__, array('YouTubePrefs', 'initoptions')); $youtubeplgplus = new YouTubePrefs(); add_action("wp_ajax_my_embedplus_pro_record", array('YouTubePrefs', 'my_embedplus_pro_record')); add_action("wp_ajax_my_embedplus_clearspdc", array('YouTubePrefs', 'my_embedplus_clearspdc')); add_action("wp_ajax_my_embedplus_glance_vids", array('YouTubePrefs', 'my_embedplus_glance_vids')); add_action("wp_ajax_my_embedplus_glance_count", array('YouTubePrefs', 'my_embedplus_glance_count')); add_action("wp_ajax_my_embedplus_dismiss_double_plugin_warning", array('YouTubePrefs', 'my_embedplus_dismiss_double_plugin_warning')); add_action("wp_ajax_my_embedplus_gallery_page", array('YouTubePrefs', 'my_embedplus_gallery_page')); add_action("wp_ajax_nopriv_my_embedplus_gallery_page", array('YouTubePrefs', 'my_embedplus_gallery_page')); add_action('admin_enqueue_scripts', 'youtubeprefs_admin_enqueue_scripts'); function youtubeprefs_admin_enqueue_scripts() { wp_enqueue_style('embedplusyoutube', plugins_url() . '/youtube-embed-plus/scripts/embedplus_mce.css'); add_action('wp_print_scripts', 'youtubeprefs_output_scriptvars'); wp_enqueue_script('__ytprefs_admin__', plugins_url('scripts/ytprefs-admin.min.js', __FILE__), array('jquery')); if ( //(!(isset(YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro]) && strlen(trim(YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro])) > 0)) && // display only if not pro ooopointer (get_bloginfo('version') >= '3.3') && YouTubePrefs::custom_admin_pointers_check() ) { add_action('admin_print_footer_scripts', 'YouTubePrefs::custom_admin_pointers_footer'); wp_enqueue_script('wp-pointer'); wp_enqueue_style('wp-pointer'); } if (YouTubePrefs::$alloptions['glance'] == 1) { add_action('admin_print_footer_scripts', 'YouTubePrefs::glance_script'); } } function youtubeprefs_output_scriptvars() { YouTubePrefs::$scriptsprinted++; if (YouTubePrefs::$scriptsprinted == 1) { $blogwidth = YouTubePrefs::get_blogwidth(); $epprokey = YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro]; $myytdefaults = http_build_query(YouTubePrefs::$alloptions); ?>