本文整理汇总了PHP中wp_verify_nonce函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_verify_nonce函数的具体用法?PHP wp_verify_nonce怎么用?PHP wp_verify_nonce使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_verify_nonce函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_ryuzine_stylesheets
function generate_ryuzine_stylesheets()
{
// verify this came from the our screen and with proper authorization.
if (!wp_verify_nonce($_POST['ryu_regenstyles_noncename'], 'ryuzine-regenstyles_install')) {
return;
}
// Check permissions
if (!current_user_can('administrator')) {
echo "<div class='error'><p>Sorry, you do not have the correct priveledges to install the files.</p></div>";
return;
}
$my_query = null;
$my_query = new WP_Query(array('post_type' => 'ryuzine'));
if ($my_query->have_posts()) {
while ($my_query->have_posts()) {
$my_query->the_post();
$stylesheet = "";
$issuestyles = get_post_meta(get_the_ID(), '_ryustyles', false);
if (!empty($issuestyles)) {
foreach ($issuestyles as $appendstyle) {
// If there are multiple ryustyles append them //
$stylesheet = $stylesheet . $appendstyle;
}
}
if ($stylesheet != "") {
ryu_create_css($stylesheet, get_the_ID());
}
}
}
// reset css check //
// update_option('ryu_css_admin',0);
wp_reset_query();
return;
}
示例2: post_save
/**
* Save Force SSL option to post or page
*
* @param int $post_id
* @return int $post_id
*/
public function post_save($post_id)
{
if (array_key_exists($this->getPlugin()->getSlug(), $_POST)) {
if (!wp_verify_nonce($_POST[$this->getPlugin()->getSlug()], $this->getPlugin()->getSlug())) {
return $post_id;
}
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
if (@$_POST['post_type'] == 'page') {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} else {
if (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
}
$force_ssl = @$_POST['force_ssl'] == 1 ? true : false;
if ($force_ssl) {
update_post_meta($post_id, 'force_ssl', 1);
} else {
delete_post_meta($post_id, 'force_ssl');
}
$force_ssl_children = @$_POST['force_ssl_children'] == 1 ? true : false;
if ($force_ssl_children) {
update_post_meta($post_id, 'force_ssl_children', 1);
} else {
delete_post_meta($post_id, 'force_ssl_children');
}
}
return $post_id;
}
示例3: perpageath_save_postdata
/**
* When the post is saved, saves our custom data.
*
* @param int $post_id The ID of the post being saved.
*/
function perpageath_save_postdata($post_id)
{
/*
* We need to verify this came from the our screen and with proper authorization,
* because save_post can be triggered at other times.
*/
// Check if our nonce is set.
if (!isset($_POST['athcontent'])) {
return $post_id;
}
$nonce = $_POST['athcontent'];
// Verify that the nonce is valid.
if (!wp_verify_nonce($nonce, 'athcallback')) {
return $post_id;
}
// If this is an autosave, our form has not been submitted, so we don't want to do anything.
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// Check the user's permissions.
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} else {
if (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
}
/* OK, its safe for us to save the data now. */
// Sanitize user input.
$mydata = esc_sql(str_replace(array("\r\n", "\r", "\n"), '%BREAK%', $_POST['per-page-ath']));
// Update the meta field in the database.
update_post_meta($post_id, 'per-page-ath-content', $mydata);
}
示例4: linkblog_save_post
function linkblog_save_post($post_id)
{
// Ignore if doing an autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
}
// verify data came from the linkblog meta box
if (!wp_verify_nonce($_POST['linkblog_noncename'], plugin_basename(__FILE__))) {
return;
}
// Check user permissions
if ('post' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return;
}
} else {
if (!current_user_can('edit_post', $post_id)) {
return;
}
}
$linkblog_data = $_POST['linkblog_url'];
if ($linkblog_data == "") {
return;
} else {
update_post_meta($post_id, 'linkblog_url', $linkblog_data);
}
}
示例5: ultimatum_meta_save_postdata
function ultimatum_meta_save_postdata( $post_id, $post ) {
//echo '<pre>';print_r($_POST);die();
//* Verify the nonce
if ( ! isset( $_POST[ 'ultimatum_additional_meta_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'ultimatum_additional_meta_nonce' ], 'ultimatum_additional_meta' ) )
return;
//* Don't try to save the data under autosave, ajax, or future post.
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
return;
if ( defined( 'DOING_CRON' ) && DOING_CRON )
return;
//* Grab the post object
$post = get_post( $post );
//* Don't save if WP is creating a revision (same as DOING_AUTOSAVE?)
if ( 'revision' === $post->post_type )
return;
//* Check that the user is allowed to edit the post
if ( ! current_user_can( 'edit_post', $post->ID ) )
return;
$mydata = $_POST['ultimatum_video'];
update_post_meta($post->ID, 'ultimatum_video', $mydata);
$mydata = $_POST['ultimatum_author'];
update_post_meta($post->ID, 'ultimatum_author', $mydata);
}
示例6: comcon_meta_save
function comcon_meta_save()
{
global $post;
$post_id = $post->ID;
if (!isset($_POST['comcon-form-nonce']) || !wp_verify_nonce($_POST['comcon-form-nonce'], basename(__FILE__))) {
return $post->ID;
}
$post_type = get_post_type_object($post->post_type);
if (!current_user_can($post_type->cap->edit_post, $post_id)) {
return $post->ID;
}
$input = array();
$input['position'] = isset($_POST['comcon-form-position']) ? $_POST['comcon-form-position'] : '';
$input['major'] = isset($_POST['comcon-form-major']) ? $_POST['comcon-form-major'] : '';
$input['order'] = str_pad($input['order'], 3, "0", STR_PAD_LEFT);
foreach ($input as $field => $value) {
$old = get_post_meta($post_id, 'comcon-form-' . $field, true);
if ($value && '' == $old) {
add_post_meta($post_id, 'comcon-form-' . $field, $value, true);
} else {
if ($value && $value != $old) {
update_post_meta($post_id, 'comcon-form-' . $field, $value);
} else {
if ('' == $value && $old) {
delete_post_meta($post_id, 'comcon-form-' . $field, $old);
}
}
}
}
}
示例7: submitAJAX
function submitAJAX()
{
// check noncee
$nonce = $_POST['nonce'];
if (!wp_verify_nonce($nonce, 'qb_ajax_nonce')) {
echo json_encode(array('errors' => 'Invalid nonce; please try refreshing the page'));
exit;
}
$form_name = $_POST['form_name'];
/* Permissions levels:
edit_posts = contributor
publish_posts = author
edit_pages = editor
edit_users = admin
*/
//if ( current_user_can( 'publish_posts' ) ) {
include_once TEMPLATEPATH . '/includes/' . $form_name . '.php';
// generate the response
$response = json_encode($_POST);
// response output
header("Content-Type: application/json");
echo $response;
//}
exit;
}
示例8: tz_save_data_page
function tz_save_data_page($post_id)
{
global $meta_box_category;
// verify nonce
if (!isset($_POST['tz_meta_box_nonce']) || !wp_verify_nonce($_POST['tz_meta_box_nonce'], basename(__FILE__))) {
return $post_id;
}
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// check permissions
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
foreach ($meta_box_category['fields'] as $field) {
$old = get_post_meta($post_id, $field['id'], true);
$new = $_POST[$field['id']];
if ($new && $new != $old) {
update_post_meta($post_id, $field['id'], stripslashes(htmlspecialchars($new)));
} elseif ('' == $new && $old) {
delete_post_meta($post_id, $field['id'], $old);
}
}
}
示例9: admin_head
function admin_head()
{
// save
if (isset($_POST['acf_options_page'])) {
if (wp_verify_nonce($_POST['acf_options_page'], 'acf_options_page')) {
do_action('acf_save_post', 'options');
$this->data['admin_message'] = __("Options Updated", 'acf');
}
}
// get field groups
$filter = array();
$metabox_ids = array();
$metabox_ids = apply_filters('acf/location/match_field_groups', $metabox_ids, $filter);
if (empty($metabox_ids)) {
$this->data['no_fields'] = true;
return false;
}
// Style
echo '<style type="text/css">#side-sortables.empty-container { border: 0 none; }</style>';
// add user js + css
do_action('acf_head-input');
// get acf's
$acfs = $this->parent->get_field_groups();
if ($acfs) {
foreach ($acfs as $acf) {
// hide / show
$show = in_array($acf['id'], $metabox_ids) ? 1 : 0;
if ($show) {
// add meta box
add_meta_box('acf_' . $acf['id'], $acf['title'], array($this->parent->input, 'meta_box_input'), 'acf_options_page', $acf['options']['position'], 'high', array('fields' => $acf['fields'], 'options' => $acf['options'], 'show' => $show, 'post_id' => "options"));
}
}
}
}
示例10: save
/**
* Save metabox data.
*
* @param int $post_id Current post type ID.
*
* @return void
*/
public function save($post_id)
{
// Verify nonce.
if (!isset($_POST['wcboleto_metabox_nonce']) || !wp_verify_nonce($_POST['wcboleto_metabox_nonce'], basename(__FILE__))) {
return $post_id;
}
// Verify if this is an auto save routine.
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// Check permissions.
if ('shop_order' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
if (isset($_POST['wcboleto_expiration_date']) && !empty($_POST['wcboleto_expiration_date'])) {
// Gets boleto data.
$boleto_data = get_post_meta($post_id, 'wc_boleto_data', true);
$boleto_data['data_vencimento'] = sanitize_text_field($_POST['wcboleto_expiration_date']);
// Update boleto data.
update_post_meta($post_id, 'wc_boleto_data', $boleto_data);
// Gets order data.
$order = new WC_Order($post_id);
// Add order note.
$order->add_order_note(sprintf(__('Expiration date updated to: %s', 'wcboleto'), $boleto_data['data_vencimento']));
// Send email notification.
$this->email_notification($order, $boleto_data['data_vencimento']);
}
}
示例11: ajax_widget_reports
/**
* Ajax handler for Admin Widget
*
* @return json|int
*/
function ajax_widget_reports()
{
global $GADASH_Config;
if (!isset($_REQUEST['gadash_security_widget_reports']) or !wp_verify_nonce($_REQUEST['gadash_security_widget_reports'], 'gadash_get_widgetreports')) {
wp_die(-30);
}
$projectId = $_REQUEST['projectId'];
$from = $_REQUEST['from'];
$to = $_REQUEST['to'];
$query = $_REQUEST['query'];
if (ob_get_length()) {
ob_clean();
}
$tools = new GADASH_Tools();
if (!$tools->check_roles($GADASH_Config->options['ga_dash_access_back']) or 0 == $GADASH_Config->options['dashboard_widget']) {
wp_die(-31);
}
if ($GADASH_Config->options['ga_dash_token'] and $projectId and $from and $to) {
include_once $GADASH_Config->plugin_path . '/tools/gapi.php';
global $GADASH_GAPI;
} else {
wp_die(-24);
}
$profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
if (isset($profile_info[4])) {
$GADASH_GAPI->timeshift = $profile_info[4];
} else {
$GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
}
$GADASH_GAPI->get($projectId, $query, $from, $to);
}
示例12: save
/**
* Save the custom Status, used when posting to an Fan Page's Timeline
*
* @since 1.0
* @param int $post_id post identifier
*/
public static function save($post_id)
{
// verify if this is an auto save routine.
// If it is our form has not been submitted, so we dont want to do anything
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
}
// verify this came from the our screen and with proper authorization,
// because save_post can be triggered at other times
if (!isset($_POST[self::FIELD_MESSAGE]) || empty($_POST[self::NONCE_NAME]) || !wp_verify_nonce($_POST[self::NONCE_NAME], plugin_basename(__FILE__))) {
return;
}
// Check permissions
$post_type = get_post_type($post_id);
if (!($post_type && post_type_supports($post_type, 'author'))) {
return;
}
if (!class_exists('Facebook_Social_Publisher')) {
require_once dirname(__FILE__) . '/social_publisher.php';
}
$capability_singular_base = Facebook_Social_Publisher::post_type_capability_base($post_type);
if (!current_user_can('edit_' . $capability_singular_base, $post_id)) {
return;
}
$message = trim(sanitize_text_field($_POST[self::FIELD_MESSAGE]));
if ($message) {
update_post_meta($post_id, self::POST_META_KEY, $message);
}
}
示例13: user_can_save
public function user_can_save($post_id)
{
$is_valid_nonce = isset($_POST['tmj-post-notice-nonce']) && wp_verify_nonce($_POST['tmj-post-notice-nonce'], 'tmj-post-notice-save');
$is_autosave = wp_is_post_autosave($post_id);
$is_revision = wp_is_post_revision($post_id);
return !($is_autosave || $is_revision) && $is_valid_nonce;
}
示例14: edd_process_login_form
/**
* Process Login Form
*
* @since 1.0
* @param array $data Data sent from the login form
* @return void
*/
function edd_process_login_form($data)
{
if (wp_verify_nonce($data['edd_login_nonce'], 'edd-login-nonce')) {
$user_data = get_user_by('login', $data['edd_user_login']);
if (!$user_data) {
$user_data = get_user_by('email', $data['edd_user_login']);
}
if ($user_data) {
$user_ID = $user_data->ID;
$user_email = $user_data->user_email;
if (wp_check_password($data['edd_user_pass'], $user_data->user_pass, $user_data->ID)) {
edd_log_user_in($user_data->ID, $data['edd_user_login'], $data['edd_user_pass']);
} else {
edd_set_error('password_incorrect', __('The password you entered is incorrect', 'edd'));
}
} else {
edd_set_error('username_incorrect', __('The username you entered does not exist', 'edd'));
}
// Check for errors and redirect if none present
$errors = edd_get_errors();
if (!$errors) {
$redirect = apply_filters('edd_login_redirect', $data['edd_redirect'], $user_ID);
wp_redirect($redirect);
edd_die();
}
}
}
示例15: upgradeNotice
/**
* Given we have a valid nonce we:
* convert the legacy settings
* update the settings in the db
* delete the legacy settings
*
* @since 2.0.0
*/
public function upgradeNotice()
{
if (isset($_GET['zm_alr_update_nonce']) && wp_verify_nonce($_GET['zm_alr_update_nonce'], 'zm_alr_do_update')) {
$this->convertLegacySettingToQuilt();
$this->deleteLegacySettings();
}
}