本文整理汇总了PHP中wp_safe_redirect函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_safe_redirect函数的具体用法?PHP wp_safe_redirect怎么用?PHP wp_safe_redirect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_safe_redirect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gmw_pt_update_posts_database_table
function gmw_pt_update_posts_database_table()
{
if (empty($_POST['gmw_action']) || $_POST['gmw_action'] != 'posts_db_table_update') {
return;
}
//look for nonce
if (empty($_POST['gmw_posts_db_table_update_nonce'])) {
wp_die(__('Cheatin\' eh?!', 'GMW'));
}
//varify nonce
if (!wp_verify_nonce($_POST['gmw_posts_db_table_update_nonce'], 'gmw_posts_db_table_update_nonce')) {
wp_die(__('Cheatin\' eh?!', 'GMW'));
}
global $wpdb;
$dbTable = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}places_locator");
//Add column if not present.
if (!isset($dbTable->street_number)) {
$wpdb->query("ALTER TABLE {$wpdb->prefix}places_locator ADD COLUMN `street_name` varchar(128) NOT NULL AFTER `long`");
$wpdb->query("ALTER TABLE {$wpdb->prefix}places_locator ADD COLUMN `street_number` varchar(60) NOT NULL AFTER `long`");
//update database version
update_option("gmw_pt_db_version", GMW_PT_DB_VERSION);
} else {
update_option("gmw_pt_db_version", GMW_PT_DB_VERSION);
}
wp_safe_redirect(admin_url('admin.php?page=gmw-add-ons&gmw_notice=posts_db_table_updated&gmw_notice_status=updated'));
exit;
}
示例2: gmw_fl_update_members_database_table
function gmw_fl_update_members_database_table()
{
if (empty($_POST['gmw_action']) || $_POST['gmw_action'] != 'members_db_table_update') {
return;
}
//look for nonce
if (empty($_POST['gmw_members_db_table_update_nonce'])) {
wp_die(__('Cheatin\' eh?!', 'GMW'));
}
//varify nonce
if (!wp_verify_nonce($_POST['gmw_members_db_table_update_nonce'], 'gmw_members_db_table_update_nonce')) {
wp_die(__('Cheatin\' eh?!', 'GMW'));
}
global $wpdb;
$dbTable = $wpdb->get_row("SELECT * FROM wppl_friends_locator");
//Add column if not present.
if (!isset($dbTable->street_name)) {
$wpdb->query("ALTER TABLE wppl_friends_locator ADD COLUMN `street_name` varchar(128) NOT NULL AFTER `long`");
}
if (!isset($dbTable->street_number)) {
$wpdb->query("ALTER TABLE wppl_friends_locator ADD COLUMN `street_number` varchar(60) NOT NULL AFTER `long`");
}
if (!isset($dbTable->feature)) {
$wpdb->query("ALTER TABLE wppl_friends_locator ADD COLUMN `feature` tinyint NOT NULL default '0' AFTER `member_id`");
}
update_option("gmw_fl_db_version", GMW_FL_DB_VERSION);
wp_safe_redirect(admin_url('admin.php?page=gmw-add-ons&gmw_notice=members_db_table_updated&gmw_notice_status=updated'));
exit;
}
示例3: admin_init
/**
* Process redirection of all dashboard pages for password reset
*
* @since 1.8
*
* @return void
*/
public function admin_init() {
if ( isset( get_current_screen()->id ) && ( 'profile' === get_current_screen()->id || 'profile-network' === get_current_screen()->id ) ) {
if ( isset( $this->settings['expire'] ) && $this->settings['expire'] === true ) { //make sure we're enforcing a password change
$current_user = wp_get_current_user();
if ( isset( $current_user->ID ) && $current_user->ID !== 0 ) { //make sure we have a valid user
$required = get_user_meta( $current_user->ID, 'itsec_password_change_required', true );
if ( $required == true ) {
wp_safe_redirect( admin_url( 'profile.php?itsec_password_expired=true#pass1' ) );
exit();
}
}
}
}
}
示例4: settings_import
/**
* Process a settings import from a json file
* @since 1.0.0
*/
public function settings_import()
{
if (empty($_POST['g_action']) || 'import_settings' != $_POST['g_action']) {
return;
}
if (!wp_verify_nonce($_POST['g_import_nonce'], 'g_import_nonce')) {
return;
}
if (!current_user_can('manage_options')) {
return;
}
$extension = end(explode('.', $_FILES['import_file']['name']));
if ($extension != 'json') {
wp_die(__('Please upload a valid .json file', GT_SETTINGS));
}
$import_file = $_FILES['import_file']['tmp_name'];
if (empty($import_file)) {
wp_die(__('Please upload a file to import', GT_SETTINGS));
}
// Retrieve the settings from the file and convert the json object to an array.
$settings = (array) json_decode(file_get_contents($import_file));
update_option($this->plugin_slug . '-settings', get_object_vars($settings[0]));
wp_safe_redirect(admin_url('options-general.php?page=' . GT_SETTINGS));
exit;
}
示例5: __construct
function __construct()
{
global $wpdb;
$this->bmp_table = $wpdb->base_prefix . 'rt_rtm_media';
add_action('admin_menu', array($this, 'menu'));
add_action('wp_ajax_bp_media_rt_db_migration', array($this, 'migrate_to_new_db'));
if (isset($_REQUEST['page']) && 'rtmedia-migration' == $_REQUEST['page'] && isset($_REQUEST['hide']) && 'true' == $_REQUEST['hide']) {
$this->hide_migration_notice();
wp_safe_redirect(esc_url_raw($_SERVER['HTTP_REFERER']));
}
if (false !== rtmedia_get_site_option('rt_migration_hide_notice')) {
return true;
}
if (isset($_REQUEST['force']) && 'true' === $_REQUEST['force']) {
$pending = false;
} else {
$pending = rtmedia_get_site_option('rtMigration-pending-count');
}
if (false === $pending) {
$total = $this->get_total_count();
$done = $this->get_done_count();
$pending = $total - $done;
if ($pending < 0) {
$pending = 0;
}
rtmedia_update_site_option('rtMigration-pending-count', $pending);
}
if ($pending > 0) {
if (!(isset($_REQUEST['page']) && 'rtmedia-migration' == $_REQUEST['page'])) {
add_action('admin_notices', array(&$this, 'add_migration_notice'));
}
}
}
示例6: prerender
function prerender()
{
$ip = $_SERVER['REMOTE_ADDR'];
//print_r($info);
$info = $this->data();
if (isset($info->id)) {
$lists = SendPress_Data::get_list_ids_for_subscriber($info->id);
//$lists = explode(',',$info->listids);
foreach ($lists as $list) {
$status = SendPress_Data::get_subscriber_list_status($list->listID, $info->id);
if ($status->statusid == 1) {
SendPress_Data::update_subscriber_status($list->listID, $info->id, '2');
}
}
SPNL()->db("Subscribers_Tracker")->open($info->report, $info->id, 4);
}
if (SendPress_Option::get('confirm-page') == 'custom') {
$page = SendPress_Option::get('confirm-page-id');
if ($page != false) {
$plink = get_permalink($page);
if ($plink != "") {
wp_safe_redirect(esc_url_raw($plink));
exit;
}
}
}
}
示例7: otl_authenticate_one_time_login
/**
* Process one time login
*
* @since 1.0.0
*
* @return void
*/
function otl_authenticate_one_time_login()
{
// No need to run if not a singular query for the one time login
if (!is_single()) {
return;
}
// No need to run if not a onetimelogin post
global $post;
if ('onetimelogin' !== $post->post_type) {
return;
}
$user_id = get_post_meta(get_the_ID(), 'otl_user', true);
$valid_user = get_userdata($user_id) ? true : false;
$login_uses = get_post_meta(get_the_ID(), 'otl_times_used', true);
// If the one time login is unused and the user is valid, log in
if ('0' === $login_uses && $valid_user) {
// Log in
wp_clear_auth_cookie();
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
// Update some meta for logging and to prevent multiple uses
update_post_meta(get_the_ID(), 'otl_times_used', '1');
update_post_meta(get_the_ID(), 'otl_datetime_used', current_time('mysql'));
// Redirect to wp-admin
wp_safe_redirect(user_admin_url());
exit;
} else {
wp_redirect(home_url());
exit;
}
return;
}
示例8: vip_dashboard_prevent_admin_access
/**
* Limit plugins.php access to vip_support role
*
* @return void
*/
function vip_dashboard_prevent_admin_access()
{
$user = wp_get_current_user();
if (!in_array('vip_support', $user->roles)) {
wp_safe_redirect(esc_url(add_query_arg(array('page' => 'vip-plugins'), admin_url('admin.php'))));
}
}
示例9: __construct
function __construct()
{
global $wpdb;
$this->bmp_table = $wpdb->base_prefix . "rt_rtm_media";
add_action('admin_menu', array($this, 'menu'));
add_action('wp_ajax_bp_media_rt_db_migration', array($this, "migrate_to_new_db"));
if (isset($_REQUEST["page"]) && $_REQUEST["page"] == "rtmedia-migration" && isset($_REQUEST["hide"]) && $_REQUEST["hide"] == "true") {
$this->hide_migration_notice();
wp_safe_redirect($_SERVER["HTTP_REFERER"]);
}
if (rtmedia_get_site_option("rt_migration_hide_notice") !== false) {
return true;
}
if (isset($_REQUEST["force"]) && $_REQUEST["force"] === "true") {
$pending = false;
} else {
$pending = rtmedia_get_site_option("rtMigration-pending-count");
}
if ($pending === false) {
$total = $this->get_total_count();
$done = $this->get_done_count();
$pending = $total - $done;
if ($pending < 0) {
$pending = 0;
}
rtmedia_update_site_option("rtMigration-pending-count", $pending);
}
if ($pending > 0) {
if (!(isset($_REQUEST["page"]) && $_REQUEST["page"] == "rtmedia-migration")) {
add_action('admin_notices', array(&$this, 'add_migration_notice'));
}
}
}
示例10: welcome
/**
* Sends user to the Settings page on first activation of MASHSB as well as each
* time MASHSB is upgraded to a new version
*
* @access public
* @since 1.0.1
* @global $mashsb_options Array of all the MASHSB Options
* @return void
*/
public function welcome()
{
global $mashsb_options;
// Bail if no activation redirect
if (!get_transient('_mashsb_activation_redirect')) {
return;
}
// Delete the redirect transient
delete_transient('_mashsb_activation_redirect');
// Bail if activating from network, or bulk
if (is_network_admin() || isset($_GET['activate-multi'])) {
return;
}
$upgrade = get_option('mashsb_version_upgraded_from');
//@since 2.0.3
if (!$upgrade) {
// First time install
wp_safe_redirect(admin_url('options-general.php?page=mashsb-settings&tab=networks'));
exit;
} else {
// Update
wp_safe_redirect(admin_url('options-general.php?page=mashsb-settings&tab=networks'));
exit;
}
}
示例11: uf_perform_logout
/**
* Loads the current user out
*
* @wp-hook uf_logout
* @return void
*/
function uf_perform_logout()
{
wp_logout();
$url_after_logout = apply_filters('uf_perform_logout_url', '/user-login/?message=loggedout');
wp_safe_redirect(home_url($url_after_logout));
exit;
}
示例12: welcome
/**
* Sends user to the Settings page on first activation of WPSTG as well as each
* time WPSTG is upgraded to a new version
*
* @access public
* @since 0.9.0
* @global $wpstg_options Array of all the WPSTG Options
* @return void
*/
public function welcome()
{
global $wpstg_options;
// Bail if no activation redirect
if (!get_transient('_wpstg_activation_redirect')) {
return;
}
// Delete the redirect transient
delete_transient('_wpstg_activation_redirect');
// Bail if activating from network, or bulk
if (is_network_admin() || isset($_GET['activate-multi'])) {
return;
}
$upgrade = get_option('wpstg_version_upgraded_from');
//@since 0.9.0
if (!$upgrade) {
// First time install
wp_safe_redirect(admin_url('admin.php?page=wpstg_clone'));
exit;
} else {
// Update
wp_safe_redirect(admin_url('admin.php?page=wpstg_clone'));
exit;
}
}
示例13: isTriggered
public function isTriggered()
{
$flusher =& $_REQUEST['bf-flusher'];
$nonce =& $_REQUEST['_wpnonce'];
// Don't do anything if we don't see a flush request or the user is not an administrator
if (!isset($flusher) || !current_user_can('administrator')) {
return;
}
// Verify the nonce security token. If not valid die with permission denied
if (!isset($nonce) || !wp_verify_nonce($nonce, 'flush_' . $flusher)) {
wp_die(esc_html__('Permission Denied', 'bfflusher'));
}
// Which flush action are we to perform?
switch ($flusher) {
case 'permalinks':
flush_rewrite_rules();
break;
case 'object-cache':
function_exists('wp_cache_flush_site') ? wp_cache_flush_site() : wp_cache_flush();
break;
}
// Safe redirect to the page that the user originally came from.
wp_safe_redirect($_SERVER['HTTP_REFERER']);
die;
}
示例14: wsu_news_redirect_publication_id
/**
* Redirect old PublicationID based detail pages for articles to the corresponding
* article's new URL at news.wsu.edu.
*/
function wsu_news_redirect_publication_id()
{
/* @var WPDB $wpdb */
global $wpdb;
if (!isset($_SERVER['HTTP_HOST'])) {
return;
}
//pattern:
//http://news.wsu.edu/pages/publications.asp?Action=Detail&PublicationID=36331&TypeID=1
if (isset($_GET['PublicationID']) && isset($_GET['Action']) && 'Detail' === $_GET['Action'] && 0 !== absint($_GET['PublicationID'])) {
$publication_id = absint($_GET['PublicationID']);
$post_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM wp_postmeta WHERE meta_key = '_publication_id' AND meta_value = %s", $publication_id));
if (0 !== absint($post_id)) {
wp_safe_redirect(get_permalink($post_id), 301);
exit;
}
}
//pattern:
//http://news.wsu.edu/articles/36828/1/New-cyber-security-firm-protects-Seattle-businesses
$actual_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
if (strpos($actual_link, '/articles/') > -1) {
$urlparts = explode('/', $actual_link);
$publication_id = absint($urlparts[4]);
$post_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM wp_postmeta WHERE meta_key = '_publication_id' AND meta_value = %s", $publication_id));
if (0 !== absint($post_id)) {
wp_safe_redirect(get_permalink($post_id), 301);
exit;
}
}
return;
}
示例15: error
/**
* do the error
* @author Lukas Juhas
* @date 2016-02-05
* @param [type] $message [description]
* @return [type] [description]
*/
private function error($message = false)
{
// redirect back
// TODO: probably add some error message - added attribute already
wp_safe_redirect(wp_get_referer());
exit;
}