<\/iframe>#Usm', $the_content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $the_content = str_replace($match[0], 'httpv://youtu.be/'.$match[1], $the_content); } } } if ( strpos($the_content,".*
(.*)
<\!--\s?/wp:(?:core[-|/])?embed(?:/youtube)?\s?-->%Us'; $the_content = preg_replace($gutenbeard_playlist_regex, '
httpv://www.youtube.com/playlist?list=\1
\2
',$the_content); } $gutenbeard_single_regex = '%<\!--\s?wp:(?:core[-|/])?embed(?:/youtube)?\s?{"url":"https?://(?:www\.)?youtu(?:be\.com|.be)/(?:watch\?v=)?(.*)"}\s?-->.*
(.*)
<\!--\s?/wp:(?:core[-|/])?embed(?:/youtube)?\s?-->%Us'; $the_content = preg_replace($gutenbeard_single_regex, '
httpv://www.youtube.com/watch?v=\1
\2
',$the_content); } if((strpos($the_content, "httpv")!==FALSE)||(strpos($the_content, "httpa")!==FALSE)) { if (apply_filters('lyte_remove_wpautop',false)) { remove_filter('the_content','wpautop'); } $char_codes = array('×','–'); $replacements = array("x", "--"); $the_content=str_replace($char_codes, $replacements, $the_content); $lyte_feed=is_feed(); $hidefClass = ($lyteSettings['hidef']==="1") ? " hidef" : ""; $postID = get_the_ID(); $toCache_index=array(); $lytes_regexp="/(?:

)?http(v|a):\/\/([a-zA-Z0-9\-\_]+\.|)(youtube|youtu)(\.com|\.be)\/(((watch(\?v\=|\/v\/)|.+?v\=|)([a-zA-Z0-9\-\_]{11}))|(playlist\?list\=([a-zA-Z0-9\-\_]*)))([^\s<]*)()?/"; preg_match_all($lytes_regexp, $the_content, $matches, PREG_SET_ORDER); foreach($matches as $match) { /** API: filter hook to preparse fragment in a httpv-url, e.g. to force hqThumb=1 or showinfo=0 */ $match[12] = apply_filters( 'lyte_match_preparse_fragment',$match[12] ); preg_match("/stepSize\=([\+\-0-9]{2})/",$match[12],$sMatch); preg_match("/showinfo\=([0-1]{1})/",$match[12],$showinfo); preg_match("/start\=([0-9]*)/",$match[12],$start); preg_match("/enablejsapi\=([0-1]{1})/",$match[12],$jsapi); preg_match("/hqThumb\=([0-1]{1})/",$match[12],$hqThumb); preg_match("/noMicroData\=([0-1]{1})/",$match[12],$microData); $thumb="normal"; if ($lyteSettings['hidef']==="1") { $thumb="highres"; } else if (!empty($hqThumb)) { if ($hqThumb[0]==="hqThumb=1") { $thumb="highres"; } } $noMicroData="0"; if (!empty($microData)) { if ($microData[0]==="noMicroData=1") { $noMicroData="1"; } } $qsa=""; if (!empty($showinfo[0])) { $qsa="&".$showinfo[0]; $titleClass=" hidden"; } else { $titleClass=""; } if (!empty($start[0])) $qsa.="&".$start[0]; if (!empty($jsapi[0])) $qsa.="&".$jsapi[0]."&origin=".$origin; if (!empty($qsa)) { $esc_arr=array("&" => "\&", "?" => "\?", "=" => "\="); $qsaClass=" qsa_".strtr($qsa,$esc_arr); } else { $qsaClass=""; } if (!empty($sMatch)) { $newSize=(int) $sMatch[1]; $newPos=(int) $lyteSettings['selSize']+$newSize; if ($newPos<0) { $newPos=0; } else if ($newPos > count($lyteSettings['sizeArray'])-1) { $newPos=count($lyteSettings['sizeArray'])-1; } $lyteSettings[2]=$lyteSettings['sizeArray'][$newPos]['w']; $lyteSettings[3]=$lyteSettings['sizeArray'][$newPos]['h']; } else { $lyteSettings[2]=$lyteSettings['sizeArray'][$lyteSettings['selSize']]['w']; $lyteSettings[3]=$lyteSettings['sizeArray'][$lyteSettings['selSize']]['h']; } if ($match[1]!=="a") { $divHeight=$lyteSettings[3]; $audioClass=""; $audio=false; } else { $audio=true; $audioClass=" lyte-audio"; $divHeight=38; } $NSimgHeight=$divHeight-20; if ($match[11]!="") { $plClass=" playlist"; $vid=$match[11]; switch ($lyteSettings['links']) { case "0": $noscript_post="
".__("Watch this playlist on YouTube","wp-youtube-lyte"); $noscript=""; $lytelinks_txt=""; break; default: $noscript=""; $lytelinks_txt="

