function display () {
		global $wpdb, $wp_db_version, $fwp_path;
		global $fwp_post;
		
		if (FeedWordPress::needs_upgrade()) :
			fwp_upgrade_page();
			return;
		endif;
	
		// If this is a POST, validate source and user credentials
		FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_diagnostics', /*capability=*/ 'manage_options');
	
		if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
			$this->accept_POST($fwp_post);
			do_action('feedwordpress_admin_page_diagnostics_save', $GLOBALS['fwp_post'], $this);
		endif;

		////////////////////////////////////////////////
		// Prepare settings page ///////////////////////
		////////////////////////////////////////////////

		$this->display_update_notice_if_updated('Diagnostics');

		$this->open_sheet('FeedWordPress Diagnostics');
		?>
		<div id="post-body">
		<?php
		$boxes_by_methods = array(
			'info_box' => __('Diagnostic Information'),
			'diagnostics_box' => __('Display Diagnostics'),
			'updates_box' => __('Updates'),
			'tests_box' => __('Diagnostic Tests'),
		);
	
		foreach ($boxes_by_methods as $method => $title) :
			add_meta_box(
				/*id=*/ 'feedwordpress_'.$method,
				/*title=*/ $title,
				/*callback=*/ array('FeedWordPressDiagnosticsPage', $method),
				/*page=*/ $this->meta_box_context(),
				/*context=*/ $this->meta_box_context()
			);
		endforeach;
		do_action('feedwordpress_admin_page_diagnostics_meta_boxes', $this);
		?>
			<div class="metabox-holder">
			<?php
			fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
			?>
			</div> <!-- class="metabox-holder" -->
		</div> <!-- id="post-body" -->

		<?php
		$this->close_sheet();
	} /* FeedWordPressDiagnosticsPage::display () */
Пример #2
0
    function display()
    {
        global $wpdb, $wp_db_version, $fwp_path;
        global $fwp_post;
        if (FeedWordPress::needs_upgrade()) {
            fwp_upgrade_page();
            return;
        }
        // If this is a POST, validate source and user credentials
        FeedWordPressCompatibility::validate_http_request('feedwordpress_performance', 'manage_options');
        if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
            $this->accept_POST($fwp_post);
            do_action('feedwordpress_admin_page_performance_save', $fwp_post, $this);
        }
        ////////////////////////////////////////////////
        // Prepare settings page ///////////////////////
        ////////////////////////////////////////////////
        $this->display_update_notice_if_updated('Performance');
        $this->open_sheet('FeedWordPress Performance');
        ?>
		<div id="post-body">
		<?php 
        $boxes_by_methods = array('performance_box' => __('Performance'));
        foreach ($boxes_by_methods as $method => $title) {
            add_meta_box('feedwordpress_' . $method, $title, array('FeedWordPressPerformancePage', $method), $this->meta_box_context(), $this->meta_box_context());
        }
        do_action('feedwordpress_admin_page_performance_meta_boxes', $this);
        ?>
			<div class="metabox-holder">
			<?php 
        fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
        ?>
			</div> <!-- class="metabox-holder" -->
		</div> <!-- id="post-body" -->

		<?php 
        $this->close_sheet();
    }
    function display_alt_feed_box($lookup, $params = false)
    {
        global $fwp_post;
        if (is_bool($params)) {
            $params = array("alt" => $params);
        }
        $params = wp_parse_args($params, array("alt" => false, "err" => NULL, "auth" => NULL, "password" => NULL, "username" => NULL));
        $alt = $params['alt'];
        ?>
		<form action="admin.php?page=<?php 
        print $GLOBALS['fwp_path'];
        ?>
/<?php 
        echo basename(__FILE__);
        ?>
" method="post">
		<div class="inside"><?php 
        FeedWordPressCompatibility::stamp_nonce($this->dispatch);
        ?>
		<fieldset class="alt"
		<?php 
        if (!$alt) {
            ?>
style="margin: 1.0em 3.0em; font-size: smaller;"<?php 
        }
        ?>
>
		<legend><?php 
        if ($alt) {
            ?>
Alternative feeds<?php 
        } else {
            ?>
Find feeds<?php 
        }
        ?>
</legend>
		<?php 
        if ($alt) {
            ?>
<h3>Use a different feed</h3><?php 
        }
        ?>
		<?php 
        if (is_wp_error($params['err'])) {
            ?>
		<p><em><strong>401 Not Authorized.</strong> This URL may require
		a username and password to access it.</em> You may want to add login
		credentials below and check it again.</p>
		<?php 
        }
        ?>
		<div><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 
        }
        ?>
		size="64" style="max-width: 80%" /></label>
		<?php 
        if (is_null($lookup)) {
            ?>
		<?php 
            FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed');
            ?>
		<?php 
        }
        ?>

		<?php 
        $this->stamp_link_id('link_id');
        ?>
		<input type="hidden" name="action" value="feedfinder" />
		<input type="submit" class="button<?php 
        if ($alt) {
            ?>
-primary<?php 
        }
        ?>
