Changeset 1266778
- Timestamp:
- 10/15/2015 05:58:42 PM (10 years ago)
- Location:
- yandexnews-feed-by-teplitsa/trunk
- Files:
-
- 4 edited
-
inc/feed.php (modified) (2 diffs)
-
inc/tst-yandex-feed-core.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
-
tst-yandex-feed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
yandexnews-feed-by-teplitsa/trunk/inc/feed.php
r1207288 r1266778 9 9 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?>'; 10 10 ?> 11 <rss xmlns:yandex="http://news.yandex.ru" xmlns:media 12 ="http://search.yahoo.com/mrss/" version="2.0"> 11 <rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" version="2.0"> 13 12 <channel> 14 13 <title><?php bloginfo_rss('name');?></title> … … 51 50 <enclosure url="<?php echo esc_url($img['url']);?>" type="<?php echo esc_attr($img['mime']);?>"/> 52 51 <?php endforeach; endif;?> 53 <?php //media group 54 $media = La_Yandex_Feed_Core::item_media(); 55 if(!empty($media)): foreach($media as $media_obj) : 52 <?php 53 $media = La_Yandex_Feed_Core::item_media(); 54 if(!empty($media)): 55 //media group 56 56 ?> 57 57 <media:group> 58 <?php foreach($media as $media_obj):?> 59 <media:content url="<?php echo esc_url($media_obj['url']);?>"> 58 60 <media:player url="<?php echo esc_url($media_obj['url']);?>" /> 59 61 <?php if(!empty($media_obj['thumb'])) { ?> 60 62 <media:thumbnail url="<?php echo esc_url($media_obj['thumb']);?>"/> 61 63 <?php }?> 64 </media:content> 65 <?php endforeach; ?> 62 66 </media:group> 67 <?php endif;?> 63 68 <?php 64 endforeach; endif;65 69 $related = La_Yandex_Feed_Core::item_related(); 66 70 if(!empty($related)): -
yandexnews-feed-by-teplitsa/trunk/inc/tst-yandex-feed-core.php
r1207288 r1266778 186 186 187 187 188 /** formatting */ 188 /** formatting */ 189 189 function full_text_formatting($text){ 190 190 … … 207 207 return self::_valid_characters($text); 208 208 } 209 209 210 210 static function _valid_characters($text) { 211 211 … … 253 253 } 254 254 255 $out = do_shortcode($post->post_content); 256 //preg_match_all('!http://.+\.(?:jpe?g|png|gif)!Ui' , $out , $matches); 257 preg_match_all('!<img(.*)src(.*)=(.*)"(.*)"!U', $out, $matches); 258 259 if(isset($matches[4]) && !empty($matches)){ 260 $enclosure = array_merge($enclosure, $matches[4]); 261 } 255 $out = do_shortcode($post->post_content); 256 if(preg_match('/youtube\.com/', $post->post_content) || preg_match('/youtu\.be/', $post->post_content)) { 257 preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', $post->post_content, $urls_match); 258 if($urls_match && count($urls_match) && $urls_match[0]) { 259 foreach($urls_match[0] as $url) { 260 $thumbnail_url = self::get_youtube_thumbnail_url($url); 261 if($thumbnail_url) { 262 $enclosure[] = $thumbnail_url; 263 } 264 } 265 } 266 } 267 else { 268 //preg_match_all('!http://.+\.(?:jpe?g|png|gif)!Ui' , $out , $matches); 269 preg_match_all('!<img(.*)src(.*)=(.*)"(.*)"!U', $out, $matches); 270 if(isset($matches[4]) && !empty($matches)){ 271 $enclosure = array_merge($enclosure, $matches[4]); 272 } 273 } 262 274 263 275 if(empty($enclosure)) … … 314 326 $return = array(); 315 327 if(!empty($res)){ foreach($res as $i => $url) { 316 $return[] = array('url' => $url, 'thumb' => ''); 328 $thumbnail_url = self::get_youtube_thumbnail_url($url); 329 $return[] = array('url' => $url, 'thumb' => $thumbnail_url); 317 330 }} 318 331 … … 388 401 $category = apply_filters('layf_category', $category, get_the_ID()); 389 402 return $category; 403 } 404 405 static function get_youtube_thumbnail_url($url) { 406 $ret = ''; 407 if(preg_match('/youtube\.com/', $url) || preg_match('/youtu\.be/', $url)) { 408 preg_match("#(?<=vi\/)[^&\n]+|(?<=v\/)[^&\n]+|(?<=user\/)[^&\n]+|(?<=embed\/)[^&\n]+|(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $url, $youtube_id_matches); 409 if($youtube_id_matches && count($youtube_id_matches)) { 410 $youtube_video_id = $youtube_id_matches[0]; 411 $ret = 'https://img.youtube.com/vi/' . $youtube_video_id . '/1.jpg'; 412 } 413 } 414 return $ret; 390 415 } 391 416 -
yandexnews-feed-by-teplitsa/trunk/readme.txt
r1207288 r1266778 3 3 Tags: yandex,news,xml,rss,seo,Yandex.News 4 4 Requires at least: 3.9 5 Tested up to: 4. 2.35 Tested up to: 4.3.1 6 6 Stable tag: trunk 7 7 License: GPLv2 or later … … 105 105 == Changelog == 106 106 107 = 1.8.4 = 108 * New: Youtube video thumbnails added 109 * Fix: media:group structure optimized 110 107 111 = 1.8.3 = 108 112 * Fix: Minor fixes and updates for feed content -
yandexnews-feed-by-teplitsa/trunk/tst-yandex-feed.php
r1207288 r1266778 3 3 Plugin Name: Yandex.News Feed by Teplitsa 4 4 Description: The plugin creates feed for Yandex.News service 5 Version: 1.8. 35 Version: 1.8.4 6 6 Author: Teplitsa 7 7 Author URI: http://te-st.ru/ … … 38 38 // Plugin version: 39 39 if( !defined('LAYF_VERSION') ) 40 define('LAYF_VERSION', '1.8. 2');40 define('LAYF_VERSION', '1.8.4'); 41 41 42 42 // Plugin DIR, with trailing slash:
Note: See TracChangeset
for help on using the changeset viewer.