php.test



カテゴリ:[ プログラミング ] キーワード: php wordpress


19件の内、新着の記事から10件ずつ表示します。


[19] feedwordpress/feedwordpressrpc.class.php

投稿者: aaa 投稿日:2013年12月18日(水)00時27分39秒 FL1-219-107-53-105.fko.mesh.ad.jp  通報   返信・引用

<?php
################################################################################
## XML-RPC HOOKS: accept XML-RPC update pings from Contributors ################
################################################################################

class FeedWordPressRPC {
function FeedWordPressRPC () {
add_filter('xmlrpc_methods', array($this, 'xmlrpc_methods'));
}

function xmlrpc_methods ($args = array()) {
$args['weblogUpdates.ping'] = array($this, 'ping');
$args['feedwordpress.subscribe'] = array($this, 'subscribe');
$args['feedwordpress.deactivate'] = array($this, 'deactivate');
$args['feedwordpress.delete'] = array($this, 'delete');
$args['feedwordpress.nuke'] = array($this, 'nuke');
return $args;
}

function ping ($args) {
global $feedwordpress;

$delta = @$feedwordpress->update($args[1]);
if (is_null($delta)):
return array('flerror' => true, 'message' => "Sorry. I don't syndicate <$args[1]>.");
else:
$mesg = array();
if (isset($delta['new'])) { $mesg[] = ' '.$delta['new'].' new posts were syndicated'; }
if (isset($delta['updated'])) { $mesg[] = ' '.$delta['updated'].' existing posts were updated'; }

return array('flerror' => false, 'message' => "Thanks for the ping.".implode(' and', $mesg));
endif;
}

function validate (&$args) {
global $wp_xmlrpc_server;

// First two params are username/password
$username = $wp_xmlrpc_server->escape(array_shift($args));
$password = $wp_xmlrpc_server->escape(array_shift($args));

$ret = array();
if ( !$user = $wp_xmlrpc_server->login($username, $password) ) :
$ret = $wp_xmlrpc_server->error;
elseif (!current_user_can('manage_links')) :
$ret = new IXR_Error(401, 'Sorry, you cannot change the subscription list.');
endif;
return $ret;
}

function subscribe ($args) {
$ret = $this->validate($args);
if (is_array($ret)) : // Success
// The remaining params are feed URLs
foreach ($args as $arg) :
$finder = new FeedFinder($arg, /*verify=*/ false, /*fallbacks=*/ 1);
$feeds = array_values(array_unique($finder->find()));

if (count($feeds) > 0) :
$link_id = FeedWordPress::syndicate_link(
/*title=*/ feedwordpress_display_url($feeds[0]),
/*homepage=*/ $feeds[0],
/*feed=*/ $feeds[0]
);
$ret[] = array(
'added',
$feeds[0],
$arg,
);
else :
$ret[] = array(
'error',
$arg
);
endif;
endforeach;
endif;
return $ret;
} /* FeedWordPressRPC::subscribe () */

function unsubscribe ($method, $args) {
$ret = $this->validate($args);
if (is_array($ret)) : // Success
// The remaining params are feed URLs
foreach ($args as $arg) :
$link_id = FeedWordPress::find_link($arg);

if (!$link_id) :
$link_id = FeedWordPress::find_link($arg, 'link_url');
endif;

if ($link_id) :
$link = new SyndicatedLink($link_id);

$link->{$method}();
$ret[] = array(
'deactivated',
$arg,
);
else :
$ret[] = array(
'error',
$arg,
);
endif;
endforeach;
endif;
return $ret;
} /* FeedWordPress::unsubscribe () */

function deactivate ($args) {
return $this->unsubscribe('deactivate', $args);
} /* FeedWordPressRPC::deactivate () */

function delete ($args) {
return $this->unsubscribe('delete', $args);
} /* FeedWordPressRPC::delete () */

function nuke ($args) {
return $this->unsubscribe('nuke', $args);
} /* FeedWordPressRPC::nuke () */
} /* class FeedWordPressRPC */




[18] feedwordpress/compatability.php

投稿者: aaa 投稿日:2013年12月18日(水)00時27分16秒 FL1-219-107-53-105.fko.mesh.ad.jp  通報   返信・引用

<?php
################################################################################
## LEGACY API: Replicate or mock up functions for legacy support purposes ######
################################################################################

class FeedWordPressCompatibility {

/**
* FeedWordPressCompatibility::test_version: test version of WordPress
* based on the database schema version.
*
* @param int $floor The minimum version necessary
* @param mixed $ceiling The first version that is too high. If omitted
* or NULL, no version is too high.
* @return bool TRUE if within the range of versions, FALSE if too low
* or too high.
*/
/*static*/ function test_version ($floor, $ceiling = null) {
global $wp_db_version;

$ver = (isset($wp_db_version) ? $wp_db_version : 0);
$good = ($ver >= $floor);
if (!is_null($ceiling)) :
$good = ($good and ($ver < $ceiling));
endif;
return $good;
} /* FeedWordPressCompatibility::test_version() */

/*static*/ function insert_link_category ($name) {
global $wpdb;

// WordPress 2.3+ term/taxonomy API
$term = wp_insert_term($name, 'link_category');

// OK: returned array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id)
if (!is_wp_error($term)) :
$cat_id = $term['term_id'];

// Error: term with this name already exists. Well, let's use that then.
elseif ($term->get_error_code() == 'term_exists') :
// Already-existing term ID is returned in data field
$cat_id = $term->get_error_data('term_exists');

// Error: another kind of error, harder to recover from. Return WP_Error.
else :
$cat_id = $term;
endif;

// Return newly-created category ID
return $cat_id;
} /* FeedWordPressCompatibility::insert_link_category () */

/*static*/ function link_category_id ($value, $key = 'cat_name') {
global $wpdb;

$cat_id = NULL;

$the_term = term_exists($value, 'link_category');

// Sometimes, in some versions, we get a row
if (is_array($the_term)) :
$cat_id = $the_term['term_id'];

// other times we get an integer result
else :
$cat_id = $the_term;
endif;

return $cat_id;
} /* FeedWordPressCompatibility::link_category_id () */

/*static*/ function validate_http_request ($action = -1, $capability = null) {
// Only worry about this if we're using a method with significant side-effects
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') :
// Limit post by user capabilities
if (!is_null($capability) and !current_user_can($capability)) :
wp_die(__('Cheatin’ uh?'));
endif;

// If check_admin_referer() checks a nonce.
if (function_exists('wp_verify_nonce')) :
check_admin_referer($action);

// No nonces means no checking nonces.
else :
check_admin_referer();
endif;
endif;
} /* FeedWordPressCompatibility::validate_http_request() */

/*static*/ function stamp_nonce ($action = -1) {
// stamp form with hidden fields for a nonce in WP 2.0.3 & later
if (function_exists('wp_nonce_field')) :
wp_nonce_field($action);
endif;
} /* FeedWordPressCompatibility::stamp_nonce() */

/*static*/ function bottom_script_hook ($filename) {
global $fwp_path;

$hook = 'admin_footer-'.$fwp_path.'/'.basename($filename);
return $hook;
} /* FeedWordPressCompatibility::bottom_script_hook() */
} /* class FeedWordPressCompatibility */

// Compat

if (!function_exists('set_post_field')) {

/**
* Update data from a post field based on Post ID
*
* Examples of the post field will be, 'post_type', 'post_status', 'post_content', etc.
*
* The context values are based off of the taxonomy filter functions and
* supported values are found within those functions.
*
* @uses sanitize_post_field()
*
* @param string $field Post field name
* @param mixed $value New value for post field
* @param id $post Post ID
* @return bool Result of UPDATE query
*
* Included under terms of GPL from WordPress Ticket #10946 <http://core.trac.wordpress.org/attachment/ticket/10946/post.php.diff>
*/
function set_post_field ($field, $value, $post_id) {
global $wpdb;

$post_id = absint($post_id);
// sigh ... when FWP is active, I need to avoid avoid_kses_munge
// $value = sanitize_post_field($field, $value, $post_id, 'db');
return $wpdb->update($wpdb->posts, array($field => $value), array('ID' => $post_id));
} /* function set_post_field () */

} /* if */

require_once(dirname(__FILE__).'/feedwordpress-walker-category-checklist.class.php');

function fwp_category_checklist ($post_id = 0, $descendents_and_self = 0, $selected_cats = false, $params = array()) {
if (is_string($params)) :
$prefix = $params;
$taxonomy = 'category';
elseif (is_array($params)) :
$prefix = (isset($params['prefix']) ? $params['prefix'] : '');
$taxonomy = (isset($params['taxonomy']) ? $params['taxonomy'] : 'category');
endif;

$walker = new FeedWordPress_Walker_Category_Checklist($params);
$walker->set_prefix($prefix);
$walker->set_taxonomy($taxonomy);
wp_terms_checklist(/*post_id=*/ $post_id, array(
'taxonomy' => $taxonomy,
'descendents_and_self' => $descendents_and_self,
'selected_cats' => $selected_cats,
'popular_cats' => false,
'walker' => $walker,
'checked_ontop' => true,
));
}

function fwp_time_elapsed ($ts) {
if (function_exists('human_time_diff')) :
if ($ts >= time()) :
$ret = __(human_time_diff($ts)." from now");
else :
$ret = __(human_time_diff($ts)." ago");
endif;
else :
$ret = strftime('%x %X', $ts);
endif;
return $ret;
}

################################################################################
## UPGRADE INTERFACE: Have users upgrade DB from older versions of FWP #########
################################################################################

function fwp_upgrade_page () {
if (MyPHP::post('action')=='Upgrade') :
$ver = get_option('feedwordpress_version');
if (get_option('feedwordpress_version') != FEEDWORDPRESS_VERSION) :
echo "

\n";
echo "<h2>Upgrading FeedWordPress...</h2>";

$feedwordpress = new FeedWordPress;
$feedwordpress->upgrade_database($ver);
echo "

Done! Upgraded database to version ".FEEDWORDPRESS_VERSION.".

\n";
echo "<form action=\"\" method=\"get\">\n";
echo "
<input type=\"hidden\" name=\"page\" value=\"syndication.php\" />";
echo "<input type=\"submit\" value=\"Continue »\" /></form>
\n";
echo "
\n";
return;
else :
echo "

Already at version ".FEEDWORDPRESS_VERSION."!

";
endif;
endif;
?>

<h2>Upgrade FeedWordPress</h2>

It appears that you have installed FeedWordPress
<?php echo FEEDWORDPRESS_VERSION; ?> as an upgrade to an existing installation of
FeedWordPress. That's no problem, but you will need to take a minute out first
to upgrade your database: some necessary changes in how the software keeps
track of posts and feeds will cause problems such as duplicate posts and broken
templates if we were to continue without the upgrade.



Note that most of FeedWordPress's functionality is temporarily disabled
until we have successfully completed the upgrade. Everything should begin
working as normal again once the upgrade is complete. There's extraordinarily
little chance of any damage as the result of the upgrade, but if you're paranoid
like me you may want to back up your database before you proceed.



This may take several minutes for a large installation.



<form action="" method="post">
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_upgrade'); ?>
<input type="submit" name="action" value="Upgrade" />

</form>

<?php
} // function fwp_upgrade_page ()

function remove_dummy_zero ($var) {
return !(is_numeric($var) and ((int) $var == 0));
}



[17] feedwordpress/categories-page.php②

投稿者: aaa 投稿日:2013年12月18日(水)00時25分39秒 FL1-219-107-53-105.fko.mesh.ad.jp  通報   返信・引用

function save_settings ($post) {
if (isset($post['match_categories'])) :
foreach ($post['match_categories'] as $what => $set) :
// Defaulting is controlled by a separate radio button
if ($this->for_feed_settings()
and isset($post['match_default'])
and isset($post['match_default'][$what])
and $post['match_default'][$what]=='yes') :
$set = NULL; // Defaulted!
endif;

$this->update_setting("match/$what", $set, NULL);
endforeach;
endif;
$optionMap = $this->term_option_map();
$settingMap = $this->term_setting_map();

$saveTerms = array(); $separateSaveTerms = array('category' => array(), 'post_tag' => array());

if (!isset($post['tax_input'])) : $post['tax_input'] = array(); endif;

// Merge in data from older-notation category check boxes
if (isset($post['post_category'])) :
// Just merging in for processing below.
$post['tax_input']['category'] = array_merge(
(isset($post['tax_input']['category']) ? $post['tax_input']['category'] : array()),
$post['post_category']
);
endif;

// Process data from term tag boxes and check boxes
foreach ($post['tax_input'] as $tax => $terms) :
$saveTerms[$tax] = array();
if (is_array($terms)) : // Numeric IDs from checklist
foreach ($terms as $term) :
if ($term) :
$saveTerms[$tax][] = '{'.$tax.'#'.$term.'}';
endif;
endforeach;
else : // String from tag input
$saveTerms[$tax] = explode(",", $terms);
endif;
$saveTerms[$tax] = array_map('trim', $saveTerms[$tax]);

if (isset($optionMap[$tax])) :
$separateSaveTerms[$tax] = $saveTerms[$tax];
unset($saveTerms[$tax]);
endif;
endforeach;

if (isset($post['post_category'])) :
foreach ($post['post_category'] as $cat) :
$separateSaveTerms['category'][] = '{category#'.$cat.'}';
endforeach;
endif;

// Unmatched categories and tags
foreach (array('category', 'post_tag') as $what) :
if (isset($post["unfamiliar_{$what}"])) :
$this->update_setting(
"unfamiliar {$what}",
$post["unfamiliar_{$what}"],
'site-default'
);
endif;
endforeach;

// Categories and Tags
foreach ($separateSaveTerms as $tax => $terms) :
if ($this->for_feed_settings()) :
$this->link->update_setting($settingMap[$tax], $terms, array());
else :
if (!empty($terms)) :
update_option($optionMap[$tax], implode(FEEDWORDPRESS_CAT_SEPARATOR, $terms));
else :
delete_option($optionMap[$tax]);
endif;
endif;
endforeach;

// Other terms
$this->update_setting(array('feed'=>'terms', 'global'=>'syndication_terms'), $saveTerms, array());

if ($this->for_feed_settings()) :
// Category splitting regex
if (isset($post['cat_split'])) :
$this->link->update_setting('cat_split', trim($post['cat_split']), '');
endif;

// Treat global terms (cats, tags, etc.) as additional,
// or as defaults to be overridden and replaced?
if (isset($post['add_global'])) :
foreach ($post['add_global'] as $what => $value) :
$this->link->update_setting("add/$what", $value);
endforeach;
endif;
endif;
parent::save_settings($post);
} /* FeedWordPressCategoriesPage::save_settings() */

function display () {
////////////////////////////////////////////////
// Display settings boxes //////////////////////
////////////////////////////////////////////////

$this->boxes_by_methods = array(
'feed_categories_box' => __('Feed Categories & Tags'),
'categories_box' => array('title' => __('Categories'), 'id' => 'categorydiv'),
);

parent::display();
}
}

$categoriesPage = new FeedWordPressCategoriesPage;
$categoriesPage->display();



[16] feedwordpress/categories-page.php

投稿者: aaa 投稿日:2013年12月18日(水)00時23分10秒 FL1-219-107-53-105.fko.mesh.ad.jp  通報   返信・引用

<?php
require_once(dirname(__FILE__) . '/admin-ui.php');

