$post_id)); } /** * render_metabox * * @param $post * @param $metabox */ function render_metabox($post, $metabox){ // post id $post_id = $metabox['args']['post_id']; $config = acfe_get_performance_config(); $fields = array( array( 'key' => 'field_mode', 'label' => '', 'name' => 'options', 'prefix' => 'acfe_performance', 'aria-label' => '', 'type' => 'radio', 'value' => $config['mode'], 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => 0, 'choices' => array( 'test' => __('Test Drive', 'acfe'), 'production' => __('Production', 'acfe'), 'rollback' => __('Rollback', 'acfe'), ), ), ); // vars $status = acfe_get_object_performance_status($post_id); $conflict = acfe_get_object_performance_conflict($post_id); ?>
:
:
get_meta_key($post_id); // meta ref if(isset($wp_meta[ $meta_key ])){ $_key = $meta_key; // '_acf' or '_options_acf' $_f_key = "_$key"; // '_my_field' if($type === 'option'){ // convert 'options_my_field' > '_my_field' $_f_key = substr_replace($key, '_', 0, strlen($id) + 1); } $_acf = maybe_unserialize($wp_meta[ $_key ]['value']); if(isset($_acf[ $_f_key ])){ $ref = $wp_meta[ $_key ]; $ref['key'] = $_f_key; $ref['value'] = $_acf[ $_f_key ]; if($type === 'option'){ $ref['key'] = "_$id" . $ref['key']; } } } return $ref; } /** * get_config * * @param $config * * @return mixed */ function get_config($config){ if($config['ui']){ $post_config = acf_maybe_get_POST('acfe_performance'); if(!empty($post_config)){ $config['mode'] = $post_config['field_mode']; } } return $config; } } acf_new_instance('acfe_performance_ui'); endif;