Пример #1
0
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
0
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;
}
	/**
	 * 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
0
 /**
  * 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
0
 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'));
         }
     }
 }
 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
0
/**
 * 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;
}
/**
 * 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'))));
    }
}
 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
0
 /**
  * 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
0
/**
 * 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
0
 /**
  * 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
0
 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;
 }
/**
 * 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;
}
 /**
  * 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;
 }
Пример #16
0
function dp_admin_init()
{
    global $pagenow, $typenow, $post;
    ob_start();
    // Install - Add pages button
    if (!empty($_GET['install_dp_pages'])) {
        dp_create_pages();
        // We no longer need to install pages
        delete_option('dp_needs_pages');
        // What's new redirect
        wp_safe_redirect(admin_url('admin.php?page=display-product-page'));
        exit;
        // Skip button
    } elseif (!empty($_GET['skip_install_dp_pages'])) {
        // We no longer need to install pages
        update_option('dp_needs_pages', 0);
        // What's new redirect
        wp_safe_redirect(admin_url('admin.php?page=display-product-page'));
        exit;
    } elseif (!empty($_GET['reset_install_dp_pages'])) {
        dp_reset_create_pages();
        update_option("dp_replace_woo_page", 0);
        // We no longer need to install pages
        update_option('dp_needs_pages', 0);
        // What's new redirect
        wp_safe_redirect(admin_url('admin.php?page=display-product-page'));
        exit;
    }
}
Пример #17
0
 /**
  * Process a settings import from a json file
  * @since 5.3.2
  */
 function process_settings_import()
 {
     if (empty($_POST['action']) || 'import_settings' !== $_POST['action']) {
         return;
     }
     if (!wp_verify_nonce($_POST['import_nonce'], 'import_nonce')) {
         return;
     }
     if (!current_user_can('manage_options')) {
         return;
     }
     $extension = end(explode('.', $_FILES['import_file']['name']));
     if ('json' !== $extension) {
         wp_die(__('Please upload a valid .json file', 'jm-tc'));
     }
     $import_file = $_FILES['import_file']['tmp_name'];
     if (empty($import_file)) {
         wp_die(__('Please upload a file to import', 'jm-tc'));
     }
     /**
      * array associative
      *
      */
     $settings = (array) json_decode(file_get_contents($import_file), true);
     if (!empty($settings['tc'])) {
         update_option('jm_tc', (array) $settings['tc']);
     }
     if (!empty($settings['ie'])) {
         update_option('jm_tc_cpt', (array) $settings['ie']);
     }
     wp_safe_redirect(admin_url('admin.php?page=jm_tc'));
     exit;
 }
function photograph_feature()
{
    if (!is_admin()) {
        die;
    }
    if (!current_user_can('edit_posts')) {
        wp_die(__('You do not have sufficient permissions to access this page.', 'colabsthemes'));
    }
    if (!check_admin_referer('photograph-feature')) {
        wp_die(__('You have taken too long. Please go back and retry.', 'colabsthemes'));
    }
    $post_id = isset($_GET['id']) && (int) $_GET['id'] ? (int) $_GET['id'] : '';
    if (!$post_id) {
        die;
    }
    $post = get_post($post_id);
    if (!$post || $post->post_type !== 'photograph') {
        die;
    }
    $featured = get_post_meta($post->ID, 'colabs_feature_photograph', true);
    if ($featured == 'true') {
        update_post_meta($post->ID, 'colabs_feature_photograph', 'false');
    } else {
        update_post_meta($post->ID, 'colabs_feature_photograph', 'true');
    }
    wp_safe_redirect(remove_query_arg(array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer()));
}
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($message_id = 0)
 {
     global $woothemes_sensei, $sensei_email_data;
     $this->message = get_post($message_id);
     $learner_username = get_post_meta($message_id, '_sender', true);
     $this->learner = get_user_by('login', $learner_username);
     $teacher_username = get_post_meta($message_id, '_receiver', true);
     $this->teacher = get_user_by('login', $teacher_username);
     $content_type = get_post_meta($message_id, '_posttype', true);
     $content_id = get_post_meta($message_id, '_post', true);
     $content_title = get_the_title($content_id);
     // setup the post type parameter
     $content_type = get_post_type($content_id);
     if (!$content_type) {
         $content_type = '';
     }
     // Construct data array
     $sensei_email_data = apply_filters('sensei_email_data', array('template' => $this->template, $content_type . '_id' => $content_id, 'heading' => $this->heading, 'teacher_id' => $this->teacher->ID, 'learner_id' => $this->learner->ID, 'learner_name' => $this->learner->display_name, 'message_id' => $message_id, 'message' => $this->message->post_content, 'content_title' => $content_title, 'content_type' => $content_type), $this->template);
     // Set recipient (teacher)
     $this->recipient = stripslashes($this->teacher->user_email);
     // Send mail
     $woothemes_sensei->emails->send($this->recipient, $this->subject, $woothemes_sensei->emails->get_content($this->template));
     wp_safe_redirect(esc_url_raw(add_query_arg(array('send' => 'complete'))));
     exit;
 }