class FeedWordPressCategoriesPage extends FeedWordPressAdminPage {
function FeedWordPressCategoriesPage ($link = -1) {
if (is_numeric($link) and -1 == $link) :
$link = $this->submitted_link();
endif;

FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresscategories', $link);
$this->dispatch = 'feedwordpress_admin_page_categories';
$this->pagenames = array(
'default' => 'Categories & Tags',
'settings-update' => 'Syndicated Categories & Tags',
'open-sheet' => 'Categories & Tags',
);
$this->filename = __FILE__;
}

function unfamiliar_category_label ($name) {
if (preg_match('/^create:(.*)$/', $name, $refs)) :
$tax = get_taxonomy($refs[1]);
$name = sprintf(__('Create new %s to match them'), $tax->labels->name);
endif;
return $name;
}


function feed_categories_box ($page, $box = NULL) {
$link = $page->link;

$globalPostType = get_option('feedwordpress_syndicated_post_type', 'post');
if ($this->for_feed_settings()) :
$post_type = $link->setting('syndicated post type', 'syndicated_post_type', 'post');
else :
$post_type = $globalPostType;
endif;
$taxonomies = get_object_taxonomies(array('object_type' => $post_type), 'names');

$unmatched = array('category' => array(), 'post_tag' => array());
$matchUl = array('cats' => array(), 'tags' => array(), 'filter' => array());
$tagLikeTaxonomies = array();
foreach ($taxonomies as $tax) :
$taxonomy = get_taxonomy($tax);

if (!$taxonomy->hierarchical) :
$tagLikeTaxonomies[] = $tax;
endif;

$name = 'create:'.$tax;
foreach (array('category', 'post_tag') as $what) :
$unmatched[$what][$name] = array(
'label' => $this->unfamiliar_category_label($name),
);
$unmatchedRadio[$what][$name] = '';
endforeach;

foreach (array('cats', 'tags', 'filter') as $what) :
$matchUl[$what][$tax] = array(
'checked' => '',
'labels' => $taxonomy->labels,
);
endforeach;
endforeach;

foreach ($unmatched as $what => $um) :
$unmatched[$what]['null'] = array('label' => __('Don\'t create any matching terms'));
$unmatchedRadio[$what]['null'] = '';
endforeach;

$globalUnmatched = array(
'category' => FeedWordPress::on_unfamiliar('category'),
'post_tag' => FeedWordPress::on_unfamiliar('post_tag'),
);
foreach ($globalUnmatched as $what => $value) :
if ($value=='create') : $value = 'create:category'; endif;
if ($value=='tag') : $value = 'create:post_tag'; endif;
$globalUnmatched[$what] = $value;
endforeach;

$globalMatch['cats'] = get_option('feedwordpress_match_cats', $taxonomies);
$globalMatch['tags'] = get_option('feedwordpress_match_tags', $tagLikeTaxonomies);
$globalMatch['filter'] = get_option('feedwordpress_match_filter', array());

$globalMatchLabels = array();
$nothingDoing = array('cats' => "won't try to match", 'tags' => "won't try to match", "filter" => "won't filter");

foreach ($globalMatch as $what => $domain) :
$labels = array(); $domain = array_filter($domain, 'remove_dummy_zero');
foreach ($domain as $tax) :
$tax = get_taxonomy($tax);
$labels[] = $tax->labels->name;
endforeach;

if (count($labels) > 0) :
$globalMatchLabels[$what] = implode(", ", $labels);
else :
$globalMatchLabels[$what] = $nothingDoing[$what];
endif;
endforeach;

if ($this->for_feed_settings()) :
$href = $this->admin_page_href(basename(__FILE__));

foreach ($unmatched as $what => $um) :
// Is the global default setting appropriate to this post type?
$GUC = $globalUnmatched[$what];
if (isset($um[$GUC])) :
// Yup. Let's add a site-default option
$currently = $um[$GUC]['label'];
$defaultLi = array(
'site-default' => array(
'label' => sprintf(
__('Use the site-wide setting Currently: %s'),
$href,
$currently
),
), );
$unmatchedColumns[$what] = array(
$defaultLi,
);
$unmatchedDefault[$what] = 'site-default';
$unmatchedRadio[$what]['site-default'] = '';
else :
$opts = array_keys($unmatched[$what]);
$unmatchedDefault[$what] = $opts[0];
$unmatchedColumns[$what] = array();
endif;

$ucKey[$what] = $link->setting("unfamiliar $what", NULL, NULL);
endforeach;

$match['cats'] = $this->link->setting('match/cats', NULL, NULL);
$match['tags'] = $this->link->setting('match/tags', NULL, NULL);
$match['filter'] = $this->link->setting('match/filter', NULL, NULL);
else :
foreach ($unmatched as $what => $um) :
$ucKey[$what] = FeedWordPress::on_unfamiliar($what);
endforeach;

$match = $globalMatch;
endif;

foreach ($ucKey as $what => $uck) :
if ($uck == 'tag') : $uck = 'create:post_tag'; endif;
if ($uck == 'create') : $uck = 'create:category'; endif;

if (!is_string($uck)) :
$uck = $unmatchedDefault[$what];
endif;
$ucKey[$what] = $uck;

if (!array_key_exists($uck, $unmatchedRadio[$what])) :
$obsoleteLi = array(
$uck => array(
'label' => ' '.$this->unfamiliar_category_label($uck).' (This setting is no longer applicable to the type of post syndicated from this feed!)

Please change this one of the following settings:

',
),
);
$unmatched[$what] = array_merge($obsoleteLi, $unmatched[$what]);
$unmatchedRadio[$what][$uck] = ' disabled="disabled"';
endif;

$unmatchedRadio[$what][$uck] .= ' checked="checked"';

$unmatchedColumns[$what][] = $unmatched[$what];
endforeach;

$defaulted = array();
foreach ($match as $what => $set) :
$defaulted[$what] = false;
if (is_null($set) or (count($set) < 1)) :
$defaulted[$what] = true;
if ($this->for_feed_settings()) :
$set = $globalMatch[$what];
$match[$what] = $globalMatch[$what];
endif;
endif;

if (!$defaulted[$what] or $this->for_feed_settings()) :
foreach ($set as $against) :
if (array_key_exists($against, $matchUl[$what])) :
$matchUl[$what][$against]['checked'] = ' checked="checked"';
endif;
endforeach;
endif;
endforeach;

// Hey ho, let's go...
$offerSiteWideSettings = ($page->for_feed_settings() and ($post_type==$globalPostType));
?>
<table class="edit-form narrow">
<tr>
<th scope="row">Match feed categories:</th>
<td><input type="hidden" name="match_categories[cats][]" value="0" />
<?php if ($offerSiteWideSettings) : ?>
<table class="twofer">
<tbody>
<tr><td class="equals first <?php if ($defaulted['cats']) : ?>active<?php else: ?>inactive<?php endif; ?>">

<label><input type="radio" name="match_default[cats]"
value="yes" <?php if ($defaulted['cats']) : ?> checked="checked"<?php endif; ?> />
Use the ">site-wide setting
Currently: <?php print $globalMatchLabels['cats']; ?></label>

</td>
<td class="equals second <?php if ($defaulted['cats']) : ?>inactive<?php else: ?>active<?php endif; ?>">

<label><input type="radio" name="match_default[cats]"
value="no" <?php if (!$defaulted['cats']) : ?> checked="checked"<?php endif; ?> />
Do something different with this feed.</label>
<?php else : ?>


<?php endif; ?>
When a feed provides categories for a post, try to match those categories
locally with:


<ul class="options compact">
<?php foreach ($matchUl['cats'] as $name => $li) : ?>
<li><label><input type="checkbox"
name="match_categories[cats][]" value="<?php print $name; ?>"
<?php print $li['checked']; ?> /> <?php $l = $li['labels']; print $l->name; ?></label></li>
<?php endforeach; ?>
</ul>
<?php if ($offerSiteWideSettings) : ?>
</td></tr>
</tbody>
</table>
<?php endif; ?>
</td>
</tr>

<tr>
<th scope="row">Unmatched categories:</th>
<td>

When <?php print $this->these_posts_phrase(); ?> have categories on
the feed that don't have any local matches yet...



<?php if (count($unmatchedColumns['category']) > 1) : ?>
<table class="twofer">
<?php else : ?>
<table style="width: 100%">
<?php endif; ?>
<tbody>
<tr>
<?php foreach ($unmatchedColumns['category'] as $index => $column) : ?>
<td class="equals <?php print (($index == 0) ? 'first' : 'second'); ?> inactive"><ul class="options">
<?php foreach ($column as $name => $li) : ?>
<li><label><input type="radio" name="unfamiliar_category" value="<?php print $name; ?>"<?php print $unmatchedRadio['category'][$name]; ?> /> <?php print $li['label']; ?></label></li>
<?php endforeach; ?>
</ul></td>
<?php endforeach; ?>
</tr>
</tbody>
</table>
</td></tr>

<tr>
<th scope="row">Match inline tags:

Applies only to inline tags marked
as links in the text of syndicated posts, using the
<code><a rel="tag">...</a></code> microformat.
Most feeds with "tags" just treat them as normal feed categories,
like those handled above.


</th>
<td><input type="hidden" name="match_categories[tags][]" value="0" />
<?php if ($offerSiteWideSettings) : ?>
<table class="twofer">
<tbody>
<tr><td class="equals first <?php if ($defaulted['tags']) : ?>active<?php else: ?>inactive<?php endif; ?>">

<label><input type="radio" name="match_default[tags]"
value="yes" <?php if ($defaulted['tags']) : ?> checked="checked"<?php endif; ?> />
Use the ">site-wide setting
Currently: <?php print $globalMatchLabels['tags']; ?></label>


</td>
<td class="equals second <?php if ($defaulted['tags']) : ?>inactive<?php else: ?>active<?php endif; ?>">

<label><input type="radio" name="match_default[tags]"
value="no" <?php if (!$defaulted['tags']) : ?> checked="checked"<?php endif; ?> />
Do something different with this feed.</label>
<?php else : ?>


<?php endif; ?>
When a feed provides tags inline in a post, try to match those tags
locally with:


<ul class="options compact">
<?php foreach ($matchUl['tags'] as $name => $li) : ?>
<li><label><input type="checkbox"
name="match_categories[tags][]" value="<?php print $name; ?>"
<?php print $li['checked']; ?> /> <?php $l = $li['labels']; print $l->name; ?></label></li>
<?php endforeach; ?>
</ul>
<?php if ($offerSiteWideSettings) : ?>
</td></tr>
</tbody>
</table>
<?php endif; ?>
</td>
</tr>

<tr>
<th scope="row">Unmatched inline tags:</th>
<td>

When the text of <?php print $this->these_posts_phrase(); ?> contains
inline tags that don't have any local matches yet...



<?php if (count($unmatchedColumns['post_tag']) > 1) : ?>
<table class="twofer">
<?php else : ?>
<table style="width: 100%">
<?php endif; ?>
<tbody>
<tr>
<?php foreach ($unmatchedColumns['post_tag'] as $index => $column) : ?>
<td class="equals <?php print (($index == 0) ? 'first' : 'second'); ?> inactive"><ul class="options">
<?php foreach ($column as $name => $li) : ?>
<li><label><input type="radio" name="unfamiliar_post_tag" value="<?php print $name; ?>"<?php print $unmatchedRadio['post_tag'][$name]; ?> /> <?php print $li['label']; ?></label></li>
<?php endforeach; ?>
</ul></td>
<?php endforeach; ?>
</tr>
</tbody>
</table>

</td></tr>

<tr>
<th scope="row">Filter:</th>
<td><input type="hidden" name="match_categories[filter][]" value="0" />
<?php if ($offerSiteWideSettings) : ?>
<table class="twofer">
<tbody>
<tr>
<td class="equals first <?php if ($defaulted['filter']) : ?>active<?php else: ?>inactive<?php endif; ?>">

<label><input type="radio" name="match_default[filter]"
value="yes" <?php if ($defaulted['filter']) : ?> checked="checked"<?php endif; ?> />
Use the ">site-wide setting
Currently: <?php print $globalMatchLabels['filter']; ?></label>


</td>
<td class="equals second <?php if ($defaulted['filter']) : ?>inactive<?php else: ?>active<?php endif; ?>">

<label><input type="radio" name="match_default[filter]"
value="no" <?php if (!$defaulted['filter']) : ?> checked="checked"<?php endif; ?> />
Do something different with this feed:</label>



<?php endif; ?>

<ul class="options">
<?php foreach ($matchUl['filter'] as $tax => $li) : ?>
<li><label><input type="checkbox" name="match_categories[filter][]" value="<?php print $tax; ?>"
<?php print $li['checked']; ?> /> Don't syndicate posts unless they match at
least one local <?php $l = $li['labels']; print $l->singular_name; ?></label></li>
<?php endforeach; ?>
</ul>

<?php if ($offerSiteWideSettings) : ?>

</td></tr>
</tbody>
</table>
<?php endif; ?>
</td>
</tr>
<?php if ($page->for_feed_settings()) : ?>
<tr>
<th scope="row">Multiple categories:</th>
<td>
<input type="text" size="20" id="cat_split" name="cat_split" value="<?php if (isset($link->settings['cat_split'])) : echo htmlspecialchars($link->settings['cat_split']); endif; ?>" />

Enter a Perl-compatible regular expression here if the feed provides multiple
categories in a single category element. The regular expression should match
the characters used to separate one category from the next. If the feed uses
spaces (like del.icio.us), use the pattern "\s".
If the feed does not provide multiple categories in a single element, leave this
blank.

</td>
</tr>
<?php endif; ?>
</table>
<?php
} /* FeedWordPressCategoriesPage::feed_categories_box() */

function term_option_map () {
return array(
'category' => 'feedwordpress_syndication_cats',
'post_tag' => 'feedwordpress_syndication_tags',
);
}
function term_setting_map () {
return array(
'category' => 'cats',
'post_tag' => 'tags',
);
}

function categories_box ($page, $box = NULL) {
$link = $page->link;

if ($this->for_feed_settings()) :
$post_type = $link->setting('syndicated post type', 'syndicated_post_type', 'post');
else :
$post_type = get_option('feedwordpress_syndicated_post_type', 'post');
endif;
$taxonomies = get_object_taxonomies(array('object_type' => $post_type), 'names');

$option_map = $this->term_option_map();
$setting_map = $this->term_setting_map();
$globalTax = get_option('feedwordpress_syndication_terms', array());
if ($page->for_feed_settings()) :
$terms = $link->setting('terms', NULL, array());
endif;

?>
<table class="edit-form narrow">
<tbody>
<?php
foreach ($taxonomies as $tax) :
$taxonomy = get_taxonomy($tax);
?>
<tr><th><?php print $taxonomy->labels->name; ?></th>
<td><?php
if (isset($option_map[$tax])) :
$option = $option_map[$tax];
$globalCats = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option($option));
elseif (isset($globalTax[$tax])) :
$globalCats = $globalTax[$tax];
else :
$globalCats = array();
endif;
$globalCats = array_map('trim', $globalCats);

if ($page->for_feed_settings()) :
$add_global_categories = $link->setting("add/$tax", NULL, 'yes');
$checked = array('yes' => '', 'no' => '');
$checked[$add_global_categories] = ' checked="checked"';

if (isset($setting_map[$tax])) :
$setting = $setting_map[$tax];
$cats = $link->setting($setting, NULL, NULL);
if (is_null($cats)) : $cats = array(); endif;
elseif (isset($terms[$tax])) :
$cats = $terms[$tax];
else :
$cats = array();
endif;
else :
$cats = $globalCats;
endif;

if ($page->for_feed_settings()) :
?>
<table class="twofer">
<tbody>
<tr>
<td class="primary">
<?php
endif;

$dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL, /*taxonomies=*/ array($tax));

