當前位置: 首頁>>代碼示例>>PHP>>正文


PHP cmb_Meta_Box::nonce方法代碼示例

本文整理匯總了PHP中cmb_Meta_Box::nonce方法的典型用法代碼示例。如果您正苦於以下問題:PHP cmb_Meta_Box::nonce方法的具體用法?PHP cmb_Meta_Box::nonce怎麽用?PHP cmb_Meta_Box::nonce使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cmb_Meta_Box的用法示例。


在下文中一共展示了cmb_Meta_Box::nonce方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: intercept_post_id

 /**
  * Get data before saving to CMB.
  */
 public function intercept_post_id()
 {
     // Check for $_POST data
     if (empty($_POST)) {
         return false;
     }
     // Check nonce
     if (!(isset($_POST['submit-cmb'], $_POST['wp_meta_box_nonce']) && wp_verify_nonce($_POST['wp_meta_box_nonce'], cmb_Meta_Box::nonce()))) {
         return;
     }
     // Setup and sanitize data
     if (isset($_POST[$this->prefix . 'place_name'])) {
         $this->new_submission = wp_insert_post(array('post_title' => sanitize_text_field($_POST[$this->prefix . 'place_name']), 'post_author' => get_current_user_id(), 'post_status' => 'draft', 'post_type' => 'accommodations', 'post_content' => wp_kses($_POST[$this->prefix . 'place_notes'], '<b><strong><i><em><h1><h2><h3><h4><h5><h6><pre><code><span>')), true);
         // If no errors, save the data into a new post draft
         if (!is_wp_error($this->new_submission)) {
             $address = sanitize_text_field($_POST['address']);
             $lat = sanitize_text_field($_POST['lat']);
             $lng = sanitize_text_field($_POST['lng']);
             $formatted_address = sanitize_text_field($_POST['formatted_address']);
             // Update the meta field in the database.
             update_post_meta($this->new_submission, 'address', $address);
             update_post_meta($this->new_submission, 'lat', $lat);
             update_post_meta($this->new_submission, 'lng', $lng);
             update_post_meta($this->new_submission, 'formatted_address', $formatted_address);
             update_post_meta($this->new_submission, 'place_image_id', $_POST['place_image_id']);
             //update post parent in place_image_id
             $image = array('ID' => get_post_meta($this->new_submission, 'place_image_id', 1), 'post_parent' => $this->new_submission);
             wp_update_post($image);
             set_post_thumbnail($this->new_submission, get_post_meta($this->new_submission, 'place_image_id', 1));
             return $this->new_submission;
         }
     }
     return false;
 }
開發者ID:bulini,項目名稱:booking-wp,代碼行數:37,代碼來源:accommodation.php

示例2: do_save

 /**
  * Handles saving of the $_POST data
  * @since  0.1.3
  * @param  int $term_id Term's ID
  */
 public function do_save($term_id)
 {
     if (!class_exists('cmb_Meta_Box')) {
         return;
     }
     if (!isset($_POST['term_opt_name'], $_POST['wp_meta_box_nonce'], $_POST['action']) || !wp_verify_nonce($_POST['wp_meta_box_nonce'], cmb_Meta_Box::nonce())) {
         return;
     }
     $this->do_override_filters($term_id);
     // Save the metabox if it's been submitted
     cmb_save_metabox_fields($this->fields(), $this->id());
 }
開發者ID:ryscript,項目名稱:Scinttek-Decade-Project,代碼行數:17,代碼來源:Taxonomy_MetaData_CMB.php

示例3: intercept_post_id

 /**
  * Get data before saving to CMB.
  */
 public function intercept_post_id()
 {
     // Check for $_POST data
     if (empty($_POST)) {
         return false;
     }
     // Check nonce
     if (!(isset($_POST['submit-cmb'], $_POST['wp_meta_box_nonce']) && wp_verify_nonce($_POST['wp_meta_box_nonce'], cmb_Meta_Box::nonce()))) {
         return;
     }
     // Setup and sanitize data
     if (isset($_POST[$this->prefix . 'memorial_first_name'])) {
         add_filter('user_has_cap', array($this, 'grant_publish_caps'), 0, 3);
         $this->new_submission = wp_insert_post(array('post_title' => sanitize_text_field($_POST[$this->prefix . 'memorial_first_name'] . ' ' . $_POST[$this->prefix . 'memorial_last_name']), 'post_author' => get_current_user_id(), 'post_status' => 'draft', 'post_type' => 'memorials', 'post_content_filtered' => wp_kses($_POST[$this->prefix . 'memorial_story'], '<b><strong><i><em><h1><h2><h3><h4><h5><h6><pre><code><span>')), true);
         // If no errors, save the data into a new post draft
         if (!is_wp_error($this->new_submission)) {
             return $this->new_submission;
         }
     }
     return false;
 }
開發者ID:devd123,項目名稱:wpaam,代碼行數:24,代碼來源:custom-post.php

示例4: cmb_metabox_form

/**
 * Display a metabox form & save it on submission
 * @since  1.0.0
 * @param  array   $meta_box  Metabox config array
 * @param  int     $object_id Object ID
 * @param  boolean $return    Whether to return or echo form
 * @return string             CMB html form markup
 */
function cmb_metabox_form($meta_box, $object_id, $echo = true)
{
    $meta_box = cmb_Meta_Box::set_mb_defaults($meta_box);
    // Make sure form should be shown
    if (!apply_filters('cmb_show_on', true, $meta_box)) {
        return '';
    }
    // Make sure that our object type is explicitly set by the metabox config
    cmb_Meta_Box::set_object_type(cmb_Meta_Box::set_mb_type($meta_box));
    // Save the metabox if it's been submitted
    // check permissions
    // @todo more hardening?
    if (isset($_POST['submit-cmb'], $_POST['object_id'], $_POST['wp_meta_box_nonce']) && wp_verify_nonce($_POST['wp_meta_box_nonce'], cmb_Meta_Box::nonce()) && $_POST['object_id'] == $object_id) {
        cmb_save_metabox_fields($meta_box, $object_id);
    }
    // Show specific metabox form
    // Get cmb form
    ob_start();
    cmb_print_metabox($meta_box, $object_id);
    $form = ob_get_contents();
    ob_end_clean();
    $form_format = apply_filters('cmb_frontend_form_format', '<form class="cmb-form" method="post" id="%s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="object_id" value="%s">%s<input type="submit" name="submit-cmb" value="%s" class="button-primary"></form>', $object_id, $meta_box, $form);
    $form = sprintf($form_format, $meta_box['id'], $object_id, $form, __('Save'));
    if ($echo) {
        echo $form;
    }
    return $form;
}
開發者ID:Inteleck,項目名稱:hwc,代碼行數:36,代碼來源:init.php


注:本文中的cmb_Meta_Box::nonce方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。