".__("Watch this playlist","wp-youtube-lyte")." ".__("on YouTube","wp-youtube-lyte")."
"; } } else if ($match[9]!="") { $plClass=""; $vid=$match[9]; switch ($lyteSettings['links']) { case "0": $noscript_post="
".__("Watch this video on YouTube","wp-youtube-lyte"); $lytelinks_txt="
"; break; default: $noscript_post=""; $lytelinks_txt="
".__("Watch this video","wp-youtube-lyte")." ".__("on YouTube","wp-youtube-lyte").".
"; } $thumbUrl = $lyteSettings['scheme']."://i.ytimg.com/vi/".$vid."/0.jpg"; if (get_option('lyte_local_thumb','0') === '1') { $thumbUrl = plugins_url( 'lyteThumbs.php?origThumbUrl=' . urlencode($thumbUrl) , __FILE__ ); } $noscript=""; } // add disclaimer to lytelinks $disclaimer = wp_kses_data( get_option( 'lyte_disclaimer', '') ); if ( !empty( $disclaimer ) ) { $disclaimer = '' . $disclaimer . ''; } if ( $disclaimer && empty( $lytelinks_txt ) ) { $lytelinks_txt = "
".$diclaimer."
"; } else if ( $disclaimer ) { $lytelinks_txt = str_replace('','
'.$disclaimer.'',$lytelinks_txt); } // fetch data from YT api (v2 or v3) $isPlaylist=false; if ($plClass===" playlist") { $isPlaylist=true; } $cachekey = '_lyte_' . $vid; $yt_resp_array=lyte_get_YT_resp($vid,$isPlaylist,$cachekey); // If there was a result from youtube or from cache, use it if ( $yt_resp_array ) { if (is_array($yt_resp_array)) { if ($isPlaylist!==true) { // captions, thanks to Benetech $captionsMeta=""; $doCaptions=true; /** API: filter hook to disable captions */ $doCaptions = apply_filters( 'lyte_docaptions', $doCaptions ); if(($lyteSettings['microdata'] === "1")&&($noMicroData !== "1" )&&($doCaptions === true)) { if (array_key_exists('captions_data',$yt_resp_array)) { if ($yt_resp_array["captions_data"]=="true") { $captionsMeta=""; $forceCaptionsUpdate=false; } else { $forceCaptionsUpdate=true; } } else { $forceCaptionsUpdate=true; $yt_resp_array["captions_data"]=false; } if ($forceCaptionsUpdate===true) { $captionsMeta=""; $threshold = 30; if (array_key_exists('captions_timestamp',$yt_resp_array)) { $cache_timestamp = $yt_resp_array["captions_timestamp"]; $interval = (strtotime("now") - $cache_timestamp)/60/60/24; } else { $cache_timestamp = false; $interval = $threshold+1; } if(!is_int($cache_timestamp) || ($interval > $threshold && !is_null( $yt_resp_array["captions_data"]))) { $yt_resp_array['captions_timestamp'] = strtotime("now"); wp_schedule_single_event(strtotime("now") + 60*60, 'schedule_captions_lookup', array($postID, $cachekey, $vid)); $yt_resp_precache=json_encode($yt_resp_array); $toCache=base64_encode(gzcompress($yt_resp_precache)); update_post_meta($postID, $cachekey, $toCache); } } } } $thumbUrl=""; if (($thumb==="highres") && (!empty($yt_resp_array["HQthumbUrl"]))){ $thumbUrl=$yt_resp_array["HQthumbUrl"]; } else { if (!empty($yt_resp_array["thumbUrl"])) { $thumbUrl=$yt_resp_array["thumbUrl"]; } else { $thumbUrl="//i.ytimg.com/vi/".$vid."/hqdefault.jpg"; } } } else { // no useable result from youtube, fallback on video thumbnail (doesn't work on playlist) $thumbUrl = "//i.ytimg.com/vi/".$vid."/hqdefault.jpg"; } } else { // same fallback $thumbUrl = "//i.ytimg.com/vi/".$vid."/hqdefault.jpg"; } // do we have to serve the thumbnail from local cache? if (get_option('lyte_local_thumb','0') === '1') { $thumbUrl = plugins_url( 'lyteThumbs.php?origThumbUrl=' . urlencode($thumbUrl) , __FILE__ ); } /** API: filter hook to override thumbnail URL */ $thumbUrl = apply_filters( 'lyte_match_thumburl', $thumbUrl, $vid ); if ($audio===true) { $wrapper="
"; } else { $wrapper="
"; } if ($doExcerpt) { $lytetemplate=""; $templateType="excerpt"; } elseif ($lyte_feed) { $postURL = get_permalink( $postID ); $textLink = ($lyteSettings['links']===0)? "" : "
".strip_tags($lytelinks_txt, '')."
"; $lytetemplate = "
\"YouTube".$textLink; $templateType="feed"; } elseif (($audio !== true) && ( $plClass !== " playlist") && (($lyteSettings['microdata'] === "1")&&($noMicroData !== "1" ))) { $lytetemplate = $wrapper."
".$captionsMeta."
".$yt_resp_array["title"]."
".$noscript."
".$lytelinks_txt; $templateType="postMicrodata"; } else { $lytetemplate = $wrapper."
"; if (isset($yt_resp_array) && !empty($yt_resp_array) && !empty($yt_resp_array["title"])) { $lytetemplate .= "
".$yt_resp_array['title']."
"; } $lytetemplate .= "
".$noscript."
".$lytelinks_txt; $templateType="post"; } /** API: filter hook to parse template before being applied */ $lytetemplate = str_replace('$','$',$lytetemplate); $lytetemplate = apply_filters( 'lyte_match_postparse_template',$lytetemplate,$templateType ); $the_content = preg_replace($lytes_regexp, $lytetemplate, $the_content, 1); } // update lyte_cache_index if ((is_array($toCache_index))&&(!empty($toCache_index))) { $lyte_cache=json_decode(get_option('lyte_cache_index'),true); $lyte_cache[$postID]=$toCache_index; update_option('lyte_cache_index',json_encode($lyte_cache)); } if (!$lyte_feed) { lyte_initer(); } } /** API: filter hook to postparse the_content before returning */ $the_content = apply_filters( 'lyte_content_postparse',$the_content ); return $the_content; } function captions_lookup($postID, $cachekey, $vid) { // captions lookup at YouTube via a11ymetadata.org $response = wp_remote_request("http://api.a11ymetadata.org/captions/youtubeid=".$vid."/youtube"); if(!is_wp_error($response)) { $rawJson = wp_remote_retrieve_body($response); $decodeJson = json_decode($rawJson, true); $yt_resp = get_post_meta($postID, $cachekey, true); if (!empty($yt_resp)) { $yt_resp = gzuncompress(base64_decode($yt_resp)); if($yt_resp) { $yt_resp_array=json_decode($yt_resp,true); if ($decodeJson['status'] == 'success' && $decodeJson['data']['captions'] == '1') { $yt_resp_array['captions_data'] = true; } else { $yt_resp_array['captions_data'] = false; } $yt_resp_array['captions_timestamp'] = strtotime("now"); $yt_resp_precache=json_encode($yt_resp_array); $toCache=base64_encode(gzcompress($yt_resp_precache)); update_post_meta($postID, $cachekey, $toCache); } } } } function lyte_get_YT_resp($vid,$playlist=false,$cachekey,$apiTestKey="",$isWidget=false) { /** logic to get video info from cache or get it from YouTube and set it */ global $postID, $cachekey, $toCache_index; $_thisLyte = array(); $yt_error = array(); if ( $postID && empty($apiTestKey) && !$isWidget ) { $cache_resp = get_post_meta( $postID, $cachekey, true ); if (!empty($cache_resp)) { $_thisLyte = json_decode(gzuncompress(base64_decode($cache_resp)),1); // make sure there are not old APIv2 full responses in cache if (array_key_exists('entry', $_thisLyte)) { if ($_thisLyte['entry']['xmlns$yt']==="http://gdata.youtube.com/schemas/2007") { $_thisLyte = array(); } } } } else if ($isWidget) { $cache_resp = get_option("lyte_widget_cache"); if (!empty($cache_resp)) { $widget_cache = json_decode(gzuncompress(base64_decode($cache_resp)),1); $_thisLyte = $widget_cache[$vid]; } } if ( empty( $_thisLyte ) ) { // get info from youtube // first get yt api key $lyte_yt_api_key = get_option('lyte_yt_api_key',''); $lyte_yt_api_key = apply_filters('lyte_filter_yt_api_key', $lyte_yt_api_key); if (!empty($apiTestKey)) { $lyte_yt_api_key=$apiTestKey; } if (($lyte_yt_api_key==="none") || (empty($lyte_yt_api_key))) { $_thisLyte['title']=""; if ($playlist) { $_thisLyte['thumbUrl']=""; $_thisLyte['HQthumbUrl']=""; } else { $_thisLyte['thumbUrl']="//i.ytimg.com/vi/".$vid."/hqdefault.jpg"; $_thisLyte['HQthumbUrl']="//i.ytimg.com/vi/".$vid."/maxresdefault.jpg"; } $_thisLyte['dateField']=""; $_thisLyte['duration']=""; $_thisLyte['description']=""; $_thisLyte['captions_data']="false"; $_thisLyte['captions_timestamp']=strtotime("now"); return $_thisLyte; } else { // v3, feeling somewhat lonely now v2 has gently been put to sleep $yt_api_base = "https://www.googleapis.com/youtube/v3/"; if ($playlist) { $yt_api_target = "playlists?part=snippet%2C+id&id=".$vid."&key=".$lyte_yt_api_key; } else { $yt_api_target = "videos?part=id%2C+snippet%2C+contentDetails&id=".$vid."&key=".$lyte_yt_api_key; } } $yt_api_url = $yt_api_base.$yt_api_target; $yt_resp = wp_remote_get($yt_api_url); // check if we got through if ( is_wp_error($yt_resp) ) { $yt_error['code']=408; $yt_error['reason']=$yt_resp->get_error_message(); $yt_error['timestamp']=strtotime("now"); if (!empty($apiTestKey)) { return $yt_error; } } else { $yt_resp_array = (array) json_decode(wp_remote_retrieve_body($yt_resp),true); if(is_array($yt_resp_array)) { // extract relevant data // v3 if (in_array(wp_remote_retrieve_response_code($yt_resp),array(400,403,404))) { $yt_error['code']=wp_remote_retrieve_response_code($yt_resp); $yt_error['reason']=$yt_resp_array['error']['errors'][0]['reason']; $yt_error['timestamp']=strtotime("now"); if (empty($apiTestKey)) { update_option("lyte_api_error",json_encode($yt_error)); } else { return $yt_error; } } else { if ($playlist) { $_thisLyte['title']="Playlist: ".esc_attr(sanitize_text_field(@$yt_resp_array['items'][0]['snippet']['title'])); $_thisLyte['thumbUrl']=esc_url(@$yt_resp_array['items'][0]['snippet']['thumbnails']['high']['url']); $_thisLyte['HQthumbUrl']=esc_url(@$yt_resp_array['items'][0]['snippet']['thumbnails']['maxres']['url']); $_thisLyte['dateField']=sanitize_text_field(@$yt_resp_array['items'][0]['snippet']['publishedAt']); $_thisLyte['duration']=""; $_thisLyte['description']=esc_attr(sanitize_text_field(@$yt_resp_array['items'][0]['snippet']['description'])); $_thisLyte['captions_data']="false"; $_thisLyte['captions_timestamp'] = ""; } else { $_thisLyte['title']=esc_attr(sanitize_text_field(@$yt_resp_array['items'][0]['snippet']['title'])); $_thisLyte['thumbUrl']=esc_url(@$yt_resp_array['items'][0]['snippet']['thumbnails']['high']['url']); $_thisLyte['HQthumbUrl']=esc_url(@$yt_resp_array['items'][0]['snippet']['thumbnails']['maxres']['url']); $_thisLyte['dateField']=sanitize_text_field(@$yt_resp_array['items'][0]['snippet']['publishedAt']); $_thisLyte['duration']=sanitize_text_field(@$yt_resp_array['items'][0]['contentDetails']['duration']); $_thisLyte['description']=esc_attr(sanitize_text_field(@$yt_resp_array['items'][0]['snippet']['description'])); $_thisLyte['captions_data']=sanitize_text_field(@$yt_resp_array['items'][0]['contentDetails']['caption']); $_thisLyte['captions_timestamp'] = strtotime("now"); } } // try to cache the result if ( (($postID) || ($isWidget)) && !empty($_thisLyte) && empty($apiTestKey) ) { $_thisLyte['lyte_date_added']=time(); if ( $postID && !$isWidget ) { $yt_resp_precache=json_encode($_thisLyte); // then gzip + base64 (to limit amount of data + solve problems with wordpress removing slashes) $yt_resp_precache=base64_encode(gzcompress($yt_resp_precache)); // and do the actual caching $toCache = ( $yt_resp_precache ) ? $yt_resp_precache : '{{unknown}}'; update_post_meta( $postID, $cachekey, $toCache ); // and finally add new cache-entry to toCache_index which will be added to lyte_cache_index pref $toCache_index[]=$cachekey; } else if ($isWidget) { $widget_cache[$vid]=$_thisLyte; update_option("lyte_widget_cache",base64_encode(gzcompress(json_encode($widget_cache)))); } } } } } foreach (array("title","thumbUrl","HQthumbUrl","dateField","duration","description","captions_data","captions_timestamp") as $key) { if (!array_key_exists($key,$_thisLyte)) { $_thisLyte[$key]=""; } } return $_thisLyte; } /* only add js/css once and only if needed */ function lyte_initer() { global $lynited; if (!$lynited) { $lynited=true; add_action('wp_footer', 'lyte_init'); } } /* actual initialization */ function lyte_init() { global $lyteSettings; $lyte_css = ".lyte-wrapper-audio div, .lyte-wrapper div {margin:0px; overflow:hidden;} .lyte,.lyMe{position:relative;padding-bottom:56.25%;height:0;overflow:hidden;background-color:#777;} .fourthree .lyMe, .fourthree .lyte {padding-bottom:75%;} .lidget{margin-bottom:5px;} .lidget .lyte, .widget .lyMe {padding-bottom:0!important;height:100%!important;} .lyte-wrapper-audio .lyte{height:38px!important;overflow:hidden;padding:0!important} .lyMe iframe, .lyte iframe,.lyte .pL{position:absolute !important;top:0;left:0;width:100%;height:100%!important;background:no-repeat scroll center #000;background-size:cover;cursor:pointer} .tC{left:0;position:absolute;top:0;width:100%} .tC{background-image:linear-gradient(to bottom,rgba(0,0,0,0.6),rgba(0,0,0,0))} .tT{color:#FFF;font-family:Roboto,sans-serif;font-size:16px;height:auto;text-align:left;padding:5px 10px 50px 10px} .play{background:no-repeat scroll 0 0 transparent;width:88px;height:63px;position:absolute;left:43%;left:calc(50% - 44px);left:-webkit-calc(50% - 44px);top:38%;top:calc(50% - 31px);top:-webkit-calc(50% - 31px);} .widget .play {top:30%;top:calc(45% - 31px);top:-webkit-calc(45% - 31px);transform:scale(0.6);-webkit-transform:scale(0.6);-ms-transform:scale(0.6);} .lyte:hover .play{background-position:0 -65px;} .lyte-audio .pL{max-height:38px!important} .lyte-audio iframe{height:438px!important} .ctrl{background:repeat scroll 0 -220px rgba(0,0,0,0.3);width:100%;height:40px;bottom:0px;left:0;position:absolute;} .lyte-wrapper .ctrl{display:none}.Lctrl{background:no-repeat scroll 0 -137px transparent;width:158px;height:40px;bottom:0;left:0;position:absolute} .Rctrl{background:no-repeat scroll -42px -179px transparent;width:117px;height:40px;bottom:0;right:0;position:absolute;padding-right:10px;}.lyte-audio .play{display:none}.lyte-audio .ctrl{background-color:rgba(0,0,0,1)}.hidden{display:none}"; // by default show lyte vid on mobile (requiring user clicking play two times) // but can be overruled by this filter // also "do lyte mobile" when option to cache thumbnails is on to ensure privacy (gdpr) $mobLyte = apply_filters( 'lyte_do_mobile', false ); if ( $mobLyte || get_option( 'lyte_local_thumb', 0 ) ) { $mobJS = "var mOs=null;"; } else { $mobJS = "var mOs=navigator.userAgent.match(/(iphone|ipad|ipod|android)/i);"; } /** API: filter hook to change css */ $lyte_css = apply_filters( 'lyte_css', $lyte_css); echo ""; echo ""; } /** override default wp_trim_excerpt to have lyte_parse remove the httpv-links */ function lyte_trim_excerpt($text) { global $post; $raw_excerpt = $text; if ( '' == $text ) { $text = get_the_content(''); $text = lyte_parse($text, true); $text = strip_shortcodes( $text ); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); $excerpt_length = apply_filters('excerpt_length', 55); $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]'); if (function_exists('wp_trim_words')) { $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); } else { $length = $excerpt_length*6; $text = substr( strip_tags(trim(preg_replace('/\s+/', ' ', $text))), 0, $length ); $text .= $excerpt_more; } } return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); } /** Lyte shortcode */ function shortcode_lyte($atts) { extract(shortcode_atts(array( "id" => '', "audio" => '', "playlist" => '', "start" => '', "showinfo" => '', "stepsize" => '', "hqthumb" => '', ), $atts)); $qs = ''; if ($audio) {$proto="httpa";} else {$proto="httpv";} if ($start !== '') { $qs .= "&start=".$start; } if ($showinfo === "false") { $qs .= "&showinfo=0"; } if ($hqthumb) { $qs .= "&hqThumb=1"; } if ($stepsize) { $qs .= "#stepSize=".$stepsize; } if ($playlist) {$action="playlist?list=";} else {$action="watch?v=";} return lyte_parse($proto.'://www.youtube.com/'.$action.$id.$qs); } /** update functions */ /** upgrade, so lyte should not be greedy */ function lyte_not_greedy() { update_option( "lyte_greedy", "0" ); } /** function to flush YT responses from cache */ function lyte_rm_cache() { // remove thumbnail cache if (get_option('lyte_local_thumb','0') === '1') { if ( ! defined( 'LYTE_CACHE_DIR' ) ) { define( 'LYTE_CACHE_CHILD_DIR', 'cache/lyteThumbs' ); define( 'LYTE_CACHE_DIR', WP_CONTENT_DIR .'/'. LYTE_CACHE_CHILD_DIR ); } array_map('unlink', glob(LYTE_CACHE_DIR . "/*")); } // and remove cached YT data from postmeta try { ini_set('max_execution_time',90); // give PHP some more time for this, post-meta can be sloooooow // cache in post_meta, for posts $lyte_posts = json_decode(get_option("lyte_cache_index"),true); $lyteCacheIterator = 0; $lytePurgeThreshold = 500; $returnCode = "OK"; if (is_array($lyte_posts)){ foreach ($lyte_posts as $postID => $lyte_post) { foreach ($lyte_post as $cachekey) { delete_post_meta($postID, $cachekey); } unset ($lyte_posts[$postID]); $lyteCacheIterator++; if ($lyteCacheIterator > ($lytePurgeThreshold-1)) { $returnCode = "PART"; break; } } update_option("lyte_cache_index",json_encode($lyte_posts)); } // and the widget cache which isn't in post_meta update_option('lyte_widget_cache',''); return $returnCode; } catch(Exception $e) { return $e->getMessage(); } } /** function to call from within themes */ /* use with e.g. : */ function lyte_preparse($videoId) { return lyte_parse('httpv://www.youtube.com/watch?v='.$videoId); } function lyte_add_action_link($links) { $links[]='' . __('Settings') . ''; return $links; } /** is_amp, but I shouldn't have to do this, should I? */ if (!function_exists("is_amp")) { function is_amp() { if ((strpos($_SERVER['REQUEST_URI'],'?amp')!==false) || (strpos($_SERVER['REQUEST_URI'],'/amp/')!==false)) { return true; } else { return false; } } } /** hooking it all up to wordpress */ if ( is_admin() ) { require_once(dirname(__FILE__).'/options.php'); add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'lyte_add_action_link' ); } else { add_filter('the_content', 'lyte_parse', 4); add_shortcode("lyte", "shortcode_lyte"); remove_filter('get_the_excerpt', 'wp_trim_excerpt'); add_filter('get_the_excerpt', 'lyte_trim_excerpt'); add_action('schedule_captions_lookup', 'captions_lookup', 1, 3); /** API: action hook to allow extra actions or filters to be added */ do_action("lyte_actionsfilters"); } ?>