| @@ -32,10 +32,10 @@ | ||
| 32 | 32 | # |
| 33 | 33 | # Values of keys in link_notes are accessible from templates using |
| 34 | 34 | # the function `get_feed_meta($key)` if this plugin is activated. |
| 35 | 35 | |
| 36 | -require_once dirname( __FILE__ ) . '/magpiefromsimplepie.class.php'; | |
| 37 | -require_once dirname( __FILE__ ) . '/feedwordpressparsedpostmeta.class.php'; | |
| 36 | +require_once(dirname(__FILE__).'/magpiefromsimplepie.class.php'); | |
| 37 | +require_once(dirname(__FILE__).'/feedwordpressparsedpostmeta.class.php'); | |
| 38 | 38 | |
| 39 | 39 | class SyndicatedLink { |
| 40 | 40 | var $id = null; |
| 41 | 41 | var $link = null; |
| @@ -43,8 +43,10 @@ | ||
| 43 | 43 | public $simplepie = null; |
| 44 | 44 | var $magpie = null; |
| 45 | 45 | |
| 46 | 46 | public function __construct( $link ) { |
| 47 | + global $wpdb; | |
| 48 | + | |
| 47 | 49 | if (is_object($link)) : |
| 48 | 50 | $this->link = $link; |
| 49 | 51 | $this->id = $link->link_id; |
| 50 | 52 | else : |
| @@ -76,11 +78,11 @@ | ||
| 76 | 78 | if ($this->setting('update/hold')=='ping') : |
| 77 | 79 | $stale = false; // don't update on any timed updates; pings only |
| 78 | 80 | elseif ($this->setting('update/hold')=='next') : |
| 79 | 81 | $stale = true; // update on the next timed update |
| 80 | - elseif ( ! $this->setting('update/last') ) : | |
| 82 | + elseif ( !$this->setting('update/last') ) : | |
| 81 | 83 | $stale = true; // initial update |
| 82 | - elseif ( !empty($feedwordpress) and $feedwordpress->force_update_all()) : | |
| 84 | + elseif ($feedwordpress->force_update_all()) : | |
| 83 | 85 | $stale = true; // forced general updating |
| 84 | 86 | else : |
| 85 | 87 | $after = ( |
| 86 | 88 | (int) $this->setting('update/last') |
| @@ -107,11 +109,11 @@ | ||
| 107 | 109 | else : |
| 108 | 110 | $this->magpie = new MagpieFromSimplePie($this->simplepie, NULL); |
| 109 | 111 | endif; |
| 110 | 112 | } /* SyndicatedLink::fetch () */ |
| 111 | - | |
| 113 | + | |
| 112 | 114 | public function live_posts () { |
| 113 | - if ( !is_object($this->simplepie)) : | |
| 115 | + if (!is_object($this->simplepie)) : | |
| 114 | 116 | $this->fetch(); |
| 115 | 117 | endif; |
| 116 | 118 | |
| 117 | 119 | if (is_object($this->simplepie) and method_exists($this->simplepie, 'get_items')) : |
| @@ -125,20 +127,16 @@ | ||
| 125 | 127 | endif; |
| 126 | 128 | return $ret; |
| 127 | 129 | } /* SyndicatedLink::live_posts () */ |
| 128 | 130 | |
| 129 | - protected function pause_updates () { | |
| 130 | - return ('yes'==$this->setting("update/pause", "update_pause", 'no')); | |
| 131 | - } /* SyndicatedLink::pause_updates () */ | |
| 132 | - | |
| 133 | 131 | public function poll ($crash_ts = NULL) { |
| 134 | 132 | global $wpdb; |
| 135 | 133 | |
| 136 | 134 | $url = $this->uri(array('add_params' => true, 'fetch' => true)); |
| 137 | 135 | FeedWordPress::diagnostic('updated_feeds', 'Polling feed ['.$url.']'); |
| 138 | - | |
| 136 | + | |
| 139 | 137 | $this->fetch(); |
| 140 | - | |
| 138 | + | |
| 141 | 139 | $new_count = NULL; |
| 142 | 140 | |
| 143 | 141 | $resume = ('yes'==$this->setting('update/unfinished')); |
| 144 | 142 | if ($resume) : |
| @@ -161,9 +159,9 @@ | ||
| 161 | 159 | if (is_string($oldError)) : |
| 162 | 160 | $oldError = unserialize($oldError); |
| 163 | 161 | endif; |
| 164 | 162 | |
| 165 | - if ( !is_null($oldError)) : | |
| 163 | + if (!is_null($oldError)) : | |
| 166 | 164 | // Copy over the in-error-since timestamp |
| 167 | 165 | $theError['since'] = $oldError['since']; |
| 168 | 166 | |
| 169 | 167 | // If this is a repeat error, then we should |
| @@ -172,9 +170,9 @@ | ||
| 172 | 170 | $this->update_setting('update/last', time(), NULL); |
| 173 | 171 | $ttl = $this->automatic_ttl(); |
| 174 | 172 | $ttl = apply_filters('syndicated_feed_ttl', $ttl, $this); |
| 175 | 173 | $ttl = apply_filters('syndicated_feed_ttl_from_error', $ttl, $this); |
| 176 | - $this->update_setting('update/ttl', $ttl); | |
| 174 | + $this->update_setting('update/ttl', $ttl, $this); | |
| 177 | 175 | $this->update_setting('update/timed', 'automatically'); |
| 178 | 176 | endif; |
| 179 | 177 | |
| 180 | 178 | do_action('syndicated_feed_error', $theError, $oldError, $this); |
| @@ -186,27 +184,27 @@ | ||
| 186 | 184 | |
| 187 | 185 | // Success; clear out error setting, if any. |
| 188 | 186 | $this->update_setting('update/error', NULL); |
| 189 | 187 | |
| 190 | - $new_count = array('new' => 0, 'updated' => 0, 'stored' => 0); | |
| 188 | + $new_count = array('new' => 0, 'updated' => 0); | |
| 191 | 189 | |
| 192 | 190 | # -- Update Link metadata live from feed |
| 193 | 191 | $channel = $this->magpie->channel; |
| 194 | 192 | |
| 195 | - if ( !isset($channel['id'])) : | |
| 193 | + if (!isset($channel['id'])) : | |
| 196 | 194 | $channel['id'] = $this->link->link_rss; |
| 197 | 195 | endif; |
| 198 | 196 | |
| 199 | 197 | $update = array(); |
| 200 | - if ( ! $this->hardcode('url') and isset($channel['link'])) : | |
| 198 | + if (!$this->hardcode('url') and isset($channel['link'])) : | |
| 201 | 199 | $update[] = "link_url = '".esc_sql($channel['link'])."'"; |
| 202 | 200 | endif; |
| 203 | 201 | |
| 204 | - if ( ! $this->hardcode('name') and isset($channel['title'])) : | |
| 202 | + if (!$this->hardcode('name') and isset($channel['title'])) : | |
| 205 | 203 | $update[] = "link_name = '".esc_sql($channel['title'])."'"; |
| 206 | 204 | endif; |
| 207 | 205 | |
| 208 | - if ( ! $this->hardcode('description')) : | |
| 206 | + if (!$this->hardcode('description')) : | |
| 209 | 207 | if (isset($channel['tagline'])) : |
| 210 | 208 | $update[] = "link_description = '".esc_sql($channel['tagline'])."'"; |
| 211 | 209 | elseif (isset($channel['description'])) : |
| 212 | 210 | $update[] = "link_description = '".esc_sql($channel['description'])."'"; |
| @@ -212,16 +210,31 @@ | ||
| 212 | 210 | $update[] = "link_description = '".esc_sql($channel['description'])."'"; |
| 213 | 211 | endif; |
| 214 | 212 | endif; |
| 215 | 213 | |
| 216 | - $this->update_setting('link/feed_type', $this->simplepie->get_type()); | |
| 217 | - | |
| 218 | 214 | $this->merge_settings($channel, 'feed/'); |
| 219 | 215 | |
| 220 | 216 | $this->update_setting('update/last', time()); |
| 221 | - $this->do_update_ttl(); | |
| 217 | + list($ttl, $xml) = $this->ttl(/*return element=*/ true); | |
| 222 | 218 | |
| 223 | - if ( ! $this->setting('update/hold') != 'ping') : | |
| 219 | + if (!is_null($ttl)) : | |
| 220 | + $this->update_setting('update/ttl', $ttl); | |
| 221 | + $this->update_setting('update/xml', $xml); | |
| 222 | + $this->update_setting('update/timed', 'feed'); | |
| 223 | + else : | |
| 224 | + $ttl = $this->automatic_ttl(); | |
| 225 | + $this->update_setting('update/ttl', $ttl); | |
| 226 | + $this->update_setting('update/xml', NULL); | |
| 227 | + $this->update_setting('update/timed', 'automatically'); | |
| 228 | + endif; | |
| 229 | + $this->update_setting('update/fudge', rand(0, ($ttl/3))*60); | |
| 230 | + $this->update_setting('update/ttl', apply_filters( | |
| 231 | + 'syndicated_feed_ttl', | |
| 232 | + $this->setting('update/ttl'), | |
| 233 | + $this | |
| 234 | + )); | |
| 235 | + | |
| 236 | + if (!$this->setting('update/hold') != 'ping') : | |
| 224 | 237 | $this->update_setting('update/hold', 'scheduled'); |
| 225 | 238 | endif; |
| 226 | 239 | |
| 227 | 240 | $this->update_setting('update/unfinished', 'yes'); |
| @@ -241,9 +254,9 @@ | ||
| 241 | 254 | # -- Add new posts from feed and update any updated posts |
| 242 | 255 | $crashed = false; |
| 243 | 256 | |
| 244 | 257 | $posts = $this->live_posts(); |
| 245 | - | |
| 258 | + | |
| 246 | 259 | $this->magpie->originals = $posts; |
| 247 | 260 | |
| 248 | 261 | // If this is a complete feed, rather than an incremental feed, we |
| 249 | 262 | // need to prepare to mark everything for presumptive retirement. |
| @@ -261,26 +274,25 @@ | ||
| 261 | 274 | endif; |
| 262 | 275 | |
| 263 | 276 | if (is_array($posts)) : |
| 264 | 277 | foreach ($posts as $key => $item) : |
| 265 | - if ( ! $this->pause_updates()) : | |
| 266 | - $post = new SyndicatedPost($item, $this); | |
| 278 | + $post = new SyndicatedPost($item, $this); | |
| 267 | 279 | |
| 268 | - if ( ! $resume or !in_array(trim($post->guid()), $processed)) : | |
| 269 | - $processed[] = $post->guid(); | |
| 270 | - if ( ! $post->filtered()) : | |
| 271 | - $new = $post->store(); | |
| 272 | - if ( $new !== false ) $new_count[$new]++; | |
| 273 | - endif; | |
| 280 | + if (!$resume or !in_array(trim($post->guid()), $processed)) : | |
| 281 | + $processed[] = $post->guid(); | |
| 282 | + if (!$post->filtered()) : | |
| 283 | + $new = $post->store(); | |
| 284 | + if ( $new !== false ) $new_count[$new]++; | |
| 285 | + endif; | |
| 274 | 286 | |
| 275 | - if ( !is_null($crash_ts) and (time() > $crash_ts)) : | |
| 276 | - $crashed = true; | |
| 277 | - break; | |
| 278 | - endif; | |
| 287 | + if (!is_null($crash_ts) and (time() > $crash_ts)) : | |
| 288 | + $crashed = true; | |
| 289 | + break; | |
| 279 | 290 | endif; |
| 291 | + endif; | |
| 280 | 292 | |
| 281 | - unset($post); | |
| 282 | - endif; | |
| 293 | + unset($post); | |
| 294 | + | |
| 283 | 295 | endforeach; |
| 284 | 296 | endif; |
| 285 | 297 | |
| 286 | 298 | if ('yes'==$this->setting('tombstones', 'tombstones', 'yes')) : |
| @@ -286,9 +298,9 @@ | ||
| 286 | 298 | if ('yes'==$this->setting('tombstones', 'tombstones', 'yes')) : |
| 287 | 299 | // Check for use of Atom tombstones. Spec: |
| 288 | 300 | // <http://tools.ietf.org/html/draft-snell-atompub-tombstones-18> |
| 289 | 301 | $tombstones = $this->simplepie->get_feed_tags('http://purl.org/atompub/tombstones/1.0', 'deleted-entry'); |
| 290 | - if ( !is_null($tombstones) && count($tombstones) > 0) : | |
| 302 | + if (count($tombstones) > 0) : | |
| 291 | 303 | foreach ($tombstones as $tombstone) : |
| 292 | 304 | $ref = NULL; |
| 293 | 305 | foreach (array('', 'http://purl.org/atompub/tombstones/1.0') as $ns) : |
| 294 | 306 | if (isset($tombstone['attribs'][$ns]) |
| @@ -316,12 +328,12 @@ | ||
| 316 | 328 | endif; |
| 317 | 329 | |
| 318 | 330 | $suffix = ($crashed ? 'crashed' : 'completed'); |
| 319 | 331 | do_action('update_syndicated_feed_items', $this->id, $this); |
| 320 | - do_action("update_syndicated_feed_items_{$suffix}", $this->id, $this); | |
| 332 | + do_action("update_syndicated_feed_items_${suffix}", $this->id, $this); | |
| 321 | 333 | |
| 322 | 334 | $this->update_setting('update/processed', $processed); |
| 323 | - if ( ! $crashed) : | |
| 335 | + if (!$crashed) : | |
| 324 | 336 | $this->update_setting('update/unfinished', 'no'); |
| 325 | 337 | endif; |
| 326 | 338 | $this->update_setting('link/item count', count($posts)); |
| 327 | 339 | |
| @@ -326,22 +338,16 @@ | ||
| 326 | 338 | $this->update_setting('link/item count', count($posts)); |
| 327 | 339 | |
| 328 | 340 | // Copy back any changes to feed settings made in the |
| 329 | 341 | // course of updating (e.g. new author rules) |
| 330 | - $update_set = "link_notes = '" . esc_sql($this->settings_to_notes())."'"; | |
| 342 | + $update_set = "link_notes = '".esc_sql($this->settings_to_notes())."'"; | |
| 331 | 343 | |
| 332 | 344 | // Update the properties of the link from the feed information |
| 333 | 345 | $result = $wpdb->query(" |
| 334 | - UPDATE {$wpdb->links} | |
| 335 | - SET {$update_set} | |
| 336 | - WHERE link_id='{$this->id}' | |
| 346 | + UPDATE $wpdb->links | |
| 347 | + SET $update_set | |
| 348 | + WHERE link_id='$this->id' | |
| 337 | 349 | "); |
| 338 | - if ( FALSE === $result ) : | |
| 339 | - FeedWordPress::diagnostic( | |
| 340 | - 'SyndicatedLink/poll', | |
| 341 | - 'Database update failed', | |
| 342 | - ); | |
| 343 | - endif; | |
| 344 | 350 | |
| 345 | 351 | do_action("update_syndicated_feed_completed", $this->id, $this); |
| 346 | 352 | endif; |
| 347 | 353 | |
| @@ -357,43 +363,11 @@ | ||
| 357 | 363 | |
| 358 | 364 | return $new_count; |
| 359 | 365 | } /* SyndicatedLink::poll() */ |
| 360 | 366 | |
| 361 | - /** | |
| 362 | - * Update the time to live of this link. | |
| 363 | - */ | |
| 364 | - public function do_update_ttl(): void { | |
| 365 | - // Get ttl and xml elements, return them if available | |
| 366 | - list( $ttl, $xml ) = $this->ttl( /*return element=*/ true); | |
| 367 | + public function process_retirements ($delta) { | |
| 368 | + global $post; | |
| 367 | 369 | |
| 368 | - // Check if ttl is not null | |
| 369 | - if ( !is_null( $ttl ) ) { | |
| 370 | - $this->update_setting( 'update/ttl', $ttl ); | |
| 371 | - $this->update_setting( 'update/xml', $xml ); | |
| 372 | - $this->update_setting( 'update/timed', 'feed' ); | |
| 373 | - } else { | |
| 374 | - // Fallback to automatic ttl if null | |
| 375 | - $ttl = $this->automatic_ttl(); | |
| 376 | - $this->update_setting( 'update/ttl', $ttl ); | |
| 377 | - $this->update_setting( 'update/xml', null ); // Explicit null | |
| 378 | - $this->update_setting( 'update/timed', 'automatically' ); | |
| 379 | - } | |
| 380 | - | |
| 381 | - // Adding a random fudge value (ensure it works across versions) | |
| 382 | - $this->update_setting( 'update/fudge', rand( 0, (int) ( $ttl / 3 ) ) * 60 ); | |
| 383 | - | |
| 384 | - // Apply filter to ttl (should be compatible with all PHP 8.x versions) | |
| 385 | - $this->update_setting( | |
| 386 | - 'update/ttl', | |
| 387 | - apply_filters( | |
| 388 | - 'syndicated_feed_ttl', | |
| 389 | - $this->setting( 'update/ttl' ), | |
| 390 | - $this | |
| 391 | - ) | |
| 392 | - ); | |
| 393 | - } /* SyndicatedLink::do_update_ttl () */ | |
| 394 | - | |
| 395 | - public function process_retirements ($delta) { | |
| 396 | 370 | $q = new WP_Query(array( |
| 397 | 371 | 'fields' => '_synfrom', |
| 398 | 372 | 'post_status__not' => 'fwpretired', |
| 399 | 373 | 'ignore_sticky_posts' => true, |
| @@ -537,9 +511,9 @@ | ||
| 537 | 511 | foreach ($notes as $note): |
| 538 | 512 | $pair = explode(": ", $note, 2); |
| 539 | 513 | $key = (isset($pair[0]) ? $pair[0] : null); |
| 540 | 514 | $value = (isset($pair[1]) ? $pair[1] : null); |
| 541 | - if ( !is_null($key) and !is_null($value)) : | |
| 515 | + if (!is_null($key) and !is_null($value)) : | |
| 542 | 516 | // Unescape and trim() off the whitespace. |
| 543 | 517 | // Thanks to Ray Lischner for pointing out the |
| 544 | 518 | // need to trim off whitespace. |
| 545 | 519 | $this->settings[$key] = stripcslashes (trim($value)); |
| @@ -568,9 +542,9 @@ | ||
| 568 | 542 | |
| 569 | 543 | // Set this up automagically for del.icio.us |
| 570 | 544 | $bits = parse_url($this->link->link_rss); |
| 571 | 545 | $tagspacers = array('del.icio.us', 'feeds.delicious.com'); |
| 572 | - if ( !isset($this->settings['cat_split']) and in_array($bits['host'], $tagspacers)) : | |
| 546 | + if (!isset($this->settings['cat_split']) and in_array($bits['host'], $tagspacers)) : | |
| 573 | 547 | $this->settings['cat_split'] = '\s'; // Whitespace separates multiple tags in del.icio.us RSS feeds |
| 574 | 548 | endif; |
| 575 | 549 | |
| 576 | 550 | // Simple lists |
| @@ -586,9 +560,9 @@ | ||
| 586 | 560 | if (isset($this->settings['terms'])) : |
| 587 | 561 | // Look for new format |
| 588 | 562 | $this->settings['terms'] = maybe_unserialize($this->settings['terms']); |
| 589 | 563 | |
| 590 | - if ( !is_array($this->settings['terms'])) : | |
| 564 | + if (!is_array($this->settings['terms'])) : | |
| 591 | 565 | // Deal with old format instead. Ugh. |
| 592 | 566 | |
| 593 | 567 | // Split on two *or more* consecutive breaks |
| 594 | 568 | // because in the old format, a taxonomy |
| @@ -617,10 +591,9 @@ | ||
| 617 | 591 | if (isset($this->settings['map authors'])) : |
| 618 | 592 | $author_rules = explode("\n\n", $this->settings['map authors']); |
| 619 | 593 | $ma = array(); |
| 620 | 594 | foreach ($author_rules as $rule) : |
| 621 | - $parts = array_pad(explode("\n", $rule), 3, ''); | |
| 622 | - list($rule_type, $author_name, $author_action) = $parts; | |
| 595 | + list($rule_type, $author_name, $author_action) = explode("\n", $rule); | |
| 623 | 596 | |
| 624 | 597 | // Normalize for case and whitespace |
| 625 | 598 | $rule_type = strtolower(trim($rule_type)); |
| 626 | 599 | $author_name = strtolower(trim($author_name)); |
| @@ -698,13 +671,8 @@ | ||
| 698 | 671 | SET $update_set |
| 699 | 672 | WHERE link_id='$this->id' |
| 700 | 673 | "); |
| 701 | 674 | |
| 702 | - if ( $result === false ) | |
| 703 | - { | |
| 704 | - error_log("query failed: " . $wpdb->last_error); | |
| 705 | - } | |
| 706 | - | |
| 707 | 675 | if ($reload) : |
| 708 | 676 | // force reload of link information from DB |
| 709 | 677 | if (function_exists('clean_bookmark_cache')) : |
| 710 | 678 | clean_bookmark_cache($this->id); |
| @@ -715,73 +683,57 @@ | ||
| 715 | 683 | /** |
| 716 | 684 | * Retrieves the value of a setting, allowing for a global setting to be |
| 717 | 685 | * used as a fallback, or a constant value, or both. |
| 718 | 686 | * |
| 719 | - * @param string $name The link setting key. | |
| 720 | - * @param mixed $fallback_global If the link setting is nonexistent or | |
| 721 | - * marked as a use-default value, fall back | |
| 722 | - * to the value of this global setting. | |
| 723 | - * @param mixed $fallback_value If the link setting and the global setting are | |
| 724 | - * nonexistent or marked as ause-default value, | |
| 725 | - * fall back to this constant value. | |
| 726 | - * | |
| 727 | - * @return mixed|null Should *not* return a boolean!! | |
| 687 | + * @param string $name The link setting key | |
| 688 | + * @param mixed $fallback_global If the link setting is nonexistent or marked as a use-default value, fall back to the value of this global setting. | |
| 689 | + * @param mixed $fallback_value If the link setting and the global setting are nonexistent or marked as a use-default value, fall back to this constant value. | |
| 690 | + * @return bool TRUE on success, FALSE on failure. | |
| 728 | 691 | */ |
| 729 | - public function setting( $name, $fallback_global = NULL, $fallback_value = NULL, $default = 'default' ) { | |
| 692 | + public function setting ($name, $fallback_global = NULL, $fallback_value = NULL, $default = 'default') { | |
| 730 | 693 | $ret = NULL; |
| 731 | - if ( isset( $this->settings[ $name ] ) ) : | |
| 732 | - $ret = $this->settings[ $name ]; | |
| 694 | + if (isset($this->settings[$name])) : | |
| 695 | + $ret = $this->settings[$name]; | |
| 733 | 696 | endif; |
| 734 | 697 | |
| 735 | 698 | $no_value = ( |
| 736 | - is_null( $ret ) | |
| 737 | - or ( is_string( $ret ) and strtolower( $ret ) == $default ) | |
| 699 | + is_null($ret) | |
| 700 | + or (is_string($ret) and strtolower($ret)==$default) | |
| 738 | 701 | ); |
| 739 | 702 | |
| 740 | - if ( $no_value and ! is_null( $fallback_global ) ) : | |
| 703 | + if ($no_value and !is_null($fallback_global)) : | |
| 741 | 704 | // Avoid duplication of this correction |
| 742 | - $fallback_global = preg_replace( '/^feedwordpress_/', '', $fallback_global ); | |
| 705 | + $fallback_global = preg_replace('/^feedwordpress_/', '', $fallback_global); | |
| 743 | 706 | |
| 744 | 707 | // Occasionally we'll get an array back. Convert it to a string |
| 745 | - if ( is_array( $fallback_global ) && sizeof( $fallback_global ) ) : | |
| 746 | - $fallback_global = reset( $fallback_global ); | |
| 747 | - endif; | |
| 708 | + if ( is_array($fallback_global) && sizeof($fallback_global) ) | |
| 709 | + $fallback_global = reset($fallback_global); | |
| 748 | 710 | |
| 749 | - if ( ! empty( $fallback_global ) ) : | |
| 750 | - $ret = get_option( 'feedwordpress_' . $fallback_global, /*default=*/ NULL ); | |
| 751 | - endif; | |
| 711 | + if ( !empty($fallback_global) ) | |
| 712 | + $ret = get_option('feedwordpress_'.$fallback_global, /*default=*/ NULL); | |
| 752 | 713 | endif; |
| 753 | 714 | |
| 754 | 715 | $no_value = ( |
| 755 | - is_null( $ret ) | |
| 756 | - or ( is_string( $ret ) and strtolower( $ret ) == $default ) | |
| 716 | + is_null($ret) | |
| 717 | + or (is_string($ret) and strtolower($ret)==$default) | |
| 757 | 718 | ); |
| 758 | 719 | |
| 759 | - if ( $no_value and ! is_null( $fallback_value ) ) : | |
| 720 | + if ($no_value and !is_null($fallback_value)) : | |
| 760 | 721 | $ret = $fallback_value; |
| 761 | 722 | endif; |
| 762 | 723 | return $ret; |
| 763 | - } /* SyndicatedLink::setting() */ | |
| 724 | + } /* SyndicatedLink::setting () */ | |
| 764 | 725 | |
| 765 | - /** | |
| 766 | - * Merge current settings with array of additional data. | |
| 767 | - * | |
| 768 | - * @param array $data Settings to merge with. | |
| 769 | - * @param string $prefix Hierarchical prefix (e.g. "feed/" as in "feed/a/b/c"). | |
| 770 | - * @param string $separator Hierarchy separator (e.g., '/'). | |
| 771 | - * | |
| 772 | - * @see SyndicatedLink::flatten_array() | |
| 773 | - */ | |
| 774 | - public function merge_settings( $data, $prefix, $separator = '/' ) { | |
| 775 | - $dd = $this->flatten_array( $data, $prefix, $separator ); | |
| 776 | - $this->settings = array_merge( $this->settings, $dd ); | |
| 726 | + public function merge_settings ($data, $prefix, $separator = '/') { | |
| 727 | + $dd = $this->flatten_array($data, $prefix, $separator); | |
| 728 | + $this->settings = array_merge($this->settings, $dd); | |
| 777 | 729 | } /* SyndicatedLink::merge_settings () */ |
| 778 | 730 | |
| 779 | - public function update_setting( $name, $value, $default = 'default' ) { | |
| 780 | - if ( !is_null( $value ) and $value != $default ) : | |
| 781 | - $this->settings[ $name ] = $value; | |
| 731 | + public function update_setting ($name, $value, $default = 'default') { | |
| 732 | + if (!is_null($value) and $value != $default) : | |
| 733 | + $this->settings[$name] = $value; | |
| 782 | 734 | else : // Zap it. |
| 783 | - unset( $this->settings[ $name ] ); | |
| 735 | + unset($this->settings[$name]); | |
| 784 | 736 | endif; |
| 785 | 737 | } /* SyndicatedLink::update_setting () */ |
| 786 | 738 | |
| 787 | 739 | public function is_non_incremental () { |
| @@ -787,44 +739,8 @@ | ||
| 787 | 739 | public function is_non_incremental () { |
| 788 | 740 | return ('complete'==$this->setting('update_incremental', 'update_incremental', 'incremental')); |
| 789 | 741 | } /* SyndicatedLink::is_non_incremental () */ |
| 790 | 742 | |
| 791 | - public function get_feed_type () { | |
| 792 | - $type_code = $this->setting('link/feed_type'); | |
| 793 | - | |
| 794 | - // list derived from: <http://simplepie.org/api/class-SimplePie.html>, retrieved 2020/01/18 | |
| 795 | - $bitmasks = array( | |
| 796 | - SIMPLEPIE_TYPE_RSS_090 => 'RSS 0.90', | |
| 797 | - SIMPLEPIE_TYPE_RSS_091_NETSCAPE => 'RSS 0.91 (Netscape)', | |
| 798 | - SIMPLEPIE_TYPE_RSS_091_USERLAND => 'RSS 0.91 (Userland)', | |
| 799 | - SIMPLEPIE_TYPE_RSS_091 => 'RSS 0.91', | |
| 800 | - SIMPLEPIE_TYPE_RSS_092 => 'RSS 0.92', | |
| 801 | - SIMPLEPIE_TYPE_RSS_093 => 'RSS 0.93', | |
| 802 | - SIMPLEPIE_TYPE_RSS_094 => 'RSS 0.94', | |
| 803 | - SIMPLEPIE_TYPE_RSS_10 => 'RSS 1.0', | |
| 804 | - SIMPLEPIE_TYPE_RSS_20 => 'RSS 2.0.x', | |
| 805 | - SIMPLEPIE_TYPE_RSS_RDF => 'RDF-based RSS', | |
| 806 | - SIMPLEPIE_TYPE_RSS_SYNDICATION => 'Non-RDF-based RSS', | |
| 807 | - SIMPLEPIE_TYPE_RSS_ALL => 'Any version of RSS', | |
| 808 | - SIMPLEPIE_TYPE_ATOM_03 => 'Atom 0.3', | |
| 809 | - SIMPLEPIE_TYPE_ATOM_10 => 'Atom 1.0', | |
| 810 | - SIMPLEPIE_TYPE_ATOM_ALL => 'Atom (any version)', | |
| 811 | - SIMPLEPIE_TYPE_ALL => 'Supported Feed (unspecified format)', | |
| 812 | - ); | |
| 813 | - | |
| 814 | - $type = "Unknown or unsupported format"; | |
| 815 | - foreach ($bitmasks as $format_flag => $format_string) : | |
| 816 | - if (is_numeric($format_flag)) : // Guard against failure of constants to be defined. | |
| 817 | - if ($type_code & $format_flag) : | |
| 818 | - $type = $format_string; | |
| 819 | - break; // foreach | |
| 820 | - endif; | |
| 821 | - endif; | |
| 822 | - endforeach; | |
| 823 | - | |
| 824 | - return $type; | |
| 825 | - } /* SyndicatedLink::get_feed_type () */ | |
| 826 | - | |
| 827 | 743 | public function uri ($params = array()) { |
| 828 | 744 | $params = wp_parse_args($params, array( |
| 829 | 745 | 'add_params' => false, |
| 830 | 746 | 'fetch' => false, |
| @@ -831,15 +747,15 @@ | ||
| 831 | 747 | )); |
| 832 | 748 | |
| 833 | 749 | // Initialize $qp (= array for added query parameters, if any) |
| 834 | 750 | $qp = array(); |
| 835 | - | |
| 836 | - $link_rss = (is_object($this->link) ? $this->link->link_rss : NULL); | |
| 837 | - | |
| 751 | + | |
| 752 | + $link_rss = (is_object($this->link) ? $this->link->link_rss : NULL); | |
| 753 | + | |
| 838 | 754 | // $link_rss stores the URI for the subscription as stored in the feed's record. |
| 839 | - // $uri stores the effective URI of the request including any/all added query parameters | |
| 755 | + // $uri stores the effective URI of the request including any/all added query parameters | |
| 840 | 756 | $uri = $link_rss; |
| 841 | - if ( !is_null($uri) and strlen($uri) > 0 and $params['add_params']) : | |
| 757 | + if (!is_null($uri) and strlen($uri) > 0 and $params['add_params']) : | |
| 842 | 758 | $qp = maybe_unserialize($this->setting('query parameters', array())); |
| 843 | 759 | |
| 844 | 760 | // For high-tech HTTP feed request kung fu |
| 845 | 761 | $qp = apply_filters('syndicated_feed_parameters', $qp, $uri, $this); |
| @@ -861,9 +777,9 @@ | ||
| 861 | 777 | |
| 862 | 778 | // Do we have any filters that apply here? |
| 863 | 779 | $uri = apply_filters('syndicated_link_uri', $uri, $link_rss, $qp, $params, $this); |
| 864 | 780 | |
| 865 | - // Return the filtered link URI. | |
| 781 | + // Return the filtered link URI. | |
| 866 | 782 | return $uri; |
| 867 | 783 | } /* SyndicatedLink::uri () */ |
| 868 | 784 | |
| 869 | 785 | public function username () { |
| @@ -874,19 +790,15 @@ | ||
| 874 | 790 | return $this->setting('http password', 'http_password', NULL); |
| 875 | 791 | } /* SyndicatedLink::password () */ |
| 876 | 792 | |
| 877 | 793 | public function authentication_method () { |
| 878 | - // Retrieve the authentication method from settings | |
| 879 | - $auth = $this->setting( 'http auth method', null ); | |
| 880 | - | |
| 881 | - // If the value is '-' or empty, treat it as NULL | |
| 882 | - if ( '-' === $auth || empty( $auth ) ) { | |
| 883 | - $auth = null; | |
| 884 | - } | |
| 885 | - | |
| 794 | + $auth = $this->setting('http auth method', NULL); | |
| 795 | + if (('-' == $auth) or (strlen($auth)==0)) : | |
| 796 | + $auth = NULL; | |
| 797 | + endif; | |
| 886 | 798 | return $auth; |
| 887 | 799 | } /* SyndicatedLink::authentication_method () */ |
| 888 | - | |
| 800 | + | |
| 889 | 801 | var $postmeta = array(); |
| 890 | 802 | public function postmeta ($params = array()) { |
| 891 | 803 | $params = wp_parse_args($params, /*defaults=*/ array( |
| 892 | 804 | "field" => NULL, |
| @@ -899,9 +811,9 @@ | ||
| 899 | 811 | $default_custom_settings = get_option('feedwordpress_custom_settings'); |
| 900 | 812 | if ($default_custom_settings and !is_array($default_custom_settings)) : |
| 901 | 813 | $default_custom_settings = unserialize($default_custom_settings); |
| 902 | 814 | endif; |
| 903 | - if ( !is_array($default_custom_settings)) : | |
| 815 | + if (!is_array($default_custom_settings)) : | |
| 904 | 816 | $default_custom_settings = array(); |
| 905 | 817 | endif; |
| 906 | 818 | |
| 907 | 819 | // Next, get the settings for this particular feed. |
| @@ -908,9 +820,9 @@ | ||
| 908 | 820 | $custom_settings = $this->setting('postmeta', NULL, NULL); |
| 909 | 821 | if ($custom_settings and !is_array($custom_settings)) : |
| 910 | 822 | $custom_settings = unserialize($custom_settings); |
| 911 | 823 | endif; |
| 912 | - if ( !is_array($custom_settings)) : | |
| 824 | + if (!is_array($custom_settings)) : | |
| 913 | 825 | $custom_settings = array(); |
| 914 | 826 | endif; |
| 915 | 827 | |
| 916 | 828 | $this->postmeta[/*parsed=*/ false] = array_merge($default_custom_settings, $custom_settings); |
| @@ -917,15 +829,15 @@ | ||
| 917 | 829 | $this->postmeta[/*parsed=*/ true] = array(); |
| 918 | 830 | |
| 919 | 831 | // Now, run through and parse them all. |
| 920 | 832 | foreach ($this->postmeta[/*parsed=*/ false] as $key => $meta) : |
| 921 | - $meta = apply_filters("syndicated_link_post_meta_{$key}_pre", $meta, $this); | |
| 833 | + $meta = apply_filters("syndicated_link_post_meta_${key}_pre", $meta, $this); | |
| 922 | 834 | $this->postmeta[/*parsed=*/ false][$key] = $meta; |
| 923 | 835 | $this->postmeta[/*parsed=*/ true][$key] = new FeedWordPressParsedPostMeta($meta); |
| 924 | 836 | endforeach; |
| 925 | 837 | endif; |
| 926 | 838 | |
| 927 | - $ret = $this->postmeta[!! $params['parsed']]; | |
| 839 | + $ret = $this->postmeta[!!$params['parsed']]; | |
| 928 | 840 | if (is_string($params['field'])) : |
| 929 | 841 | $ret = $ret[$params['field']]; |
| 930 | 842 | endif; |
| 931 | 843 | return $ret; |
| @@ -935,13 +847,12 @@ | ||
| 935 | 847 | $value = NULL; |
| 936 | 848 | if ($fromFeed) : |
| 937 | 849 | $value = $this->setting($setting, NULL, NULL, NULL); |
| 938 | 850 | |
| 939 | - $simp_pie = $this->simplepie; | |
| 940 | - $callable = ( is_object( $simp_pie ) and method_exists( $simp_pie, $method ) ); | |
| 941 | - if ( is_null( $value ) and $callable ) : | |
| 942 | -// $fallback = $s->{$method}(); // what is fallback supposed to be here? (gwyneth 20230816) | |
| 943 | - $value = $simp_pie->{$method}(); // makes more sense this way! | |
| 851 | + $s = $this->simplepie; | |
| 852 | + $callable = (is_object($s) and method_exists($s, $method)); | |
| 853 | + if (is_null($value) and $callable) : | |
| 854 | + $fallback = $s->{$method}(); | |
| 944 | 855 | endif; |
| 945 | 856 | else : |
| 946 | 857 | $value = $this->link->{$link_field}; |
| 947 | 858 | endif; |
| @@ -986,9 +897,9 @@ | ||
| 986 | 897 | public function links ($params = array()) { |
| 987 | 898 | $params = wp_parse_args($params, array( |
| 988 | 899 | "rel" => NULL, |
| 989 | 900 | )); |
| 990 | - | |
| 901 | + | |
| 991 | 902 | $fLinks = array(); |
| 992 | 903 | $search = array( |
| 993 | 904 | array('', 'link'), |
| 994 | 905 | array(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'), |
| @@ -993,9 +904,9 @@ | ||
| 993 | 904 | array('', 'link'), |
| 994 | 905 | array(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'), |
| 995 | 906 | array(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'), |
| 996 | 907 | ); |
| 997 | - | |
| 908 | + | |
| 998 | 909 | foreach ($search as $pair) : |
| 999 | 910 | if ($link_tags = $this->simplepie->get_feed_tags($pair[0], $pair[1])) : |
| 1000 | 911 | $fLinks = array_merge($fLinks, $link_tags); |
| 1001 | 912 | endif; |
| @@ -1002,13 +913,13 @@ | ||
| 1002 | 913 | if ($link_tags = $this->simplepie->get_channel_tags($pair[0], $pair[1])) : |
| 1003 | 914 | $fLinks = array_merge($fLinks, $link_tags); |
| 1004 | 915 | endif; |
| 1005 | 916 | endforeach; |
| 1006 | - | |
| 917 | + | |
| 1007 | 918 | $ret = array(); |
| 1008 | 919 | foreach ($fLinks as $link) : |
| 1009 | 920 | $filter = false; |
| 1010 | - if ( !is_null($params['rel'])) : | |
| 921 | + if (!is_null($params['rel'])) : | |
| 1011 | 922 | $filter = true; |
| 1012 | 923 | |
| 1013 | 924 | if (isset($link['attribs'])) : |
| 1014 | 925 | // Get a list of NSes from the search |
| @@ -1013,15 +924,15 @@ | ||
| 1013 | 924 | if (isset($link['attribs'])) : |
| 1014 | 925 | // Get a list of NSes from the search |
| 1015 | 926 | foreach ($search as $pair) : |
| 1016 | 927 | $ns = $pair[0]; |
| 1017 | - | |
| 928 | + | |
| 1018 | 929 | if (isset($link['attribs'][$ns]) |
| 1019 | 930 | and isset($link['attribs'][$ns]['rel']) |
| 1020 | 931 | ) : |
| 1021 | 932 | $rel = strtolower(trim($link['attribs'][$ns]['rel'])); |
| 1022 | 933 | $fRel = strtolower(trim($params['rel'])); |
| 1023 | - | |
| 934 | + | |
| 1024 | 935 | if ($rel == $fRel) : |
| 1025 | 936 | $filter = false; |
| 1026 | 937 | endif; |
| 1027 | 938 | endif; |
| @@ -1027,10 +938,10 @@ | ||
| 1027 | 938 | endif; |
| 1028 | 939 | endforeach; |
| 1029 | 940 | endif; |
| 1030 | 941 | endif; |
| 1031 | - | |
| 1032 | - if ( ! $filter) : | |
| 942 | + | |
| 943 | + if (!$filter) : | |
| 1033 | 944 | $ret[] = $link; |
| 1034 | 945 | endif; |
| 1035 | 946 | endforeach; |
| 1036 | 947 | |
| @@ -1035,9 +946,9 @@ | ||
| 1035 | 946 | endforeach; |
| 1036 | 947 | |
| 1037 | 948 | return $ret; |
| 1038 | 949 | } |
| 1039 | - | |
| 950 | + | |
| 1040 | 951 | public function ttl ($return_element = false) { |
| 1041 | 952 | if (is_object($this->magpie)) : |
| 1042 | 953 | $channel = $this->magpie->channel; |
| 1043 | 954 | else : |
| @@ -1063,9 +974,9 @@ | ||
| 1063 | 974 | // "sy:updatePeriod: Describes the period over which the |
| 1064 | 975 | // channel format is updated. Acceptable values are: |
| 1065 | 976 | // hourly, daily, weekly, monthly, yearly. If omitted, |
| 1066 | 977 | // daily is assumed." <http://web.resource.org/rss/1.0/modules/syndication/> |
| 1067 | - if (isset($channel['sy']['updateperiod'])) : $period = trim($channel['sy']['updateperiod']); | |
| 978 | + if (isset($channel['sy']['updateperiod'])) : $period = $channel['sy']['updateperiod']; | |
| 1068 | 979 | else : $period = 'daily'; |
| 1069 | 980 | endif; |
| 1070 | 981 | |
| 1071 | 982 | // "sy:updateFrequency: Used to describe the frequency |
| @@ -1076,18 +987,10 @@ | ||
| 1076 | 987 | if (isset($channel['sy']['updatefrequency'])) : $freq = (int) $channel['sy']['updatefrequency']; |
| 1077 | 988 | else : $freq = 1; |
| 1078 | 989 | endif; |
| 1079 | 990 | |
| 1080 | - // normalize the period name... | |
| 1081 | - $period = strtolower(trim($period)); | |
| 1082 | - | |
| 1083 | - // do we recognize the alphanumeric period name? if not, then guess | |
| 1084 | - // a responsible default, e.g. roughly hourly | |
| 1085 | - $mins = (isset($period_minutes[$period]) ? $period_minutes[$period] : 67); | |
| 1086 | - | |
| 1087 | 991 | $xml = 'sy:updateFrequency'; |
| 1088 | - $ret = (int) ($mins / $freq); | |
| 1089 | - | |
| 992 | + $ret = (int) ($period_minutes[$period] / $freq); | |
| 1090 | 993 | else : |
| 1091 | 994 | $xml = NULL; |
| 1092 | 995 | $ret = NULL; |
| 1093 | 996 | endif; |
| @@ -1098,28 +1001,23 @@ | ||
| 1098 | 1001 | if ($min > $ret) : |
| 1099 | 1002 | $ret = NULL; |
| 1100 | 1003 | endif; |
| 1101 | 1004 | endif; |
| 1102 | - return ( $return_element ? array( $ret, $xml ) : $ret ); | |
| 1005 | + return ($return_element ? array($ret, $xml) : $ret); | |
| 1103 | 1006 | } /* SyndicatedLink::ttl() */ |
| 1104 | 1007 | |
| 1105 | - /** | |
| 1106 | - * Sets the automatic time interval for | |
| 1107 | - * | |
| 1108 | - * @return | |
| 1109 | - */ | |
| 1110 | - public function automatic_ttl() { | |
| 1008 | + public function automatic_ttl () { | |
| 1111 | 1009 | // spread out over a time interval for staggered updates |
| 1112 | - $updateWindow = $this->setting( 'update/window', 'update_window', DEFAULT_UPDATE_PERIOD ); | |
| 1113 | - if ( ! is_numeric( $updateWindow ) or ( $updateWindow < 1 ) ) : | |
| 1010 | + $updateWindow = $this->setting('update/window', 'update_window', DEFAULT_UPDATE_PERIOD); | |
| 1011 | + if (!is_numeric($updateWindow) or ($updateWindow < 1)) : | |
| 1114 | 1012 | $updateWindow = DEFAULT_UPDATE_PERIOD; |
| 1115 | 1013 | endif; |
| 1116 | 1014 | |
| 1117 | 1015 | // We get a fudge of 1/3 of window from elsewhere. We'll do some more |
| 1118 | 1016 | // fudging here. |
| 1119 | - $fudgedInterval = $updateWindow + rand( - ( $updateWindow / 6 ), 5 * ( $updateWindow / 12 ) ); | |
| 1120 | - return apply_filters( 'syndicated_feed_automatic_ttl', $fudgedInterval, $this ); | |
| 1121 | - } /* SyndicatedLink::automatic_ttl() */ | |
| 1017 | + $fudgedInterval = $updateWindow+rand(-($updateWindow/6), 5*($updateWindow/12)); | |
| 1018 | + return apply_filters('syndicated_feed_automatic_ttl', $fudgedInterval, $this); | |
| 1019 | + } /* SyndicatedLink::automatic_ttl () */ | |
| 1122 | 1020 | |
| 1123 | 1021 | /** |
| 1124 | 1022 | * SyndicatedLink::flatten_array (): flatten an array. Useful for |
| 1125 | 1023 | * hierarchical and namespaced elements. |
| @@ -1130,53 +1028,46 @@ | ||
| 1130 | 1028 | * structure. Thus, for example, if $a['b']['c']['d'] == 'e', then the |
| 1131 | 1029 | * returned array for FeedWordPress::flatten_array($a) will contain a key |
| 1132 | 1030 | * $a['feed/b/c/d'] with value 'e'. |
| 1133 | 1031 | * |
| 1134 | - * @param array $arr Array to flatten. | |
| 1135 | - * @param string $prefix Hierarchical prefix (e.g. "feed/" as in "feed/a/b/c"). | |
| 1136 | - * @param string $separator Hierarchy separator (e.g., '/'). | |
| 1137 | - * @return array Flattened one-dimensional array. | |
| 1032 | + * @param array $arr | |
| 1033 | + * @param string $prefix | |
| 1034 | + * @param string $separator | |
| 1035 | + * @return array | |
| 1138 | 1036 | */ |
| 1139 | - public function flatten_array( $arr, $prefix = 'feed/', $separator = '/' ) { | |
| 1140 | - $ret = array(); | |
| 1141 | - if ( is_array( $arr ) ) : | |
| 1142 | - foreach ( $arr as $key => $value ) : | |
| 1143 | - if ( is_scalar( $value ) ) : | |
| 1144 | - $ret[ $prefix.$key ] = $value; | |
| 1037 | + public function flatten_array ($arr, $prefix = 'feed/', $separator = '/') { | |
| 1038 | + $ret = array (); | |
| 1039 | + if (is_array($arr)) : | |
| 1040 | + foreach ($arr as $key => $value) : | |
| 1041 | + if (is_scalar($value)) : | |
| 1042 | + $ret[$prefix.$key] = $value; | |
| 1145 | 1043 | else : |
| 1146 | - $ret = array_merge( $ret, $this->flatten_array( $value, $prefix.$key.$separator, $separator ) ); | |
| 1044 | + $ret = array_merge($ret, $this->flatten_array($value, $prefix.$key.$separator, $separator)); | |
| 1147 | 1045 | endif; |
| 1148 | 1046 | endforeach; |
| 1149 | 1047 | endif; |
| 1150 | 1048 | return $ret; |
| 1151 | - } /* SyndicatedLink::flatten_array() */ | |
| 1049 | + } /* SyndicatedLink::flatten_array () */ | |
| 1152 | 1050 | |
| 1153 | - /** | |
| 1154 | - * Check if a setting is hardcoded or not. | |
| 1155 | - * | |
| 1156 | - * @param string $what The setting we're checking for. | |
| 1157 | - * | |
| 1158 | - * @return bool True if the setting's value is 'yes', false otherwise. | |
| 1159 | - */ | |
| 1160 | - public function hardcode( $what ) { | |
| 1161 | - return 'yes' == $this->setting( 'hardcode ' . $what, 'hardcode_' . $what, NULL ); | |
| 1162 | - // Simplified logic. (gwyneth 20230920) | |
| 1051 | + public function hardcode ($what) { | |
| 1052 | + | |
| 1053 | + $ret = $this->setting('hardcode '.$what, 'hardcode_'.$what, NULL); | |
| 1054 | + | |
| 1055 | + if ('yes' == $ret) : | |
| 1056 | + $ret = true; | |
| 1057 | + else : | |
| 1058 | + $ret = false; | |
| 1059 | + endif; | |
| 1060 | + return $ret; | |
| 1163 | 1061 | } /* SyndicatedLink::hardcode () */ |
| 1164 | 1062 | |
| 1165 | - /** | |
| 1166 | - * Returns the syndicated status for one item. | |
| 1167 | - * | |
| 1168 | - * @param string $what Item's name. | |
| 1169 | - * @param mixed $default Default value for this item. | |
| 1170 | - * @param boolean $fallback If true, falls back to global setting. | |
| 1171 | - * | |
| 1172 | - * @return string SQL-ready escaped status. | |
| 1173 | - */ | |
| 1174 | - public function syndicated_status( $what, $default, $fallback = true ) { | |
| 1175 | - $g_set = ( $fallback ? 'syndicated_' . $what . '_status' : NULL ); | |
| 1176 | - $ret = $this->setting( $what . ' status', $g_set, $default ); | |
| 1063 | + public function syndicated_status ($what, $default, $fallback = true) { | |
| 1064 | + global $wpdb; | |
| 1177 | 1065 | |
| 1178 | - return esc_sql( trim( strtolower( $ret ) ) ); | |
| 1066 | + $g_set = ($fallback ? 'syndicated_' . $what . '_status' : NULL); | |
| 1067 | + $ret = $this->setting($what.' status', $g_set, $default); | |
| 1068 | + | |
| 1069 | + return esc_sql(trim(strtolower($ret))); | |
| 1179 | 1070 | } /* SyndicatedLink:syndicated_status () */ |
| 1180 | 1071 | |
| 1181 | 1072 | public function taxonomies () { |
| 1182 | 1073 | $post_type = $this->setting('syndicated post type', 'syndicated_post_type', 'post'); |
| @@ -1224,9 +1115,9 @@ | ||
| 1224 | 1115 | |
| 1225 | 1116 | if ($oTerm->is_familiar()) : |
| 1226 | 1117 | |
| 1227 | 1118 | $tax = $oTerm->taxonomy(); |
| 1228 | - if ( !isset($terms[$tax])) : | |
| 1119 | + if (!isset($terms[$tax])) : | |
| 1229 | 1120 | $terms[$tax] = array(); |
| 1230 | 1121 | endif; |
| 1231 | 1122 | $terms[$tax][] = $oTerm->id(); |
| 1232 | 1123 | |
| @@ -1244,10 +1135,10 @@ | ||
| 1244 | 1135 | $tax = $ref[2]; |
| 1245 | 1136 | endif; |
| 1246 | 1137 | |
| 1247 | 1138 | $inserted = $oTerm->insert($tax); |
| 1248 | - if ( !is_null($inserted)) : | |
| 1249 | - if ( !isset($terms[$tax])) : | |
| 1139 | + if (!is_null($inserted)) : | |
| 1140 | + if (!isset($terms[$tax])) : | |
| 1250 | 1141 | $terms[$tax] = array(); |
| 1251 | 1142 | endif; |
| 1252 | 1143 | $terms[$tax][] = $inserted; |
| 1253 | 1144 | else : |