if ($taxonomy->hierarchical) : // Use a category-style checkbox
fwp_category_box($dogs, 'all '.$page->these_posts_phrase(), /*tags=*/ array(), /*params=*/ array('taxonomy' => $tax));
else : // Use a tag-style edit box
fwp_tags_box($cats, 'all '.$page->these_posts_phrase(), /*params=*/ array('taxonomy' => $tax));
endif;

$globalDogs = SyndicatedPost::category_ids($globalCats, /*unfamiliar=*/ 'create:'.$tax, /*taxonomies=*/ array($tax));

$siteWideHref = $this->admin_page_href(basename(__FILE__));

if ($page->for_feed_settings()) :
?>
</td>
<td class="secondary">
<h4>Site-wide <?php print $taxonomy->labels->name; ?></h4>
<?php if (count($globalCats) > 0) : ?>
  <ul class="current-setting">
  <?php foreach ($globalDogs as $dog) : ?>
    <li><?php $cat = get_term($dog, $tax); print $cat->name; ?></li>
  <?php endforeach; ?>
  </ul>
  
  


<?php else : ?>
  

Site-wide settings may also assign categories to syndicated
posts.
<?php endif; ?>
Should <?php print $page->these_posts_phrase(); ?> be assigned
these <?php print $taxonomy->labels->name; ?> from the ">site-wide settings, in
addition to the feed-specific <?php print $taxonomy->labels->name; ?> you set up here?



<ul class="settings">
<li>

<label><input type="radio" name="add_global[<?php print $tax; ?>]" value="yes" <?php print $checked['yes']; ?> /> Yes. Place <?php print $page->these_posts_phrase(); ?> under all these categories.</label>

</li>
<li>

<label><input type="radio" name="add_global[<?php print $tax; ?>]" value="no" <?php print $checked['no']; ?> /> No. Only use the categories I set up on the left. Do not use the global defaults for <?php print $page->these_posts_phrase(); ?></label>

</li>
</ul>
</td>
</tr>
</tbody>
</table>
<?php
endif;
?>
</td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
<?php
} /* FeedWordPressCategoriesPage::categories_box () */



[15] feedwordpress/feeds-page.php③

投稿者: aaa 投稿日:2013年12月18日(水)00時22分3秒 FL1-219-107-53-105.fko.mesh.ad.jp  通報   返信・引用

function display_feedfinder () {
global $wpdb;

$lookup = (isset($_REQUEST['lookup']) ? $_REQUEST['lookup'] : NULL);

$auth = MyPHP::request('link_rss_auth_method');
$username = MyPHP::request('link_rss_username');
$password = MyPHP::request('link_rss_password');
$credentials = array(
"authentication" => $auth,
"username" => $username,
"password" => $password,
);

$feeds = array(); $feedSwitch = false; $current = null;
if ($this->for_feed_settings()) : // Existing feed?
$feedSwitch = true;
if (is_null($lookup)) :
// Switch Feed without a specific feed yet suggested
// Go to the human-readable homepage to look for
// auto-detection links

$lookup = $this->link->link->link_url;
$auth = $this->link->setting('http auth method');
$username = $this->link->setting('http username');
$password = $this->link->setting('http password');

// Guarantee that you at least have the option to
// stick with what works.
$current = $this->link->link->link_rss;
$feeds[] = $current;
endif;
$name = esc_html($this->link->link->link_name);
else: // Or a new subscription to add?
$name = "Subscribe to <code>".esc_html(feedwordpress_display_url($lookup))."</code>";
endif;
?>


<h2>Feed Finder: <?php echo $name; ?></h2>

<?php
if ($feedSwitch) :
$this->display_alt_feed_box($lookup);
endif;

$finder = array();
if (!is_null($current)) :
$finder[$current] = new FeedFinder($current);
endif;
$finder[$lookup] = new FeedFinder($lookup);

foreach ($finder as $url => $ff) :
$feeds = array_merge($feeds, $ff->find(
/*url=*/ NULL,
/*params=*/ $credentials));
endforeach;

$feeds = array_values( // Renumber from 0..(N-1)
$feeds
);

// Allow for some simple FeedFinder results filtering
$feeds = apply_filters(
'feedwordpress_feedfinder_results',
$feeds,
array(
"url" => $lookup,
"auth" => $auth,
"username" => $username,
"password" => $password,
"finder" => $finder,
),
$this
);

if (count($feeds) > 0):
if ($feedSwitch) :
?>
<h3>Feeds Found</h3>
<?php
endif;

if (count($feeds) > 1) :
$option_template = 'Option %d: ';
$form_class = ' class="multi"';
?>

This web page provides at least <?php print count($feeds); ?> different feeds. These feeds may provide the same information
in different formats, or may track different items. (You can check the Feed Information and the
Sample Item for each feed to get an idea of what the feed provides.) Please select the feed that you'd like to subscribe to.


<?php
else :
$option_template = '';
$form_class = '';
endif;

global $fwp_credentials;

foreach ($feeds as $key => $f):
$ofc = $fwp_credentials;
$fwp_credentials = $credentials; // Set
$pie = FeedWordPress::fetch($f, array("cache" => false));
$fwp_credentials = $ofc; // Re-Set

$rss = (is_wp_error($pie) ? $pie : new MagpieFromSimplePie($pie));

if ($this->url_for_401($pie)) :
$this->display_alt_feed_box($lookup, array(
"err" => $pie,
"auth" => $auth,
"username" => $username,
"password" => $password
));
continue;
endif;

if ($rss and !is_wp_error($rss)):
$feed_link = (isset($rss->channel['link'])?$rss->channel['link']:'');
$feed_title = (isset($rss->channel['title'])?$rss->channel['title']:$feed_link);
$feed_type = ($rss->feed_type ? $rss->feed_type : 'Unknown');
$feed_version_template = '%.1f';
$feed_version = $rss->feed_version;
else :
// Give us some sucky defaults
$feed_title = feedwordpress_display_url($lookup);
$feed_link = $lookup;
$feed_type = 'Unknown';
$feed_version_template = '';
$feed_version = '';
endif;
?>
<form<?php print $form_class; ?> action="<?php $this->form_action('syndication.php'); ?>" method="post">
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?>

<?php
$classes = array('feed-found'); $currentFeed = '';
if (!is_null($current) and $current==$f) :
$classes[] = 'current';
$currentFeed = ' (currently subscribed)';
endif;
if ($key%2) :
$classes[] = 'alt';
endif;
?>
<fieldset class="<?php print implode(" ", $classes); ?>">
<legend><?php printf($option_template, ($key+1)); print $feed_type." "; printf($feed_version_template, $feed_version); ?> feed<?php print $currentFeed; ?></legend>

<?php
$this->stamp_link_id();

// No feed specified = add new feed; we
// need to pass along a starting title
// and homepage URL for the new Link.
if (!$this->for_feed_settings()):
?>
<input type="hidden" name="feed_title" value="<?php echo esc_html($feed_title); ?>" />
<input type="hidden" name="feed_link" value="<?php echo esc_html($feed_link); ?>" />
<?php
endif;
?>

<input type="hidden" name="feed" value="<?php echo esc_html($f); ?>" />
<input type="hidden" name="action" value="switchfeed" />



<?php
$link = NULL;
$post = NULL;
if (!is_wp_error($rss) and count($rss->items) > 0):
// Prepare to display Sample Item
$link = new MagpieMockLink(array('simplepie' => $pie, 'magpie' => $rss), $f);
$post = new SyndicatedPost(array('simplepie' => $rss->originals[0], 'magpie' => $rss->items[0]), $link);
?>
<h3>Sample Item</h3>
<ul>
<li>Title: post['meta']['syndication_permalink']; ?>"><?php echo $post->post['post_title']; ?></li>
<li>Date: <?php print date('d-M-y g:i:s a', $post->published()); ?></li>
</ul>

<?php print $post->post['post_content']; ?>

<?php
do_action('feedwordpress_feed_finder_sample_item', $f, $post, $link);
else:
if (is_wp_error($rss)) :
print '
';
print "<h3>Problem:</h3>\n";
print "

FeedWordPress encountered the following error
when trying to retrieve this feed:

";
print '

<code>'.$rss->get_error_message().'</code>

';
print "

If you think this is a temporary problem, you can still force FeedWordPress to add the subscription. FeedWordPress will not be able to find any syndicated posts until this problem is resolved.

";
print "
";
endif;
?>
<h3>No Items</h3>

FeedWordPress found no posts on this feed.


<?php
endif;
?>



<h3>Feed Information</h3>
<ul>
<li>Homepage: "><?php echo is_null($feed_title)?'Unknown':$feed_title; ?></li>
<li>Feed URL: " href="<?php echo esc_html($f); ?>"><?php echo esc_html(feedwordpress_display_url($f, 40, 10)); ?> (> for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate)</li>
<li>Encoding: <?php echo isset($rss->encoding)?esc_html($rss->encoding):"Unknown"; ?></li>
<li>Description: <?php echo isset($rss->channel['description'])?esc_html($rss->channel['description']):"Unknown"; ?></li>
</ul>
<?php $this->display_authentication_credentials_box(array(
'username' => $username,
'password' => $password,
'method' => $auth,
)); ?>
<?php do_action('feedwordpress_feedfinder_form', $f, $post, $link, $this->for_feed_settings()); ?>
<input type="submit" class="button-primary" name="Use" value="« Use this feed" />
<input type="submit" class="button" name="Cancel" value="× Cancel" />



</fieldset>
<!-- class="inside" -->
</form>
<?php
unset($link);
unset($post);
endforeach;
else:
foreach ($finder as $url => $ff) :
$url = esc_html($url);
print "<h3>Searched for feeds at ${url}</h3>\n";
print "

".__('Error').": ".__("FeedWordPress couldn't find any feeds at").' <code>'.htmlspecialchars($lookup).'</code>';
print ". ".__('Try another URL').".

";

// Diagnostics
print "
\n";
print "<h3>".__('Diagnostic information')."</h3>\n";
if (!is_null($ff->error()) and strlen($ff->error()) > 0) :
print "<h4>".__('HTTP request failure')."</h4>\n";
print "

".$ff->error()."

\n";
else :
print "<h4>".__('HTTP request completed')."</h4>\n";
print "

Status ".$ff->status().": ".$this->HTTPStatusMessages[(int) $ff->status()]."

\n";
endif;

// Do some more diagnostics if the API for it is available.
if (function_exists('_wp_http_get_object')) :
$httpObject = _wp_http_get_object();

if (is_callable(array($httpObject, '_getTransport'))) :
$transports = $httpObject->_getTransport();

print "<h4>".__('HTTP Transports available').":</h4>\n";
print "<ol>\n";
print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n";
print "</ol>\n";
elseif (is_callable(array($httpObject, '_get_first_available_transport'))) :
$transport = $httpObject->_get_first_available_transport(
array(),
$url
);

print "<h4>".__("HTTP Transport").":</h4>\n";
print "<ol>\n";
print "<li>".FeedWordPress::val($transport)."</li>\n";
print "</ol>\n";
endif;

print "
\n";
endif;
endforeach;
endif;

if (!$feedSwitch) :
$this->display_alt_feed_box($lookup, /*alt=*/ true);
endif;
?>
<!-- class="wrap" -->
<?php
return false; // Don't continue
} /* FeedWordPressFeedsPage::display_feedfinder() */