Пример #20
0
function mpp_gallery_archive_redirect()
{
    if (is_post_type_archive(mpp_get_gallery_post_type()) && mediapress()->is_bp_active() && mpp_get_option('has_gallery_directory') && isset(buddypress()->pages->mediapress->id)) {
        wp_safe_redirect(get_permalink(buddypress()->pages->mediapress->id), 301);
        exit(0);
    }
}
Пример #21
0
/**
 * Upgrades all commission records to use a taxonomy for tracking the status of the commission
 *
 * @since 2.8
 * @return void
 */
function eddcr_upgrade_post_meta()
{
    if (!current_user_can('manage_shop_settings')) {
        return;
    }
    define('EDDCR_DOING_UPGRADES', true);
    ignore_user_abort(true);
    if (!edd_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) {
        set_time_limit(0);
    }
    $step = isset($_GET['step']) ? absint($_GET['step']) : 1;
    $args = array('posts_per_page' => 20, 'paged' => $step, 'status' => 'any', 'order' => 'ASC', 'post_type' => 'any', 'fields' => 'ids', 'meta_key' => '_edd_cr_restricted_to');
    $items = get_posts($args);
    if ($items) {
        // items found so upgrade them
        foreach ($items as $post_id) {
            $restricted_to = get_post_meta($post_id, '_edd_cr_restricted_to', true);
            $price_id = get_post_meta($post_id, '_edd_cr_restricted_to_variable', true);
            $args = array();
            $args[] = array('download' => $restricted_to, 'price_id' => $price_id);
            update_post_meta($post_id, '_edd_cr_restricted_to', $args);
            add_post_meta($restricted_to, '_edd_cr_protected_post', $post_id);
        }
        $step++;
        $redirect = add_query_arg(array('page' => 'edd-upgrades', 'edd-upgrade' => 'upgrade_cr_post_meta', 'step' => $step), admin_url('index.php'));
        wp_safe_redirect($redirect);
        exit;
    } else {
        // No more items found, finish up
        update_option('eddcr_version', EDD_CONTENT_RESTRICTION_VER);
        delete_option('edd_doing_upgrade');
        wp_redirect(admin_url());
        exit;
    }
}
Пример #22
0
 /**
  * Payment return url callback
  */
 public static function onMollieReturn()
 {
     $data_helper = self::getDataHelper();
     $order_id = !empty($_GET['order_id']) ? $_GET['order_id'] : NULL;
     $key = !empty($_GET['key']) ? $_GET['key'] : NULL;
     $order = $data_helper->getWcOrder($order_id);
     if (!$order) {
         self::setHttpResponseCode(404);
         self::debug(__METHOD__ . ":  Could not find order {$order_id}.");
         return;
     }
     if (!$order->key_is_valid($key)) {
         self::setHttpResponseCode(401);
         self::debug(__METHOD__ . ":  Invalid key {$key} for order {$order_id}.");
         return;
     }
     $gateway = $data_helper->getWcPaymentGatewayByOrder($order);
     if (!$gateway) {
         self::setHttpResponseCode(404);
         self::debug(__METHOD__ . ":  Could not find gateway for order {$order_id}.");
         return;
     }
     if (!$gateway instanceof Mollie_WC_Gateway_Abstract) {
         self::setHttpResponseCode(400);
         self::debug(__METHOD__ . ": Invalid gateway " . get_class($gateway) . " for this plugin. Order {$order_id}.");
         return;
     }
     /** @var Mollie_WC_Gateway_Abstract $gateway */
     $redirect_url = $gateway->getReturnRedirectUrlForOrder($order);
     // Add utm_nooverride query string
     $redirect_url = add_query_arg(array('utm_nooverride' => 1), $redirect_url);
     self::debug(__METHOD__ . ": Redirect url on return order " . $gateway->id . ", order {$order_id}: {$redirect_url}");
     wp_safe_redirect($redirect_url);
 }
