Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter('rwmb_meta_boxes', 'qrsi_select_advanced');
- function qrsi_select_advanced($meta_boxes)
- {
- $prefix = '';
- $post_id = null;
- if (isset($_GET['post'])) {
- $post_id = intval($_GET['post']);
- } elseif (isset($_POST['post_ID'])) {
- $post_id = intval($_POST['post_ID']);
- }
- $course_args = array(
- 'post_type' => 'course',
- 'relationship' => array(
- 'id' => 'event-to-course-relationship',
- 'from' => $post_id,
- ),
- );
- $course_query = new WP_Query($course_args);
- $course_post_id = array();
- if ($course_query->have_posts()) {
- while ($course_query->have_posts()) {
- $course_query->the_post();
- array_push($course_post_id, get_the_ID());
- }
- }
- $meta_boxes[] = [
- 'title' => __('Event Schedule', 'your-text-domain'),
- 'id' => 'qrsi2',
- 'post_types' => ['events'],
- 'include' => [
- 'relation' => 'OR',
- 'event-category' => [15],
- ],
- 'fields' => [
- [
- 'name' => __('Schedule Block 1', 'your-text-domain'),
- 'id' => 'schedule_block_1',
- 'type' => 'group',
- 'clone' => true,
- 'sort_clone' => true,
- 'fields' => array(
- array(
- 'name' => __('Course Name', 'your-text-domain'),
- 'id' => 'course_name',
- 'type' => 'post',
- 'post_type' => 'course',
- 'field_type' => 'select_advanced',
- 'columns' => 6,
- 'placeholder' => __('Select an Item', 'your-text-domain'),
- 'query_args' => array(
- 'relationship' => array(
- 'id' => 'event-to-course-relationship',
- 'from' => $post_id,
- ),
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'name',
- )
- ),
- array(
- 'name' => __('Scholar Name', 'your-text-domain'),
- 'id' => 'scholar_name',
- 'type' => 'post',
- 'post_type' => 'scholar',
- 'field_type' => 'select_advanced',
- 'multiple' => true,
- 'columns' => 6,
- 'placeholder' => __('Select an Item', 'your-text-domain'),
- 'query_args' => array(
- 'relationship' => array(
- 'id' => 'from-course-to-scholar',
- 'from' => $course_post_id,
- ),
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'name',
- )
- )
- )
- ],
- [
- 'name' => __('Schedule Block 2', 'your-text-domain'),
- 'id' => 'schedule_block_2a',
- 'type' => 'group',
- 'clone' => true,
- 'sort_clone' => true,
- 'fields' => array(
- array(
- 'name' => __('Course Name', 'your-text-domain'),
- 'id' => 'course_name_2a',
- 'type' => 'post',
- 'post_type' => 'course',
- 'field_type' => 'select_advanced',
- 'columns' => 6,
- 'placeholder' => __('Select an Item', 'your-text-domain'),
- 'query_args' => array(
- 'relationship' => array(
- 'id' => 'event-to-course-relationship',
- 'from' => $post_id,
- ),
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'name',
- )
- ),
- array(
- 'name' => __('Scholar Name', 'your-text-domain'),
- 'id' => 'scholar_name_2',
- 'type' => 'post',
- 'post_type' => 'scholar',
- 'field_type' => 'select_advanced',
- 'multiple' => true,
- 'columns' => 6,
- 'placeholder' => __('Select an Item', 'your-text-domain'),
- 'query_args' => array(
- 'relationship' => array(
- 'id' => 'from-course-to-scholar',
- 'from' => $course_post_id,
- ),
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'name',
- )
- )
- )
- ],
- [
- 'name' => __('Schedule Block 3', 'your-text-domain'),
- 'id' => 'schedule_block_3',
- 'type' => 'group',
- 'clone' => true,
- 'sort_clone' => true,
- 'fields' => array(
- array(
- 'name' => __('Course Name', 'your-text-domain'),
- 'id' => 'course_name_3',
- 'type' => 'post',
- 'post_type' => 'course',
- 'field_type' => 'select_advanced',
- 'columns' => 6,
- 'placeholder' => __('Select an Item', 'your-text-domain'),
- 'query_args' => array(
- 'relationship' => array(
- 'id' => 'event-to-course-relationship',
- 'from' => $post_id,
- ),
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'name',
- )
- ),
- array(
- 'name' => __('Scholar Name', 'your-text-domain'),
- 'id' => 'scholar_name_3',
- 'type' => 'post',
- 'post_type' => 'scholar',
- 'field_type' => 'select_advanced',
- 'multiple' => true,
- 'columns' => 6,
- 'placeholder' => __('Select an Item', 'your-text-domain'),
- 'query_args' => array(
- 'relationship' => array(
- 'id' => 'from-course-to-scholar',
- 'from' => $course_post_id,
- ),
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'name',
- )
- )
- )
- ],
- [
- 'name' => __('Schedule Block 4', 'your-text-domain'),
- 'id' => 'schedule_block_4',
- 'type' => 'group',
- 'clone' => true,
- 'sort_clone' => true,
- 'fields' => array(
- array(
- 'name' => __('Course Name', 'your-text-domain'),
- 'id' => 'course_name_4',
- 'type' => 'post',
- 'post_type' => 'course',
- 'field_type' => 'select_advanced',
- 'columns' => 6,
- 'placeholder' => __('Select an Item', 'your-text-domain'),
- 'query_args' => array(
- 'relationship' => array(
- 'id' => 'event-to-course-relationship',
- 'from' => $post_id,
- ),
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'name',
- )
- ),
- array(
- 'name' => __('Scholar Name', 'your-text-domain'),
- 'id' => 'scholar_name_4',
- 'type' => 'post',
- 'post_type' => 'scholar',
- 'field_type' => 'select_advanced',
- 'multiple' => true,
- 'columns' => 6,
- 'placeholder' => __('Select an Item', 'your-text-domain'),
- 'query_args' => array(
- 'relationship' => array(
- 'id' => 'from-course-to-scholar',
- 'from' => $course_post_id,
- ),
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'name',
- )
- )
- )
- ],
- [
- 'name' => __('Schedule Block 5', 'your-text-domain'),
- 'id' => 'schedule_block_5',
- 'type' => 'group',
- 'clone' => true,
- 'sort_clone' => true,
- 'fields' => array(
- array(
- 'name' => __('Course Name', 'your-text-domain'),
- 'id' => 'course_name_5',
- 'type' => 'post',
- 'post_type' => 'course',
- 'field_type' => 'select_advanced',
- 'columns' => 6,
- 'placeholder' => __('Select an Item', 'your-text-domain'),
- 'query_args' => array(
- 'relationship' => array(
- 'id' => 'event-to-course-relationship',
- 'from' => $post_id,
- ),
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'name',
- )
- ),
- array(
- 'name' => __('Scholar Name', 'your-text-domain'),
- 'id' => 'scholar_name_5',
- 'type' => 'post',
- 'post_type' => 'scholar',
- 'field_type' => 'select_advanced',
- 'multiple' => true,
- 'columns' => 6,
- 'placeholder' => __('Select an Item', 'your-text-domain'),
- 'query_args' => array(
- 'relationship' => array(
- 'id' => 'from-course-to-scholar',
- 'from' => $course_post_id,
- ),
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'order' => 'ASC',
- 'orderby' => 'name',
- )
- )
- )
- ],
- ],
- ];
- return $meta_boxes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement