当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_nonce_ays函数代码示例

本文整理汇总了PHP中wp_nonce_ays函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_nonce_ays函数的具体用法?PHP wp_nonce_ays怎么用?PHP wp_nonce_ays使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_nonce_ays函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process_post_data

 public function process_post_data($post_data)
 {
     if (!wp_verify_nonce($_REQUEST['jwp6_nonce'], $this->page_slug)) {
         wp_nonce_ays($this->page_slug);
     }
     parent::process_post_data($post_data, true);
 }
开发者ID:venamax,项目名称:trixandtrax-cl,代码行数:7,代码来源:jwp6-class-admin-page-settings.php

示例2: template_redirect

 public static function template_redirect()
 {
     global $wp_query;
     if (isset($wp_query->query_vars['wpak_addon_file']) && !empty($wp_query->query_vars['wpak_addon_file'])) {
         if (!empty($_GET['wpak_app_id'])) {
             $app_id = esc_attr($_GET['wpak_app_id']);
             //can be ID or slug
             $app = WpakApps::get_app($app_id);
             if (!empty($app)) {
                 $app_id = $app->ID;
                 $default_capability = current_user_can('wpak_edit_apps') ? 'wpak_edit_apps' : 'manage_options';
                 $capability = apply_filters('wpak_private_simulation_capability', $default_capability, $app_id);
                 if (WpakApps::get_app_simulation_is_secured($app_id) && !current_user_can($capability)) {
                     wp_nonce_ays('wpak-addon-file');
                 }
                 $file = $wp_query->query_vars['wpak_addon_file'];
                 if (preg_match('/([^\\/]+?)\\/(.+[\\.js|\\.css|\\.html])$/', $file, $matches)) {
                     $addon_slug = $matches[1];
                     $asset_file = $matches[2];
                     $app_addons = self::get_app_addons($app_id);
                     if (array_key_exists($addon_slug, $app_addons)) {
                         $addon = $app_addons[$addon_slug];
                         if ($asset_full_path = $addon->get_asset_file($asset_file)) {
                             $file_type = pathinfo($asset_full_path, PATHINFO_EXTENSION);
                             if ($file_type == 'js') {
                                 header("Content-type: text/javascript;  charset=utf-8");
                             } elseif ($file_type == 'css') {
                                 header("Content-type: text/css;  charset=utf-8");
                             } elseif ($file_type == 'html') {
                                 header("Content-type: text/html;  charset=utf-8");
                             }
                             echo file_get_contents($asset_full_path);
                             exit;
                         } else {
                             header("HTTP/1.0 404 Not Found");
                             _e('Addon file not found', WpAppKit::i18n_domain);
                             exit;
                         }
                     } else {
                         header("HTTP/1.0 404 Not Found");
                         _e('Addon not found for this app', WpAppKit::i18n_domain);
                         exit;
                     }
                 } else {
                     header("HTTP/1.0 404 Not Found");
                     _e('Wrong addon file', WpAppKit::i18n_domain);
                     exit;
                 }
             } else {
                 header("HTTP/1.0 404 Not Found");
                 _e('App not found', WpAppKit::i18n_domain) . ' : [' . $app_id . ']';
                 exit;
             }
         } else {
             header("HTTP/1.0 404 Not Found");
             _e('App id not found in _GET parmeters', WpAppKit::i18n_domain);
             exit;
         }
     }
 }
开发者ID:hiddenpearls,项目名称:wp-appkit,代码行数:60,代码来源:addons.php

示例3: check_admin_referer

 /**
  * Checks if the given nonce is valid, and if not, terminates WordPress execution unless this is an admin request.
  *
  * This function is the MultilingualPress equivalent of the WordPress function with the same name.
  *
  * @since 3.0.0
  *
  * @param Nonce $nonce Nonce object.
  *
  * @return bool Whether or not the nonce is valid.
  */
 function check_admin_referer(Nonce $nonce)
 {
     if ($nonce->is_valid()) {
         return true;
     }
     if (0 !== strpos(strtolower(wp_get_referer()), strtolower(admin_url()))) {
         wp_nonce_ays(null);
         call_exit();
     }
     return false;
 }
开发者ID:inpsyde,项目名称:multilingual-press,代码行数:22,代码来源:functions.php

示例4: process_post_data

 public function process_post_data($post_data)
 {
     if (!wp_verify_nonce($_REQUEST['jwp6_nonce'], $this->page_slug . $_REQUEST['player_id'])) {
         wp_nonce_ays($this->page_slug);
     }
     parent::process_post_data($post_data, false);
     if (isset($_GET['player_id'])) {
         return $this->process_edit_post_data($post_data);
     } else {
         return $this->process_overview_post_data($post_data);
     }
 }
开发者ID:venamax,项目名称:trixandtrax-cl,代码行数:12,代码来源:jwp6-class-admin-page-players.php