function display_alt_feed_box ($lookup, $params = false) {
global $fwp_post;

if (is_bool($params)) :
$params = array("alt" => $params);
endif;

$params = wp_parse_args($params, array( // Defaults
"alt" => false,
"err" => NULL,
"auth" => NULL,
"password" => NULL,
"username" => NULL,
));
$alt = $params['alt'];

?>
<form action="<?php $this->form_action(); ?>" method="post">
<?php
FeedWordPressCompatibility::stamp_nonce($this->dispatch);
?>
<fieldset class="alt"
<?php if (!$alt): ?>style="margin: 1.0em 3.0em; font-size: smaller;"<?php endif; ?>>
<legend><?php if ($alt) : ?>Alternative feeds<?php else: ?>Find feeds<?php endif; ?></legend>
<?php if ($alt) : ?><h3>Use a different feed</h3><?php endif; ?>
<?php if (is_wp_error($params['err'])) :
?>

401 Not Authorized. This URL may require
a username and password to access it.
You may want to add login
credentials below and check it again.


<?php
endif;
?>
<label>Address:
<input type="text" name="lookup" id="use-another-feed"
placeholder="URL"
<?php if (is_null($lookup)) : ?>
value="URL"
<?php else : ?>
value="<?php print esc_html($lookup); ?>"
<?php endif; ?>
size="64" style="max-width: 80%" /></label>
<?php if (is_null($lookup)) : ?>
<?php FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed'); ?>
<?php endif; ?>

<?php $this->stamp_link_id('link_id'); ?>
<input type="hidden" name="action" value="feedfinder" />
<input type="submit" class="button<?php if ($alt): ?>-primary<?php endif; ?>" value="Check »" />


<?php $this->display_authentication_credentials_box(array(
'username' => $params['username'],
'password' => $params['password'],
'method' => $params['auth'],
)); ?>

This can be the address of a feed, or of a website. FeedWordPress
will try to automatically detect any feeds associated with a
website.


<!-- class="inside" -->
</fieldset></form>

<?php
} /* FeedWordPressFeedsPage::display_alt_feed_box() */

function save_settings ($post) {
if ($this->for_feed_settings()) :

if (isset($post['link_rss_params_key'])) :
$qp = array();
foreach ($post['link_rss_params_key'] as $index => $key) :
if (strlen($key) > 0) :
if (isset($post['link_rss_params_value'][$index])
and strlen($post['link_rss_params_value'][$index])) :
$value = $post['link_rss_params_value'][$index];
$qp[] = array($key, $value);
endif;
endif;
endforeach;
$this->update_setting('query parameters', serialize($qp));
endif;

// custom feed settings first
foreach ($post['notes'] as $mn) :
$mn['key0'] = (isset($mn['key0']) ? trim($mn['key0']) : NULL);
$mn['key1'] = trim($mn['key1']);
if (preg_match("\007^(("
.implode(')|(',$this->special_settings)
."))$\007i",
$mn['key1'])) :
$mn['key1'] = 'user/'.$mn['key1'];
endif;

if (strlen($mn['key0']) > 0) :
unset($this->link->settings[$mn['key0']]); // out with the old
endif;

if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
$this->link->settings[$mn['key1']] = $mn['value']; // in with the new
endif;
endforeach;

// now stuff through the web form
// hardcoded feed info

foreach (array('name', 'description', 'url') as $what) :
// We have a checkbox for "No," so if it's unchecked, mark as "Yes."
$this->link->settings["hardcode {$what}"] = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes');
if (FeedWordPress::affirmative($this->link->settings, "hardcode {$what}")) :
$this->link->link->{'link_'.$what} = $post['link'.$what];
endif;
endforeach;

// Update scheduling
if (isset($post['update_schedule'])) :
$this->link->settings['update/hold'] = $post['update_schedule'];
endif;

if (isset($post['use_default_update_window']) and strtolower($post['use_default_update_window'])=='yes') :
unset($this->link->settings['update/window']);
elseif (isset($post['update_window'])):
if ((int) $post['update_window'] > 0) :
$this->link->settings['update/window'] = (int) $post['update_window'];
endif;
endif;

else :
// Global
update_option('feedwordpress_cat_id', $post['syndication_category']);

if (!isset($post['automatic_updates']) or !in_array($post['automatic_updates'], array('init', 'shutdown'))) :
$automatic_updates = NULL;
else :
$automatic_updates = $post['automatic_updates'];
endif;
update_option('feedwordpress_automatic_updates', $automatic_updates);

if (isset($post['update_window'])):
if ((int) $post['update_window'] > 0) :
update_option('feedwordpress_update_window', (int) $post['update_window']);
endif;
endif;

update_option('feedwordpress_update_time_limit', ($post['update_time_limit']=='yes')?(int) $post['time_limit_seconds']:0);

foreach (array('name', 'description', 'url') as $what) :
// We have a checkbox for "No," so if it's unchecked, mark as "Yes."
$hardcode = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes');
update_option("feedwordpress_hardcode_{$what}", $hardcode);
endforeach;

endif;

if (isset($post['fetch_timeout'])) :
if (isset($post['fetch_timeout_default']) and $post['fetch_timeout_default']=='yes') :
$timeout = NULL;
else :
$timeout = $post['fetch_timeout'];
endif;

if (is_int($timeout)) :
$timeout = intval($timeout);
endif;
$this->update_setting('fetch timeout', $timeout);
endif;

if (isset($post['update_incremental'])) :
$this->update_setting('update_incremental', $post['update_incremental']);
endif;

if (isset($post['tombstones'])) :
$this->update_setting('tombstones', $post['tombstones']);
endif;

if (isset($post['update_minimum'])) :
$this->update_setting('update/minimum', $post['update_minimum']);
endif;

if (
isset($post['link_rss_auth_method'])
and $post['link_rss_auth_method']
and ('-' != $post['link_rss_auth_method'])
) :
$this->update_setting('http auth method', $post['link_rss_auth_method']);
else :
$this->update_setting('http auth method', NULL);
endif;

if (
isset($post['link_rss_username'])
and (strlen($post['link_rss_username']) > 0)
and ('-' != $post['link_rss_auth_method'])
) :
$this->update_setting('http username', $post['link_rss_username']);
else :
$this->update_setting('http username', NULL);
endif;

if (
isset($post['link_rss_password'])
and (strlen($post['link_rss_password']) > 0)
and ('-' != $post['link_rss_auth_method'])
) :
$this->update_setting('http password', $post['link_rss_password']);
else :
$this->update_setting('http password', NULL);
endif;

$this->updatedPosts->accept_POST($post);

parent::save_settings($post);
} /* FeedWordPressFeedsPage::save_settings() */

} /* class FeedWordPressFeedsPage */

$feedsPage = new FeedWordPressFeedsPage;
$feedsPage->display();



[14] feedwordpress/feeds-page.php②

投稿者: aaa 投稿日:2013年12月18日(水)00時19分20秒 FL1-219-107-53-105.fko.mesh.ad.jp  通報   返信・引用

