/** * Hijacks saving of cached oEmbed. * Saves cached data to relevant object metadata (vs postmeta) * * @since 0.9.5 * @param boolean $check Whether to continue setting postmeta * @param int $object_id Object ID to get postmeta from * @param string $meta_key Postmeta's key * @param mixed $meta_value Value of the postmeta to be saved * @return boolean Whether to continue setting */ public static function hijack_oembed_cache_set($check, $object_id, $meta_key, $meta_value) { if (!self::$hijack || self::$object_id != $object_id && 1987645321 !== $object_id) { return $check; } // Cache the result to our metadata if ('options-page' === self::$object_type) { // Set the option cmb_Meta_Box::update_option(self::$object_id, self::$embed_args['cache_key'], $meta_value, array('type' => 'oembed')); // Save the option cmb_Meta_Box::save_option(self::$object_id); } else { update_metadata(self::$object_type, self::$object_id, $meta_key, $meta_value); } // Anything other than `null` to cancel saving to postmeta return true; }
/** * Updates metadata/option data * @since 1.0.1 * @param mixed $value Value to update data with * @param bool $single Whether data is an array (add_metadata) */ public function update_data($new_value, $single = true) { extract($this->data_args(array('new_value' => $new_value, 'single' => $single))); $new_value = $repeat ? array_values($new_value) : $new_value; if ('options-page' === $type) { return cmb_Meta_Box::update_option($id, $field_id, $new_value, $single); } if (!$single) { return add_metadata($type, $id, $field_id, $new_value, false); } return update_metadata($type, $id, $field_id, $new_value); }
/** * Saves the cached oEmbed value to relevant object metadata (vs postmeta) * * @since 1.3.0 * @param string $meta_key Postmeta's key * @param mixed $meta_value Value of the postmeta to be saved */ public static function oembed_cache_set($meta_key, $meta_value) { // Cache the result to our metadata if ('options-page' === self::$object_type) { // Set the option cmb_Meta_Box::update_option(self::$object_id, self::$embed_args['cache_key'], $meta_value, array('type' => 'oembed')); // Save the option cmb_Meta_Box::save_option(self::$object_id); } else { update_metadata(self::$object_type, self::$object_id, $meta_key, $meta_value); } }