Beispiel #1
0
function hocwp_meta_box_side_image($args = array())
{
    global $pagenow;
    if ('post-new.php' == $pagenow || 'post.php' == $pagenow) {
        $id = hocwp_get_value_by_key($args, 'id', 'secondary_image_box');
        $title = hocwp_get_value_by_key($args, 'title', __('Secondary Image', 'hocwp-theme'));
        $post_types = hocwp_get_value_by_key($args, 'post_type');
        if ('all' == $post_types) {
            $post_types = array();
            $types = get_post_types(array('public' => true), 'objects');
            hocwp_exclude_special_post_types($types);
            foreach ($types as $key => $object_type) {
                $post_types[] = $key;
            }
        }
        $post_types = hocwp_sanitize_array($post_types);
        $field_id = hocwp_get_value_by_key($args, 'field_id', 'secondary_image');
        $post_types = apply_filters('hocwp_post_type_user_large_thumbnail', $post_types);
        if (!hocwp_array_has_value($post_types)) {
            return;
        }
        $meta = new HOCWP_Meta('post');
        $meta->set_post_types($post_types);
        $meta->set_id($id);
        $meta->set_title($title);
        $meta->set_context('side');
        $meta->set_priority('low');
        $field_args = array('id' => $field_id, 'field_callback' => 'hocwp_field_media_upload_simple');
        $field_name = hocwp_get_value_by_key($args, 'field_name', $field_id);
        $field_args['name'] = $field_name;
        $meta->add_field($field_args);
        $meta->init();
    }
}