Plugin Directory

Changeset 1138170


Ignore:
Timestamp:
04/18/2015 08:50:38 PM (11 years ago)
Author:
foralien
Message:

Version 1.8

  • New: Support for YouTube video embedded in the post content
  • News: Custom URL for the feed (with pretty permalinks active)
  • Fix: Image caption text stripped out from the translation context
Location:
yandexnews-feed-by-teplitsa/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • yandexnews-feed-by-teplitsa/trunk/inc/admin.php

    r1091243 r1138170  
    5858       
    5959        add_settings_field(
     60            'layf_custom_url',
     61            __('URL for feed', 'layf'),
     62            array($this, 'settngs_custom_url_callback'),
     63            'layf_settings',
     64            'layf_base'
     65        );
     66       
     67        add_settings_field(
    6068            'layf_post_types',
    6169            __('Post types for feed', 'layf'),
     
    102110        register_setting( 'layf_settings', 'layf_filter_taxonomy' );
    103111        register_setting( 'layf_settings', 'layf_filter_terms' );
    104        
     112        register_setting( 'layf_settings', 'layf_custom_url' );
    105113
    106114    }
    107    
     115       
    108116    function layf_settings_screen(){
    109117       
     
    125133    function layf_base_section_screen($args) {
    126134        //may be some description
     135    }
     136   
     137    function settngs_custom_url_callback() {
     138       
     139        $value = trailingslashit(get_option('layf_custom_url', 'yandex/news'));
     140        update_option('layf_permalinks_flushed', 0); //is it ok?
     141       
     142    ?>
     143        <label for="layf_custom_url">
     144            <?php echo home_url('/');?><input name="layf_custom_url" id="layf_custom_url" type="text" class="regular-text code" value="<?php echo $value;?>"> </label>
     145        <p class="description"><?php _e('Customoze the URL of the feed if needed', 'layf');?></p>
     146    <?php   
    127147    }
    128148 
  • yandexnews-feed-by-teplitsa/trunk/inc/feed.php

    r1091243 r1138170  
    5252<category><?php echo $category;?></category>
    5353<?php endif; ?>
    54 <?php
     54<?php //enclosures
    5555    $enclosure = La_Yandex_Feed_Core::item_enclosure();
    5656    if(!empty($enclosure)): foreach($enclosure as $i => $img):
     
    5858<enclosure url="<?php echo esc_url($img['url']);?>" type="<?php echo esc_attr($img['mime']);?>"/>
    5959<?php endforeach; endif;?>
     60<?php //media group
     61    $media = La_Yandex_Feed_Core::item_media();
     62    if(!empty($media)): foreach($media as $media_obj) :
     63?>
     64<media:group>
     65<media:content url=""/>
     66<media player url="<?php echo esc_url($media_obj['url']);?>"/>
     67<?php if(!empty($media_obj['thumb'])) { ?>
     68<media:thumbnail url="<?php echo esc_url($media_obj['thumb']);?>"/>
     69<?php }?>
     70</media:group>
    6071<?php
     72    endforeach; endif;
    6173    $related = La_Yandex_Feed_Core::item_related();
    6274    if(!empty($related)):
  • yandexnews-feed-by-teplitsa/trunk/inc/tst-yandex-feed-core.php

    r1068031 r1138170  
    8585       
    8686        $wp->add_query_var('yandex_feed');
     87        //deafult
    8788        add_rewrite_rule('^yandex/([^/]*)/?', 'index.php?yandex_feed=$matches[1]', 'top');
     89       
     90        //custom
     91        $slug = trailingslashit(get_option('layf_custom_url', 'yandex/news'));
     92        if($slug != 'yandex/news/'){
     93            add_rewrite_rule("^$slug?", 'index.php?yandex_feed=news', 'top');
     94        }
    8895       
    8996        if( !get_option('layf_permalinks_flushed') ) {
     
    202209   
    203210   
     211   
     212   
    204213    /** template helpers */
    205214    static function get_the_content_feed() {
     
    207216        $post = get_post();     
    208217        $content = str_replace(']]>', ']]&gt;', $post->post_content);
     218       
     219        add_filter('img_caption_shortcode', 'layf_filter_image_caption', 20, 3); //filter caption text
     220        add_filter( 'layf_content_feed', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 ); //embed media to HTML
    209221       
    210222        add_filter( 'layf_content_feed', 'wptexturize'        );
     
    216228               
    217229       
    218         return apply_filters('layf_content_feed', $content);   
    219        
    220     }
    221    
    222     static function item_enclosure(){
     230        return apply_filters('layf_content_feed', $content);       
     231    }
     232   
     233   
     234    /* @to-do: add support for support video files */
     235    static function item_enclosure(){
    223236        global $post;
    224237       
     
    269282       
    270283        return $mime;
     284    }
     285   
     286   
     287    /* videos */
     288    static function item_media(){
     289        global $post;
     290       
     291        $matches = $res = array();
     292        //include shorcodes and oembeds
     293        $out = do_shortcode($post->post_content);
     294        $out = $GLOBALS['wp_embed']->autoembed($out);
     295           
     296        //youtube
     297        $youtube_regexp = "/(?:http(?:s)?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([\w-]{10,12})/";
     298        preg_match_all($youtube_regexp, $out, $matches);       
     299        if(isset($matches[0]) && !empty($matches[0]))
     300            $res = array_merge($res, $matches[0]); //append links
     301       
     302        //@to_do: add another video providers
     303       
     304        //modify $res to be able add thumbnails
     305        $return = array();
     306        if(!empty($res)){ foreach($res as $i => $url) {
     307            $return[] = array('url' => $url, 'thumb' => '');
     308        }}
     309       
     310        return apply_filters('layf_video_embeds', $return, $post->ID);
    271311    }
    272312   
     
    565605}
    566606
     607
     608function layf_filter_image_caption($out, $attr, $content) {
     609       
     610    return $content;           
     611}
    567612?>
  • yandexnews-feed-by-teplitsa/trunk/readme.md

    r1091243 r1138170  
    3131![](http://itv.te-st.ru/wp-content/uploads/screen-2.png)
    3232
    33 Трансляция (фид) доступна для просмотра по ссылке _domain.ru/yandex/news/_. Пример выдачи
     33Трансляция (фид) доступна для просмотра по ссылке _domain.ru/yandex/news/_. В настройках может быть указан собственный адрес, которые работает при активных "красивых пермалинках". Пример выдачи
    3434![](http://itv.te-st.ru/wp-content/uploads/screen-1.png)
    3535
     
    8080After installing the plugin settings are available under menu _Settings -> Yandex.Novosti_.
    8181
    82 Feed is accessible at the link _domain.ru/yandex/news/_.
     82Feed is accessible at the link _domain.ru/yandex/news/_. A custom URL could be specify through Settings page in case of active "pretty permalinks".
    8383
    8484The plugin has the minimum of settings. Read more about it's usage at the developers' website:
  • yandexnews-feed-by-teplitsa/trunk/readme.txt

    r1091243 r1138170  
    33Tags: yandex,news,xml,rss,seo
    44Requires at least: 3.9
    5 Tested up to: 4.1
     5Tested up to: 4.1.1
    66Stable tag: trunk
    77License: GPLv2 or later
     
    3232После установки настройки плагина доступны через меню _Настройки -> Яндекс.Новости_.
    3333
    34 Трансляция (фид) доступна для просмотра по ссылке _domain.ru/yandex/news/_.
     34Трансляция (фид) доступна для просмотра по ссылке _domain.ru/yandex/news/_. В настройках может быть указан собственный адрес, которые работает при активных "красивых пермалинках".
    3535
    3636Плагин имеет минимум необходимых настроек. Подробнее о его использовании можно узнать на сайте разработчиков:
     
    7272After installing the plugin settings are available under menu _Settings -> Yandex.Novosti_.
    7373
    74 Feed is accessible at the link _domain.ru/yandex/news/_.
     74Feed is accessible at the link _domain.ru/yandex/news/_. A custom URL could be specify through Settings page in case of active "pretty permalinks".
    7575
    7676The plugin has the minimum of settings. Read more about it's usage at the developers' website:
     
    105105== Changelog ==
    106106
     107= 1.8 =
     108* New: Support for YouTube video embedded in the post content
     109* News: Custom URL for the feed (with pretty permalinks active)
     110* Fix: Image caption text stripped out from the translation context
     111
    107112= 1.7 =
    108113* New: Added support for new Yandex square logo format update
  • yandexnews-feed-by-teplitsa/trunk/tst-yandex-feed.php

    r1091243 r1138170  
    33Plugin Name: Yandex.News Feed by Teplitsa
    44Description: The plugin creates feed for Yandex.News service
    5 Version: 1.7
     5Version: 1.8
    66Author: Teplitsa
    77Author URI: http://te-st.ru/
Note: See TracChangeset for help on using the changeset viewer.