function hocwp_video_source_meta_box($post_types = array()) { if (!hocwp_array_has_value($post_types)) { $post_types[] = 'post'; } $meta = new HOCWP_Meta('post'); $meta->set_post_types($post_types); $meta->set_title(__('Video Source Information', 'hocwp-theme')); $meta->set_id('hocwp_theme_video_source_information'); $meta->add_field(array('field_args' => array('id' => 'video_url', 'label' => 'Video URL:'))); $meta->add_field(array('field_args' => array('id' => 'video_code', 'label' => 'Video code:'), 'field_callback' => 'hocwp_field_textarea')); $meta->init(); }
function hocwp_meta_box_editor($args = array()) { global $pagenow; if ('post-new.php' == $pagenow || 'post.php' == $pagenow) { $post_type = hocwp_get_value_by_key($args, 'post_type'); if (!is_array($post_type)) { $post_type = array($post_type); } $box_title = hocwp_get_value_by_key($args, 'title', __('Additional Information', 'hocwp-theme')); $current_type = hocwp_get_current_post_type(); if (is_array($current_type)) { $current_type = current($current_type); } $box_id = hocwp_get_value_by_key($args, 'id'); if (empty($box_id)) { $box_id = hocwp_sanitize_id($box_title); if (empty($box_id)) { return; } } if (!empty($current_type)) { $box_id = $current_type . '_' . $box_id; } $field_args = hocwp_get_value_by_key($args, 'field_args', array()); $field_args = hocwp_sanitize_array($field_args); $field_args['field_callback'] = 'hocwp_field_editor'; $field_args['label'] = ''; $field_id = hocwp_get_value_by_key($args, 'field_id', hocwp_get_value_by_key($field_args, 'field_id')); $field_name = hocwp_get_value_by_key($args, 'field_name', hocwp_get_value_by_key($field_args, 'field_name')); hocwp_transmit_id_and_name($field_id, $field_name); if (empty($field_id)) { return; } $field_args['id'] = $field_id; $field_args['name'] = $field_name; $meta = new HOCWP_Meta('post'); $meta->set_title($box_title); $meta->set_id($box_id); $meta->set_post_types($post_type); $meta->add_field($field_args); $meta->init(); } }