Пример #23
0
function matt_random_redirect()
{
    // Acceptables URL formats: /[...]/?random=[post type], /?random, /&random, /&random=1
    if (!isset($_GET['random']) && !in_array(strtolower($_SERVER['REQUEST_URI']), array('/&random', '/&random=1'))) {
        return;
    }
    // Ignore requests that include more than just the random parameter.
    if (!empty($_POST) || isset($_GET['random']) && count($_GET) > 1) {
        return;
    }
    // Persistent AppEngine abuse.  ORDER BY RAND is expensive.
    if (strstr($_SERVER['HTTP_USER_AGENT'], 'AppEngine-Google')) {
        wp_die('Please <a href="http://en.support.wordpress.com/contact/">contact support</a>');
    }
    // Use the post type of the current page as the context for the random lookup.
    $post_type = get_post_type();
    // /?random should always show a random post, even if the home page is a static page.
    if ('/' == $_SERVER['DOCUMENT_URI']) {
        $post_type = 'post';
    } else {
        $post_type = get_post_type();
    }
    if (!$post_type) {
        $post_type = 'post';
    }
    global $wpdb;
    $random_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_password = '' AND post_status = 'publish' ORDER BY RAND() LIMIT 1", $post_type));
    $permalink = get_permalink($random_id);
    wp_safe_redirect($permalink);
    exit;
}
Пример #24
0
 public function create_transfer()
 {
     if (!wp_verify_nonce($_POST['omise_create_transfer_nonce'], 'omise_create_transfer')) {
         die('Nonce verification failure');
     }
     if (!isset($_POST['_wp_http_referer'])) {
         die('Missing target');
     }
     $transfer_amount = isset($_POST['omise_transfer_amount']) ? $_POST['omise_transfer_amount'] : '';
     $result_message = '';
     try {
         if (!empty($transfer_amount) && !is_numeric($transfer_amount)) {
             throw new Exception("Transfer amount must be a numeric");
         }
         $transfer = Omise::create_transfer($this->private_key, empty($transfer_amount) ? null : $transfer_amount * 100);
         // transfer in satangs
         if ($this->is_transfer_success($transfer)) {
             $result_message = "A fund transfer request has been sent.";
         } else {
             $result_message = $this->get_transfer_error_message($transfer);
         }
     } catch (Exception $e) {
         $result_message = $e->getMessage();
     }
     $url = add_query_arg('omise_result_msg', urlencode($result_message), urldecode($_POST['_wp_http_referer']));
     wp_safe_redirect($url);
     exit;
 }
