/** * 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); } }
/** * Determine whether the CMB2 object should be saved. All tests must be true, hence return false for * any failure. * * @param string $id @since 1.1.0 * @param \CMB2 $cmb * * @return bool * * @since 1.1.0 static unclung * @since 1.0.3 made static method * @since 1.0.1 */ private function should_save($cmb, $id) { // was this flagged to save fields? if (!$cmb->prop('save_fields')) { return FALSE; } // are these values set? if (!isset($_POST['submit-cmb'], $_POST['object_id'], $_POST[$cmb->nonce()])) { return FALSE; } // does the nonce match? if (!wp_verify_nonce($_POST[$cmb->nonce()], $cmb->nonce())) { return FALSE; } // does the object_id equal the settings key? if (!$_POST['object_id'] == self::$props[$id]['key']) { return FALSE; } return TRUE; }