WP YouTube Lyte - Version 1.2.2

Version Description

  • bugfix: apply sanitize_text_field to microdata description- and title-fields to escape e.g. quotes
  • bugfix: added CSS resets to better avoid CSS-conflicts with themes (as reported by longtime user FruityOaty)
  • bugfix: fallback for missing wp_trim_words function in wordpress < 3.3 (as reported by Armude)
  • bugfix: check if the data from cache/ youtube is valid before trying to extract info from it as reported by Collin
  • improvement: better support for RSS/ ATOM feeds as requested by drreen
  • added item in FAQ on how to force normal YouTube links to be parsed by WP YouTube Lyte as well
  • tested with WordPress 3.6 beta 1
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 WP YouTube Lyte
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

Files changed (2) hide show
  1. readme.txt +23 -3
  2. wp-youtube-lyte.php +39 -20
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: futtta
3
  Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio, playlist, youtube playlist, hd, performance, accessibility, sidebar, lazy load, responsive, microdata, videoobject
4
  Requires at least: 2.9
5
  Tested up to: 3.6
6
- Stable tag: 1.2.1
7
 
8
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
9
 
@@ -73,12 +73,23 @@ This was added as a beta feature in version 1.1.0; add ?enablejsapi=1 to the htt
73
  * Widgets are not responsive.
74
  * if the content div width gets to around 200 pixels, the LYTE UI will become garbled (YouTube requires the minimum embed width to be 200px as well).
75
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  = Any bugs/ issues should I know about? =
77
  * Although the widget is available in (very) small sizes, these do not display that great and might, in the near future, be disabled by YouTube as their Terms of Service state that the smallest available embedded player is 200X200 pixels. Use the deprecated smaller sizes at your own risk.
78
  * Having the same YouTube-video on one page can cause WP YouTube Lyte to malfunction (as the YouTube id is used as the div's id in the DOM, and DOM id's are supposed to be unique)
79
  * As youtube-nocookie.com does not serve the HTML5-player, WP YouTube Lyte uses the youtube.com domain (which provides less privacy), but as soon as youtube-nocookie.com serves HTML5-video, this will become the default domain for WP YouTube Lyte again.