function display_authentication_credentials_box ($params = array()) {
static $count = 0;

$params = wp_parse_args($params, array(
'username' => NULL,
'password' => NULL,
'method' => '-',
));

// Equivalents
if (is_null($params['method'])) : $params['method'] = '-'; endif;

$count++;
$slug = ($count > 1 ? '-'.$count : '');

global $feedwordpress;
$authMethods = apply_filters(
'feedwordpress_http_auth_methods',
$feedwordpress->httpauth->methods_available()
);

if (count($authMethods) > 1) : /* More than '-' */
?>



<script type="text/javascript">
jQuery('<td>" href="#">(X) Remove</td>')
.appendTo('#link-rss-authentication-credentials<?php print $slug; ?>')
.click( feedAuthenticationMethodUnPress );
jQuery('#link-rss-auth-method<?php print $slug; ?>').change( feedAuthenticationMethod );
feedAuthenticationMethod({
init: true,
node: jQuery('#link-rss-authentication<?php print $slug; ?>') });
</script>

<?php
endif;
}

function feed_information_box ($page, $box = NULL) {
global $wpdb;
$link_rss_params = maybe_unserialize($page->setting('query parameters', ''));
if (!is_array($link_rss_params)) :
$link_rss_params = array();
endif;

if ($page->for_feed_settings()) :
$info['name'] = esc_html($page->link->link->link_name);
$info['description'] = esc_html($page->link->link->link_description);
$info['url'] = esc_html($page->link->link->link_url);
$rss_url = $page->link->link->link_rss;

$hardcode['name'] = $page->link->hardcode('name');
$hardcode['description'] = $page->link->hardcode('description');
$hardcode['url'] = $page->link->hardcode('url');
else :
$cat_id = FeedWordPress::link_category_id();

$params = array();
if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_USES_ARGS_TAXONOMY)) :
$params['taxonomy'] = 'link_category';
else :
$params['type'] = 'link';
endif;
$params['hide_empty'] = false;
$results = get_categories($params);

// Guarantee that the Contributors category will be in the drop-down chooser, even if it is empty.
$found_link_category_id = false;
foreach ($results as $row) :
// Normalize case
if (!isset($row->cat_id)) : $row->cat_id = $row->cat_ID; endif;

if ($row->cat_id == $cat_id) : $found_link_category_id = true; endif;
endforeach;

if (!$found_link_category_id) :
$results[] = get_category($cat_id);
endif;

$info = array();
$rss_url = null;

$hardcode['name'] = get_option('feedwordpress_hardcode_name');
$hardcode['description'] = get_option('feedwordpress_hardcode_description');
$hardcode['url'] = get_option('feedwordpress_hardcode_url');
endif;

$hideAuth = false;

$username = $this->setting('http username', NULL);

if (is_null($username)) :
$username = '';
$hideAuth = true;
endif;

$password = $this->setting('http password', NULL);
if (is_null($password)) :
$password = '';
endif;

$auth = $this->setting('http auth method', NULL);

global $feedwordpress;

if (is_null($auth) or (strlen($auth)==0)) :
$auth = '-';
$hideAuth = true;
endif;

// Hey ho, let's go

?>
<table class="edit-form">

<?php if ($page->for_feed_settings()) : ?>

<tr>
<th scope="row"><?php _e('Feed URL:') ?></th>
<td>"><?php echo esc_html($rss_url); ?>
(?url=<?php echo urlencode($rss_url); ?>"
title="Check feed <<?php echo esc_html($rss_url); ?>> for validity">validate
)
<input type="submit" name="feedfinder" value="switch →" style="font-size:smaller" />

<?php $this->display_authentication_credentials_box(array(
'username' => $username,
'password' => $password,
'method' => $auth,
)); ?>

<table id="link-rss-params">
<tbody>
<?php
$link_rss_params['new'] = array('', '');
$i = 0;
foreach ($link_rss_params as $index => $pair) :
?>
<tr class="link-rss-params-row" id="link-rss-params-<?php print $index; ?>">
<td><label>Parameter: <input type="text" class="link_params_key"
name="link_rss_params_key[<?php print $index; ?>]" value="<?php print esc_html($pair[0]); ?>"
size="5" style="width: 5em" placeholder="name" /></label></td>
<td class="link-rss-params-value-cell"><label class="link_params_value_label">= <input type="text" class="link_params_value"
name="link_rss_params_value[<?php print $index; ?>]" value="<?php print esc_html($pair[1]); ?>"
size="8" placeholder="value" /></label></td>
</tr>
<?php
$i++;
endforeach;
?>
</tbody>
</table>

<input type="hidden" id="link-rss-params-num" name="link_rss_params_num" value="<?php print $i; ?>" />


<script type="text/javascript">
function linkParamsRowRemove (element) {
jQuery(element).closest('tr').fadeOut('slow', function () {
jQuery(this).remove();
} );
}

jQuery('<td>(X) Remove</td>').insertAfter('.link-rss-params-value-cell');

jQuery('#link-rss-params-new').hide();
jQuery('+ Add a query parameter').insertAfter('#link-rss-params');
jQuery('#link-rss-params-add').click( function () {
var next = jQuery('#link-rss-params-num').val();
var newRow = jQuery('#link-rss-params-new').clone().attr('id', 'link-rss-params-'+next);
newRow.find('.link_params_key').attr('name', 'link_rss_params_key['+next+']');
newRow.find('.link_params_value').attr('name', 'link_rss_params_value['+next+']');

newRow.find('.link-rss-params-remove').click( function () {
linkParamsRowRemove(this);
return false;
} );

newRow.appendTo('#link-rss-params');
newRow.show();

// Update counter for next row.
next++;
jQuery('#link-rss-params-num').val(next);

return false;
} );
jQuery('.link-rss-params-remove').click( function () {
linkParamsRowRemove(this);
return false;
} );
</script>
</td>
</tr>

<?php
$rows = array(
"name" => __('Link Name'),
"description" => __('Short Description'),
"url" => __('Homepage'),
);
foreach ($rows as $what => $label) :
?>
<tr>
<th scope="row"><?php print $label ?></th>
<td>
-edit"><input type="text" name="link<?php print $what; ?>"
value="<?php echo $info[$what]; ?>" style="width: 95%" />




<label><input id="basics-hardcode-<?php print $what; ?>"
type="radio" name="hardcode_<?php print $what; ?>" value="no"
<?php echo (($hardcode[$what]=='yes')?'':' checked="checked"');?>
onchange="contextual_appearance('basics-hardcode-<?php print $what; ?>', 'basics-<?php print $what; ?>-view', 'basics-<?php print $what; ?>-edit', 'no', 'block', /*checkbox=*/ true)"
/> Update automatically from feed</label>
<label><input type="radio" name="hardcode_<?php print $what; ?>" value="yes"
<?php echo (($hardcode[$what]!='yes')?'':' checked="checked"');?>
onchange="contextual_appearance('basics-hardcode-<?php print $what; ?>', 'basics-<?php print $what; ?>-view', 'basics-<?php print $what; ?>-edit', 'no', 'block', /*checkbox=*/ true)"
/> Edit manually</label>

</td>
</tr>
<?php
endforeach;
?>

<?php else : ?>

<tr>
<th scope="row">Syndicated Link category:</th>
<td>

<select name="syndication_category" size="1">
<?php
foreach ($results as $row) :
// Normalize case
if (!isset($row->cat_id)) : $row->cat_id = $row->cat_ID; endif;

echo "\n\t<option value=\"$row->cat_id\"";
if ($row->cat_id == $cat_id) :
echo " selected='selected'";
endif;
echo ">$row->cat_id: ".esc_html($row->cat_name);
echo "</option>\n";
endforeach;
?></select>


FeedWordPress will syndicate the
links placed under this link category.


</td>
</tr>

<tr>
<th scope="row">Link Names:</th>
<td><label><input type="checkbox" name="hardcode_name" value="no"<?php echo (($hardcode['name']=='yes')?'':' checked="checked"');?>/> Update contributor titles automatically when the feed title changes</label></td>
</tr>

<tr>
<th scope="row">Short descriptions:</th>
<td><label><input type="checkbox" name="hardcode_description" value="no"<?php echo (($hardcode['description']=='yes')?'':' checked="checked"');?>/> Update contributor descriptions automatically when the feed tagline changes</label></td>
</tr>

<tr>
<th scope="row">Homepages:</th>
<td><label><input type="checkbox" name="hardcode_url" value="no"<?php echo (($hardcode['url']=='yes')?'':' checked="checked"');?>/> Update contributor homepages automatically when the feed link changes</label></td>
</tr>

<?php endif; ?>

</table>
<?php
} /* FeedWordPressFeedsPage::feed_information_box() */

function custom_settings_box ($page, $box = NULL) {
$postsSettings = $this->admin_page_href('posts-page.php', array(), $page->link);
?>

These custom settings are special fields for the feed you are
syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create
custom fields on syndicated posts. If you want to create custom fields that are applied to each
individual post from this feed, set up the settings in ">Syndicated Posts.




<table id="meta-list" cellpadding="3">
<tr>
<th>Key</th>
<th>Value</th>
<th>Action</th>
</tr>

<?php
$i = 0;
foreach ($page->link->settings as $key => $value) :
if (!preg_match("\007^((".implode(')|(', $page->special_settings)."))$\007i", $key)) :
?>
<tr style="vertical-align:top">
<th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo esc_html($key); ?>" />
<input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo esc_html($key); ?>" /></th>
<td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo esc_html($value); ?></textarea></td>
<td width="10%"><select name="notes[<?php echo $i; ?>][action]">
<option value="update">save changes</option>
<option value="delete">delete this setting</option>
</select></td>
</tr>
<?php
$i++;
endif;
endforeach;
?>
<tr>
<th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
<td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
<td>add new setting...<input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
</tr>
</table>
<!-- id="postcustomstuff" -->
<?php
}

function url_for_401 ($err) {
$ret = NULL;
if (is_wp_error($err)) :
if ($err->get_error_code()=='http_request_failed') :
$data = $err->get_error_data('http_request_failed');

if (is_array($data) and isset($data['status'])) :
if (401==$data['status']) :
$ret = $data['uri'];
endif;
endif;
endif;
endif;
return $ret;
}



[13] feedwordpress/feeds-page.php

投稿者: aaa 投稿日:2013年12月18日(水)00時18分14秒 FL1-219-107-53-105.fko.mesh.ad.jp  通報   返信・引用