示例5: template_redirect

 public static function template_redirect()
 {
     global $wp_query;
     if (isset($wp_query->query_vars['wpak_appli_file']) && !empty($wp_query->query_vars['wpak_appli_file'])) {
         if (!empty($_GET['wpak_app_id'])) {
             $app_id = esc_attr($_GET['wpak_app_id']);
             //can be ID or slug
             $app = WpakApps::get_app($app_id);
             if (!empty($app)) {
                 $app_id = $app->ID;
                 $default_capability = current_user_can('wpak_edit_apps') ? 'wpak_edit_apps' : 'manage_options';
                 $capability = apply_filters('wpak_private_simulation_capability', $default_capability, $app_id);
                 if (WpakApps::get_app_simulation_is_secured($app_id) && !current_user_can($capability)) {
                     wp_nonce_ays($action);
                 }
                 $file = $wp_query->query_vars['wpak_appli_file'];
                 switch ($file) {
                     case 'config.js':
                         header("Content-type: text/javascript;  charset=utf-8");
                         echo "/* Wp AppKit simulator config.js */\n";
                         self::get_config_js($app_id, true);
                         exit;
                     case 'config.xml':
                         header("Content-type: text/xml;  charset=utf-8");
                         self::get_config_xml($app_id, true);
                         exit;
                     default:
                         exit;
                 }
             } else {
                 echo __('App not found', WpAppKit::i18n_domain) . ' : [' . $app_id . ']';
                 exit;
             }
         } else {
             _e('App id not found in _GET parameters', WpAppKit::i18n_domain);
             exit;
         }
     }
 }
开发者ID:hiddenpearls,项目名称:wp-appkit,代码行数:39,代码来源:config-file.php

示例6: nonceAys

 /**
  * Display 'Are you sure you want to do this?' message to confirm the action being taken. 
  * If the action has the nonce explain message, then it will be displayed along with the 'Are you sure?' message.
  *
  * @param string $action Required. The nonce action.
  */
 public function nonceAys($action)
 {
     return wp_nonce_ays($action);
 }
开发者ID:kamalyon,项目名称:wp-nonce,代码行数:10,代码来源:wp-nonce.php

示例7: load

 /**
  * Load action
  *
  * @return void
  */
 function load()
 {
     w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/admin.php');
     $this->_page = w3tc_get_current_page();
     /**
      * Run plugin action
      */
     $action = false;
     foreach ($_REQUEST as $key => $value) {
         if (strpos($key, 'w3tc_') === 0) {
             $action = 'action_' . substr($key, 5);
             break;
         }
     }
     $flush = false;
     $cdn = false;
     $support = false;
     $action_handler = w3_instance('W3_AdminActions_ActionHandler');
     $action_handler->set_default($this);
     $action_handler->set_current_page($this->_page);
     if ($action && $action_handler->exists($action)) {
         if (!wp_verify_nonce(W3_Request::get_string('_wpnonce'), 'w3tc')) {
             wp_nonce_ays('w3tc');
         }
         try {
             $action_handler->execute($action);
         } catch (Exception $e) {
             w3_admin_redirect_with_custom_messages(array(), array($e->getMessage()));
         }
         exit;
     }
 }
开发者ID:jfbelisle,项目名称:magexpress,代码行数:37,代码来源:TotalCacheAdmin.php

示例8: run_export

 /**
  * The actual export is done here
  */
 function run_export()
 {
     if (is_admin() && isset($_GET['wp-attachment-export-download'])) {
         if (current_user_can('administrator') && isset($_REQUEST['wp_attachment_export_nonce']) && wp_verify_nonce($_REQUEST['wp_attachment_export_nonce'], 'wp_attachment_export_download')) {
             require_once ABSPATH . '/wp-admin/includes/export.php';
             $args = array();
             $args['content'] = $_GET['content'];
             export_wp($args);
             die;
         } else {
             wp_nonce_ays('wp_attachment_export_download');
         }
     }
 }
开发者ID:Jessekevon,项目名称:alturas,代码行数:17,代码来源:wp-attachment-export.php

