ajax_nonce_fields() static public method

* FeedWordPressSettingsUI::admin_styles ()
static public ajax_nonce_fields ( )
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 
}
Ejemplo n.º 2
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 open_sheet($header)
    {
        // Set up prepatory AJAX stuff
        $this->ajax_interface_js();
        if (function_exists('add_meta_box')) {
            add_action(FeedWordPressCompatibility::bottom_script_hook($this->filename), array($this, 'fix_toggles'), 10000);
            FeedWordPressSettingsUI::ajax_nonce_fields();
        }
        ?>
		<div class="wrap" style="position:relative">
		<?php 
        if (!is_null($header)) {
            $this->display_sheet_header($header);
        }
        if (!is_null($this->dispatch)) {
            ?>
			<form action="admin.php?page=<?php 
            echo $this->filename;
            ?>
" method="post">
			<div><?php 
            FeedWordPressCompatibility::stamp_nonce($this->dispatch);
            $this->stamp_link_id();
            ?>
</div>
			<?php 
        }
        if ($this->has_link()) {
            $this->display_feed_select_dropdown();
            $this->display_settings_scope_message();
        }
        if (function_exists('do_meta_boxes')) {
            ?>
			<div id="poststuff">
			<?php 
        } else {
            ?>
			</div> <!-- class="wrap" -->
			<?php 
        }
        if (!is_null($this->dispatch)) {
            fwp_settings_form_single_submit();
        }
    }