80
  * When using the Firefox plugin Karma Blocker, the [video isn't visible when clicking "play", with a warning message being shown instead](http://blog.futtta.be/?p=7584). This is expected behavior and should be solved by tweaking Karma Blocker's configuration.
81
- * If you use a CDN and you are upgrading, you'll have to make sure to either flush the CDN cache or -if available- make sure it is set not to ignore the querystring parameters (e.g. "Treat Query Strings as a separate cacheable item" at MaxCDN/NetDNA) to avoid that an old version of lyte-min.js is loaded.
82
  * The translations have not been updated entirely for version 1.2.0, this will be included in 1.2.1. Help with translations is always welcome!
83
 
84
  = I found a bug/ I would like a feature to be added! =
@@ -91,8 +102,17 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
91
 
92
  == Changelog ==
93
 
 
 
 
 
 
 
 
 
 
94
  = 1.2.1 =
95
- * bugfix: if e.g. modernizr added "audio" as class to the html element, wp youtube lyte got confused, as reported by [Peco of dubtechnoblog.com](http://www.dubtechnoblog.com/) and [Delphuk](http://delphuk.ru/), thanks guys!
96
  * tested succesfully with WordPress 3.6 (development-version)
97
 
98
  = 1.2.0 =
3
  Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio, playlist, youtube playlist, hd, performance, accessibility, sidebar, lazy load, responsive, microdata, videoobject
4
  Requires at least: 2.9
5
  Tested up to: 3.6
6
+ Stable tag: 1.2.2
7
 
8
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
9
 
73
  * Widgets are not responsive.
74
  * if the content div width gets to around 200 pixels, the LYTE UI will become garbled (YouTube requires the minimum embed width to be 200px as well).
75
 
76
+ = Can I use WP YouTube Lyte on normal YouTube links? =
77
+ Sure, just add the following code-snippet in your theme's functions.php:
78
+
79
+ `
80
+ /** force wp youtube lyte on http://www.youtube.com url's as well */
81
+ add_filter('the_content', 'force_lyte_parse', 1);
82
+ function force_lyte_parse($content) {
83
+ $content=str_replace('http://www.youtube.com/watch?v=','httpv://www.youtube.com/watch?v=',$content);
84
+ return $content;
85
+ }
86
+ `
87
+
88
  = Any bugs/ issues should I know about? =
89
  * Although the widget is available in (very) small sizes, these do not display that great and might, in the near future, be disabled by YouTube as their Terms of Service state that the smallest available embedded player is 200X200 pixels. Use the deprecated smaller sizes at your own risk.
90
  * Having the same YouTube-video on one page can cause WP YouTube Lyte to malfunction (as the YouTube id is used as the div's id in the DOM, and DOM id's are supposed to be unique)
91
  * As youtube-nocookie.com does not serve the HTML5-player, WP YouTube Lyte uses the youtube.com domain (which provides less privacy), but as soon as youtube-nocookie.com serves HTML5-video, this will become the default domain for WP YouTube Lyte again.
92
  * When using the Firefox plugin Karma Blocker, the [video isn't visible when clicking "play", with a warning message being shown instead](http://blog.futtta.be/?p=7584). This is expected behavior and should be solved by tweaking Karma Blocker's configuration.
 
93
  * The translations have not been updated entirely for version 1.2.0, this will be included in 1.2.1. Help with translations is always welcome!
94
 
95
  = I found a bug/ I would like a feature to be added! =
102
 
103
  == Changelog ==
104
 
105
+ = 1.2.2 =
106
+ * bugfix: apply sanitize_text_field to microdata description- and title-fields to escape e.g. quotes
107
+ * bugfix: added CSS resets to better avoid CSS-conflicts with themes (as reported by longtime user [FruityOaty](http://fruityoaty.com/))
108
+ * bugfix: fallback for missing wp_trim_words function in wordpress < 3.3 (as reported by [Armude](http://www.armudepictures.es/))
109
+ * bugfix: check if the data from cache/ youtube is valid before trying to extract info from it [as reported by Collin](http://blog.futtta.be/2013/03/01/the-best-wp-youtube-lyte-to-date/#li-comment-39222)
110
+ * improvement: better support for RSS/ ATOM feeds [as requested by drreen](http://wordpress.org/support/topic/textlinks-around-embedded-video-in-rss-feed)
111
+ * added item in FAQ on how to force normal YouTube links to be parsed by WP YouTube Lyte as well
112
+ * tested with WordPress 3.6 beta 1
113
+
114
  = 1.2.1 =
115
+ * bugfix: if e.g. modernizr added "audio" as class to the html element, wp youtube lyte got confused. reported by [Peco of dubtechnoblog.com](http://www.dubtechnoblog.com/) and [Delphuk](http://delphuk.ru/)
116
  * tested succesfully with WordPress 3.6 (development-version)
117
 
118
  = 1.2.0 =
wp-youtube-lyte.php CHANGED
@@ -4,14 +4,14 @@ Plugin Name: WP YouTube Lyte
4
  Plugin URI: http://blog.futtta.be/wp-youtube-lyte/
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
- Version: 1.2.1
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
11
  */
12
 
13
  $debug=false;
14
- $lyte_version="1.2.1";
15
  $lyte_db_version=get_option('lyte_version','none');
16
 
17
  /** have we updated? */
@@ -77,6 +77,7 @@ function lyte_parse($the_content,$doExcerpt=false) {
77
  $char_codes = array('&#215;','&#8211;');
78
  $replacements = array("x", "--");
79
  $the_content=str_replace($char_codes, $replacements, $the_content);
 
80
 
81
  $hidefClass = ($lyteSettings['hidef']==="1") ? " hidef" : "";
82
 
@@ -207,18 +208,20 @@ function lyte_parse($the_content,$doExcerpt=false) {
207
 
208
  // first add timestamp
209
  $yt_resp_array=json_decode($yt_resp,true);
210
- $yt_resp_array['lyte_date_added']=time();
211
- $yt_resp_precache=json_encode($yt_resp_array);
 
212
 
213
- // then gzip + base64 (to limit amount of data + solve problems with wordpress removing slashes)
214
- $yt_resp_precache=base64_encode(gzcompress($yt_resp_precache));
215
 
216
- // and do the actual caching
217
- $toCache = ( $yt_resp_precache ) ? $yt_resp_precache : '{{unknown}}';
218
- update_post_meta( $postID, $cachekey, $toCache );
219
 
220
- // and finally add new cache-entry to toCache_index which will be added to lyte_cache_index pref
221
- $toCache_index[]=$cachekey;
 
222
  }
223
  }
224
  }
@@ -226,18 +229,20 @@ function lyte_parse($the_content,$doExcerpt=false) {
226
  // If there was a result from youtube or from cache, use it
227
  if ( $yt_resp ) {
228
  $yt_resp_array=json_decode($yt_resp,true);
229
- if ($plClass===" playlist") {
230
- $yt_title="Playlist: ".sanitize_text_field($yt_resp_array['feed']['title']['$t']);
 
231
  $thumbUrl=esc_url($yt_resp_array['feed']['media$group']['media$thumbnail'][2]['url']);
232
  $dateField=sanitize_text_field($yt_resp_array['feed']['updated']['$t']);
233
  $duration="";
234
  $description=$yt_title;
235
- } else {
236
- $yt_title=sanitize_text_field($yt_resp_array['entry']['title']['$t']);
237
  $thumbUrl=esc_url($lyteSettings['scheme']."://i.ytimg.com/vi/".$vid."/0.jpg");
238
  $dateField=sanitize_text_field($yt_resp_array['entry']['published']['$t']);
239
  $duration="T".sanitize_text_field($yt_resp_array['entry']['media$group']['yt$duration']['seconds'])."S";
240
- $description=sanitize_text_field($yt_resp_array['entry']['media$group']['media$description']['$t']);
 
241
  }
242
  }
243
 
@@ -249,7 +254,11 @@ function lyte_parse($the_content,$doExcerpt=false) {
249
 
250
  if ($doExcerpt) {
251
  $lytetemplate="";
252
- } elseif (($audio!==true)&&($plClass!==" playlist")&&($lyteSettings['microdata']==="1")) {
 
 
 
 
253
  $lytetemplate = $wrapper."<div class=\"lyMe".$audioClass.$hidefClass.$plClass.$qsaClass."\" id=\"WYL_".$vid."\" itemprop=\"video\" itemscope itemtype=\"http://schema.org/VideoObject\"><meta itemprop=\"duration\" content=\"".$duration."\" /><meta itemprop=\"thumbnailUrl\" content=\"".$thumbUrl."\" /><meta itemprop=\"embedURL\" content=\"http://www.youtube.com/embed/".$vid."\" /><meta itemprop=\"uploadDate\" content=\"".$dateField."\" /><div id=\"lyte_".$vid."\" data-src=\"".$thumbUrl."\" class=\"pL\"><div class=\"tC".$titleClass."\"><div class=\"tT\" itemprop=\"name\">".$yt_title."</div></div><div class=\"play\"></div><div class=\"ctrl\"><div class=\"Lctrl\"></div><div class=\"Rctrl\"></div></div></div>".$noscript."<meta itemprop=\"description\" content=\"".$description."\"></div></div>".$lytelinks_txt;
254
  } else {
255
  $lytetemplate = $wrapper."<div class=\"lyMe".$audioClass.$hidefClass.$plClass.$qsaClass."\" id=\"WYL_".$vid."\"><div id=\"lyte_".$vid."\" data-src=\"".$thumbUrl."\" class=\"pL\"><div class=\"tC".$titleClass."\"><div class=\"tT\">".$yt_title."</div></div><div class=\"play\"></div><div class=\"ctrl\"><div class=\"Lctrl\"></div><div class=\"Rctrl\"></div></div></div>".$noscript."</div></div>".$lytelinks_txt;
@@ -263,7 +272,10 @@ function lyte_parse($the_content,$doExcerpt=false) {
263
  $lyte_cache[$postID]=$toCache_index;
264
  update_option('lyte_cache_index',json_encode($lyte_cache));
265
  }
266
- lyte_initer();
 
 
 
267
  }
268
  return $the_content;
269
  }
@@ -280,13 +292,14 @@ function lyte_initer() {
280
  /* actual initialization */
281
  function lyte_init() {
282
  global $lyteSettings;
283
- echo "<script type=\"text/javascript\">var bU='".$lyteSettings['path']."';style = document.createElement('style');style.type = 'text/css';rules = document.createTextNode(\".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} .lyte iframe,.lyte .pL{position:absolute;top:0;left:0;width:100%;height:100%;background:no-repeat scroll center #000;background-size:cover;cursor:pointer} .tC{background-color:rgba(0,0,0,0.5);left:0;position:absolute;top:0;width:100%} .tT{color:#FFF;font-family:sans-serif;font-size:12px;height:auto;text-align:left;padding:5px 10px} .tT:hover{text-decoration:underline} .play{background:no-repeat scroll 0 0 transparent;width:90px;height:62px;position:absolute;left:43%;left:calc(50% - 45px);left:-webkit-calc(50% - 45px);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 -215px transparent;width:100%;height:40px;bottom:0;left:0;position:absolute} .Lctrl{background:no-repeat scroll 0 -132px transparent;width:158px;height:40px;bottom:0;left:0;position:absolute} .Rctrl{background:no-repeat scroll -42px -174px transparent;width:117px;height:40px;bottom:0;right:0;position:absolute} .lyte-audio .play,.lyte-audio .tC{display:none} .hidden{display:none}\" );if(style.styleSheet) { style.styleSheet.cssText = rules.nodeValue;} else {style.appendChild(rules);}document.getElementsByTagName('head')[0].appendChild(style);</script>";
284
  echo "<script type=\"text/javascript\" async=true src=\"".$lyteSettings['path'].$lyteSettings['file']."\"></script>";
285
  }
286
 
287
  /** override default wp_trim_excerpt to have lyte_parse remove the httpv-links */
288
  function lyte_trim_excerpt($text) {
289
  global $post;
 
290
  if ( '' == $text ) {
291
  $text = get_the_content('');
292
  $text = lyte_parse($text, true);
@@ -295,7 +308,13 @@ function lyte_trim_excerpt($text) {
295
  $text = str_replace(']]>', ']]&gt;', $text);
296
  $excerpt_length = apply_filters('excerpt_length', 55);
297
  $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
298
- $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
 
 
 
 
 
 
299
  }
300
  return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
301
  }
4
  Plugin URI: http://blog.futtta.be/wp-youtube-lyte/
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
+ Version: 1.2.2
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
11
  */
12
 
13
  $debug=false;
14
+ $lyte_version="1.2.2";
15
  $lyte_db_version=get_option('lyte_version','none');
16
 
17
  /** have we updated? */
77
  $char_codes = array('&#215;','&#8211;');
78
  $replacements = array("x", "--");
79
  $the_content=str_replace($char_codes, $replacements, $the_content);
80
+ $lyte_feed=is_feed();
81
 
82
  $hidefClass = ($lyteSettings['hidef']==="1") ? " hidef" : "";
83
 
208
 
209
  // first add timestamp
210
  $yt_resp_array=json_decode($yt_resp,true);
211
+ if(is_array($yt_resp_array)) {
212
+ $yt_resp_array['lyte_date_added']=time();
213
+ $yt_resp_precache=json_encode($yt_resp_array);
214
 
215
+ // then gzip + base64 (to limit amount of data + solve problems with wordpress removing slashes)
216
+ $yt_resp_precache=base64_encode(gzcompress($yt_resp_precache));
217
 
218
+ // and do the actual caching
219
+ $toCache = ( $yt_resp_precache ) ? $yt_resp_precache : '{{unknown}}';
220
+ update_post_meta( $postID, $cachekey, $toCache );
221
 
222
+ // and finally add new cache-entry to toCache_index which will be added to lyte_cache_index pref
223
+ $toCache_index[]=$cachekey;
224
+ }
225
  }
226
  }
227
  }
229
  // If there was a result from youtube or from cache, use it
230
  if ( $yt_resp ) {
231
  $yt_resp_array=json_decode($yt_resp,true);
232
+ if (is_array($yt_resp_array)) {
233
+ if ($plClass===" playlist") {
234
+ $yt_title="Playlist: ".esc_attr(sanitize_text_field($yt_resp_array['feed']['title']['$t']));
235
  $thumbUrl=esc_url($yt_resp_array['feed']['media$group']['media$thumbnail'][2]['url']);
236
  $dateField=sanitize_text_field($yt_resp_array['feed']['updated']['$t']);
237
  $duration="";
238
  $description=$yt_title;
239
+ } else {
240
+ $yt_title=esc_attr(sanitize_text_field($yt_resp_array['entry']['title']['$t']));
241
  $thumbUrl=esc_url($lyteSettings['scheme']."://i.ytimg.com/vi/".$vid."/0.jpg");
242
  $dateField=sanitize_text_field($yt_resp_array['entry']['published']['$t']);
243
  $duration="T".sanitize_text_field($yt_resp_array['entry']['media$group']['yt$duration']['seconds'])."S";
244
+ $description=esc_attr(sanitize_text_field($yt_resp_array['entry']['media$group']['media$description']['$t']));
245
+ }
246
  }
247
  }
248
 
254
 
255
  if ($doExcerpt) {
256
  $lytetemplate="";
257
+ } elseif ($lyte_feed) {
258
+ $postURL = get_permalink( $postID );
259
+ $textLink = ($lyteSettings['links']===0)? "" : "<br />".strip_tags($lytelinks_txt, '<a>')."<br />";
260
+ $lytetemplate = "<a href=\"".$postURL."\"><img src=\"".$lyteSettings['scheme']."://i.ytimg.com/vi/".$vid."/0.jpg\" alt=\"YouTube Video\"></a>".$textLink;
261
+ } elseif (($audio !== true) && ( $plClass !== " playlist") && ($lyteSettings['microdata'] === "1")) {
262
  $lytetemplate = $wrapper."<div class=\"lyMe".$audioClass.$hidefClass.$plClass.$qsaClass."\" id=\"WYL_".$vid."\" itemprop=\"video\" itemscope itemtype=\"http://schema.org/VideoObject\"><meta itemprop=\"duration\" content=\"".$duration."\" /><meta itemprop=\"thumbnailUrl\" content=\"".$thumbUrl."\" /><meta itemprop=\"embedURL\" content=\"http://www.youtube.com/embed/".$vid."\" /><meta itemprop=\"uploadDate\" content=\"".$dateField."\" /><div id=\"lyte_".$vid."\" data-src=\"".$thumbUrl."\" class=\"pL\"><div class=\"tC".$titleClass."\"><div class=\"tT\" itemprop=\"name\">".$yt_title."</div></div><div class=\"play\"></div><div class=\"ctrl\"><div class=\"Lctrl\"></div><div class=\"Rctrl\"></div></div></div>".$noscript."<meta itemprop=\"description\" content=\"".$description."\"></div></div>".$lytelinks_txt;
263
  } else {
264
  $lytetemplate = $wrapper."<div class=\"lyMe".$audioClass.$hidefClass.$plClass.$qsaClass."\" id=\"WYL_".$vid."\"><div id=\"lyte_".$vid."\" data-src=\"".$thumbUrl."\" class=\"pL\"><div class=\"tC".$titleClass."\"><div class=\"tT\">".$yt_title."</div></div><div class=\"play\"></div><div class=\"ctrl\"><div class=\"Lctrl\"></div><div class=\"Rctrl\"></div></div></div>".$noscript."</div></div>".$lytelinks_txt;
272
  $lyte_cache[$postID]=$toCache_index;
273
  update_option('lyte_cache_index',json_encode($lyte_cache));
274
  }
275
+
276
+ if (!$lyte_feed) {
277
+ lyte_initer();
278
+ }
279
  }
280
  return $the_content;
281
  }
292
  /* actual initialization */
293
  function lyte_init() {
294
  global $lyteSettings;
295
+ echo "<script type=\"text/javascript\">var bU='".$lyteSettings['path']."';style = document.createElement('style');style.type = 'text/css';rules = document.createTextNode(\".lyte-wrapper-audio div, .lyte-wrapper div {margin:0px !important; 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} .lyte iframe,.lyte .pL{position:absolute;top:0;left:0;width:100%;height:100%;background:no-repeat scroll center #000;background-size:cover;cursor:pointer} .tC{background-color:rgba(0,0,0,0.5);left:0;position:absolute;top:0;width:100%} .tT{color:#FFF;font-family:sans-serif;font-size:12px;height:auto;text-align:left;padding:5px 10px} .tT:hover{text-decoration:underline} .play{background:no-repeat scroll 0 0 transparent;width:90px;height:62px;position:absolute;left:43%;left:calc(50% - 45px);left:-webkit-calc(50% - 45px);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 -215px transparent;width:100%;height:40px;bottom:0;left:0;position:absolute} .Lctrl{background:no-repeat scroll 0 -132px transparent;width:158px;height:40px;bottom:0;left:0;position:absolute} .Rctrl{background:no-repeat scroll -42px -174px transparent;width:117px;height:40px;bottom:0;right:0;position:absolute} .lyte-audio .play,.lyte-audio .tC{display:none} .hidden{display:none}\" );if(style.styleSheet) { style.styleSheet.cssText = rules.nodeValue;} else {style.appendChild(rules);}document.getElementsByTagName('head')[0].appendChild(style);</script>";
296
  echo "<script type=\"text/javascript\" async=true src=\"".$lyteSettings['path'].$lyteSettings['file']."\"></script>";
297
  }
298
 
299
  /** override default wp_trim_excerpt to have lyte_parse remove the httpv-links */
300
  function lyte_trim_excerpt($text) {
301
  global $post;
302
+ $raw_excerpt = $text;
303
  if ( '' == $text ) {
304
  $text = get_the_content('');
305
  $text = lyte_parse($text, true);
308
  $text = str_replace(']]>', ']]&gt;', $text);
309
  $excerpt_length = apply_filters('excerpt_length', 55);
310
  $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
311
+ if (function_exists('wp_trim_words')) {
312
+ $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
313
+ } else {
314
+ $length = $excerpt_length*6;
315
+ $text = substr( strip_tags(trim(preg_replace('/\s+/', ' ', $text))), 0, $length );
316
+ $text .= $excerpt_more;
317
+ }
318
  }
319
  return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
320
  }