Пример #25
0
 public function post_restore()
 {
     if (isset($_POST['job_id']) && isset($_POST['backup_uniqid']) && isset($_POST['_wpnonce']) && isset($_POST['method'])) {
         $nonce = filter_input(INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING);
         if (!wp_verify_nonce($nonce, 'my-wp-backup-restore-backup')) {
             wp_die(esc_html__('Nope! Security check failed!', 'my-wp-backup'));
         }
         $id = absint($_POST['job_id']);
         $uniqid = sanitize_key($_POST['backup_uniqid']);
         $method = filter_input(INPUT_POST, 'method', FILTER_SANITIZE_STRING);
         $backup = self::get($id, $uniqid);
         if (!isset($backup['duration'])) {
             add_settings_error('', '', __('Invalid backup id/uniqid.', 'my-wp-backup'));
             set_transient('settings_errors', get_settings_errors());
             wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
         }
         if (!$backup->has_archives()) {
             // No local copy and no remote copy === DEAD END.
             if (empty($backup['destinations'])) {
                 add_settings_error('', '', __('Backup files missing.', 'my-wp-backup'));
                 set_transient('settings_errors', get_settings_errors());
                 wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
             }
             if (!isset($backup['destinations'][$method])) {
                 add_settings_error('', '', sprintf(__('No backup files from %s.', 'my-wp-backup'), Job::$destinations[$method]));
                 set_transient('settings_errors', get_settings_errors());
                 wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
             }
         }
         wp_schedule_single_event(time(), 'wp_backup_restore_backup', array(array($id, $uniqid, $method)));
         wp_safe_redirect($this->admin->get_page_url('backup', array('uniqid' => $uniqid, 'action' => 'viewprogress', 'id' => $id)));
     }
 }
/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 */
function wc_template_redirect()
{
    global $wp_query, $wp;
    if (!empty($_GET['page_id']) && '' === get_option('permalink_structure') && wc_get_page_id('shop') == $_GET['page_id']) {
        // When default permalinks are enabled, redirect shop page to post type archive url
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    } elseif (is_page(wc_get_page_id('checkout')) && wc_get_page_id('checkout') !== wc_get_page_id('cart') && WC()->cart->is_empty() && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
        // When on the checkout with an empty cart, redirect to cart page
        wc_add_notice(__('Checkout is not available whilst your cart is empty.', 'woocommerce'), 'notice');
        wp_redirect(wc_get_page_permalink('cart'));
        exit;
    } elseif (isset($wp->query_vars['customer-logout'])) {
        // Logout
        wp_redirect(str_replace('&amp;', '&', wp_logout_url(wc_get_page_permalink('myaccount'))));
        exit;
    } elseif (is_search() && is_post_type_archive('product') && apply_filters('woocommerce_redirect_single_search_result', true) && 1 === absint($wp_query->found_posts)) {
        // Redirect to the product page if we have a single product
        $product = wc_get_product($wp_query->post);
        if ($product && $product->is_visible()) {
            wp_safe_redirect(get_permalink($product->get_id()), 302);
            exit;
        }
    } elseif (is_add_payment_method_page()) {
        // Ensure payment gateways are loaded early
        WC()->payment_gateways();
    } elseif (is_checkout()) {
        // Checkout pages handling
        // Buffer the checkout page
        ob_start();
        // Ensure gateways and shipping methods are loaded early
        WC()->payment_gateways();
        WC()->shipping();
    }
}
Пример #27
0
 /**
  * Load post new action
  * Redirect to right url if no page type is set.
  */
 public function load_post_new()
 {
     $request_uri = $_SERVER['REQUEST_URI'];
     $post_types = papi_get_post_types();
     if (in_array($this->post_type, $post_types, true) && strpos($request_uri, 'page_type=') === false) {
         $parsed_url = parse_url($request_uri);
         $only_page_type = papi_filter_settings_only_page_type($this->post_type);
         $page_types = papi_get_all_page_types($this->post_type);
         $show_standard = false;
         if (count($page_types) === 1 && empty($only_page_type)) {
             $show_standard = $page_types[0]->standard_type;
             $show_standard = $show_standard ? papi_filter_settings_show_standard_page_type($this->post_type) : $show_standard;
             $only_page_type = $show_standard ? '' : $page_types[0]->get_id();
         }
         // Check if we should show one post type or not and
         // create the right url for that.
         if (!empty($only_page_type) && !$show_standard) {
             $url = papi_get_page_new_url($only_page_type, false);
         } else {
             $page = 'page=papi-add-new-page,' . $this->post_type;
             if ($this->post_type !== 'post') {
                 $page = '&' . $page;
             }
             $url = 'edit.php?' . $parsed_url['query'] . $page;
         }
         wp_safe_redirect($url);
         is_admin() && exit;
     }
 }