<?php
require_once(dirname(__FILE__) . '/admin-ui.php');
require_once(dirname(__FILE__) . '/magpiemocklink.class.php');
require_once(dirname(__FILE__) . '/feedfinder.class.php');
require_once(dirname(__FILE__) . '/updatedpostscontrol.class.php');

class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
var $HTTPStatusMessages = array (
200 => 'OK. FeedWordPress had no problems retrieving the content at this URL but the content does not seem to be a feed, and does not seem to include links to any feeds.',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
307 => 'Temporary Redirect',
400 => 'Bad Request',
401 => 'Unauthorized. This URL probably needs a username and password for you to access it.',
402 => 'Payment Required',
403 => 'Forbidden. The URL is not made available for the machine that FeedWordPress is running on.',
404 => 'Not Found. There is nothing at this URL. Have you checked the address for typos?',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Timeout',
409 => 'Conflict',
410 => 'Gone. This URL is no longer available on this server and no forwarding address is known.',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Requested Range Not Satisfiable',
417 => 'Expectation Failed',
500 => 'Internal Server Error. Something unexpected went wrong with the configuration of the server that hosts this URL. You might try again later to see if this issue has been resolved.',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable. The server is currently unable to handle the request due to a temporary overloading or maintenance of the server that hosts this URL. This is probably a temporary condition and you should try again later to see if the issue has been resolved.',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported',
);
var $updatedPosts = NULL;

var $special_settings = array ( /* Regular expression syntax is OK here */
'cats',
'cat_split',
'fetch timeout',
'freeze updates',
'hardcode name',
'hardcode url',
'hardcode description',
'hardcode categories', /* Deprecated */
'comment status',
'terms',
'map authors',
'munge permalink',
'ping status',
'post status',
'postmeta',
'query parameters',
'resolve relative',
'syndicated post type',
'tags',
'unfamiliar author',
'unfamliar categories', /* Deprecated */
'unfamiliar category',
'unfamiliar post_tag',
'add/.*',
'update/.*',
'feed/.*',
'link/.*',
'match/.*',
);

/**
* Constructs the Feeds page object
*
* @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings
*/
function FeedWordPressFeedsPage ($link = -1) {
if (is_numeric($link) and -1 == $link) :
$link = FeedWordPressAdminPage::submitted_link();
endif;

FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressfeeds', $link);

$this->dispatch = 'feedwordpress_admin_page_feeds';
$this->pagenames = array(
'default' => 'Feeds',
'settings-update' => 'Syndicated feed',
'open-sheet' => 'Feed and Update',
);
$this->filename = __FILE__;
$this->updatedPosts = new UpdatedPostsControl($this);

$this->special_settings = apply_filters('syndicated_feed_special_settings', $this->special_settings, $this);
} /* FeedWordPressFeedsPage constructor */

function display () {
global $fwp_post;
global $post_source;

$this->boxes_by_methods = array(
'feed_information_box' => __('Feed Information'),
'global_feeds_box' => __('Update Scheduling'),
'updated_posts_box' => __('Updated Posts'),
'custom_settings_box' => __('Custom Feed Settings (for use in templates)'),
'advanced_settings_box' => __('Advanced Settings'),
);
if ($this->for_default_settings()) :
unset($this->boxes_by_methods['custom_settings_box']);
endif;

// Allow overriding of normal source for FeedFinder, which may
// be called from multiple points.
if (isset($post_source) and !is_null($post_source)) :
$source = $post_source;
else :
$source = $this->dispatch;
endif;

if (isset($_REQUEST['feedfinder'])
or (isset($_REQUEST['action']) and $_REQUEST['action']=='feedfinder')
or (isset($_REQUEST['action']) and $_REQUEST['action']==FWP_SYNDICATE_NEW)) :
// If this is a POST, validate source and user credentials
FeedWordPressCompatibility::validate_http_request(/*action=*/ $source, /*capability=*/ 'manage_links');

return $this->display_feedfinder(); // re-route to Feed Finder page
endif;

parent::display();
return false; // Don't continue
} /* FeedWordPressFeedsPage::display() */

function ajax_interface_js () {
FeedWordPressAdminPage::ajax_interface_js();
?>

jQuery(document).ready( function () {
contextual_appearance('automatic-updates-selector', 'cron-job-explanation', null, 'no');
contextual_appearance('time-limit', 'time-limit-box', null, 'yes');
contextual_appearance('use-default-update-window-no', 'update-scheduling-note', null, null, 'block', true);
jQuery('#use-default-update-window-yes, #use-default-update-window-no').click( function () {
contextual_appearance('use-default-update-window-no', 'update-scheduling-note', null, null, 'block', true);
} );

var els = ['name', 'description', 'url'];
for (var i = 0; i < els.length; i++) {
contextual_appearance(
/*item=*/ 'basics-hardcode-'+els[i],
/*appear=*/ 'basics-'+els[i]+'-view',
/*disappear=*/ 'basics-'+els[i]+'-edit',
/*value=*/ 'no',
/*visibleStyle=*/ 'block',
/*checkbox=*/ true
);
} /* for */
} );

<?php
}

/*static*/ function updated_posts_box ($page, $box = NULL) {
?>
<table class="edit-form">
<?php $page->updatedPosts->display(); ?>
</table>
<?php
} /* FeedWordPressFeedsPage::updated_posts_box() */

/*static*/ function global_feeds_box ($page, $box = NULL) {
global $feedwordpress;
$automatic_updates = $feedwordpress->automatic_update_hook(array('setting only' => true));
$update_time_limit = (int) get_option('feedwordpress_update_time_limit');

// Hey, ho, let's go...
?>

<table class="edit-form">
<?php if ($page->for_default_settings()) : ?>

<tr>
<th scope="row">Updates:</th>
<td><select id="automatic-updates-selector" name="automatic_updates" size="1" onchange="contextual_appearance('automatic-updates-selector', 'cron-job-explanation', null, 'no');">
<option value="shutdown"<?php echo ($automatic_updates=='shutdown')?' selected="selected"':''; ?>>automatically check for updates after pages load</option>
<option value="init"<?php echo ($automatic_updates=='init')?' selected="selected"':''; ?>>automatically check for updates before pages load</option>
<option value="no"<?php echo (!$automatic_updates)?' selected="selected"':''; ?>>cron job or manual updates</option>
</select>


<?php
$path = `which curl`; $opts = '--silent %s';
if (is_null($path) or strlen(trim($path))==0) :
$path = `which wget`; $opts = '-q -O - %s';
if (is_null($path) or strlen(trim($path))==0) :
$path = '/usr/bin/curl'; $opts = '--silent %s';
endif;
endif;
$path = preg_replace('/\n+$/', '', $path);
$crontab = `crontab -l`;

$cmdline = $path . ' ' . sprintf($opts, get_bloginfo('url').'?update_feedwordpress=1');

?>If you want to use a cron job,
you can perform scheduled updates by sending regularly-scheduled
requests to ?update_feedwordpress=1"><code><?php bloginfo('url') ?>?update_feedwordpress=1</code>
For example, inserting the following line in your crontab:


<code>*/10 * * * * <?php print esc_html($cmdline); ?></code>

will check in every 10 minutes
and check for updates on any feeds that are ready to be polled for updates.



</td>
</tr>

<?php else : /* Feed-specific settings */ ?>

<tr>
<th scope="row"><?php _e('Last update') ?>:</th>
<td><?php
if (isset($page->link->settings['update/last'])) :
echo fwp_time_elapsed($page->link->settings['update/last'])." ";
else :
echo " none yet";
endif;
?></td></tr>

<tr><th><?php _e('Next update') ?>:</th>
<td><?php
$holdem = (isset($page->link->settings['update/hold']) ? $page->link->settings['update/hold'] : 'scheduled');
?>
<select name="update_schedule">
<option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
echo " (";
if (isset($page->link->settings['update/ttl']) and is_numeric($page->link->settings['update/ttl'])) :
if (isset($page->link->settings['update/timed']) and $page->link->settings['update/timed']=='automatically') :
echo 'next: ';
$next = $page->link->settings['update/last'] + ((int) $page->link->settings['update/ttl'] * 60);
if (strftime('%x', time()) != strftime('%x', $next)) :
echo strftime('%x', $next)." ";
endif;
echo strftime('%X', $page->link->settings['update/last']+((int) $page->link->settings['update/ttl']*60));
else :
echo "every ".$page->link->settings['update/ttl']." minute".(($page->link->settings['update/ttl']!=1)?"s":"");
endif;
else:
echo "next scheduled update";
endif;
echo ")";
?></option>
<option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option>
<option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option>
</select></td></tr>

<?php endif; ?>

<tr>
<th scope="row"><?php print __('Update scheduling:') ?></th>
<td>

How long should FeedWordPress wait between updates before it considers this feed ready to be polled for updates again?


<?php

$this->setting_radio_control(
'update/window', 'update_window',
array($this, 'update_window_edit_box'),
array(
'global-setting-default' => DEFAULT_UPDATE_PERIOD,
'default-input-name' => 'use_default_update_window',
'default-input-id' => 'use-default-update-window-yes',
'default-input-id-no' => 'use-default-update-window-no',
'labels' => array($this, 'update_window_currently'),
)
);
?></td>
</tr>

<tr>
<th scope="row"><?php print __('Minimum Interval:'); ?></th>
<td>

Some feeds include standard elements that
request a specific update schedule. If the interval requested by the
feed provider is longer than FeedWordPress's normal scheduling,
FeedWordPress will always respect their request to slow down. But what
should it do if the update interval is shorter than the schedule set above?


<?php
$this->setting_radio_control(
'update/minimum', 'update_minimum',
/*options=*/ array(
'no' => 'Speed up and accept the interval from the feed provider',
'yes' => 'Keep pace and use the longer scheduling from FeedWordPress',
),
/*params=*/ array(
'setting-default' => NULL,
'global-setting-default' => 'no',
'default-input-value' => 'default',
)
);
?>
</td>
</tr>

<?php if ($this->for_default_settings()) : ?>

<tr>
<th scope="row"><?php print __('Time limit on updates'); ?>:</th>
<td><select id="time-limit" name="update_time_limit" size="1" onchange="contextual_appearance('time-limit', 'time-limit-box', null, 'yes');">
<option value="no"<?php echo ($update_time_limit>0)?'':' selected="selected"'; ?>>no time limit on updates</option>
<option value="yes"<?php echo ($update_time_limit>0)?' selected="selected"':''; ?>>limit updates to no more than...</option>
</select>
<label><input type="text" name="time_limit_seconds" value="<?php print $update_time_limit; ?>" size="5" /> seconds</label>
</tr>

<?php endif; ?>

</table>

<?php
} /* FeedWordPressFeedsPage::global_feeds_box() */