" value="Check &raquo;" /></div>

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

		<p>This can be the address of a feed, or of a website. FeedWordPress
		will try to automatically detect any feeds associated with a
		website.</p>
		</div> <!-- class="inside" -->
		</fieldset></form>
		
		<?php 
    }
 function link_category_id()
 {
     global $wpdb, $wp_db_version;
     $cat_id = get_option('feedwordpress_cat_id');
     // If we don't yet have the category ID stored, search by name
     if (!$cat_id) {
         $cat_id = FeedWordPressCompatibility::link_category_id(DEFAULT_SYNDICATION_CATEGORY);
         if ($cat_id) {
             // We found it; let's stamp it.
             update_option('feedwordpress_cat_id', $cat_id);
         }
         // If we *do* have the category ID stored, verify that it exists
     } else {
         $cat_id = FeedWordPressCompatibility::link_category_id((int) $cat_id, 'cat_id');
     }
     // If we could not find an appropriate link category,
     // make a new one for ourselves.
     if (!$cat_id) {
         $cat_id = FeedWordPressCompatibility::insert_link_category(DEFAULT_SYNDICATION_CATEGORY);
         if (!is_wp_error($cat_id)) {
             // Stamp it
             update_option('feedwordpress_cat_id', $cat_id);
         }
     }
     return $cat_id;
 }
Пример #5
0
    function open_sheet($header)
    {
        // Set up prepatory AJAX stuff
        ?>
		<script type="text/javascript">
		<?php 
        $this->ajax_interface_js();
        ?>
		</script>

		<?php 
        add_action(FeedWordPressCompatibility::bottom_script_hook($this->filename), array($this, 'fix_toggles'), 10000);
        FeedWordPressSettingsUI::ajax_nonce_fields();
        ?>
		<div class="wrap feedwordpress-admin" id="feedwordpress-admin-<?php 
        print $this->pageslug();
        ?>
">
		<?php 
        if (!is_null($header)) {
            $this->display_sheet_header($header);
        }
        if (!is_null($this->dispatch)) {
            ?>
			<form action="<?php 
            print $this->form_action();
            ?>
" method="post">
			<div><?php 
            FeedWordPressCompatibility::stamp_nonce($this->dispatch);
            $this->stamp_link_id();
            ?>
</div>
			<?php 
        }
        if ($this->has_link()) {
            $this->display_settings_scope_message();
        }
        ?>
<div class="tablenav"><?php 
        if (!is_null($this->dispatch)) {
            ?>
<div class="alignright"><?php 
            $this->save_button();
            ?>
</div><?php 
        }
        if ($this->has_link()) {
            $this->display_feed_select_dropdown();
        }
        ?>
		</div>

		<div id="poststuff">
		<?php 
    }
function fwp_posts_page()
{
    global $wp_db_version;
    global $fwp_post;
    if (FeedWordPress::needs_upgrade()) {
        fwp_upgrade_page();
        return;
    }
    // If this is a POST, validate source and user credentials
    FeedWordPressCompatibility::validate_http_request('feedwordpress_posts_settings', 'manage_links');
    $link = FeedWordPressAdminPage::submitted_link();
    $postsPage = new FeedWordPressPostsPage($link);
    $mesg = null;
    ////////////////////////////////////////////////
    // Process POST request, if any ////////////////
    ////////////////////////////////////////////////
    if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
        $postsPage->accept_POST($fwp_post);
        do_action('feedwordpress_admin_page_posts_save', $fwp_post, $postsPage);
    }
    $postsPage->ajax_interface_js();
    if ($postsPage->updated) {
        ?>
<div class="updated"><p>Syndicated posts settings updated.</p></div>
<?php 
    } elseif (!is_null($mesg)) {
        ?>
<div class="updated"><p><?php 
        print esc_html($mesg);
        ?>
</p></div>
<?php 
    }
    ?>

<?php 
    $links = FeedWordPress::syndicated_links();
    $postsPage->open_sheet('Syndicated Posts & Links');
    ?>
<style type="text/css">
	table.edit-form th, table.form-table th { width: 27%; vertical-align: top; }
	table.edit-form td, table.form-table td { width: 73%; vertical-align: top; }
	ul.options { margin: 0; padding: 0; list-style: none; }
