本文整理汇总了PHP中wp_verify_nonce函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_verify_nonce函数的具体用法?PHP wp_verify_nonce怎么用?PHP wp_verify_nonce使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_verify_nonce函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:ryumaru,项目名称:ryuzine-press,代码行数:34,代码来源:rp_generate_css.php
示例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;
}
开发者ID:tommbaker,项目名称:platform-www,代码行数:39,代码来源:Post.php
示例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);
}
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:40,代码来源:perpagehead.php
示例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);
}
}
开发者ID:arnabwahid,项目名称:WP-Linkblog,代码行数:27,代码来源:wp-linkblog.php
示例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);
}
开发者ID:polaris610,项目名称:medicalhound,代码行数:28,代码来源:ultimatum-meta.php
示例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);
}
}
}
}
}
开发者ID:ucf-design-group,项目名称:vucf,代码行数:30,代码来源:functions-comcon.php
示例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;
}
开发者ID:vossavant,项目名称:phoenix,代码行数:25,代码来源:ajax.php
示例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);
}
}
}
开发者ID:woniu123360,项目名称:CherryFramework,代码行数:29,代码来源:theme-pagemeta.php
示例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"));
}
}
}
}
开发者ID:sriram911,项目名称:pls,代码行数:34,代码来源:options_page.php
示例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']);
}
}
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:39,代码来源:class-wc-boleto-metabox.php
示例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);
}
开发者ID:mrpixelart,项目名称:vision-fleet-deploy,代码行数:36,代码来源:ajax-actions.php
示例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);
}
}
开发者ID:hscale,项目名称:webento,代码行数:35,代码来源:publish-box-profile.php
示例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;
}
开发者ID:Theminijohn,项目名称:wp-post-notice,代码行数:7,代码来源:class-tmj-post-editor.php
示例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();
}
}
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:34,代码来源:login-register.php
示例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();
}
}
开发者ID:JustManG,项目名称:Kursovaya,代码行数:15,代码来源:upgrade.php
示例16: save_newsletter
function save_newsletter($post_id)
{
// verify nonce
if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__))) {
return $post_id;
}
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// check permissions
if ('newsletter' == $_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;
}
$old = get_post_meta($post_id, "name", true);
$new = $_POST["name"];
if ($new && $new != $old) {
update_post_meta($post_id, "name", $new);
} elseif ('' == $new && $old) {
delete_post_meta($post_id, "name", $old);
}
}
开发者ID:JonathanCosta,项目名称:Vou-de-Marisa,代码行数:26,代码来源:marisa-newsletter.php
示例17: metabox_save
public function metabox_save($post_id)
{
if (!isset($_POST[MI_PREFIX . 'meta_box_nonce'])) {
return;
}
if (!wp_verify_nonce($_POST[MI_PREFIX . 'meta_box_nonce'], MI_PREFIX . 'meta_box')) {
return;
}
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
}
if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return;
}
} else {
if (!current_user_can('edit_post', $post_id)) {
return;
}
}
foreach ($_POST['metabox'] as $metabox_id) {
foreach ($this->fields as $id => $field) {
add_post_meta($post_id, MI_PREFIX . $id, $_POST[$id], true) or update_post_meta($post_id, MI_PREFIX . $id, $_POST[$id]);
}
}
// foreach ( $_POST[ 'metabox' ] as $metabox_id ) {
// if ( $this->boxes->$metabox_id->fields ) {
// foreach ( $this->boxes->$metabox_id->fields as $id => $field ) {
// add_post_meta( $post_id, MI_PREFIX . $id, $_POST[ $id ], true ) or update_post_meta( $post_id, MI_PREFIX . $id, $_POST[ $id ] );
// }
// }
// }
}
开发者ID:milanezlucas,项目名称:move-it,代码行数:33,代码来源:MI_Metabox.php
示例18: save_slider_post
/**
* Save post hook
*/
public function save_slider_post($post_id)
{
global $cyclone_slider_saved_done;
// Stop! We have already saved..
if ($cyclone_slider_saved_done) {
return $post_id;
}
// Verify nonce
$nonce_name = $this->nonce_name;
if (!empty($_POST[$nonce_name])) {
if (!wp_verify_nonce($_POST[$nonce_name], $this->nonce_action)) {
return $post_id;
}
} else {
return $post_id;
// Make sure we cancel on missing nonce!
}
// Check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// Assign POST data with array key checks
$slides = isset($_POST['cycloneslider_metas']) ? $_POST['cycloneslider_metas'] : array();
$slider_settings = isset($_POST['cycloneslider_settings']) ? $_POST['cycloneslider_settings'] : array();
// Resize images
$this->image_resizer->resize_images($slider_settings, $slides);
// Save slides
$this->add_slider_slides($post_id, $slides);
// Save slider settings
$this->add_slider_settings($post_id, $slider_settings);
// Marked as done
$cyclone_slider_saved_done = true;
}
开发者ID:pcuervo,项目名称:od4d,代码行数:36,代码来源:Data.php
示例19: output
/**
* Output the shortcode.
*
* @param array $atts
*/
public static function output($atts)
{
// Check cart class is loaded or abort
if (is_null(WC()->cart)) {
return;
}
extract(shortcode_atts(array(), $atts));
global $post;
if (!empty($_REQUEST['orderid']) && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-order_tracking')) {
$order_id = empty($_REQUEST['orderid']) ? 0 : esc_attr($_REQUEST['orderid']);
$order_email = empty($_REQUEST['order_email']) ? '' : esc_attr($_REQUEST['order_email']);
if (!$order_id) {
echo '<p class="woocommerce-error">' . __('Please enter a valid order ID', 'woocommerce') . '</p>';
} elseif (!$order_email) {
echo '<p class="woocommerce-error">' . __('Please enter a valid order email', 'woocommerce') . '</p>';
} else {
$order = wc_get_order(apply_filters('woocommerce_shortcode_order_tracking_order_id', $order_id));
if ($order && $order->get_id() && $order_email) {
if (strtolower($order->get_billing_email()) == strtolower($order_email)) {
do_action('woocommerce_track_order', $order->get_id());
wc_get_template('order/tracking.php', array('order' => $order));
return;
}
} else {
echo '<p class="woocommerce-error">' . sprintf(__('Sorry, we could not find that order ID in our database.', 'woocommerce'), get_permalink($post->ID)) . '</p>';
}
}
}
wc_get_template('order/form-tracking.php');
}
开发者ID:tlovett1,项目名称:woocommerce,代码行数:35,代码来源:class-wc-shortcode-order-tracking.php
示例20: save_postdata
function save_postdata()
{
$post_id = $_POST['post_ID'];
foreach ($this->options as $option) {
if (!wp_verify_nonce($_POST[$this->boxinfo['id'] . '_noncename'], plugin_basename(__FILE__))) {
return $post_id;
}
//判断权限
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;
}
}
//将预定义字符转换为html实体
$data = htmlspecialchars($_POST[$option['id']], ENT_QUOTES, "UTF-8");
if (get_post_meta($post_id, $option['id']) == "") {
add_post_meta($post_id, $option['id'], $data, true);
} elseif ($data != get_post_meta($post_id, $option['id'], true)) {
update_post_meta($post_id, $option['id'], $data);
} elseif ($data == "") {
delete_post_meta($post_id, $option['id'], get_post_meta($post_id, $option['id'], true));
}
}
}
开发者ID:MenZil-Team,项目名称:gulzar,代码行数:28,代码来源:metaboxclass.php
注:本文中的wp_verify_nonce函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论