示例9: add_custom_pages

 /**
  * Create Custom Archives pages when needed.
  * 
  * @since    2.1
  * 
  * @return   array    IDs a newly created pages.
  */
 public static function add_custom_pages()
 {
     global $wpmoly_redux_config;
     $nonce = '_wpmolynonce_create_custom_pages';
     if (!isset($_GET[$nonce]) || !wpmoly_verify_nonce($_GET[$nonce], 'create-custom-pages')) {
         wp_nonce_ays('create-custom-pages');
         return false;
     }
     $allowed = array('all', 'movie', 'collection', 'genre', 'actor');
     $create = sanitize_text_field($_GET['create_pages']);
     if (!in_array($create, $allowed)) {
         return false;
     }
     switch ($create) {
         case 'all':
             $pages = array('movie' => __('Movies', 'wpmovielibrary'), 'collection' => __('Collections', 'wpmovielibrary'), 'genre' => __('Genres', 'wpmovielibrary'), 'actor' => __('Actors', 'wpmovielibrary'));
             break;
         case 'movie':
             $pages = array('movie' => __('Movies', 'wpmovielibrary'));
             break;
         case 'collection':
             $pages = array('collection' => __('Collections', 'wpmovielibrary'));
             break;
         case 'genre':
             $pages = array('genre' => __('Genres', 'wpmovielibrary'));
             break;
         case 'actor':
             $pages = array('actor' => __('Actors', 'wpmovielibrary'));
             break;
         default:
             $pages = array();
             break;
     }
     if (empty($pages)) {
         return false;
     }
     $post = array('ID' => null, 'post_content' => '', 'post_name' => '', 'post_title' => '', 'post_status' => 'publish', 'post_type' => 'page', 'post_author' => 1, 'ping_status' => '', 'post_excerpt' => '', 'post_date' => '', 'post_date_gmt' => '', 'comment_status' => '');
     $_pages = array();
     foreach ($pages as $slug => $page) {
         $exists = intval(wpmoly_o("{$slug}-archives"));
         if (!$exists) {
             $post['post_title'] = $page;
             $page = wp_insert_post($post);
             $_pages[$slug] = $page;
             if ($page) {
                 $wpmoly_redux_config->ReduxFramework->set("wpmoly-{$slug}-archives", $page);
             }
         }
     }
     $self = new WPMOLY_Archives();
     if ($self->has_custom_page()) {
         update_option('wpmoly_has_custom_pages', 'yes');
     }
     return $_pages;
 }
开发者ID:masterdoed,项目名称:wpmovielibrary,代码行数:62,代码来源:class-wpmoly-archives.php

示例10: check_admin_referer

 function check_admin_referer($action = -1, $query_arg = "_wpnonce")
 {
     global $secure_url;
     $secure_uris = as_secure_uris();
     $adminurl = strtolower(in_array("wp-admin", $secure_uris) || in_array("wp-admin/", $secure_uris) ? $secure_url : get_option("siteurl")) . "/wp-admin";
     $referer = strtolower(wp_get_referer());
     $result = wp_verify_nonce($_REQUEST[$query_arg], $action);
     if (!$result && !(-1 == $action && strpos($referer, $adminurl) !== false)) {
         wp_nonce_ays($action);
         die;
     }
     do_action("check_admin_referer", $action, $result);
     return $result;
 }
开发者ID:macconsultinggroup,项目名称:WordPress,代码行数:14,代码来源:https.php

示例11: wpNonceAys

 /**
  * Display 'Are you sure you want to do this?' message to 
  * confirm the action being taken.
  * 
  * @param  string $action The nonce action.
  * 
  * @return void
  */
 public static function wpNonceAys($action)
 {
     wp_nonce_ays($action);
 }
开发者ID:perezlabs,项目名称:wp-nonce-wrapper-class,代码行数:12,代码来源:WpNonceWrapper.php