</style>
<div id="post-body">
<?php 
    $boxes_by_methods = array('publication_box' => __('Syndicated Posts'), 'links_box' => __('Links'), 'formatting_box' => __('Formatting'), 'comments_and_pings_box' => __('Comments & Pings'), 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'));
    foreach ($boxes_by_methods as $method => $title) {
        fwp_add_meta_box('feedwordpress_' . $method, $title, array('FeedWordPressPostsPage', $method), $postsPage->meta_box_context(), $postsPage->meta_box_context());
    }
    do_action('feedwordpress_admin_page_posts_meta_boxes', $postsPage);
    ?>
	<div class="metabox-holder">
<?php 
    fwp_do_meta_boxes($postsPage->meta_box_context(), $postsPage->meta_box_context(), $postsPage);
    ?>
	</div> <!-- class="metabox-holder" -->
</div> <!-- id="post-body" -->
<?php 
    $postsPage->close_sheet();
}
 function bottom_script_hook($filename)
 {
     $hook = 'admin_footer';
     if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_28)) {
         // WordPress 2.8+
         $hook = $hook . '-' . basename($filename);
     }
     return $hook;
 }
    function magic_input_tip_js($id)
    {
        if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_25)) {
            ?>
			<script type="text/javascript">
			jQuery(document).ready( function () {
				var inputBox = jQuery("#<?php 
            print $id;
            ?>
");
				var boxEl = inputBox.get(0);
				if (boxEl.value==boxEl.defaultValue) { inputBox.addClass('form-input-tip'); }
				inputBox.focus(function() {
					if ( this.value == this.defaultValue )
						jQuery(this).val( '' ).removeClass( 'form-input-tip' );
				});
				inputBox.blur(function() {
					if ( this.value == '' )
						jQuery(this).val( this.defaultValue ).addClass( 'form-input-tip' );
				});			
			} );
			</script>
		<?php 
        }
    }
