/* Version: 3.5.2 Timestamp: Sat Nov 1 14:43:36 EDT 2014 */ .select3-container { margin: 0; position: relative; display: inline-block; /* inline-block for ie7 */ zoom: 1; *display: inline; vertical-align: middle; } .select3-container, .select3-drop, .select3-search, .select3-search input { /* Force border-box so that % widths fit the parent container without overlap because of margin/padding. More Info : http://www.quirksmode.org/css/box.html */ -webkit-box-sizing: border-box; /* webkit */ -moz-box-sizing: border-box; /* firefox */ box-sizing: border-box; /* css3 */ } .select3-container .select3-choice { display: block; height: 26px; padding: 0 0 0 8px; overflow: hidden; position: relative; border: 1px solid #aaa; white-space: nowrap; line-height: 26px; color: #444; text-decoration: none; border-radius: 4px; background-clip: padding-box; -webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; background-color: #fff; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff)); background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%); background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0); background-image: linear-gradient(to top, #eee 0%, #fff 50%); } html[dir="rtl"] .select3-container .select3-choice { padding: 0 8px 0 0; } .select3-container.select3-drop-above .select3-choice { border-bottom-color: #aaa; border-radius: 0 0 4px 4px; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff)); background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%); background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0); background-image: linear-gradient(to bottom, #eee 0%, #fff 90%); } .select3-container.select3-allowclear .select3-choice .select3-chosen { margin-right: 42px; } .select3-container .select3-choice > .select3-chosen { margin-right: 26px; display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; float: none; width: auto; } html[dir="rtl"] .select3-container .select3-choice > .select3-chosen { margin-left: 26px; margin-right: 0; } .select3-container .select3-choice abbr { display: none; width: 12px; height: 12px; position: absolute; right: 24px; top: 8px; font-size: 1px; text-decoration: none; border: 0; background: url('select3.png') right top no-repeat; cursor: pointer; outline: 0; } .select3-container.select3-allowclear .select3-choice abbr { display: inline-block; } .select3-container .select3-choice abbr:hover { background-position: right -11px; cursor: pointer; } .select3-drop-mask { border: 0; margin: 0; padding: 0; position: fixed; left: 0; top: 0; min-height: 100%; min-width: 100%; height: auto; width: auto; opacity: 0; z-index: 9998; /* styles required for IE to work */ background-color: #fff; filter: alpha(opacity=0); } .select3-drop { width: 100%; margin-top: -1px; position: absolute; z-index: 9999; top: 100%; background: #fff; color: #000; border: 1px solid #aaa; border-top: 0; border-radius: 0 0 4px 4px; -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15); box-shadow: 0 4px 5px rgba(0, 0, 0, .15); } .select3-drop.select3-drop-above { margin-top: 1px; border-top: 1px solid #aaa; border-bottom: 0; border-radius: 4px 4px 0 0; -webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15); box-shadow: 0 -4px 5px rgba(0, 0, 0, .15); } .select3-drop-active { border: 1px solid #5897fb; border-top: none; } .select3-drop.select3-drop-above.select3-drop-active { border-top: 1px solid #5897fb; } .select3-drop-auto-width { border-top: 1px solid #aaa; width: auto; } .select3-drop-auto-width .select3-search { padding-top: 4px; } .select3-container .select3-choice .select3-arrow { display: inline-block; width: 18px; height: 100%; position: absolute; right: 0; top: 0; border-left: 1px solid #aaa; border-radius: 0 4px 4px 0; background-clip: padding-box; background: #ccc; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee)); background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%); background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0); background-image: linear-gradient(to top, #ccc 0%, #eee 60%); } html[dir="rtl"] .select3-container .select3-choice .select3-arrow { left: 0; right: auto; border-left: none; border-right: 1px solid #aaa; border-radius: 4px 0 0 4px; } .select3-container .select3-choice .select3-arrow b { display: block; width: 100%; height: 100%; background: url('select3.png') no-repeat 0 1px; } html[dir="rtl"] .select3-container .select3-choice .select3-arrow b { background-position: 2px 1px; } .select3-search { display: inline-block; width: 100%; min-height: 26px; margin: 0; padding-left: 4px; padding-right: 4px; position: relative; z-index: 10000; white-space: nowrap; } .select3-search input { width: 100%; height: auto !important; min-height: 26px; padding: 4px 20px 4px 5px; margin: 0; outline: 0; font-family: sans-serif; font-size: 1em; border: 1px solid #aaa; border-radius: 0; -webkit-box-shadow: none; box-shadow: none; background: #fff url('select3.png') no-repeat 100% -22px; background: url('select3.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); background: url('select3.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); background: url('select3.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); background: url('select3.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; } html[dir="rtl"] .select3-search input { padding: 4px 5px 4px 20px; background: #fff url('select3.png') no-repeat -37px -22px; background: url('select3.png') no-repeat -37px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); background: url('select3.png') no-repeat -37px -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); background: url('select3.png') no-repeat -37px -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); background: url('select3.png') no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; } .select3-drop.select3-drop-above .select3-search input { margin-top: 4px; } .select3-search input.select3-active { background: #fff url('select3-spinner.gif') no-repeat 100%; background: url('select3-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee)); background: url('select3-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%); background: url('select3-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%); background: url('select3-spinner.gif') no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0; } .select3-container-active .select3-choice, .select3-container-active .select3-choices { border: 1px solid #5897fb; outline: none; -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3); box-shadow: 0 0 5px rgba(0, 0, 0, .3); } .select3-dropdown-open .select3-choice { border-bottom-color: transparent; -webkit-box-shadow: 0 1px 0 #fff inset; box-shadow: 0 1px 0 #fff inset; border-bottom-left-radius: 0; border-bottom-right-radius: 0; background-color: #eee; background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee)); background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%); background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0); background-image: linear-gradient(to top, #fff 0%, #eee 50%); } .select3-dropdown-open.select3-drop-above .select3-choice, .select3-dropdown-open.select3-drop-above .select3-choices { border: 1px solid #5897fb; border-top-color: transparent; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee)); background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%); background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0); background-image: linear-gradient(to bottom, #fff 0%, #eee 50%); } .select3-dropdown-open .select3-choice .select3-arrow { background: transparent; border-left: none; filter: none; } html[dir="rtl"] .select3-dropdown-open .select3-choice .select3-arrow { border-right: none; } .select3-dropdown-open .select3-choice .select3-arrow b { background-position: -18px 1px; } html[dir="rtl"] .select3-dropdown-open .select3-choice .select3-arrow b { background-position: -16px 1px; } .select3-hidden-accessible { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; } /* results */ .select3-results { max-height: 200px; padding: 0 0 0 4px; margin: 4px 4px 4px 0; position: relative; overflow-x: hidden; overflow-y: auto; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } html[dir="rtl"] .select3-results { padding: 0 4px 0 0; margin: 4px 0 4px 4px; } .select3-results ul.select3-result-sub { margin: 0; padding-left: 0; } .select3-results li { list-style: none; display: list-item; background-image: none; } .select3-results li.select3-result-with-children > .select3-result-label { font-weight: bold; } .select3-results .select3-result-label { padding: 3px 7px 4px; margin: 0; cursor: pointer; min-height: 1em; -webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .select3-results-dept-1 .select3-result-label { padding-left: 20px } .select3-results-dept-2 .select3-result-label { padding-left: 40px } .select3-results-dept-3 .select3-result-label { padding-left: 60px } .select3-results-dept-4 .select3-result-label { padding-left: 80px } .select3-results-dept-5 .select3-result-label { padding-left: 100px } .select3-results-dept-6 .select3-result-label { padding-left: 110px } .select3-results-dept-7 .select3-result-label { padding-left: 120px } .select3-results .select3-highlighted { background: #3875d7; color: #fff; } .select3-results li em { background: #feffde; font-style: normal; } .select3-results .select3-highlighted em { background: transparent; } .select3-results .select3-highlighted ul { background: #fff; color: #000; } .select3-results .select3-no-results, .select3-results .select3-searching, .select3-results .select3-ajax-error, .select3-results .select3-selection-limit { background: #f4f4f4; display: list-item; padding-left: 5px; } /* disabled look for disabled choices in the results dropdown */ .select3-results .select3-disabled.select3-highlighted { color: #666; background: #f4f4f4; display: list-item; cursor: default; } .select3-results .select3-disabled { background: #f4f4f4; display: list-item; cursor: default; } .select3-results .select3-selected { display: none; } .select3-more-results.select3-active { background: #f4f4f4 url('select3-spinner.gif') no-repeat 100%; } .select3-results .select3-ajax-error { background: rgba(255, 50, 50, .2); } .select3-more-results { background: #f4f4f4; display: list-item; } /* disabled styles */ .select3-container.select3-container-disabled .select3-choice { background-color: #f4f4f4; background-image: none; border: 1px solid #ddd; cursor: default; } .select3-container.select3-container-disabled .select3-choice .select3-arrow { background-color: #f4f4f4; background-image: none; border-left: 0; } .select3-container.select3-container-disabled .select3-choice abbr { display: none; } /* multiselect */ .select3-container-multi .select3-choices { height: auto !important; height: 1%; margin: 0; padding: 0 5px 0 0; position: relative; border: 1px solid #aaa; cursor: text; overflow: hidden; background-color: #fff; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff)); background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%); background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%); background-image: linear-gradient(to bottom, #eee 1%, #fff 15%); } html[dir="rtl"] .select3-container-multi .select3-choices { padding: 0 0 0 5px; } .select3-locked { padding: 3px 5px 3px 5px !important; } .select3-container-multi .select3-choices { min-height: 26px; } .select3-container-multi.select3-container-active .select3-choices { border: 1px solid #5897fb; outline: none; -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3); box-shadow: 0 0 5px rgba(0, 0, 0, .3); } .select3-container-multi .select3-choices li { float: left; list-style: none; } html[dir="rtl"] .select3-container-multi .select3-choices li { float: right; } .select3-container-multi .select3-choices .select3-search-field { margin: 0; padding: 0; white-space: nowrap; } .select3-container-multi .select3-choices .select3-search-field input { padding: 5px; margin: 1px 0; font-family: sans-serif; font-size: 100%; color: #666; outline: 0; border: 0; -webkit-box-shadow: none; box-shadow: none; background: transparent !important; } .select3-container-multi .select3-choices .select3-search-field input.select3-active { background: #fff url('select3-spinner.gif') no-repeat 100% !important; } .select3-default { color: #999 !important; } .select3-container-multi .select3-choices .select3-search-choice { padding: 3px 5px 3px 18px; margin: 3px 0 3px 5px; position: relative; line-height: 13px; color: #333; cursor: default; border: 1px solid #aaaaaa; border-radius: 3px; -webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05); box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05); background-clip: padding-box; -webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; background-color: #e4e4e4; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee)); background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); background-image: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%); } html[dir="rtl"] .select3-container-multi .select3-choices .select3-search-choice { margin: 3px 5px 3px 0; padding: 3px 18px 3px 5px; } .select3-container-multi .select3-choices .select3-search-choice .select3-chosen { cursor: default; } .select3-container-multi .select3-choices .select3-search-choice-focus { background: #d4d4d4; } .select3-search-choice-close { display: block; width: 12px; height: 13px; position: absolute; right: 3px; top: 4px; font-size: 1px; outline: none; background: url('select3.png') right top no-repeat; } html[dir="rtl"] .select3-search-choice-close { right: auto; left: 3px; } .select3-container-multi .select3-search-choice-close { left: 3px; } html[dir="rtl"] .select3-container-multi .select3-search-choice-close { left: auto; right: 2px; } .select3-container-multi .select3-choices .select3-search-choice .select3-search-choice-close:hover { background-position: right -11px; } .select3-container-multi .select3-choices .select3-search-choice-focus .select3-search-choice-close { background-position: right -11px; } /* disabled styles */ .select3-container-multi.select3-container-disabled .select3-choices { background-color: #f4f4f4; background-image: none; border: 1px solid #ddd; cursor: default; } .select3-container-multi.select3-container-disabled .select3-choices .select3-search-choice { padding: 3px 5px 3px 5px; border: 1px solid #ddd; background-image: none; background-color: #f4f4f4; } .select3-container-multi.select3-container-disabled .select3-choices .select3-search-choice .select3-search-choice-close { display: none; background: none; } /* end multiselect */ .select3-result-selectable .select3-match, .select3-result-unselectable .select3-match { text-decoration: underline; } .select3-offscreen, .select3-offscreen:focus { clip: rect(0 0 0 0) !important; width: 1px !important; height: 1px !important; border: 0 !important; margin: 0 !important; padding: 0 !important; overflow: hidden !important; position: absolute !important; outline: 0 !important; left: 0px !important; top: 0px !important; } .select3-display-none { display: none; } .select3-measure-scrollbar { position: absolute; top: -10000px; left: -10000px; width: 100px; height: 100px; overflow: scroll; } /* Retina-ize icons */ @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 2dppx) { .select3-search input, .select3-search-choice-close, .select3-container .select3-choice abbr, .select3-container .select3-choice .select3-arrow b { background-image: url('select3x2.png') !important; background-repeat: no-repeat !important; background-size: 60px 40px !important; } .select3-search input { background-position: 100% -21px !important; } }
/** * OceanWP Post Metabox * * @package Ocean_Extra * @category Core * @author OceanWP */ // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } // The Metabox class if ( ! class_exists( 'OceanWP_Post_Settings' ) ) { /** * Main Post Settings class. * * @since 2.2.0 * @access public */ final class OceanWP_Post_Settings { /** * Namespace. * * @var string */ protected $namespace = 'oceanwp/v'; /** * Version. * * @var string */ protected $version = '1'; /** * Ocean_Extra The single instance of Ocean_Extra. * * @var object * @access private */ private static $_instance = null; /** * Main OceanWP_Post_Settings Instance * * @static * @see OceanWP_Post_Settings() * @return Main OceanWP_Post_Settings instance */ public static function instance() { if ( is_null( self::$_instance ) ) { self::$_instance = new self(); } return self::$_instance; } /** * Constructor */ public function __construct() { $this->includes(); $capabilities = apply_filters('ocean_main_metaboxes_capabilities', 'manage_options'); add_action( 'init', array( $this, 'register_meta_settings' ), 15 ); if ( current_user_can($capabilities) ) { add_action( 'enqueue_block_editor_assets', array( $this, 'editor_enqueue_script' ), 21 ); add_filter('update_post_metadata', array( $this, 'handle_updating_post_meta' ), 20, 5); add_action( 'rest_api_init', array( $this, 'register_routes' ) ); add_filter('register_post_type_args', array( $this, 'post_args' ), 10, 2 ); } add_action( 'current_screen', array( $this, 'butterbean_loader' ), 20 ); } /** * Load required files */ public function includes() { require_once OE_PATH . 'includes/post-settings/defaults.php'; require_once OE_PATH . 'includes/post-settings/functions.php'; require_once OE_PATH . 'includes/post-settings/sanitize.php'; } /** * Register Post Meta options. * * @return void */ public function register_meta_settings() { $settings = ocean_post_setting_data(); foreach ( $settings as $key => $value ) { $sanitize_callback = isset($value['sanitize']) ? $value['sanitize'] : null; $args = array( 'object_subtype' => $value['subType'], 'single' => $value['single'], 'type' => $value['type'], 'default' => $value['value'], 'show_in_rest' => $value['rest'], 'sanitize_callback' => $sanitize_callback, 'auth_callback' => '__return_true', ); // Register meta. register_meta( 'post', $key, $args ); } } /** * Modify post type arguments to add 'custom-fields' support for specific post types. * * This function hooks into the 'register_post_type_args' filter to check if the current * post type is in the list of post types that should receive 'custom-fields' support. If * the support is not already present, it's added to the post type's arguments. * * @param array $args The original post type arguments. * @param string $post_type The slug of the current post type. * * @return array Modified post type arguments. */ public function post_args( $args, $post_type ) { // Array of post types to check for 'custom-fields' support. $post_types_to_check = oe_metabox_support_post_types(); if ( ! is_array( $post_types_to_check ) ) { $post_types_to_check = []; } // Check if the current post type is in the list to check. if ( in_array( $post_type, $post_types_to_check ) ) { // Check if 'custom-fields' support already exists. if ( ! isset( $args['supports'] ) || ! in_array( 'custom-fields', $args['supports'] ) ) { $args['supports'][] = 'custom-fields'; } } return $args; } /** * Filter callback to fix the WP REST API meta error when sending updated encoded JSON with no change. * * @param mixed $value The new value of the user metadata to be updated. * @param int $object_id The ID of the user object whose metadata is being updated. * @param mixed $meta_value The new meta value to be stored. * @param mixed $prev_value The previous meta value before the update. * @param string $meta_key Optional. The meta key for which the value is being updated. Defaults to false. * * @return mixed The filtered value. If the function returns true, it prevents the update from occurring. */ public function handle_updating_post_meta( $value, $object_id, $meta_key, $meta_value, $prev_value ) { $meta_type = 'post'; $serialized_meta_keys = get_all_meta_key(); // Check if it's a REST API request and the meta key is in the serialized meta keys array. if ( defined( 'REST_REQUEST' ) && REST_REQUEST && in_array( $meta_key, $serialized_meta_keys ) ) { // Get the meta cache for the user. $meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' ); // If meta cache doesn't exist, update the meta cache for the user. if ( ! $meta_cache ) { $meta_cache = update_meta_cache( $meta_type, array( $object_id ) ); $meta_cache = $meta_cache[$object_id]; } // Check if the meta key exists in the meta cache. if ( isset( $meta_cache[$meta_key] ) ) { // If the new meta value is the same as the one in the meta cache, return true to prevent update. if ( $meta_value === $meta_cache[$meta_key][0] ) { return true; } } } // If not a REST API request or the meta key is not in the serialized meta keys array, proceed with the update. return $value; } /** * Enqueque Editor Scripts */ public function editor_enqueue_script() { if ( false === oe_check_post_types_settings() ) { return; } if ( is_customize_preview() ) { return; } if ( get_current_screen()->base === 'widgets' ) { return; } $uri = OE_URL . 'includes/post-settings/assets/'; $asset = require OE_PATH . 'includes/post-settings/assets/index.asset.php'; $deps = $asset['dependencies']; array_push( $deps, 'updates' ); wp_register_script( 'owp-post-settings', $uri . 'index.js', $deps, filemtime( OE_PATH . 'includes/post-settings/assets/index.js' ), true ); wp_enqueue_style( 'owp-post-settings', $uri . 'style-index.css', array(), filemtime( OE_PATH . 'includes/post-settings/assets/style-index.css' ) ); wp_enqueue_script( 'owp-post-settings' ); if ( function_exists( 'wp_set_script_translations' ) ) { wp_set_script_translations( 'owp-post-settings', 'ocean-extra' ); } $editor_loc_data = $this->localize_editor_script(); if ( is_array( $editor_loc_data ) ) { wp_localize_script( 'owp-post-settings', 'owpPostSettings', $editor_loc_data ); } } /** * Localize Script. * * @return mixed|void */ public function localize_editor_script() { return apply_filters( 'ocean_post_settings_localize', array( 'choices' => oe_get_choices(), 'postTypes' => oe_metabox_support_post_types(), 'isPremium' => ocean_check_pro_license() ) ); } /** * Remove Butterbean metabox when block editor. */ public function butterbean_loader() { if ( false === oe_is_block_editor() ) { add_action( 'current_screen', 'butterbean_loader_100', 9999 ); require_once OE_PATH . '/includes/metabox/gallery-metabox/gallery-metabox.php'; } } /** * Register rest routes. */ public function register_routes() { register_rest_route( $this->namespace . $this->version, '/option-reset-current/(?P\d+)', array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => array( $this, 'current_reset_options_callback' ), 'permission_callback' => array( $this, 'settings_permission' ), ) ); } /** * Ocean Migration metabox for current page/post only. * * @param WP_REST_Request $request Request object. * * @return mixed */ public function current_reset_options_callback( WP_REST_Request $request ) { $newMetaData = ocean_post_setting_data(); $post_id = $request->get_param('post_id'); if ( $post_id > 0 ) { $post = get_post( $post_id ); if ( $post && in_array( $post->post_type, get_post_types() ) ) { $oldMetaData = get_post_custom( $post_id ); foreach ( $newMetaData as $key => $value ) { if ( isset( $oldMetaData[ $key ][0] ) && $oldMetaData[ $key ][0] !== $value['value'] ) { update_post_meta( $post_id, $key, $value['value'] ); } } return $this->success( '' ); } } } /** * Get edit options permissions. * * @return bool */ public function settings_permission() { return current_user_can( 'manage_options' ); } /** * Success * * @param mixed $response response data. * @return mixed */ public function success( $response ) { return new WP_REST_Response( array( 'success' => true, 'response' => $response, ), 200 ); } } } /** * Returns the main instance of OceanWP_Post_Settings to prevent the need to use globals. * * @return object OceanWP_Post_Settings */ function OceanWP_Post_Settings() { if ( ! defined( 'OCEAN_METABOX_LOADER' ) ) { define( 'OCEAN_METABOX_LOADER', true ); return OceanWP_Post_Settings::instance(); } } OceanWP_Post_Settings();