Die violently. If self::$debug is true, throw an exception.
public _unauthorized_access ( string $debug_message = '' ) : void | ||
$debug_message | string | |
Résultat | void | e.g. return _you_ into a void. |
/** * Check if the nonce is valid. Returns false if the nonce is missing and * throws an exception if it's invalid. If all goes well, returns true. * * @return boolean */ protected function is_valid_nonce() { if (empty($_POST['fieldmanager-' . $this->fm->name . '-nonce'])) { return false; } if (!wp_verify_nonce($_POST['fieldmanager-' . $this->fm->name . '-nonce'], 'fieldmanager-save-' . $this->fm->name)) { $this->fm->_unauthorized_access(__('Nonce validation failed', 'fieldmanager')); } return true; }
/** * Saves custom term fields * @access public * @param int $term_id * @param int $tt_id * @param string $taxonomy * @return void */ public function save_term_fields($term_id, $tt_id, $taxonomy) { // Make sure this field is attached to the taxonomy being saved and this is the appropriate action if (!in_array($taxonomy, $this->taxonomies)) { return; } // Make sure that our nonce field arrived intact if (!$this->is_valid_nonce()) { return; } // Make sure the current user can save this post $tax_obj = get_taxonomy($taxonomy); if (!current_user_can($tax_obj->cap->manage_terms)) { $this->fm->_unauthorized_access(__('User cannot edit this term', 'fieldmanager')); return; } // Save the data $this->save_to_term_meta($term_id, $taxonomy); }