function fwp_authors_page()
{
    global $wp_db_version;
    if (FeedWordPress::needs_upgrade()) {
        fwp_upgrade_page();
        return;
    }
    FeedWordPressCompatibility::validate_http_request('feedwordpress_author_settings', 'manage_links');
    $link = FeedWordPressAdminPage::submitted_link();
    $authorsPage = new FeedWordPressAuthorsPage($link);
    $mesg = null;
    if (isset($GLOBALS['fwp_post']['fix_mismatch'])) {
        $fix_mismatch_to_id = $GLOBALS['fwp_post']['fix_mismatch_to'];
        $fix_mismatch_from_id = (int) $GLOBALS['fwp_post']['fix_mismatch_from'];
        if (is_numeric($fix_mismatch_from_id)) {
            // Make a list of all the items by this author syndicated from this feed...
            $args = array('posts_per_page' => -1, 'meta_key' => 'syndication_feed_id', 'meta_value' => $link->id, 'post_author' => $fix_mismatch_from_id);
            $query = new WP_Query($args);
            $mesg = '';
            $post_ids = array();
            if ($query->have_posts()) {
                while ($query->have_posts()) {
                    global $post;
                    $query->the_post();
                    if (is_numeric($fix_mismatch_to_id)) {
                        $post->post_author = $fix_mismatch_to_id;
                        $new_post = (array) $post;
                        wp_insert_post($new_post);
                        $mesg_action = 'Re-assigned';
                        $post_ids[] = get_the_ID();
                    } else {
                        if ($fix_mismatch_to_id == 'filter') {
                            wp_delete_post($post->ID);
                            $mesg_action = 'Re-assigned';
                            $post_ids[] = get_the_ID();
                        }
                    }
                }
                $mesg = $mesg_action . ' ' . count($post_ids) . ' post' . (count($post_ids) == 1 ? '' : 's') . '.';
            } else {
                $mesg = "Couldn't find any posts that matched your criteria.";
            }
        }
        $updated_link = false;
    } elseif (isset($GLOBALS['fwp_post']['save'])) {
        if (is_object($link) and $link->found()) {
            $alter = array();
            // Unfamiliar author rule
            if (isset($GLOBALS['fwp_post']["unfamiliar_author"])) {
                if ('site-default' == $GLOBALS['fwp_post']["unfamiliar_author"]) {
                    unset($link->settings["unfamiliar author"]);
                } else {
                    $link->settings["unfamiliar author"] = $GLOBALS['fwp_post']["unfamiliar_author"];
                }
            }
            // Handle author mapping rules
            if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) {
                unset($link->settings['map authors']);
                foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) {
                    // Normalize for case and whitespace
                    $name = strtolower(trim($name));
                    $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key]));
                    if (strlen($name) > 0) {
                        $link->settings['map authors']['name'][$name] = $author_action;
                    }
                }
            }
            if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) {
                $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name']));
                $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action']));
                if (strlen($name) > 0) {
                    $link->settings['map authors']['name'][$name] = $author_action;
                }
            }
            // Save settings
            $link->save_settings(true);
            $updated_link = true;
            // Reset, reload
            $link_id = $link->id;
            unset($link);
            $link = new SyndicatedLink($link_id);
        } else {
            update_option('feedwordpress_unfamiliar_author', $GLOBALS['fwp_post']['unfamiliar_author']);
            if (isset($GLOBALS['fwp_post']['match_author_by_email']) and $GLOBALS['fwp_post']['match_author_by_email'] == 'yes') {
                update_option('feedwordpress_do_not_match_author_by_email', 'no');
            } else {
                update_option('feedwordpress_do_not_match_author_by_email', 'yes');
            }
            if (isset($GLOBALS['fwp_post']['null_emails'])) {
                update_option('feedwordpress_null_email_set', $GLOBALS['fwp_post']['null_emails']);
            }
            $updated_link = true;
        }
        do_action('feedwordpress_admin_page_authors_save', $GLOBALS['fwp_post'], $authorsPage);
        $authorsPage->refresh_author_list();
    } else {
        $updated_link = false;
    }
    ////////////////////////////////////////////////
    // Prepare settings page ///////////////////////
    ////////////////////////////////////////////////
    if ($updated_link) {
        ?>
<div class="updated"><p>Syndicated author settings updated.</p></div>
<?php 
    } elseif (!is_null($mesg)) {
        ?>
<div class="updated"><p><?php 
        print esc_html($mesg);
        ?>
</p></div>
<?php 
    }
    if (function_exists('add_meta_box')) {
        add_action(FeedWordPressCompatibility::bottom_script_hook(__FILE__), array($authorsPage, 'fix_toggles'), 10000);
        FeedWordPressSettingsUI::ajax_nonce_fields();
    }
    $authorsPage->open_sheet('Syndicated Author');
    ?>
	<div id="post-body">
	<?php 
    ////////////////////////////////////////////////
    // Display settings boxes //////////////////////
    ////////////////////////////////////////////////
    $boxes_by_methods = array('syndicated_authors_box' => __('Syndicated Authors'), 'fix_authors_box' => __('Reassign Authors'));
    if ($authorsPage->for_default_settings()) {
        unset($boxes_by_methods['fix_authors_box']);
    }
    foreach ($boxes_by_methods as $method => $row) {
        if (is_array($row)) {
            $id = $row['id'];
            $title = $row['title'];
        } else {
            $id = 'feedwordpress_' . $method;
            $title = $row;
        }
        fwp_add_meta_box($id, $title, array('FeedWordPressAuthorsPage', $method), $authorsPage->meta_box_context(), $authorsPage->meta_box_context());
    }
    do_action('feedwordpress_admin_page_authors_meta_boxes', $authorsPage);
    ?>
	<div class="metabox-holder">
<?php 
    fwp_do_meta_boxes($authorsPage->meta_box_context(), $authorsPage->meta_box_context(), $authorsPage);
    ?>
	</div> <!-- class="metabox-holder" -->
</div> <!-- id="post-body" -->
<?php 
    $authorsPage->close_sheet();
    ?>

<script type="text/javascript">
<?php 
    if (!is_object($link) or !$link->found()) {
        ?>
	contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);
<?php 
    }
    ?>