Пример #28
0
function app_process_login_form()
{
    global $posted;
    if (isset($_REQUEST['redirect_to'])) {
        $redirect_to = $_REQUEST['redirect_to'];
    } else {
        $redirect_to = admin_url();
    }
    if (is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) {
        $secure_cookie = false;
    } else {
        $secure_cookie = '';
    }
    $user = wp_signon('', $secure_cookie);
    $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
    if (!is_wp_error($user)) {
        // automatically redirect admins to the WP back-end
        if (user_can($user, 'manage_options')) {
            $redirect_to = admin_url('admin.php?page=admin-options.php');
        }
        // otherwise redirect them to the hidden post url
        wp_safe_redirect($redirect_to);
        exit;
    }
    $errors = $user;
    return $errors;
}
/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 *
 * @return void
 */
function wc_template_redirect()
{
    global $wp_query, $wp;
    // When default permalinks are enabled, redirect shop page to post type archive url
    if (!empty($_GET['page_id']) && get_option('permalink_structure') == "" && $_GET['page_id'] == wc_get_page_id('shop')) {
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    } elseif (is_page(wc_get_page_id('checkout')) && sizeof(WC()->cart->get_cart()) == 0 && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
        wp_redirect(get_permalink(wc_get_page_id('cart')));
        exit;
    } elseif (isset($wp->query_vars['customer-logout'])) {
        wp_redirect(str_replace('&amp;', '&', wp_logout_url(get_permalink(wc_get_page_id('myaccount')))));
        exit;
    } elseif (is_search() && is_post_type_archive('product') && apply_filters('woocommerce_redirect_single_search_result', true) && $wp_query->found_posts == 1) {
        $product = wc_get_product($wp_query->post);
        if ($product->is_visible()) {
            wp_safe_redirect(get_permalink($product->id), 302);
            exit;
        }
    } elseif (is_add_payment_method_page()) {
        WC()->payment_gateways();
    } elseif (is_checkout()) {
        // Buffer the checkout page
        ob_start();
        // Ensure gateways and shipping methods are loaded early
        WC()->payment_gateways();
        WC()->shipping();
    }
}
Пример #30
0
/**
 * Move the framework to the plugins directory.
 *
 * @since 1.2.0
 */
function audiotheme_framework_not_a_theme()
{
    global $wp_filesystem;
    if (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], 'audiotheme-theme-to-plugin')) {
        return false;
    }
    $move_url = wp_nonce_url('themes.php', 'audiotheme-theme-to-plugin');
    if (false === ($credentials = request_filesystem_credentials($move_url))) {
        return true;
    }
    if (!WP_Filesystem($credentials)) {
        // Credentials weren't good, ask again.
        request_filesystem_credentials($move_url);
        return true;
    }
    $plugin_dir = $wp_filesystem->wp_plugins_dir() . 'audiotheme/';
    $theme_dir = trailingslashit(get_template_directory());
    // Check if the framework plugin directory already exists.
    if (is_dir($plugin_dir)) {
        $redirect = add_query_arg('atmovemsg', 'plugin-exists', admin_url('themes.php'));
        wp_safe_redirect(esc_url_raw($redirect));
        exit;
    }
    // Move the plugin.
    if ($wp_filesystem->move($theme_dir, $plugin_dir)) {
        // @todo Any way to re-activate the previous theme?
        wp_safe_redirect(esc_url_raw(admin_url('plugins.php')));
        exit;
    } else {
        $redirect = add_query_arg('atmovemsg', 'move-failed', admin_url('themes.php'));
        wp_safe_redirect(esc_url_raw($redirect));
        exit;
    }
}