示例12: wp_ajax_w3tc_ajax

 public function wp_ajax_w3tc_ajax()
 {
     if (!wp_verify_nonce(Util_Request::get_string('_wpnonce'), 'w3tc')) {
         wp_nonce_ays('w3tc');
     }
     try {
         $base_capability = apply_filters('w3tc_ajax', 'manage_options');
         $capability = apply_filters('w3tc_ajax_capability_' . $_REQUEST['w3tc_action'], $base_capability);
         if (!empty($capability) && !current_user_can($capability)) {
             throw new \Exception('no permissions');
         }
         do_action('w3tc_ajax');
         do_action('w3tc_ajax_' . $_REQUEST['w3tc_action']);
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
     exit;
 }
开发者ID:eduardodomingos,项目名称:eduardodomingos.com,代码行数:18,代码来源:Generic_Plugin_Admin.php

示例13: check_admin_referer

 /**
  * Makes sure that a user was referred from another admin page.
  *
  * To avoid security exploits.
  *
  * @since 1.2.0
  * @uses do_action() Calls 'check_admin_referer' on $action.
  *
  * @param string $action Action nonce
  * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
  */
 function check_admin_referer($action = -1, $query_arg = '_wpnonce')
 {
     if (-1 == $action) {
         _doing_it_wrong(__FUNCTION__, __('You should specify a nonce action to be verified by using the first parameter.'), '3.2');
     }
     $adminurl = strtolower(admin_url());
     $referer = strtolower(wp_get_referer());
     $result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false;
     if (!$result && !(-1 == $action && strpos($referer, $adminurl) === 0)) {
         wp_nonce_ays($action);
         die;
     }
     do_action('check_admin_referer', $action, $result);
     return $result;
 }
开发者ID:souljatechie,项目名称:Web-Dev,代码行数:26,代码来源:pluggable.php

示例14: save_form

 /**
  * Saves a form to the database
  *
  * @param $data
  * @return int
  */
 public function save_form($data)
 {
     $post_data = array('post_type' => 'mc4wp-form', 'post_status' => !empty($data['status']) ? $data['status'] : 'publish', 'post_title' => $data['name'], 'post_content' => $data['content']);
     if (!empty($data['ID'])) {
         $post_data['ID'] = $data['ID'];
         $post = get_post($data['ID']);
         // check if attempted post is of post_type `mc4wp-form`
         if (!is_object($post) || $post->post_type !== 'mc4wp-form') {
             wp_nonce_ays('');
             return 0;
         }
     }
     $form_id = wp_insert_post($post_data);
     update_post_meta($form_id, '_mc4wp_settings', $data['settings']);
     // save form messages in individual meta keys
     foreach ($data['messages'] as $key => $message) {
         update_post_meta($form_id, 'text_' . $key, $message);
     }
     return $form_id;
 }
开发者ID:petersuhm,项目名称:mailchimp-for-wordpress,代码行数:26,代码来源:class-admin.php

示例15: handle_login

 function handle_login()
 {
     $wpcom_nonce = sanitize_key($_GET['sso_nonce']);
     $wpcom_user_id = (int) $_GET['user_id'];
     $result = sanitize_key($_GET['result']);
     Jetpack::load_xml_rpc_client();
     $xml = new Jetpack_IXR_Client(array('user_id' => get_current_user_id()));
     $xml->query('jetpack.sso.validateResult', $wpcom_nonce, $wpcom_user_id);
     if ($xml->isError()) {
         wp_die(sprintf('%s: %s', $xml->getErrorCode(), $xml->getErrorMessage()));
     }
     $user_data = $xml->getResponse();
     if (empty($user_data)) {
         wp_die(__('Error, invalid response data.', 'jetpack'));
     }
     $user_data = (object) $user_data;
     $user = null;
     do_action('jetpack_sso_pre_handle_login', $user_data);
     if (isset($_GET['state']) && 0 < strpos($_GET['state'], '|')) {
         list($state, $nonce) = explode('|', $_GET['state']);
         if (wp_verify_nonce($nonce, $state)) {
             if ('sso-link-user' == $state) {
                 $user = wp_get_current_user();
                 update_user_meta($user->ID, 'wpcom_user_id', $user_data->ID);
                 add_filter('login_redirect', array(__CLASS__, 'profile_page_url'));
             }
         } else {
             wp_nonce_ays();
         }
     }
     if (empty($user)) {
         $user = $this->get_user_by_wpcom_id($user_data->ID);
     }
     // If we don't have one by wpcom_user_id, try by the email?
     if (empty($user) && self::match_by_email()) {
         $user = get_user_by('email', $user_data->email);
         if ($user) {
             update_user_meta($user->ID, 'wpcom_user_id', $user_data->ID);
         }
     }
     // If we've still got nothing, create the user.
     if (empty($user) && (get_option('users_can_register') || self::new_user_override())) {
         $username = $user_data->login;
         if (username_exists($username)) {
             $username = $user_data->login . '_' . $user_data->ID;
         }
         $tries = 0;
         while (username_exists($username)) {
             $username = $user_data->login . '_' . $user_data->ID . '_' . mt_rand();
             if ($tries++ >= 5) {
                 wp_die(__("Error: Couldn't create suitable username.", 'jetpack'));
             }
         }
         $password = wp_generate_password(20);
         $user_id = wp_create_user($username, $password, $user_data->email);
         $user = get_userdata($user_id);
         $user->display_name = $user_data->display_name;
         $user->first_name = $user_data->first_name;
         $user->last_name = $user_data->last_name;
         $user->url = $user_data->url;
         $user->description = $user_data->description;
         wp_update_user($user);
         update_user_meta($user->ID, 'wpcom_user_id', $user_data->ID);
     }
     do_action('jetpack_sso_handle_login', $user, $user_data);
     if ($user) {
         // Cache the user's details, so we can present it back to them on their user screen.
         update_user_meta($user->ID, 'wpcom_user_data', $user_data);
         wp_set_auth_cookie($user->ID);
         $_request_redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '';
         $redirect_to = user_can($user, 'edit_posts') ? admin_url() : self::profile_page_url();
         wp_safe_redirect(apply_filters('login_redirect', $redirect_to, $_request_redirect_to, $user));
         exit;
     }
     $this->user_data = $user_data;
     add_action('login_message', array($this, 'cant_find_user'));
 }
开发者ID:KurtMakesWeb,项目名称:CandG,代码行数:77,代码来源:sso.php


注:本文中的wp_nonce_ays函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。