</script>
<?php 
}
 function admin_scripts()
 {
     global $fwp_path;
     wp_enqueue_script('post');
     // for magic tag and category boxes
     if (!FeedWordPressCompatibility::test_version(FWP_SCHEMA_29)) {
         // < 2.9
         wp_enqueue_script('thickbox');
         // for fold-up boxes
     }
     wp_enqueue_script('admin-forms');
     // for checkbox selection
     wp_register_script('feedwordpress-elements', WP_PLUGIN_URL . '/' . $fwp_path . '/feedwordpress-elements.js');
     wp_enqueue_script('feedwordpress-elements');
 }
 function display()
 {
     ////////////////////////////////////////////////
     // Display settings boxes //////////////////////
     ////////////////////////////////////////////////
     $this->boxes_by_methods = array('feed_categories_box' => __('Feed Categories' . FEEDWORDPRESS_AND_TAGS), 'categories_box' => array('title' => __('Categories'), 'id' => 'categorydiv'));
     if (!FeedWordPressCompatibility::post_tags()) {
         unset($this->boxes_by_methods['tags_box']);
     }
     parent::display();
 }
    function display()
    {
        if (FeedWordPress::needs_upgrade()) {
            fwp_upgrade_page();
            return;
        }
        ?>
		<?php 
        $cont = true;
        $dispatcher = array("feedfinder" => 'fwp_feedfinder_page', FWP_SYNDICATE_NEW => 'fwp_feedfinder_page', "switchfeed" => 'fwp_switchfeed_page', FWP_UNSUB_CHECKED => 'fwp_multidelete_page', FWP_DELETE_CHECKED => 'fwp_multidelete_page', 'Unsubscribe' => 'fwp_multidelete_page', FWP_RESUB_CHECKED => 'fwp_multiundelete_page');
        if (isset($_REQUEST['action']) and isset($dispatcher[$_REQUEST['action']])) {
            $method = $dispatcher[$_REQUEST['action']];
            $cont = call_user_func($method);
        }
        if ($cont) {
            ?>
		<style type="text/css">
			.heads-up {
				background-color: #d0d0d0;
				color: black;
				padding: 1.0em;
				margin: 0.5em 4.0em !important;
			}
			.update-form.with-donation {
				margin-right: 50%;
				min-height: 255px;
			}
			.donation-form, .donation-thanks {
				background-color: #ffffcc;
				text-align: left;
				padding: 0.5em 0.5em;
				border-left: thin dashed #777777;
				font-size: 70%;
				position: absolute;
				top: 0; bottom: 0; right: 0; left: auto;
				width: 50%;		
			}
			.donation-thanks {
				background-color: #ccffcc;
			}
			.donation-thanks .signature {
				text-align: right;
				font-style: italic;
			}
			.donation-form h4, .donation-thanks h4 {
				font-size: 10px;
				text-align: center;
				border-bottom: 1px solid #777777;
				margin: 0px;
			}
			.donation-form .donate  {
				text-align: center;
			}
			.donation-form .sod-off {
				padding-top: 0.5em;
				margin-top: 0.5em;
				border-top: thin solid #777777;
			}
			.feed-missing {
				background-color:#FFFFD0;
			}
			.unsubscribed tr {
				background-color: #FFE0E0;
			}
			.unsubscribed tr.alternate {
				background-color: #FFF0F0;
			}
			tr.feed-error {
				background-color: #FFFFD0;
			}
		</style>
		<?php 
            $links = $this->sources('Y');
            $potential_updates = (!$this->show_inactive() and count($this->sources('Y')) > 0);
            $this->open_sheet('Syndicated Sites');
            ?>
			<div id="post-body">
			<?php 
            if ($potential_updates or count($this->updates_requested()) > 0) {
                fwp_add_meta_box('feedwordpress_update_box', __('Update feeds now'), 'fwp_syndication_manage_page_update_box', $this->meta_box_context(), $this->meta_box_context());
            }
            fwp_add_meta_box('feedwordpress_feeds_box', __('Syndicated sources'), 'fwp_syndication_manage_page_links_box', $this->meta_box_context(), $this->meta_box_context());
            if (FeedWordPressCompatibility::test_version(0, FWP_SCHEMA_25)) {
                fwp_add_meta_box('feedwordpress_add_feed_box', 'Add a new syndicated source', 'fwp_syndication_manage_page_add_feed_box', $this->meta_box_context(), $this->meta_box_context());
            }
            do_action('feedwordpress_admin_page_syndication_meta_boxes', $this);
            ?>
			<div class="metabox-holder">		
			<?php 
            fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
            ?>
			</div> <!-- class="metabox-holder" -->
			</div> <!-- id="post-body" -->
		
			<?php 
            $this->close_sheet(NULL);
            ?>
		
			<div style="display: none">
			<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
			</div>
		<?php 
        }
    }
	function multiundelete_page () {
		global $wpdb;
	
		// If this is a POST, validate source and user credentials
		FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
	
		$link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
		if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
	
		if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Undelete'):
			if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) :
				$actions = $GLOBALS['fwp_post']['link_action'];
			else :
				$actions = array();
			endif;
	
			$do_it = array(
				'unhide' => array(),
			);
	
			foreach ($actions as $link_id => $what) :
				$do_it[$what][] = $link_id;
			endforeach;
	
			$alter = array();
			if (count($do_it['unhide']) > 0) :
				$unhiddem = "(".implode(', ', $do_it['unhide']).")";
				$alter[] = "
				UPDATE $wpdb->links
				SET link_visible = 'Y'
				WHERE link_id IN {$unhiddem}
				";
			endif;
	
			$errs = array(); $success = array ();
			foreach ($alter as $sql) :
				$result = $wpdb->query($sql);
				if (!$result):
					$errs[] = mysql_error();
				endif;
			endforeach;
			
			if (count($alter) > 0) :
				echo "<div class=\"updated\">\n";
				if (count($errs) > 0) :
					echo "There were some problems processing your ";
					echo "re-subscribe request. [SQL: ".implode('; ', $errs)."]";
				else :
					echo "Your re-subscribe request(s) have been processed.";
				endif;
				echo "</div>\n";
			endif;
	
			return true; // Continue on to Syndicated Sites listing
		else :
			$targets = $wpdb->get_results("
				SELECT * FROM $wpdb->links
				WHERE link_id IN (".implode(",",$link_ids).")
				");
	?>
	<form action="<?php print $this->form_action(); ?>" method="post">
	<div class="wrap">
	<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
	<input type="hidden" name="action" value="<?php print FWP_RESUB_CHECKED; ?>" />
	<input type="hidden" name="confirm" value="Undelete" />
	
	<h2>Re-subscribe to Syndicated Links:</h2>
	<?php
		foreach ($targets as $link) :
			$subscribed = ('Y' == strtoupper($link->link_visible));
			$link_url = esc_html($link->link_url);
			$link_name = esc_html($link->link_name);
			$link_description = esc_html($link->link_description);
			$link_rss = esc_html($link->link_rss);
			
			if (!$subscribed) :
	?>
	<fieldset>
	<legend><?php echo $link_name; ?></legend>
	<table class="editform" width="100%" cellspacing="2" cellpadding="5">
	<tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
	<td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr>
	<tr><th scope="row" width="20%"><?php _e('Short description:') ?></th>
	<td width="80%"><?php echo $link_description; ?></span></td></tr>
	<tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th>
	<td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr>
	<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th>
	<td width="80%"><ul style="margin:0; padding: 0; list-style: none">
	<li><input type="radio" id="unhide-<?php echo $link->link_id; ?>"
	name="link_action[<?php echo $link->link_id; ?>]" value="unhide" checked="checked" />
	<label for="unhide-<?php echo $link->link_id; ?>">Turn back on the subscription
	for this syndication source.</label></li>
	<li><input type="radio" id="nothing-<?php echo $link->link_id; ?>"
	name="link_action[<?php echo $link->link_id; ?>]" value="nothing" />
	<label for="nothing-<?php echo $link->link_id; ?>">Leave this feed as it is.
	I changed my mind.</label></li>
	</ul>
	</table>
	</fieldset>
	<?php
			endif;
		endforeach;
	?>
	
	<div class="submit">
	<input class="button-primary delete" type="submit" name="submit" value="<?php _e('Re-subscribe to selected feeds &raquo;') ?>" />
	</div>
	</div>
	<?php
			return false; // Don't continue on to Syndicated Sites listing
		endif;
	} /* FeedWordPressSyndicationPage::multiundelete_page() */
    function multiundelete_page()
    {
        global $wpdb;
        // If this is a POST, validate source and user credentials
        FeedWordPressCompatibility::validate_http_request('feedwordpress_feeds', 'manage_links');
        // Get single link ID or multiple link IDs from REQUEST parameters
        // if available. Sanitize values for MySQL.
        $link_list = $this->requested_link_ids_sql();
        if (MyPHP::post('confirm') == 'Undelete') {
            if (is_array(MyPHP::post('link_action'))) {
                $actions = MyPHP::post('link_action');
            } else {
                $actions = array();
            }
            $do_it = array('unhide' => array());
            foreach ($actions as $link_id => $what) {
                $do_it[$what][] = $link_id;
            }
            $alter = array();
            if (count($do_it['unhide']) > 0) {
                $unhiddem = "(" . implode(', ', $do_it['unhide']) . ")";
                $alter[] = "\n\t\t\t\tUPDATE {$wpdb->links}\n\t\t\t\tSET link_visible = 'Y'\n\t\t\t\tWHERE link_id IN {$unhiddem}\n\t\t\t\t";
            }
            $errs = array();
            $success = array();
            foreach ($alter as $sql) {
                $result = $wpdb->query($sql);
                if (!$result) {
                    $errs[] = mysql_error();
                }
            }
            if (count($alter) > 0) {
                echo "<div class=\"updated\">\n";
                if (count($errs) > 0) {
                    echo "There were some problems processing your ";
                    echo "re-subscribe request. [SQL: " . implode('; ', $errs) . "]";
                } else {
                    echo "Your re-subscribe request(s) have been processed.";
                }
                echo "</div>\n";
            }
            return true;
            // Continue on to Syndicated Sites listing
        } else {
            // $link_list has previously been sanitized for html by self::requested_link_ids_sql
            $targets = $wpdb->get_results("\n\t\t\t\tSELECT * FROM {$wpdb->links}\n\t\t\t\tWHERE link_id IN {$link_list}\n\t\t\t\t");
            ?>
	<form action="<?php 
            print $this->form_action();
            ?>
" method="post">
	<div class="wrap">
	<?php 
            FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds');
            ?>
	<input type="hidden" name="action" value="<?php 
            print FWP_RESUB_CHECKED;
            ?>
" />
	<input type="hidden" name="confirm" value="Undelete" />
	
	<h2>Re-subscribe to Syndicated Links:</h2>
	<?php 
            foreach ($targets as $link) {
                $subscribed = 'Y' == strtoupper($link->link_visible);
                $link_url = esc_html($link->link_url);
                $link_name = esc_html($link->link_name);
                $link_description = esc_html($link->link_description);
                $link_rss = esc_html($link->link_rss);
                if (!$subscribed) {
                    ?>
	<fieldset>
	<legend><?php 
                    echo $link_name;
                    ?>
</legend>
	<table class="editform" width="100%" cellspacing="2" cellpadding="5">
	<tr><th scope="row" width="20%"><?php 
                    _e('Feed URI:');
                    ?>
</th>
	<td width="80%"><a href="<?php 
                    echo $link_rss;
                    ?>
"><?php 
                    echo $link_rss;
                    ?>
</a></td></tr>
	<tr><th scope="row" width="20%"><?php 
                    _e('Short description:');
                    ?>
</th>
	<td width="80%"><?php 
                    echo $link_description;
                    ?>
</span></td></tr>
	<tr><th width="20%" scope="row"><?php 
                    _e('Homepage:');
                    ?>
</th>
	<td width="80%"><a href="<?php 
                    echo $link_url;
                    ?>
"><?php 
                    echo $link_url;
                    ?>
</a></td></tr>
	<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php 
                    _e('Options');
                    ?>
:</th>
	<td width="80%"><ul style="margin:0; padding: 0; list-style: none">
	<li><input type="radio" id="unhide-<?php 
                    echo $link->link_id;
                    ?>
"
	name="link_action[<?php 
                    echo $link->link_id;
                    ?>
]" value="unhide" checked="checked" />
	<label for="unhide-<?php 
                    echo $link->link_id;
                    ?>
">Turn back on the subscription
	for this syndication source.</label></li>
	<li><input type="radio" id="nothing-<?php 
                    echo $link->link_id;
                    ?>
"
	name="link_action[<?php 
                    echo $link->link_id;
                    ?>
]" value="nothing" />
	<label for="nothing-<?php 
                    echo $link->link_id;
                    ?>
">Leave this feed as it is.
	I changed my mind.</label></li>
	</ul>
	</table>
	</fieldset>
	<?php 
                }
            }
            ?>
	
	<div class="submit">
	<input class="button-primary delete" type="submit" name="submit" value="<?php 
            _e('Re-subscribe to selected feeds &raquo;');
            ?>
