syndicated_status() static public method

* function FeedWordPress::syndicate_link()
static public syndicated_status ( $what, $default )
    function comments_and_pings_box($page, $box = NULL)
    {
        $whatsits = array('comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'), 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'));
        $onThesePosts = 'on ' . $page->these_posts_phrase();
        $mcflSettings = array("yes" => __('Point to comment feeds from the original website (when provided by the syndicated feed)'), "no" => __('Point to local comment feeds on this website'));
        $mcflParams = array('setting-default' => 'default', 'global-setting-default' => 'yes', 'labels' => array('yes' => __('comment feeds from the original website'), 'no' => __('local comment feeds on this website')), 'default-input-value' => 'default');
        $settings = array();
        $params = array();
        foreach ($whatsits as $what => $how) {
            $whatsits[$what]['default'] = FeedWordPress::syndicated_status($what, 'closed');
            // Set up array for selector
            $settings[$what] = array('open' => sprintf(__("{$how['accept']} %s"), __($onThesePosts)), 'closed' => sprintf(__("Don't " . strtolower($how['accept']) . " %s"), __($onThesePosts)));
            $params[$what] = array('input-name' => "feed_{$what}_status", 'setting-default' => NULL, 'global-setting-default' => FeedWordPress::syndicated_status($what, 'closed'), 'labels' => array('open' => strtolower(__($how['accept'])), 'closed' => strtolower(__("Don't " . $how['accept']))));
        }
        // Hey ho, let's go...
        ?>
		<table class="edit-form narrow">
		<?php 
        foreach ($whatsits as $what => $how) {
            ?>
		  
		  <tr><th scope="row"><?php 
            print $how['label'];
            ?>
:</th>
		  <td><?php 
            $this->setting_radio_control("{$what} status", "syndicated_{$what}_status", $settings[$what], $params[$what]);
            ?>
</td></tr>
		  
		<?php 
        }
        ?>
		
		  <tr><th scope="row"><?php 
        _e('Comment feeds');
        ?>
</th>
		  <td><p>When WordPress feeds and templates link to comments
		  feeds for <?php 
        print $page->these_posts_phrase();
        ?>
, the
		  URLs for the feeds should...</p>
		  <?php 
        $this->setting_radio_control("munge comments feed links", "munge_comments_feed_links", $mcflSettings, $mcflParams);
        ?>
</td></tr>
		</table>

		<?php 
    }
    function comments_and_pings_box($page, $box = NULL)
    {
        $setting = array();
        $selector = array();
        $whatsits = array('comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'), 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'));
        $onThesePosts = 'on ' . $page->these_posts_phrase();
        $selected = array('munge_comments_feed_links' => array('yes' => '', 'no' => ''));
        $globalMungeCommentsFeedLinks = get_option('feedwordpress_munge_comments_feed_links', 'yes');
        if ($page->for_feed_settings()) {
            $selected['munge_comments_feed_links']['default'] = '';
            $sel = $page->link->setting('munge comments feed links', NULL, 'default');
        } else {
            $sel = $globalMungeCommentsFeedLinks;
        }
        $selected['munge_comments_feed_links'][$sel] = ' checked="checked"';
        if ($globalMungeCommentsFeedLinks != 'no') {
            $siteWide = __('comment feeds from the original website');
        } else {
            $siteWide = __('local comment feeds on this website');
        }
        foreach ($whatsits as $what => $how) {
            $whatsits[$what]['default'] = FeedWordPress::syndicated_status($what, 'closed');
            // Set up array for selector
            $setting = array('open' => array('label' => "{$how['accept']} %s", 'checked' => ''), 'closed' => array('label' => "Don't " . strtolower($how['accept']) . " %s", 'checked' => ''));
            if ($page->for_feed_settings()) {
                $href = FWP_POSTS_PAGE_SLUG;
                $currently = trim(str_replace('%s', '', strtolower(strtok($setting[$whatsits[$what]['default']]['label'], ';'))));
                $setting['site-default'] = array('label' => "Use <a href=\"admin.php?page={$href}\">site-wide setting</a>", 'checked' => '');
                $setting['site-default']['label'] .= " (currently: <strong>{$currently}</strong>)";
                $checked = $page->link->syndicated_status($what, 'site-default', false);
            } else {
                $checked = $whatsits[$what]['default'];
            }
            // Re-order appropriately
            $selector[$what] = array();
            $order = array('site-default', 'open', 'closed');
            foreach ($order as $line) {
                if (isset($setting[$line])) {
                    $selector[$what][$line] = $setting[$line];
                }
            }
            $selector[$what][$checked]['checked'] = ' checked="checked"';
        }
        // Hey ho, let's go...
        ?>
		<table class="form-table" cellspacing="2" cellpadding="5">
		<?php 
        foreach ($whatsits as $what => $how) {
            ?>
		  <tr><th scope="row"><?php 
            print $how['label'];
            ?>
:</th>
		  <td><ul class="options">
		  <?php 
            foreach ($selector[$what] as $code => $li) {
                ?>
		    <li><label><input type="radio" name="feed_<?php 
                print $what;
                ?>
_status"
		    value="<?php 
                print $code;
                ?>
"<?php 
                print $li['checked'];
                ?>
 />
		    <?php 
                print trim(str_replace('%s', $onThesePosts, $li['label']));
                ?>
</label></li>
		  <?php 
            }
            ?>
		  </ul></td></tr>
		<?php 
        }
        ?>
		  <tr><th scope="row"><?php 
        _e('Comment feeds');
        ?>
</th>
		  <td><p>When WordPress feeds and templates link to comments
		  feeds for <?php 
        print $page->these_posts_phrase();
        ?>
, the
		  URLs for the feeds should...</p>
		  <ul class="options">
		  <?php 
        if ($page->for_feed_settings()) {
            ?>
		  <li><label><input type="radio" name="munge_comments_feed_links" value="default"<?php 
            print $selected['munge_comments_feed_links']['default'];
            ?>
 /> Use <a href="admin.php?page=<?php 
            print $href;
            ?>
">site-wide setting</a> (currently: <strong><?php 
            _e($siteWide);
            ?>
</strong>)</label></li>
		  <?php 
        }
        ?>
		  <li><label><input type="radio" name="munge_comments_feed_links" value="yes"<?php 
        print $selected['munge_comments_feed_links']['yes'];
        ?>
 /> <?php 
        _e('Point to comment feeds from the original website (when provided by the syndicated feed)');
        ?>
</label></li>
		  <li><label><input type="radio" name="munge_comments_feed_links" value="no"<?php 
        print $selected['munge_comments_feed_links']['no'];
        ?>
 /> <?php 
        _e('Point to local comment feeds on this website');
        ?>
</label></li>
		  </ul></td></tr>
		</table>

		<?php 
    }
 function syndicated_status($what, $default, $fallback = true)
 {
     global $wpdb;
     // Use local setting if we have it
     if (isset($this->settings["{$what} status"])) {
         $ret = $this->settings["{$what} status"];
         // Or fall back to global default if we can
     } elseif ($fallback) {
         $ret = FeedWordPress::syndicated_status($what, $default);
         // Or use default value if we can't.
     } else {
         $ret = $default;
     }
     return $wpdb->escape(trim(strtolower($ret)));
 }