CMB2::nonce PHP Метод

nonce() публичный Метод

Generate a unique nonce for each registered meta_box
С версии: 2.0.0
public nonce ( ) : string
Результат string unique nonce string
    public function nonce()
    {
        if ($this->generated_nonce) {
            return $this->generated_nonce;
        }
        $this->generated_nonce = sanitize_html_class('nonce_' . basename(__FILE__) . $this->cmb_id);
        return $this->generated_nonce;
    }

Usage Example

 /**
  * 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('CMB2')) {
         return;
     }
     $object_id = $this->id($term_id);
     if (isset($_POST[$this->cmb->nonce()]) && wp_verify_nonce($_POST[$this->cmb->nonce()], $this->cmb->nonce())) {
         $this->do_override_filters($term_id);
         $this->cmb->save_fields($object_id, 'options-page', $_POST);
     }
 }
All Usage Examples Of CMB2::nonce