" />
	</div>
	</div>
	<?php 
            return false;
            // Don't continue on to Syndicated Sites listing
        }
    }
    function display_alt_feed_box($lookup, $alt = false)
    {
        global $fwp_post;
        ?>
		<form action="admin.php?page=<?php 
        echo FWP_FEEDS_PAGE_SLUG;
        ?>
" method="post">
		<div class="inside"><?php 
        FeedWordPressCompatibility::stamp_nonce(get_class($this));
        ?>
		<fieldset class="alt"
		<?php 
        if (!$alt) {
            ?>
style="margin: 1.0em 3.0em; font-size: smaller;"<?php 
        }
        ?>
>
		<legend><?php 
        if ($alt) {
            ?>
Alternative feeds<?php 
        } else {
            ?>
Find feeds<?php 
        }
        ?>
</legend>
		<?php 
        if ($alt) {
            ?>
<h3>Use a different feed</h3><?php 
        }
        ?>
		<div><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 
        }
        ?>
		size="64" style="max-width: 80%" /></label>
		<?php 
        if (is_null($lookup)) {
            ?>
		<?php 
            FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed');
            ?>
		<?php 
        }
        ?>
		<?php 
        $this->stamp_link_id('link_id');
        ?>
		<input type="hidden" name="action" value="feedfinder" />
		<input type="submit" class="button<?php 
        if ($alt) {
            ?>
-primary<?php 
        }
        ?>