function update_window_edit_box ($updateWindow, $defaulted, $params) {
if (!is_numeric($updateWindow)) :
$updateWindow = DEFAULT_UPDATE_PERIOD;
endif;
?>

Wait <input type="text" name="update_window" value="<?php print $updateWindow; ?>" size="4" /> minutes between polling.



<p<?php if ($updateWindow<50) : ?> style="color: white; background-color: #703030; padding: 1.0em;"<?php endif; ?>>Recommendation. Unless you are positive that you have the webmaster's permission, you generally should not set FeedWordPress to poll feeds more frequently than once every 60 minutes. Many webmasters consider more frequent automated polling to be abusive, and may complain to your web host, or ban your IP address, as retaliation for hammering their servers too hard.

Note. This is a default setting that FeedWordPress uses to schedule updates when the feed does not provide any scheduling requests. If this feed does provide update scheduling information (through elements such as <code><rss:ttl></code> or <code><sy:updateFrequency></code>), FeedWordPress will respect the feed's request.



<?php
} /* FeedWordPressFeedsPage::update_window_edit_box () */

function update_window_currently ($updateWindow, $defaulted, $params) {
$updateWindow = (int) $updateWindow;
if (1==$updateWindow) :
$caption = 'wait %d minute between polling';
else :
$caption = 'wait %d minutes between polling';
endif;
return sprintf(__($caption), $updateWindow);
} /* FeedWordPressFeedsPage::update_window_currently () */

function fetch_timeout_setting ($setting, $defaulted, $params) {
$timeout = intval($this->setting('fetch timeout', FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT));

if ($this->for_feed_settings()) :
$article = 'this';
else :
$article = 'a';
endif;
?>

Wait no more than
than <input name="fetch_timeout" type="number" min="0" size="3" value="<?php print $timeout; ?>" />
second(s) when trying to fetch <?php print $article; ?> feed to check for updates.


If <?php print $article; ?> source's web server does not respond before time runs
out, FeedWordPress will skip over the source and try again during
the next update cycle.


<?php
}
function fetch_timeout_setting_value ($setting, $defaulted, $params) {
print number_format(intval($setting)) . " " . (($setting==1) ? "second" : "seconds");
}

function advanced_settings_box ($page, $box = NULL) {
?>
<table class="edit-form">
<tr>
<th>Fetch Timeout:</th>
<td>
<?php
$this->setting_radio_control(
'fetch timeout', 'fetch_timeout',
array($this, 'fetch_timeout_setting'),
array(
'global-setting-default' => FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT,
'input-name' => 'fetch_timeout',
'default-input-name' => 'fetch_timeout_default',
'labels' => array($this, 'fetch_timeout_setting_value'),
)
);
?>
</td>
</tr>
<tr>
<th>Feed Update Type:</th>
<td><?php
$this->setting_radio_control('update_incremental', 'update_incremental',
/*options=*/ array(
'incremental' => 'Incremental. When items no longer appear on the feed, keep them in the WordPress posts table.',
'complete' => 'Complete. When items no longer appear on the feed, they are obsolete; retire them from the WordPress posts table.',
),
/*params=*/ array(
'setting-default' => NULL,
'global-setting-default' => 'incremental',
'default-input-value' => 'default',
)
); ?></td>
</tr>
<tr>
<th>Allow Feeds to Delete Posts:</th>
<td><?php
$this->setting_radio_control('tombstones', 'tombstones',
/*options=*/ array(
'yes' => 'Yes. If a feed indicates that one of its posts has been deleted, delete the local copy syndicated to this website.',
'no' => 'No. Even if a feed indicates that one of its posts has been deleted, retain the local copy on this website.',
),
/*params=*/ array(
'setting-default' => NULL,
'global-setting-default' => 'yes',
'default-input-value' => 'default',
)
); ?></td>
</tr>
</table>
<?php
} /* FeedWordPressFeedsPage::advanced_settings_box () */



[12] feedwordpress/feedwordpress-walker-category-checklist.class.

投稿者: aaa 投稿日:2013年12月18日(水)00時17分11秒 FL1-219-107-53-105.fko.mesh.ad.jp  通報   返信・引用

<?php
/**
* FeedWordPress_Walker_Category_Checklist
*
* @version 2010.0531
*
* This is the fucking stupidest thing ever.
*/

require_once(ABSPATH.'/wp-admin/includes/template.php');
// Fucking fuck.

class FeedWordPress_Walker_Category_Checklist extends Walker_Category_Checklist {
var $prefix = ''; var $taxonomy = 'category';
var $checkbox_name = NULL;
function FeedWordPress_Walker_Category_Checklist ($params = array()) {
$this->set_taxonomy('category');

if (isset($params['checkbox_name'])) :
$this->checkbox_name = $params['checkbox_name'];
endif;
}

function set_prefix ($prefix) {
$this->prefix = $prefix;
}
function set_taxonomy ($taxonomy) {
$this->taxonomy = $taxonomy;
}

function start_el (&$output, $category, $depth, $args) {
extract($args);
               if ( empty($taxonomy) ) :
$taxonomy = 'category';
endif;

if (!is_null($this->checkbox_name)) :
$name = $this->checkbox_name;
elseif ($taxonomy=='category') :
$name = 'post_category';
else :
$name = 'tax_input['.$taxonomy.']';
endif;

$unit = array();
if (strlen($this->prefix) > 0) :
$unit[] = $this->prefix;
endif;
$unit[] = $taxonomy;
$unit[] = $category->term_id;
$unitId = implode("-", $unit);

$class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category category-checkbox"' : ' class="category-checkbox"';
$output .= "\n<li id='{$unitId}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$unitId. '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
} /* FeedWordPress_Walker_Category_Checklist::start_el() */
} /* FeedWordPress_Walker_Category_Checklist */



[11] feedwordpress/feedwordpress-content-type-sniffer.class.php

投稿者: aaa 投稿日:2013年12月18日(水)00時15分10秒 FL1-219-107-53-105.fko.mesh.ad.jp  通報   返信・引用

<?php
require_once(ABSPATH . WPINC . '/class-feed.php');

class FeedWordPress_Content_Type_Sniffer extends SimplePie_Content_Type_Sniffer {
/**
* Get the Content-Type of the specified file
*
* @access public
* @return string Filtered content type
*/
function get_type () {
$contentType = null;
$charset = null;
if (isset($this->file->headers['content-type'])) :
if (!is_array($this->file->headers['content-type'])) :
$this->file->headers['content-type'] = array($this->file->headers['content-type']);
endif;

foreach ($this->file->headers['content-type'] as $type) :
$parts = array_map('trim', explode(";", $type, 2));
if (isset($parts[1])) :
$type = $parts[0];
$charset = $parts[1];
endif;

if (preg_match(
'!(application|text)/((atom|rss|rdf)\+)?xml!',
$type,
$ref
)) :
$contentType = $ref[0];
endif;
endforeach;

$outHeader = array();
if (!is_null($contentType)) :
$outHeader[] = $contentType;
else :
$outHeader[] = 'text/xml'; // Generic
endif;
if (!is_null($charset)) :
$outHeader[] = $charset;
endif;

$this->file->headers['content-type'] = implode("; ", $outHeader);
else :
// The default SimplePie behavior seems to be to return
// text/plain if it can't find a Content-Type header.
// The default SimplePie behavior sucks. Particularly
// since SimplePie gets so draconian about Content-Type.
// And since the WP SimplePie seems to drop Content-Type
// from cached copies for some unfortunate reason.
$this->file->headers['content-type'] = 'text/xml'; // Generic
endif;
return parent::get_type();
} /* FeedWordPress_Content_Type_Sniffer::get_type() */
} /* class FeedWordPress_Content_Type_Sniffer */



[10] feedwordpress/magpiemocklink.class.php

投稿者: aaa 投稿日:2013年12月18日(水)00時14分2秒 FL1-219-107-53-105.fko.mesh.ad.jp  通報   返信・引用

<?php
require_once(dirname(__FILE__) . '/syndicatedlink.class.php');

class MagpieMockLink extends SyndicatedLink {
var $url;

function MagpieMockLink ($rss, $url) {
$this->link = $rss;

if (is_array($rss) and isset($rss['simplepie']) and isset($rss['magpie'])) :
$this->simplepie = $rss['simplepie'];
$this->magpie = $rss['magpie'];
else :
$this->magpie = $rss;
endif;

$this->url = $url;
$this->id = -1;
$this->settings = array(
'unfamiliar category' => 'default',

);
} /* function MagpieMockLink::MagpieMockLink () */

function poll ($crash_ts = NULL) {
// Do nothing but update copy of feed
$this->simplepie = FeedWordPress::fetch($this->url);
$this->magpie = new MagpieFromSimplePie($this->simplepie);

$this->link = $this->magpie;
} /* function MagpieMockLink::poll () */

function uri () {
return $this->url;
} /* function MagpieMockLink::uri() */

function homepage () {
return (!is_wp_error($this->simplepie) ? $this->simplepie->get_link() : null);
} /* function MagpieMockLink::homepage () */

function save_settings ($reload = false) {
// NOOP.
}
} /* class MagpieMockLink */


レンタル掲示板
19件の内、新着の記事から10件ずつ表示します。

お知らせ · よくある質問(FAQ) · お問合せ窓口 · teacup.レンタル掲示板

© GMO Media, Inc.