本文整理汇总了PHP中wp_get_original_referer函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_original_referer函数的具体用法?PHP wp_get_original_referer怎么用?PHP wp_get_original_referer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_original_referer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($base)
{
$this->base = $base;
$this->admin = $base->admin;
$this->orig_referer = wp_get_original_referer();
if (isset($_GET['message'])) {
$this->message = intval($_GET['message']);
if ($this->message == 1 && !$this->orig_referer) {
$this->message = 4;
}
}
$this->messages[1] = sprintf(__('Page updated. Continue editing below or <a href="%s">go back</a>.', 'ktai_style'), esc_attr($this->orig_referer));
$this->messages[2] = __('Custom field updated.', 'ktai_style');
$this->messages[3] = __('Custom field deleted.', 'ktai_style');
$this->messages[4] = __('Page updated.', 'ktai_style');
$this->messages[5] = __('Page published.', 'ktai_style');
$this->messages[6] = __('Page submitted.', 'ktai_style');
if (isset($_GET['revision'])) {
$this->messages[5] = sprintf(__('Page restored to revision from %s'), wp_post_revision_title((int) $_GET['revision'], false));
}
$this->notices[1] = __('There is an autosave of this page that is more recent than the version below. <a href="%s">View the autosave</a>.');
global $post_ID, $temp_ID;
$post_ID = isset($post_ID) ? intval($post_ID) : 0;
$temp_ID = isset($temp_ID) ? intval($temp_ID) : 0;
}
示例2: wp_referer_field
function wp_referer_field()
{
$ref = wp_specialchars($_SERVER['REQUEST_URI']);
echo '<input type="hidden" name="_wp_http_referer" value="' . $ref . '" />';
if (wp_get_original_referer()) {
$original_ref = wp_specialchars(stripslashes(wp_get_original_referer()));
echo '<input type="hidden" name="_wp_original_http_referer" value="' . $original_ref . '" />';
}
}
示例3: __construct
public function __construct($base)
{
$this->base = $base;
$this->admin = $base->admin;
$this->referer = $this->admin->get_referer();
if ('' != wp_get_original_referer()) {
$this->referer = wp_get_original_referer();
}
$this->referer = remove_query_arg(array('approved', 'unapproved', 'spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids'), $this->referer);
global $action;
wp_reset_vars(array('action'));
if ('cdc' == $action) {
$action = 'delete';
} elseif ('mac' == $action) {
$action = 'approve';
}
if (isset($_GET['dt'])) {
if ('spam' == $_GET['dt']) {
$action = 'spam';
} elseif ('trash' == $_GET['dt']) {
$action = 'trash';
}
}
switch ($action) {
case 'spam':
case 'approve':
case 'delete':
case 'trash':
$this->confirm($action);
break;
case 'editcomment':
$this->edit_form();
break;
case 'deletecomment':
case 'trashcomment':
case 'untrashcomment':
case 'spamcomment':
case 'unspamcomment':
$this->delete_comment($action);
exit;
case 'approvecomment':
case 'unapprovecomment':
$this->approve_comment($action);
exit;
case 'editedcomment':
$this->edited_comment();
exit;
default:
break;
}
}
示例4: handle_members_updates
function handle_members_updates()
{
global $action, $page;
wp_reset_vars(array('action', 'page'));
if (isset($_GET['doaction']) || isset($_GET['doaction2'])) {
if (addslashes($_GET['action']) == 'toggle' || addslashes($_GET['action2']) == 'toggle') {
$action = 'bulk-toggle';
}
}
switch (addslashes($action)) {
case 'removeheader':
$this->dismiss_user_help($page);
wp_safe_redirect(remove_query_arg('action'));
break;
case 'toggle':
if (isset($_GET['member_id'])) {
$user_id = (int) $_GET['member_id'];
check_admin_referer('toggle-member_' . $user_id);
$member = new M_Membership($user_id);
if ($member->toggle_activation()) {
wp_safe_redirect(add_query_arg('msg', 7, wp_get_referer()));
} else {
wp_safe_redirect(add_query_arg('msg', 8, wp_get_referer()));
}
}
break;
case 'bulk-toggle':
check_admin_referer('bulk-members');
foreach ($_GET['users'] as $value) {
if (is_numeric($value)) {
$user_id = (int) $value;
$member = new M_Membership($user_id);
$member->toggle_activation();
}
}
wp_safe_redirect(add_query_arg('msg', 7, wp_get_referer()));
break;
case 'bulkaddlevel-level-complete':
case 'addlevel-level-complete':
check_admin_referer($action);
$members_id = $_POST['member_id'];
$members = explode(',', $members_id);
if ($members) {
foreach ($members as $member_id) {
$member = new M_Membership($member_id);
$tolevel_id = (int) $_POST['tolevel_id'];
if ($tolevel_id) {
$member->add_level($tolevel_id);
}
}
}
$this->update_levelcounts();
wp_safe_redirect(add_query_arg('msg', 3, wp_get_original_referer()));
break;
case 'bulkdroplevel-level-complete':
case 'droplevel-level-complete':
check_admin_referer($action);
$members_id = $_POST['member_id'];
$members = explode(',', $members_id);
if ($members) {
foreach ($members as $member_id) {
$member = new M_Membership($member_id);
$fromlevel_id = (int) $_POST['fromlevel_id'];
if ($fromlevel_id) {
$member->drop_level($fromlevel_id);
}
}
}
$this->update_levelcounts();
wp_safe_redirect(add_query_arg('msg', 3, wp_get_original_referer()));
break;
case 'bulkmovelevel-level-complete':
case 'movelevel-level-complete':
check_admin_referer($action);
$members_id = $_POST['member_id'];
$members = explode(',', $members_id);
if ($members) {
foreach ($members as $member_id) {
$member = new M_Membership($member_id);
$fromlevel_id = (int) $_POST['fromlevel_id'];
$tolevel_id = (int) $_POST['tolevel_id'];
if ($fromlevel_id && $tolevel_id) {
$member->move_level($fromlevel_id, $tolevel_id);
}
}
}
$this->update_levelcounts();
wp_safe_redirect(add_query_arg('msg', 3, wp_get_original_referer()));
break;
case 'bulkaddsub-sub-complete':
case 'addsub-sub-complete':
check_admin_referer($action);
$members_id = $_POST['member_id'];
$members = explode(',', $members_id);
if ($members) {
foreach ($members as $member_id) {
$member = new M_Membership($member_id);
$tosub_id = $_POST['tosub_id'];
if ($tosub_id) {
$subs = explode('-', $tosub_id);
//.........这里部分代码省略.........
示例5: logout_redirect
/**
* Handles logout redirection
*
* Callback for "logout_redirect" hook in method Theme_My_Login::the_request()
*
* @see Theme_My_Login::the_request()
* @since 6.0
* @access public
*
* @param string $redirect_to Default redirect
* @param string $request Requested redirect
* @param WP_User|WP_Error WP_User if user logged in, WP_Error otherwise
* @return string New redirect
*/
function logout_redirect($redirect_to, $request, $user)
{
global $theme_my_login;
// Determine the correct referer
if (!($http_referer = wp_get_original_referer())) {
$http_referer = wp_get_referer();
}
// Remove some arguments that may be present and shouldn't be
$http_referer = remove_query_arg(array('instance', 'action', 'checkemail', 'error', 'loggedout', 'registered', 'redirect_to', 'updated', 'key', '_wpnonce'), $http_referer);
// Make sure $user object exists and is a WP_User instance
if (!is_wp_error($user) && is_a($user, 'WP_User')) {
if (is_multisite() && empty($user->roles)) {
$user->roles = array('subscriber');
}
$redirection = array();
foreach ((array) $user->roles as $role) {
if ($theme_my_login->options->get_option(array('redirection', $role))) {
$redirection = $theme_my_login->options->get_option(array('redirection', $role));
break;
}
}
if ('referer' == $redirection['logout_type']) {
// Send 'em back to the referer
$redirect_to = $http_referer;
} elseif ('custom' == $redirection['logout_type']) {
// Send 'em to the specified URL
$redirect_to = $redirection['logout_url'];
// Allow a few user specific variables
$replace = array('%user_id%' => $user->ID, '%user_login%' => $user->user_login);
$redirect_to = str_replace(array_keys($replace), array_values($replace), $redirect_to);
}
}
// Make sure $redirect_to isn't empty or pointing to an admin URL (causing an endless loop)
if (empty($redirect_to) || strpos($redirect_to, 'wp-admin') !== false) {
$redirect_to = $theme_my_login->get_login_page_link('loggedout=true');
}
return $redirect_to;
}
示例6: logout_redirect
/**
* Handles logout redirection
*
* Callback for "logout_redirect" hook in method Theme_My_Login::the_request()
*
* @see Theme_My_Login::the_request()
* @since 6.0
* @access public
*
* @param string $redirect_to Default redirect
* @param string $request Requested redirect
* @param WP_User|WP_Error WP_User if user logged in, WP_Error otherwise
* @return string New redirect
*/
public function logout_redirect($redirect_to, $request, $user)
{
// Determine the correct referer
if (!($http_referer = wp_get_original_referer())) {
$http_referer = wp_get_referer();
}
// Remove some arguments that may be present and shouldn't be
$http_referer = remove_query_arg(array('instance', 'action', 'checkemail', 'error', 'loggedout', 'registered', 'redirect_to', 'updated', 'key', '_wpnonce'), $http_referer);
// Make sure $user object exists and is a WP_User instance
if (!is_wp_error($user) && is_a($user, 'WP_User')) {
if (is_multisite() && empty($user->roles)) {
$user->roles = array('subscriber');
}
$user_role = reset($user->roles);
$redirection = $this->get_option($user_role, array());
if ('referer' == $redirection['logout_type']) {
// Send 'em back to the referer
$redirect_to = $http_referer;
} elseif ('custom' == $redirection['logout_type']) {
// Send 'em to the specified URL
$redirect_to = $redirection['logout_url'];
// Allow a few user specific variables
$redirect_to = Theme_My_Login_Common::replace_vars($redirect_to, $user->ID, array('%user_id%' => $user->ID));
}
}
// Make sure $redirect_to isn't empty or pointing to an admin URL (causing an endless loop)
if (empty($redirect_to) || false !== strpos($redirect_to, 'wp-admin')) {
$redirect_to = add_query_arg('loggedout', 'true', wp_login_url());
}
return $redirect_to;
}
示例7: login_form
/**
* Adds "_wp_original_referer" field to login form
*
* Callback for "login_form" hook in file "login-form.php", included by method Theme_My_Login_Template::display()
*
* @see Theme_My_Login_Template::display()
* @since 6.0
* @access public
*/
public function login_form()
{
if (!empty($_REQUEST['redirect_to'])) {
$referer = wp_unslash($_REQUEST['redirect_to']);
} elseif (wp_get_original_referer()) {
$referer = wp_get_original_referer();
} else {
$referer = Theme_My_Login::is_tml_page() ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
}
echo '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr($referer) . '" />';
}
示例8: wpu_menuSettings
function wpu_menuSettings()
{
global $user_ID, $wp_roles;
$profileuser = get_user_to_edit($user_ID);
$bookmarklet_height = 440;
$wpuConnSettings = get_settings('wputd_connection');
$page_output = '';
if (isset($_GET['updated'])) {
$page_output .= '<div id="message" class="updated fade">
<p><strong>' . __('Settings updated.') . '</strong></p>
</div>';
}
if (!empty($wpuConnSettings['blogs'])) {
$pageTitle .= __('Your Blog Details');
} else {
$pageTitle .= __('Your Profile');
}
$page_output .= '<div class="wrap">';
echo $page_output;
screen_icon();
$page_output = '<h2>' . wp_specialchars($pageTitle) . '</h2>';
$page_output .= '<form name="profile" id="your-profile" action="admin.php?noheader=true&page=' . $wpuConnSettings['full_path_to_plugin'] . '&wpu_action=update-blog-profile" method="post">' . "\n";
// have to use this, because wp_nonce_field echos. //wp_nonce_field('update-blog-profile_' . $user_ID);
// beginning of nonce fields
$page_output .= '<input type="hidden" name="' . attribute_escape('_wpnonce') . '" value="' . wp_create_nonce('update-blog-profile_' . $user_ID) . '" />';
$ref = attribute_escape($_SERVER['REQUEST_URI']);
$page_output .= '<input type="hidden" name="_wp_http_referer" value="' . $ref . '" />';
if (wp_get_original_referer()) {
$original_ref = attribute_escape(stripslashes(wp_get_original_referer()));
$page_output .= '<input type="hidden" name="_wp_original_http_referer" value="' . $original_ref . '" />';
}
// End of nonce fields
$page_output .= '<p>
<!--<input type="hidden" name="page" value="' . $wpuConnSettings['full_path_to_plugin'] . '" /> -->
<!--<input type="hidden" name="action" value="update-blog-profile" />-->
<!--<input type="hidden" name="from" value="blog_settings" /> -->
<input type="hidden" name="checkuser_id" value="' . 'echo $user_ID' . '" />
</p>
<fieldset>
<legend>' . __('Name') . '</legend>
<input type="hidden" name="user_login" value="' . $profileuser->user_login . '" />
<p><label>' . __('First name:') . '<br />
<input type="text" name="first_name" value="' . $profileuser->first_name . '" /></label></p>
<p><label>' . 'Last name:' . '<br />
<input type="text" name="last_name" value="' . $profileuser->last_name . '" /></label></p>
<p><label>' . __('Nickname:') . '<br />
<input type="text" name="nickname" value="' . $profileuser->nickname . '" /></label></p>
<p><label>' . __('Display name publicly as:') . '<br />
<select name="display_name">
<option value="' . $profileuser->display_name . '">' . $profileuser->display_name . '</option>
<option value="' . $profileuser->nickname . '">' . $profileuser->nickname . '</option>
<option value="' . $profileuser->user_login . '">' . $profileuser->user_login . '</option>';
if (!empty($profileuser->first_name)) {
$page_output .= '<option value="' . $profileuser->first_name . '">' . $profileuser->first_name . '</option>';
}
if (!empty($profileuser->last_name)) {
$page_output .= '<option value="' . $profileuser->last_name . '">' . $profileuser->last_name . '</option>';
}
if (!empty($profileuser->first_name) && !empty($profileuser->last_name)) {
$page_output .= '<option value="' . $profileuser->first_name . ' ' . $profileuser->last_name . '">' . $profileuser->first_name . ' ' . $profileuser->last_name . '</option>
<option value="' . $profileuser->last_name . ' ' . $profileuser->first_name . '">' . $profileuser->last_name . ' ' . $profileuser->first_name . '</option>';
}
$page_output .= '</select></label></p>
</fieldset>';
if (!empty($wpuConnSettings['blogs'])) {
$page_output .= '<fieldset>
<legend>' . __('About Your Blog') . '</legend>
<input type="hidden" name="email" value="' . $profileuser->user_email . '" />';
// Retrieve blog options
$blog_title = get_usermeta($user_ID, 'blog_title');
$blog_tagline = get_usermeta($user_ID, 'blog_tagline');
$page_output .= '<p><label>' . __('The Title of Your Blog:') . '<br />
<input type="text" name="blog_title" value="' . $blog_title . '" /></label></p>
<p><label>' . __('Blog Tagline') . '<br />
<input type="text" name="blog_tagline" value="' . $blog_tagline . '"</label></p>
</fieldset>';
}
$page_output .= '<br clear="all" />
<fieldset>
<legend>' . __('About yourself') . '</legend>
<p class="desc">' . __('Share a little biographical information to fill out your profile. This may be shown publicly.') . '</p>
<p><textarea name="description" rows="5" cols="30">' . $profileuser->description . '</textarea></p>
</fieldset>';
do_action('show_user_profile');
$richEditing = get_user_option('rich_editing') ? "checked='checked'" : "";
$page_output .= '<br clear="all" />
<h3>' . __('Personal Options') . '</h3>
<p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" ' . $richEditing . ' />' . __('Use the visual rich editor when writing') . '</label></p>';
do_action('profile_personal_options');
$page_output .= '<table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform">';
if (count($profileuser->caps) > count($profileuser->roles)) {
$page_output .= '<tr>
<th scope="row">' . __('Additional Capabilities:') . '</th>
<td>';
//.........这里部分代码省略.........
示例9: wp_original_referer_field
/**
* Retrieve or display original referer hidden field for forms.
*
* The input name is '_wp_original_http_referer' and will be either the same
* value of wp_referer_field(), if that was posted already or it will be the
* current page, if it doesn't exist.
*
* @since 2.0.4
*
* @param bool $echo Optional. Whether to echo the original http referer. Default true.
* @param string $jump_back_to Optional. Can be 'previous' or page you want to jump back to.
* Default 'current'.
* @return string Original referer field.
*/
function wp_original_referer_field($echo = true, $jump_back_to = 'current')
{
if (!($ref = wp_get_original_referer())) {
$ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
}
$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr($ref) . '" />';
if ($echo) {
echo $orig_referer_field;
}
return $orig_referer_field;
}
示例10: redirect_post
private function redirect_post($post_ID = '')
{
$admin_dir = $this->base->get('plugin_dir') . '/' . basename(dirname(__FILE__));
$referredby = '';
if (!empty($_POST['referredby'])) {
$referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']);
$referredby = remove_query_arg('_wp_original_http_referer', $referredby);
}
$referer = preg_replace('|https?://[^/]+|i', '', $this->admin->get_referer());
if ((isset($_POST['save']) || isset($_POST['publish'])) && (empty($referredby) || $referredby == $referer || 'redo' != $referredby)) {
$orig_referer = wp_get_original_referer();
if (strpos($orig_referer, $admin_dir . '/post.php') === false && strpos($orig_referer, $admin_dir . '/post-new.php') === false) {
$location = add_query_arg(array('_wp_original_http_referer' => urlencode($orig_referer), 'message' => 1), get_edit_post_link($post_ID, 'url'));
} else {
if (isset($_POST['publish'])) {
if ('pending' == get_post_status($post_ID)) {
$location = add_query_arg('message', 8, get_edit_post_link($post_ID, 'url'));
} else {
$location = add_query_arg('message', 6, get_edit_post_link($post_ID, 'url'));
}
} else {
$location = add_query_arg('message', 7, get_edit_post_link($post_ID, 'url'));
}
}
/* } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
$location = add_query_arg( 'message', 2, $this->admin->get_referer() );
$location = explode('#', $location);
$location = $location[0] . '#postcustom';
} elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) {
$location = add_query_arg( 'message', 3, $this->admin->get_referer() );
$location = explode('#', $location);
$location = $location[0] . '#postcustom';
*/
} elseif (!empty($referredby) && $referredby != $referer) {
$location = $_POST['referredby'];
$location = remove_query_arg('_wp_original_http_referer', $location);
if (false !== strpos($location, 'edit.php')) {
$location = add_query_arg('posted', $post_ID, $location);
} elseif (false !== strpos($location, basename(dirname(__FILE__)))) {
$location = "post-new.php?posted={$post_ID}";
}
} elseif (isset($_POST['publish'])) {
$location = "post-new.php?posted={$post_ID}";
} else {
$location = add_query_arg('message', 4, get_edit_post_link($post_ID, 'url'));
}
$this->admin->redirect($location);
}
示例11: load_admin_style
function load_admin_style()
{
wp_register_style('admin_css', 'http://www.mentalhaiku.com/wp-content/themes/mentalhaiku/admin-style.css', false, '1.0.0');
wp_enqueue_style('admin_css', get_template_directory_uri() . '/admin-style.css', false, '1.0.0');
}
add_filter('ajax_query_attachments_args', 'show_users_own_attachments', 1, 1);
function show_users_own_attachments($query)
{
$id = get_current_user_id();
if (!current_user_can('manage_options')) {
$query['author'] = $id;
}
return $query;
}
add_filter('redirect_post_location', function ($location) {
global $post;
if ((isset($_POST['publish']) || isset($_POST['save'])) && preg_match("/post=([0-9]*)/", $location, $match) && $post && $post->ID == $match[1] && (isset($_POST['publish']) || $post->post_status == 'publish') && ($pl = get_permalink($post->ID))) {
if (isset($_POST['publish'])) {
// Homepage for new posts only
$location = home_url();
} elseif ($ref = wp_get_original_referer()) {
// Referer for edited posts
$ref = explode('#', $ref, 2);
$location = $ref[0] . '#post-' . $post->ID;
} else {
// Post page as a last resort
$location = $pl;
}
}
return $location;
});
示例12: process_contribution_action
/**
* Process the selected action for a single contribution
*
* @since 1.0.0
*/
public function process_contribution_action()
{
if (!isset($_REQUEST['action']) || !isset($_REQUEST['c'])) {
return;
}
switch ($_REQUEST['action']) {
case 'flagcomment':
$comment_id = absint($_REQUEST['c']);
check_admin_referer('delete-comment_' . $comment_id);
$noredir = isset($_REQUEST['noredir']);
if (!($comment = get_comment($comment_id))) {
comment_footer_die(__('Oops, no comment with this ID.', WC_Product_Reviews_Pro::TEXT_DOMAIN) . sprintf(' <a href="%s">' . __('Go back', WC_Product_Reviews_Pro::TEXT_DOMAIN) . '</a>.', 'admin.php?page=contributions'));
}
if ('' != wp_get_referer() && !$noredir && false === strpos(wp_get_referer(), 'page=contributions')) {
$redir = wp_get_referer();
} elseif ('' != wp_get_original_referer() && !$noredir) {
$redir = wp_get_original_referer();
} else {
$redir = admin_url('admin.php?page=contributions');
}
$redir = remove_query_arg(array('ids', 'flagged'), $redir);
$contribution = wc_product_reviews_pro_get_contribution($comment_id);
if ($contribution && $contribution->flag()) {
$redir = add_query_arg(array('flagged' => '1'), $redir);
}
wp_redirect(esc_url_raw($redir));
exit;
break;
}
}
示例13: universal_exceptions_note
function universal_exceptions_note($tag, $taxonomy, $post_type)
{
$tx_obj = get_taxonomy($taxonomy);
$type_obj = get_post_type_object($post_type);
?>
<div class="form-wrap"><p>
<?php
// if _wp_original_http_referer is not passed, redirect will be from universal exceptions edit form to type-specific exceptions edit form
if (!($referer = wp_get_original_referer())) {
$referer = wp_get_referer();
}
$url = add_query_arg('_wp_original_http_referer', urlencode($referer), "edit-tags.php?action=edit&taxonomy={$taxonomy}&tag_ID={$tag->term_id}&pp_universal=1");
printf(__('Displayed exceptions are those assigned for the "%1$s" type. You can also %2$sdefine universal %3$s exceptions which apply to all related post types%4$s.', 'pp'), $type_obj->labels->singular_name, "<a href='{$url}'>", $tx_obj->labels->singular_name, '</a>');
?>
</p></div>
<?php
}
示例14: pp_admin_projects
//.........这里部分代码省略.........
<th scope="row" valign="top"><label for="project_overheard"><?php
_e('Project Overheard Feeds', 'prologue-projects');
?>
</label></th>
<td><textarea name="project_overheard" id="project_overheard" rows="5" cols="40"><?php
echo wp_specialchars(join("\n", stripslashes_deep($project['overheard'])));
?>
</textarea><br />
<span class="setting-description"><?php
_e('Specify a list of feeds you wish to aggregate into the projects "overheard" sidebar. One feed per line.', 'prologue-projects');
?>
</span></td>
</tr>
</table>
<p class="submit"><input type="submit" class="button" name="submit" value="<?php
_e('Update Project', 'prologue-projects');
?>
" /></p>
</form>
</div><!-- /wrap -->
<?php
break;
case 'editedproject':
$project_ID = (int) $_POST['project_ID'];
check_admin_referer('update-project_' . $project_ID);
if (!current_user_can('manage_categories')) {
wp_die(__('Cheatin’ uh?', 'prologue-projects'));
}
$location = 'admin.php?page=prologue-projects';
if ($referer = wp_get_original_referer()) {
if (false !== strpos($referer, 'admin.php')) {
$location = $referer;
}
}
if (pp_update_project($_POST)) {
$location = add_query_arg('message', 3, $location);
} else {
$location = add_query_arg('message', 5, $location);
}
wp_redirect($location);
exit;
break;
default:
if (isset($_GET['_wp_http_referer']) && !empty($_GET['_wp_http_referer'])) {
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
exit;
}
require_once 'admin-header.php';
$messages[1] = __('Project added.', 'prologue-projects');
$messages[2] = __('Project deleted.', 'prologue-projects');
$messages[3] = __('Project updated.', 'prologue-projects');
$messages[4] = __('Project not added.', 'prologue-projects');
$messages[5] = __('Project not updated.', 'prologue-projects');
?>
<div class="wrap nosubsub">
<?php
screen_icon();
?>
<h2>
<?php
echo wp_specialchars($title);
示例15: check_for_submitted
function check_for_submitted()
{
if (!$_REQUEST['cwp_submitted_' . $this->get_page_id()]) {
return;
}
$action = $_REQUEST['action'];
$taxonomy = $_REQUEST['taxonomy'];
if (isset($_GET['action']) && isset($_GET['delete_tags']) && ('delete' == $_GET['action'] || 'delete' == $_GET['action2'])) {
$action = 'bulk-delete';
}
do_action('cwp_taxonomy_page_form_submitted_pre', array($this));
switch ($action) {
case 'addtag':
check_admin_referer('add-tag');
if (!current_user_can('manage_categories')) {
wp_die(__('Cheatin’ uh?'));
}
$ret = wp_insert_term($_POST['name'], $taxonomy, $_POST);
if (!is_wp_error($ret)) {
do_action('cwp_taxonomy_page_form_submitted_term_added', $this, $ret['term_id'], $taxonomy);
}
if ($ret && !is_wp_error($ret)) {
wp_redirect(add_query_arg('message', 1));
} else {
wp_redirect(add_query_arg('message', 4));
}
exit;
break;
case 'delete':
$tag_ID = (int) $_GET['tag_ID'];
check_admin_referer('delete-tag_' . $tag_ID);
if (!current_user_can('manage_categories')) {
wp_die(__('Cheatin’ uh?'));
}
wp_delete_term($tag_ID, $taxonomy);
$location = $this->get_page_url();
if ($referer = wp_get_referer()) {
if (false !== strpos($referer, 'edit-tags.php')) {
$location = $referer;
}
}
$location = add_query_arg('message', 2, $location);
wp_redirect($location);
exit;
break;
case 'bulk-delete':
check_admin_referer('bulk-tags');
if (!current_user_can('manage_categories')) {
wp_die(__('Cheatin’ uh?'));
}
$tags = $_GET['delete_tags'];
foreach ((array) $tags as $tag_ID) {
wp_delete_term($tag_ID, $taxonomy);
}
$location = $this->get_page_url();
if ($referer = wp_get_referer()) {
if (false !== strpos($referer, 'edit-tags.php')) {
$location = $referer;
}
}
$location = add_query_arg('message', 6, $location);
wp_redirect($location);
exit;
break;
case 'editedtag':
$tag_ID = (int) $_REQUEST['tag_ID'];
check_admin_referer('update-tag_' . $tag_ID);
if (!current_user_can('manage_categories')) {
wp_die(__('Cheatin’ uh?'));
}
$ret = wp_update_term($tag_ID, $taxonomy, $_POST);
$location = $this->get_page_url();
if ($referer = wp_get_original_referer()) {
if (false !== strpos($referer, 'edit-tags.php')) {
$location = $referer;
}
}
if ($ret && !is_wp_error($ret)) {
do_action('cwp_taxonomy_page_form_submitted_term_updated', $this, $tag_ID, $taxonomy);
}
if ($ret && !is_wp_error($ret)) {
$location = add_query_arg('message', 3, $location);
} else {
$location = add_query_arg('message', 5, $location);
}
wp_redirect($location);
exit;
break;
default:
if (isset($_GET['_wp_http_referer']) && !empty($_GET['_wp_http_referer'])) {
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
exit;
}
}
}