" value="Check &raquo;" /></div>
		<p>This can be the address of a feed, or of a website. FeedWordPress
		will try to automatically detect any feeds associated with a
		website.</p>
		</div> <!-- class="inside" -->
		</fieldset></form>
		
		<?php 
    }
Пример #16
0
function fwp_upgrade_page()
{
    if (MyPHP::post('action') == 'Upgrade') {
        $ver = get_option('feedwordpress_version');
        if (get_option('feedwordpress_version') != FEEDWORDPRESS_VERSION) {
            echo "<div class=\"wrap\">\n";
            echo "<h2>Upgrading FeedWordPress...</h2>";
            $feedwordpress = new FeedWordPress();
            $feedwordpress->upgrade_database($ver);
            echo "<p><strong>Done!</strong> Upgraded database to version " . FEEDWORDPRESS_VERSION . ".</p>\n";
            echo "<form action=\"\" method=\"get\">\n";
            echo "<div class=\"submit\"><input type=\"hidden\" name=\"page\" value=\"syndication.php\" />";
            echo "<input type=\"submit\" value=\"Continue &raquo;\" /></form></div>\n";
            echo "</div>\n";
            return;
        } else {
            echo "<div class=\"updated\"><p>Already at version " . FEEDWORDPRESS_VERSION . "!</p></div>";
        }
    }
    ?>
<div class="wrap">
<h2>Upgrade FeedWordPress</h2>

<p>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.</p>

<p>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.</p>

<p>This may take several minutes for a large installation.</p>

<form action="" method="post">
<?php 
    FeedWordPressCompatibility::stamp_nonce('feedwordpress_upgrade');
    ?>
<div class="submit"><input type="submit" name="action" value="Upgrade" /></div>
</form>
</div>
<?php 
}
    function feed_categories_box($page, $box = NULL)
    {
        $link = $page->link;
        $unfamiliar = array('create' => '', 'tag' => '', 'default' => '', 'filter' => '');
        if ($page->for_feed_settings()) {
            $unfamiliar['site-default'] = '';
            $ucKey = isset($link->settings["unfamiliar category"]) ? $link->settings["unfamiliar category"] : null;
            $ucDefault = 'site-default';
        } else {
            $ucKey = FeedWordPress::on_unfamiliar('category');
            $ucDefault = 'create';
        }
        if (!is_string($ucKey) or !array_key_exists($ucKey, $unfamiliar)) {
            $ucKey = $ucDefault;
        }
        $unfamiliar[$ucKey] = ' checked="checked"';
        // Hey ho, let's go...
        ?>
<table class="edit-form">
<tr>
<th scope="row">Unfamiliar categories:</th>
<td><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p>

<ul class="options">
<?php 
        if ($page->for_feed_settings()) {
            ?>
<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php 
            echo $unfamiliar['site-default'];
            ?>
 /> use the <a href="admin.php?page=<?php 
            echo FWP_CATEGORIES_PAGE_SLUG;
            ?>
">site-wide setting</a>
(currently <strong><?php 
            echo FeedWordPress::on_unfamiliar('category');
            ?>
</strong>)</label></li>
<?php 
        }
        ?>

<li><label><input type="radio" name="unfamiliar_category" value="create"<?php 
        echo $unfamiliar['create'];
        ?>
 /> create a new category</label></li>

<?php 
        if (FeedWordPressCompatibility::post_tags()) {
            ?>
<li><label><input type="radio" name="unfamiliar_category" value="tag"<?php 
            echo $unfamiliar['tag'];
            ?>
/> create a new tag</label></li>
<?php 
        }
        ?>

<li><label><input type="radio" name="unfamiliar_category" value="default"<?php 
        echo $unfamiliar['default'];
        ?>
 /> don't create new categories<?php 
        if (fwp_test_wp_version(FWP_SCHEMA_23)) {
            ?>
 or tags<?php 
        }
        ?>
</label></li>
<li><label><input type="radio" name="unfamiliar_category" value="filter"<?php 
        echo $unfamiliar['filter'];
        ?>
 /> don't create new categories<?php 
        if (fwp_test_wp_version(FWP_SCHEMA_23)) {
            ?>
 or tags<?php 
        }
        ?>
 and don't syndicate posts unless they match at least one familiar category</label></li>
</ul></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']);
            }
            ?>
" />
<p class="setting-description">Enter a <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Perl-compatible regular expression</a> 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 <a href="http://del.icio.us/">del.icio.us</a>), use the pattern "\s".
If the feed does not provide multiple categories in a single element, leave this
blank.</p></td>
</tr>
<?php 
        }
        ?>
</table>
		<?php 
    }