/**
* The wrapper install method. Save container values.
*
* @param int $postId The post ID value.
* @return void
*/
public function save($postId)
{
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
}
$nonceName = isset($_POST[Session::nonceName]) ? $_POST[Session::nonceName] : Session::nonceName;
if (!wp_verify_nonce($nonceName, Session::nonceAction)) {
return;
}
// Grab current custom post type name.
$postType = get_post_type($postId);
// Check user capability.
if ($this->check && $this->datas['postType'] === $postType) {
if (!$this->user->can($this->capability)) {
return;
}
}
// Check current post type...avoid to register fields for all registered post type.
if ($postType !== $this->datas['postType']) {
return;
}
$fields = [];
// Loop through the registered fields.
// With sections.
if (!empty($this->sections)) {
foreach ($this->datas['fields'] as $fs) {
$fields = $fs;
}
} else {
$fields = $this->datas['fields'];
}
// Register post meta.
$this->register($postId, $fields);
}