Server : LiteSpeed System : Linux webbox1.ncrdns.net 5.14.0-611.55.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 15:19:29 EDT 2026 x86_64 User : rahcos ( 1533) PHP Version : 8.4.23 Disable Function : NONE Directory : /home/rahcos/.trash/wp-content/themes/hara/inc/vendors/cmb2/ |
<?php
if (!function_exists('hara_tbay_post_metaboxes')) {
function hara_tbay_post_metaboxes(array $metaboxes)
{
$prefix = 'tbay_post_';
$fields = array(
array(
'id' => "{$prefix}gallery_files",
'name' => esc_html__('Images Gallery', 'hara'),
'type' => 'file_list',
),
array(
'id' => "{$prefix}video_link",
'name' => esc_html__('Video Link', 'hara'),
'type' => 'oembed',
),
array(
'id' => "{$prefix}audio_link",
'name' => esc_html__('Audio Link', 'hara'),
'type' => 'oembed',
),
);
$metaboxes[$prefix . 'format_setting'] = array(
'id' => 'post_format_standard_post_meta',
'title' => esc_html__('Format Setting', 'hara'),
'object_types' => array( 'post' ),
'context' => 'normal',
'priority' => 'high',
'show_names' => true,
'autosave' => true,
'fields' => $fields
);
return $metaboxes;
}
}
add_filter('cmb2_meta_boxes', 'hara_tbay_post_metaboxes');
function hara_tbay_standard_post_meta($post_id)
{
global $post;
$prefix = 'tbay_post_';
$type = get_post_format();
$old = array(
'gallery_files',
'video_link',
'link_text',
'link_link',
'audio_link',
);
$data = array( 'gallery' => array('gallery_files'),
'video' => array('video_link'),
'audio' => array('audio_link'));
$new = array();
if (isset($data[$type])) {
foreach ($data[$type] as $key => $value) {
$new[$prefix.$value] = $_POST[$prefix.$value];
}
}
foreach ($old as $key => $value) {
if (isset($_POST[$prefix.$value])) {
unset($_POST[$prefix.$value]);
}
}
if ($new) {
$_POST = array_merge($_POST, $new);
}
}
add_action("cmb2_meta_post_format_standard_post_meta_before_save_post", 'hara_tbay_standard_post_meta', 9);