本文整理汇总了PHP中wp_redirect函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_redirect函数的具体用法?PHP wp_redirect怎么用?PHP wp_redirect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_redirect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cp
/**
* s2Member's PayPal Auto-Return/PDT handler (inner processing routine).
*
* @package s2Member\PayPal
* @since 110720
*
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
*/
public static function cp($vars = array())
{
extract($vars);
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_return_before_no_return_data", get_defined_vars());
unset($__refs, $__v);
$paypal["s2member_log"][] = "No Return-Data. Customer MUST wait for Email Confirmation.";
$paypal["s2member_log"][] = "Note. This can sometimes happen when/if you are offering an Initial/Trial Period. There are times when a Payment Gateway will NOT supply s2Member with any data immediately after checkout. When/if this happens, s2Member must process the transaction via IPN only (i.e. behind-the-scene), and the Customer must wait for Email Confirmation in these cases.";
$paypal["s2member_log"][] = var_export($_REQUEST, true);
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_return_during_no_return_data", get_defined_vars());
unset($__refs, $__v);
if ($custom_success_redirection) {
$paypal["s2member_log"][] = "Redirecting Customer to a custom URL: " . $custom_success_redirection . ".";
wp_redirect($custom_success_redirection);
} else {
$paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after asking Customer to check their email).";
echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>Thank you! (you MUST check your email before proceeding).</strong><br /><br />* Note: It can take <em>(up to 15 minutes)</em> for Email Confirmation with important details. If you don\'t receive email confirmation in the next 15 minutes, please contact Support.', "s2member-front", "s2member") . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] || c_ws_plugin__s2member_utils_conds::pro_is_installed() && !empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_" . $paypal["subscr_gateway"] . "_sandbox"]) ? '<br /><br />' . _x('<strong>** Sandbox Mode **</strong> You may NOT receive this Email in Sandbox Mode. Sandbox addresses are usually bogus (for testing).', "s2member-front", "s2member") : ''), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
}
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_return_after_no_return_data", get_defined_vars());
unset($__refs, $__v);
return apply_filters("c_ws_plugin__s2member_paypal_return_in_no_tx_data", $paypal, get_defined_vars());
}
示例2: respond
function respond($result, $status = 'ok')
{
global $gb_json_api;
$json = $this->get_json($result, $status);
$status_redirect = "redirect_{$status}";
if ($gb_json_api->query->dev || !empty($_REQUEST['dev'])) {
// Output the result in a human-redable format
if (!headers_sent()) {
header('HTTP/1.1 200 OK');
header('Content-Type: text/plain; charset: UTF-8', true);
} else {
echo '<pre>';
}
echo $this->prettify($json);
} else {
if (!empty($_REQUEST[$status_redirect])) {
wp_redirect($_REQUEST[$status_redirect]);
} else {
if ($gb_json_api->query->redirect) {
$url = $this->add_status_query_var($gb_json_api->query->redirect, $status);
wp_redirect($url);
} else {
if ($gb_json_api->query->callback) {
// Run a JSONP-style callback with the result
$this->callback($gb_json_api->query->callback, $json);
} else {
// Output the result
$this->output($json);
}
}
}
}
exit;
}
示例3: edd_process_gateway_select
/**
* Processes gateway select on checkout. Only for users without ajax / javascript
*
* @since 1.7
*
* @param $data
*/
function edd_process_gateway_select($data)
{
if (isset($_POST['gateway_submit'])) {
wp_redirect(add_query_arg('payment-mode', $_POST['payment-mode']));
exit;
}
}
示例4: manage
public function manage() {
global $meow_provider, $wf;
$this->setup_view( array(
"title_args" => array( "text" => __("Site Content", MASTERPRESS_DOMAIN) )
)
);
$site = $wf->site();
MasterPress::$view->sets = self::assigned_field_sets();
MPC::incl("meta");
MPV::incl("meta");
if (MPC::is_postback()) {
// save the meta - this code should be moved into the controller at some stage
MPC_Meta::save_site_meta($site->id());
// redirect back to here
wp_redirect( MasterPress::admin_url( "site-content", "manage", array("updated" => "true"), false ) );
exit();
}
}
示例5: so_profile_redirect
function so_profile_redirect()
{
$result = stripos($_SERVER['REQUEST_URI'], 'profile.php');
if ($result !== false) {
wp_redirect(get_option('siteurl') . '/wp-admin/index.php');
}
}
示例6: optimizer_assign_widgets
function optimizer_assign_widgets()
{
$optimizer = get_option('optimizer');
$active_widgets = get_option('sidebars_widgets');
if (isset($_POST['assign_widgets']) && check_admin_referer('optimizer_assign_widgets', 'optimizer_assign_widgets')) {
if (empty($active_widgets['front_sidebar']) && empty($optimizer)) {
//ABOUT SECTION--------------------------------------------
$active_widgets['front_sidebar'][] = 'optimizer_front_about-1';
$about_content[1] = array('title' => __('THE OPTIMIZER', 'optimizer'), 'subtitle' => __('a little about..', 'optimizer'), 'content' => __('Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI.', 'optimizer'), 'divider' => 'fa-stop', 'title_color' => '#222222', 'content_color' => '#a8b4bf', 'content_bg' => '#ffffff');
update_option('widget_optimizer_front_about', $about_content);
//BLOCKS SECTION--------------------------------------------
$active_widgets['front_sidebar'][] = 'optimizer_front_blocks-1';
$blocks_content[1] = array('block1title' => __('Lorem Ipsum', 'optimizer'), 'block1img' => '', 'block1content' => __('Lorem ipsum dolor sit amet, consectetur dol adipiscing elit. Nam nec rhoncus risus. In ultrices lacinia ipsum, posuere faucibus velit bibe.', 'optimizer'), 'block2title' => __('Lorem Ipsum', 'optimizer'), 'block2img' => '', 'block2content' => __('Lorem ipsum dolor sit amet, consectetur dol adipiscing elit. Nam nec rhoncus risus. In ultrices lacinia ipsum, posuere faucibus velit bibe.', 'optimizer'), 'block3title' => __('Lorem Ipsum', 'optimizer'), 'block3img' => '', 'block3content' => __('Lorem ipsum dolor sit amet, consectetur dol adipiscing elit. Nam nec rhoncus risus. In ultrices lacinia ipsum, posuere faucibus velit bibe.', 'optimizer'), 'block4title' => '', 'block4img' => '', 'block4content' => '', 'block5title' => '', 'block5img' => '', 'block5content' => '', 'block6title' => '', 'block6img' => '', 'block6content' => '', 'blockstitlecolor' => '#555555', 'blockstxtcolor' => '#999999', 'blocksbgcolor' => '#f5f5f5');
update_option('widget_optimizer_front_blocks', $blocks_content);
//WELCOME TEXT SECTION--------------------------------------------
$active_widgets['front_sidebar'][] = 'optimizer_front_text-1';
$text_content[1] = array('title' => __('This Title wont be shown', 'optimizer'), 'content' => __('Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI.', 'optimizer'), 'padtopbottom' => '2', 'paddingside' => '2', 'parallax' => '', 'content_color' => '#ffffff;', 'content_bg' => '#333333;', 'content_bgimg' => '');
update_option('widget_optimizer_front_text', $text_content);
//POSTS SECTION--------------------------------------------
$active_widgets['front_sidebar'][] = 'optimizer_front_posts-1';
$posts_content[1] = array('title' => __('Our Work', 'optimizer'), 'subtitle' => __('Checkout Our Work', 'optimizer'), 'layout' => '1', 'type' => 'post', 'pages' => '', 'count' => '6', 'category' => '', 'divider' => 'fa-stop', 'navigation' => 'numbered', 'postbgcolor' => '', 'titlecolor' => '#333333', 'secbgcolor' => '#ffffff');
update_option('widget_optimizer_front_posts', $posts_content);
//Update the empty frontpage sidebar with widgets
update_option('sidebars_widgets', $active_widgets);
$redirect = admin_url('/customize.php');
wp_redirect($redirect);
}
}
}
示例7: check_access
/**
*
*/
public function check_access()
{
if (is_page(WC_Vendors::$pv_options->get_option('orders_page')) && !is_user_logged_in()) {
wp_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
exit;
}
}
示例8: custom_remove_no_admin_access
function custom_remove_no_admin_access()
{
if (!defined('DOING_AJAX') && !current_user_can('manage_options')) {
wp_redirect(home_url());
die;
}
}
示例9: redirection
/**
* will redirect old links to new link structures.
*/
public static function redirection()
{
global $wpdb, $wp_query;
if (is_object($wp_query) && $wp_query->get('em_redirect')) {
//is this a querystring url?
if ($wp_query->get('event_slug')) {
$event = $wpdb->get_row('SELECT event_id, post_id FROM ' . EM_EVENTS_TABLE . " WHERE event_slug='" . $wp_query->get('event_slug') . "' AND (blog_id=" . get_current_blog_id() . " OR blog_id IS NULL OR blog_id=0)", ARRAY_A);
if (!empty($event)) {
$EM_Event = em_get_event($event['event_id']);
$url = get_permalink($EM_Event->post_id);
}
} elseif ($wp_query->get('location_slug')) {
$location = $wpdb->get_row('SELECT location_id, post_id FROM ' . EM_LOCATIONS_TABLE . " WHERE location_slug='" . $wp_query->get('location_slug') . "' AND (blog_id=" . get_current_blog_id() . " OR blog_id IS NULL OR blog_id=0)", ARRAY_A);
if (!empty($location)) {
$EM_Location = em_get_location($location['location_id']);
$url = get_permalink($EM_Location->post_id);
}
} elseif ($wp_query->get('category_slug')) {
$url = get_term_link($wp_query->get('category_slug'), EM_TAXONOMY_CATEGORY);
}
if (!empty($url)) {
wp_redirect($url, 301);
exit;
}
}
}
示例10: do_redirects
/**
* Do the PHP redirect
*/
public function do_redirects()
{
// Check if PHP redirects are enabled.
if (false == $this->is_php_redirects_enabled()) {
return;
}
// Load redirects.
$redirects = $this->get_redirects();
// Do the actual redirect.
if (!empty($redirects)) {
// Decode the URL.
$url = htmlspecialchars_decode(urldecode($_SERVER['REQUEST_URI']));
foreach ($redirects as $regex => $redirect) {
// Check if the URL matches the $regex.
if (1 === @preg_match("`{$regex}`", $url, $this->url_matches)) {
// Replace the $regex vars with URL matches.
$redirect_url = preg_replace_callback('/[\\$0-9]+/', array($this, 'format_redirect_url'), $redirect['url']);
if ('/' === substr($redirect_url, 0, 1)) {
$redirect_url = home_url($redirect_url);
}
// Do the redirect.
wp_redirect($redirect_url, $redirect['type']);
exit;
}
// Reset url_matches.
$this->url_matches = array();
}
}
}
示例11: login_auth
/**
* Authenticate login
*
* @param string $username
* @param string $password
* @param bool $remember_login
* @param string $login_form_id
* @param string $redirect
*
* @return string/void
*/
static function login_auth($username, $password, $remember_login = true, $login_form_id = '', $redirect)
{
do_action('pp_before_login_validation', $username, $password, $login_form_id);
/* start filter Hook */
$login_errors = new WP_Error();
// call validate reg from function
$login_form_errors = apply_filters('pp_login_validation', $login_errors, $login_form_id);
if (is_wp_error($login_form_errors) && $login_form_errors->get_error_code() != '') {
return $login_form_errors;
}
/* End Filter Hook */
$creds = array();
$creds['user_login'] = $username;
$creds['user_password'] = $password;
if ($remember_login == 'true') {
$creds['remember'] = true;
}
$user = wp_signon($creds);
if (is_wp_error($user) && $user->get_error_code()) {
return $user;
} elseif (!is_wp_error($user)) {
do_action('pp_before_login_redirect', $username, $password, $login_form_id);
$login_redirect = !empty($redirect) ? $redirect : pp_login_redirect();
/** Setup a custom location of the builder */
$login_redirection = apply_filters('pp_login_redirect', $login_redirect, $login_form_id);
wp_redirect($login_redirection);
exit;
}
}
示例12: uploads_proxy
/**
* Get uploads from the production site and store them
* in the local filesystem if they don't already exist.
*
* @return void
*/
function uploads_proxy()
{
global $wp_filesystem;
WP_Filesystem();
// The relative request path
$requestPath = $_SERVER['REQUEST_URI'];
// The relative uploads path
$uploadsPath = str_replace(get_bloginfo('url'), '', wp_upload_dir()['baseurl']);
// Check if a upload was requested
if (strpos($requestPath, $uploadsPath) === 0) {
// The absolute remote path to the upload
$remotePath = UP_SITEURL . $requestPath;
// Get the remote upload file
$response = wp_remote_get($remotePath);
// Check the response code
if ($response['response']['code'] === 200) {
// The file path relative to the uploads path to store the upload file to
$relativeUploadFile = str_replace($uploadsPath, '', $_SERVER['REQUEST_URI']);
// The absolute file path to store the upload file to
$absoluteUploadFile = wp_upload_dir()['basedir'] . $relativeUploadFile;
// Make sure the upload directory exists
wp_mkdir_p(pathinfo($absoluteUploadFile)['dirname']);
if ($wp_filesystem->put_contents(urldecode($absoluteUploadFile), $response['body'], FS_CHMOD_FILE)) {
// Redirect to the stored upload
wp_redirect($requestPath);
}
}
}
}
示例13: _instagram_auth
function _instagram_auth()
{
$id = $_REQUEST['gallery'];
session_start();
$source = $_SESSION['asg_instagram_client_data'];
$auth_params = array('body' => array('client_id' => $source['client_id'], 'client_secret' => $source['client_secret'], 'grant_type' => 'authorization_code', 'redirect_uri' => $this->get_redirect_url($id), 'code' => $_REQUEST['code']));
$response = asg_remote_post('https://api.instagram.com/oauth/access_token', $auth_params);
if (is_wp_error($response)) {
wp_redirect(admin_url('admin.php?page=asg-instagram-auth-failure&message=' . urlencode($response->get_error_message())));
exit;
}
if ($response['body']) {
$body = json_decode($response['body']);
if ($body->access_token) {
wp_redirect(admin_url('admin.php?page=asg-instagram-auth-success&insta_token=' . $body->access_token));
exit;
}
}
if ($response['response']) {
wp_redirect(admin_url('admin.php?page=asg-instagram-auth-failure&message=' . $response['response']['message']));
exit;
}
wp_redirect(admin_url('admin.php?page=asg-instagram-auth-failure&message=' . urlencode('Unknown error')));
exit;
}
示例14: redirect_to_settings
function redirect_to_settings()
{
//First preserve all errors that have been generated
set_transient('settings_errors', get_settings_errors(), 30);
//Call settings url
wp_redirect($this->get_redirect_url() . '&settings-updated=true');
}
示例15: install_actions
/**
* Install actions such as installing pages when a button is clicked.
*/
public function install_actions()
{
// Install - Add pages button
if (!empty($_GET['install_woocommerce_pages'])) {
self::create_pages();
// We no longer need to install pages
delete_option('_wc_needs_pages');
delete_transient('_wc_activation_redirect');
// What's new redirect
wp_redirect(admin_url('index.php?page=wc-about&wc-installed=true'));
exit;
// Skip button
} elseif (!empty($_GET['skip_install_woocommerce_pages'])) {
// We no longer need to install pages
delete_option('_wc_needs_pages');
delete_transient('_wc_activation_redirect');
// What's new redirect
wp_redirect(admin_url('index.php?page=wc-about'));
exit;
// Update button
} elseif (!empty($_GET['do_update_woocommerce'])) {
$this->update();
// Update complete
delete_option('_wc_needs_pages');
delete_option('_wc_needs_update');
delete_transient('_wc_activation_redirect');
// What's new redirect
wp_redirect(admin_url('index.php?page=wc-about&wc-updated=true'));
exit;
}
}