Retrieves the value of a setting, allowing for a global setting to be
used as a fallback, or a constant value, or both.
public setting ( string $name, mixed $fallback_global = NULL, mixed $fallback_value = NULL, $default = 'default' ) : boolean | ||
$name | string | The link setting key |
$fallback_global | mixed | If the link setting is nonexistent or marked as a use-default value, fall back to the value of this global setting. |
$fallback_value | mixed | If the link setting and the global setting are nonexistent or marked as a use-default value, fall back to this constant value. |
Результат | boolean | TRUE on success, FALSE on failure. |
function fwp_syndication_manage_page_links_table_rows($links, $page, $visible = 'Y') { $subscribed = 'Y' == strtoupper($visible); if ($subscribed or count($links) > 0) { ?> <table class="widefat<?php if (!$subscribed) { ?> unsubscribed<?php } ?> "> <thead> <tr> <th class="check-column" scope="col"><input type="checkbox" /></th> <th scope="col"><?php _e('Name'); ?> </th> <th scope="col"><?php _e('Feed'); ?> </th> <th scope="col"><?php _e('Updated'); ?> </th> </tr> </thead> <tbody> <?php $alt_row = true; if (count($links) > 0) { foreach ($links as $link) { $trClass = array(); // Prep: Get last updated timestamp $sLink = new SyndicatedLink($link->link_id); if (!is_null($sLink->setting('update/last'))) { $lastUpdated = 'Last checked ' . fwp_time_elapsed($sLink->setting('update/last')); } else { $lastUpdated = __('None yet'); } // Prep: get last error timestamp, if any $fileSizeLines = array(); if (is_null($sLink->setting('update/error'))) { $errorsSince = ''; if (!is_null($sLink->setting('link/item count'))) { $N = $sLink->setting('link/item count'); $fileSizeLines[] = sprintf($N == 1 ? __('%d item') : __('%d items'), $N); } if (!is_null($sLink->setting('link/filesize'))) { $fileSizeLines[] = size_format($sLink->setting('link/filesize')) . ' total'; } } else { $trClass[] = 'feed-error'; $theError = unserialize($sLink->setting('update/error')); $errorsSince = "<div class=\"returning-errors\">" . "<p><strong>Returning errors</strong> since " . fwp_time_elapsed($theError['since']) . "</p>" . "<p>Most recent (" . fwp_time_elapsed($theError['ts']) . "):<br/><code>" . implode("</code><br/><code>", $theError['object']->get_error_messages()) . "</code></p>" . "</div>\n"; } $nextUpdate = "<div style='max-width: 30.0em; font-size: 0.9em;'><div style='font-style:italic;'>"; $ttl = $sLink->setting('update/ttl'); if (is_numeric($ttl)) { $next = $sLink->setting('update/last') + $sLink->setting('update/fudge') + (int) $ttl * 60; if ('automatically' == $sLink->setting('update/timed')) { if ($next < time()) { $nextUpdate .= 'Ready and waiting to be updated since '; } else { $nextUpdate .= 'Scheduled for next update '; } $nextUpdate .= fwp_time_elapsed($next); if (FEEDWORDPRESS_DEBUG) { $nextUpdate .= " [" . ($next - time()) / 60 . " minutes]"; } } else { $lastUpdated .= " · Next "; if ($next < time()) { $lastUpdated .= 'ASAP'; } elseif ($next - time() < 60) { $lastUpdated .= fwp_time_elapsed($next); } elseif ($next - time() < 60 * 60 * 24) { $lastUpdated .= gmdate('g:ia', $next + get_option('gmt_offset') * 3600); } else { $lastUpdated .= gmdate('F j', $next + get_option('gmt_offset') * 3600); } $nextUpdate .= "Scheduled to be checked for updates every " . $ttl . " minute" . ($ttl != 1 ? "s" : "") . "</div><div style='size:0.9em; margin-top: 0.5em'>\tThis update schedule was requested by the feed provider"; if ($sLink->setting('update/xml')) { $nextUpdate .= " using a standard <code style=\"font-size: inherit; padding: 0; background: transparent\"><" . $sLink->setting('update/xml') . "></code> element"; } $nextUpdate .= "."; } } else { $nextUpdate .= "Scheduled for update as soon as possible"; } $nextUpdate .= "</div></div>"; $fileSize = ''; if (count($fileSizeLines) > 0) { $fileSize = '<div>' . implode(" / ", $fileSizeLines) . "</div>"; } unset($sLink); $alt_row = !$alt_row; if ($alt_row) { $trClass[] = 'alternate'; } ?> <tr<?php echo count($trClass) > 0 ? ' class="' . implode(" ", $trClass) . '"' : ''; ?> > <th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?> " /></th> <?php $caption = strlen($link->link_rss) > 0 ? __('Switch Feed') : ($caption = __('Find Feed')); ?> <td> <strong><a href="<?php print $page->admin_page_href('feeds-page.php', array(), $link); ?> "><?php print esc_html($link->link_name); ?> </a></strong> <div class="row-actions"><?php if ($subscribed) { $page->display_feed_settings_page_links(array('before' => '<div><strong>Settings ></strong> ', 'after' => '</div>', 'subscription' => $link)); } ?> <div><strong>Actions ></strong> <?php if ($subscribed) { ?> <a href="<?php print $page->admin_page_href('syndication.php', array('action' => 'feedfinder'), $link); ?> "><?php echo $caption; ?> </a> <?php } else { ?> <a href="<?php print $page->admin_page_href('syndication.php', array('action' => FWP_RESUB_CHECKED), $link); ?> "><?php _e('Re-subscribe'); ?> </a> <?php } ?> | <a href="<?php print $page->admin_page_href('syndication.php', array('action' => 'Unsubscribe'), $link); ?> "><?php _e($subscribed ? 'Unsubscribe' : 'Delete permanently'); ?> </a> | <a href="<?php print esc_html($link->link_url); ?> "><?php _e('View'); ?> </a></div> </div> </td> <?php if (strlen($link->link_rss) > 0) { ?> <td><a href="<?php echo esc_html($link->link_rss); ?> "><?php echo esc_html(feedwordpress_display_url($link->link_rss, 32)); ?> </a></td> <?php } else { ?> <td class="feed-missing"><p><strong>no feed assigned</strong></p></td> <?php } ?> <td><div style="float: right; padding-left: 10px"> <input type="submit" class="button" name="update_uri[<?php print esc_html($link->link_rss); ?> ]" value="<?php _e('Update Now'); ?> " /> </div> <?php print $lastUpdated; ?> <?php print $fileSize; ?> <?php print $errorsSince; ?> <?php print $nextUpdate; ?> </td> </tr> <?php } } else { ?> <tr><td colspan="4"><p>There are no websites currently listed for syndication.</p></td></tr> <?php } ?> </tbody> </table> <?php } }
function fwp_syndication_manage_page_links_table_rows($links, $visible = 'Y') { $subscribed = 'Y' == strtoupper($visible); if ($subscribed or count($links) > 0) { ?> <table class="widefat<?php if (!$subscribed) { ?> unsubscribed<?php } ?> "> <thead> <tr> <th class="check-column" scope="col"><input type="checkbox" /></th> <th scope="col"><?php _e('Name'); ?> </th> <th scope="col"><?php _e('Feed'); ?> </th> <th scope="col"><?php _e('Updated'); ?> </th> </tr> </thead> <tbody> <?php $alt_row = true; if (count($links) > 0) { foreach ($links as $link) { $trClass = array(); // Prep: Get last updated timestamp $sLink = new SyndicatedLink($link->link_id); if (!is_null($sLink->setting('update/last'))) { $lastUpdated = fwp_time_elapsed($sLink->setting('update/last')); } else { $lastUpdated = __('None yet'); } // Prep: get last error timestamp, if any if (is_null($sLink->setting('update/error'))) { $errorsSince = ''; } else { $trClass[] = 'feed-error'; $theError = unserialize($sLink->setting('update/error')); $errorsSince = "<div class=\"returning-errors\">" . "<p><strong>Returning errors</strong> since " . fwp_time_elapsed($theError['since']) . "</p>" . "<p>Most recent (" . fwp_time_elapsed($theError['ts']) . "):<br/><code>" . implode("</code><br/><code>", $theError['object']->get_error_messages()) . "</code></p>" . "</div>\n"; } $nextUpdate = "<div style='font-style:italic;size:0.9em'>Ready for next update "; if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) { if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed'] == 'automatically') { $next = $sLink->settings['update/last'] + (int) $sLink->settings['update/ttl'] * 60; $nextUpdate .= fwp_time_elapsed($next); } else { $nextUpdate .= "every " . $sLink->settings['update/ttl'] . " minute" . ($sLink->settings['update/ttl'] != 1 ? "s" : ""); } } else { $nextUpdate .= "as soon as possible"; } $nextUpdate .= "</div>"; unset($sLink); $alt_row = !$alt_row; if ($alt_row) { $trClass[] = 'alternate'; } ?> <tr<?php echo count($trClass) > 0 ? ' class="' . implode(" ", $trClass) . '"' : ''; ?> > <th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?> " /></th> <?php $hrefPrefix = "admin.php?link_id={$link->link_id}&page="; $caption = strlen($link->link_rss) > 0 ? __('Switch Feed') : ($caption = __('Find Feed')); ?> <td> <strong><a href="<?php echo $hrefPrefix . FWP_FEEDS_PAGE_SLUG; ?> "><?php print esc_html($link->link_name); ?> </a></strong> <div class="row-actions"><?php if ($subscribed) { ?> <div><strong>Settings ></strong> <a href="<?php echo $hrefPrefix . FWP_FEEDS_PAGE_SLUG; ?> "><?php _e('Feed'); ?> </a> | <a href="<?php echo $hrefPrefix . FWP_POSTS_PAGE_SLUG; ?> "><?php _e('Posts'); ?> </a> | <a href="<?php echo $hrefPrefix . FWP_AUTHORS_PAGE_SLUG; ?> "><?php _e('Authors'); ?> </a> | <a href="<?php echo $hrefPrefix . FWP_CATEGORIES_PAGE_SLUG; ?> "><?php print htmlspecialchars(__('Categories' . FEEDWORDPRESS_AND_TAGS)); ?> </a></div> <?php } ?> <div><strong>Actions ></strong> <?php if ($subscribed) { ?> <a href="<?php echo $hrefPrefix . FWP_SYNDICATION_PAGE_SLUG; ?> &action=feedfinder"><?php echo $caption; ?> </a> <?php } else { ?> <a href="<?php echo $hrefPrefix . FWP_SYNDICATION_PAGE_SLUG; ?> &action=<?php print FWP_RESUB_CHECKED; ?> "><?php _e('Re-subscribe'); ?> </a> <?php } ?> | <a href="<?php echo $hrefPrefix . FWP_SYNDICATION_PAGE_SLUG; ?> &action=Unsubscribe"><?php _e($subscribed ? 'Unsubscribe' : 'Delete permanently'); ?> </a> | <a href="<?php print esc_html($link->link_url); ?> "><?php _e('View'); ?> </a></div> </div> </td> <?php if (strlen($link->link_rss) > 0) { ?> <td><a href="<?php echo esc_html($link->link_rss); ?> "><?php echo esc_html(feedwordpress_display_url($link->link_rss, 32)); ?> </a></td> <?php } else { ?> <td class="feed-missing"><p><strong>no feed assigned</strong></p></td> <?php } ?> <td><?php print $lastUpdated; ?> <?php print $errorsSince; ?> <?php print $nextUpdate; ?> </td> </tr> <?php } } else { ?> <tr><td colspan="4"><p>There are no websites currently listed for syndication.</p></td></tr> <?php } ?> </tbody> </table> <?php } }