Changeset 1207288
- Timestamp:
- 07/27/2015 08:30:16 AM (11 years ago)
- Location:
- yandexnews-feed-by-teplitsa/trunk
- Files:
-
- 4 edited
-
inc/feed.php (modified) (1 diff)
-
inc/tst-yandex-feed-core.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
-
tst-yandex-feed.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
yandexnews-feed-by-teplitsa/trunk/inc/feed.php
r1138436 r1207288 41 41 <?php endif;?> 42 42 <?php 43 $category_tax = apply_filters('layf_category_taxonomy', 'category', get_the_ID()); 44 $category = wp_get_object_terms(get_the_ID(), $category_tax); 45 if(count($category) > 1 && $category[0]->slug == 'uncategorized') 46 $category = $category[1]->name; 47 else 48 $category = $category ? reset($category)->name : '-'; 49 50 $category = apply_filters('layf_category', $category, get_the_ID()); 43 $category = La_Yandex_Feed_Core::get_proper_category(get_the_ID()); 51 44 if($category) :?> 52 45 <category><?php echo $category;?></category> -
yandexnews-feed-by-teplitsa/trunk/inc/tst-yandex-feed-core.php
r1182631 r1207288 12 12 add_action('template_redirect', array($this, 'custom_templates_redirect')); 13 13 add_action('parse_query', array($this, 'custom_request')); 14 add_filter( 'status_header', array($this, 'set_empty_feed_20ok_status'), 10, 2 ); 15 14 16 15 17 /* formatting */ … … 30 32 31 33 } 32 33 34 35 public function set_empty_feed_20ok_status($status_header, $header) { 36 global $wp_query; 37 $qv = get_query_var('yandex_feed'); 38 if('news' == $qv){ 39 if((int) $header == 404) { 40 return status_header( 200 ); 41 } 42 } 43 return $status_header; 44 } 45 34 46 /** instance */ 35 47 public static function get_instance(){ … … 146 158 147 159 } 148 160 149 161 public function custom_templates_redirect(){ 150 162 global $wp_query; … … 176 188 /** formatting */ 177 189 function full_text_formatting($text){ 190 191 $pattern = '\[(\[?)(embed|wp_caption|caption|gallery|playlist|audio|video)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)'; 192 $text = preg_replace_callback( "/$pattern/s", 'strip_shortcode_tag', $text ); 193 178 194 global $wp_query; 179 195 … … 186 202 $text = preg_replace('/\s\s+/', ' ', $text); 187 203 $text = preg_replace('/(\r|\n|\r\n){3,}/', '', $text); 204 205 188 206 189 207 return self::_valid_characters($text); … … 230 248 231 249 $enclosure = $matches = $res = array(); 250 $thumb_id = get_post_thumbnail_id($post->ID); 251 if(!empty($thumb_id)){ 252 $enclosure[0] = wp_get_attachment_url($thumb_id); 253 } 254 232 255 $out = do_shortcode($post->post_content); 233 256 //preg_match_all('!http://.+\.(?:jpe?g|png|gif)!Ui' , $out , $matches); 234 257 preg_match_all('!<img(.*)src(.*)=(.*)"(.*)"!U', $out, $matches); 235 258 236 237 if(!isset($matches[4]) || empty($matches)){ 238 $thumb_id = get_post_thumbnail_id($post->ID); 239 if(!empty($thumb_id)){ 240 $enclosure[0] = wp_get_attachment_url($thumb_id); 241 } 242 } 243 else { 244 $enclosure = $matches[4]; 259 if(isset($matches[4]) && !empty($matches)){ 260 $enclosure = array_merge($enclosure, $matches[4]); 245 261 } 246 262 … … 332 348 333 349 return $links; 350 } 351 352 static function get_proper_category($post_id) { 353 $terms = get_option('layf_filter_terms', ''); 354 $filter_tax = ''; 355 if(!empty($terms)){ 356 $filter_tax = $tax = get_option('layf_filter_taxonomy', 'category'); 357 $terms = array_map('intval', explode(',', $terms)); 358 $query->query_vars['tax_query'][] = array( 359 'taxonomy' => $tax, 360 'field' => 'id', 361 'terms' => $terms 362 ); 363 } 364 365 $category_tax = apply_filters('layf_category_taxonomy', 'category', $post_id); 366 $category = wp_get_object_terms($post_id, $category_tax); 367 368 $category_name = ''; 369 if($filter_tax && $filter_tax == $category_tax && is_array($category) && !empty($terms)) { 370 foreach($category as $cat) { 371 if(array_search($cat->term_id, $terms) !== false && $cat->slug != 'uncategorized') { 372 $category_name = $cat->name; 373 break; 374 } 375 } 376 } 377 378 if(empty($category_name)) { 379 if(count($category) > 1 && $category[0]->slug == 'uncategorized') 380 $category = $category[1]->name; 381 else 382 $category = $category ? reset($category)->name : '-'; 383 } 384 else { 385 $category = $category_name; 386 } 387 388 $category = apply_filters('layf_category', $category, get_the_ID()); 389 return $category; 334 390 } 335 391 -
yandexnews-feed-by-teplitsa/trunk/readme.txt
r1182631 r1207288 3 3 Tags: yandex,news,xml,rss,seo,Yandex.News 4 4 Requires at least: 3.9 5 Tested up to: 4.2. 25 Tested up to: 4.2.3 6 6 Stable tag: trunk 7 7 License: GPLv2 or later … … 105 105 == Changelog == 106 106 107 = 1.8.3 = 108 * Fix: Minor fixes and updates for feed content 109 107 110 = 1.8.2 = 108 111 * Fix: Minor fixes and updated for admin settings -
yandexnews-feed-by-teplitsa/trunk/tst-yandex-feed.php
r1182631 r1207288 3 3 Plugin Name: Yandex.News Feed by Teplitsa 4 4 Description: The plugin creates feed for Yandex.News service 5 Version: 1.8. 25 Version: 1.8.3 6 6 Author: Teplitsa 7 7 Author URI: http://te-st.ru/
Note: See TracChangeset
for help on using the changeset viewer.