Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamandrewpeters/1fd5eba2321c1777151712a9ec014d93 to your computer and use it in GitHub Desktop.
Save iamandrewpeters/1fd5eba2321c1777151712a9ec014d93 to your computer and use it in GitHub Desktop.
//Add Category Selector
add_filter( 'rwmb_meta_boxes', 'cat_select_register_meta_boxes' );
function cat_select_register_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array (
'title' => 'Some Extra Info',
'id' => 'post-purpose-select-title',
'post_types' => array(
0 => 'post',
),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array (
'id' => 'post_purpose_select_tax',
'desc' => 'Select the purpose of this post. This will bring up a few extra fields and control how the post looks on the website.',
'required' => 1,
'type' => 'taxonomy',
'taxonomy' => 'post-purpose',
'field_type' => 'select',
),
),
);
return $meta_boxes;
}
//Add Fields for Grant Recipients
add_filter( 'rwmb_meta_boxes', 'grant_recip_register_meta_boxes' );
function grant_recip_register_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array (
'title' => 'Grant Information',
'visible' => array('post_purpose_select_tax' , '=' , get_term_by( 'slug' , 'grant-recipients' , 'post-purpose')->term_id),
'id' => 'grant-information',
'post_types' => array(
0 => 'post',
),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array (
'id' => 'grant-year-selection',
'type' => 'taxonomy',
'name' => 'Grant Year',
'taxonomy' => 'grant-year',
'field_type' => 'select',
),
array (
'id' => 'grant_org_name',
'type' => 'text',
'name' => 'Grant Organization',
),
array (
'id' => 'grant_amount',
'type' => 'text',
'name' => 'Grant Amount',
),
array (
'id' => 'grant_student_rep',
'type' => 'text',
'name' => 'Student Rep',
),
array (
'id' => 'grant_rec_website',
'type' => 'url',
'name' => 'Recipient\'s Website Address',
),
array (
'id' => 'grant_gallery_check',
'name' => 'Does this grant story have any pictures you could add?',
'type' => 'checkbox',
'desc' => 'Yes, it does.',
),
array(
'id' => 'grant_image_advanced',
'type' => 'image_advanced',
'name' => 'Grant Images',
'max_file_uploads' => 14,
'image_size' => 'thumbnail',
'desc' => 'You can updload pictures here to create a gallery.',
'visible' => array(
'when' => array(
array (
0 => 'grant_gallery_check',
1 => '=',
2 => true,
),
),
),
),
array (
'id' => 'grant_video_check',
'name' => 'Does this grant have a Video?',
'type' => 'checkbox',
'desc' => 'Yes, it does.',
),
array (
'id' => 'video_grant_recip',
'type' => 'url',
'name' => 'Grant Recipient Video URL',
'desc' => 'Add the YouTube video URL here. Make sure to use the "long" URL from your browsers address bar, not the short one that you get when you click share.',
'sanitize_callback' => 'none',
'visible' => array(
'when' => array(
array (
0 => 'grant_video_check',
1 => '=',
2 => true,
),
),
),
),
),
);
return $meta_boxes;
}
//Add Fields for Stories
add_filter( 'rwmb_meta_boxes', 'ttr_stories_register_meta_boxes' );
function ttr_stories_register_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array (
'title' => 'Story Info',
'visible' => array('post_purpose_select_tax' , '=' , get_term_by( 'slug' , 'stories' , 'post-purpose')->term_id),
'id' => 'story-information',
'post_types' => array(
0 => 'post',
),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array (
'id' => 'story_gallery_check',
'name' => 'Does this story have any pictures you could add?',
'type' => 'checkbox',
'desc' => 'Yes, it does.',
),
array(
'id' => 'story_image_advanced',
'type' => 'image_advanced',
'name' => 'Story Images',
'max_file_uploads' => 14,
'image_size' => 'medium',
'desc' => 'You can updload pictures here to create a gallery.',
'visible' => array(
'when' => array(
array (
0 => 'story_gallery_check',
1 => '=',
2 => true,
),
),
),
),
array (
'id' => 'story_video_check',
'name' => 'Does this story have a Video?',
'type' => 'checkbox',
'desc' => 'Yes, it does.',
),
array (
'id' => 'story_video',
'type' => 'url',
'name' => 'Story Video URL',
'desc' => 'Add the YouTube video URL here. Make sure to use the "long" URL from your browsers address bar, not the short one that you get when you click share.',
'visible' => array(
'when' => array(
array (
0 => 'story_video_check',
1 => '=',
2 => true,
),
),
),
),
),
);
return $meta_boxes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment