Advertisement
mozzarellathicc

Troubleshooting

Jan 29th, 2022
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.35 KB | None | 0 0
  1. <?php
  2. add_filter('rwmb_meta_boxes', 'qrsi_select_advanced');
  3.  
  4. function qrsi_select_advanced($meta_boxes)
  5. {
  6.     $prefix = '';
  7.  
  8.     $post_id = null;
  9.     if (isset($_GET['post'])) {
  10.         $post_id = intval($_GET['post']);
  11.     } elseif (isset($_POST['post_ID'])) {
  12.         $post_id = intval($_POST['post_ID']);
  13.     }
  14.  
  15.     $course_args = array(
  16.         'post_type' => 'course',
  17.         'relationship' => array(
  18.             'id'   => 'event-to-course-relationship',
  19.             'from' => $post_id,
  20.         ),
  21.     );
  22.  
  23.     $course_query = new WP_Query($course_args);
  24.  
  25.     $course_post_id = array();
  26.  
  27.     if ($course_query->have_posts()) {
  28.         while ($course_query->have_posts()) {
  29.             $course_query->the_post();
  30.             array_push($course_post_id, get_the_ID());
  31.         }
  32.     }
  33.  
  34.     $meta_boxes[] = [
  35.         'title'      => __('Event Schedule', 'your-text-domain'),
  36.         'id'         => 'qrsi2',
  37.         'post_types' => ['events'],
  38.         'include'    => [
  39.             'relation'       => 'OR',
  40.             'event-category' => [15],
  41.         ],
  42.  
  43.  
  44.         'fields' => [
  45.             [
  46.                 'name'       => __('Schedule Block 1', 'your-text-domain'),
  47.                 'id'         => 'schedule_block_1',
  48.                 'type'       => 'group',
  49.                 'clone'      => true,
  50.                 'sort_clone' => true,
  51.                 'fields'     => array(
  52.                     array(
  53.                         'name' => __('Course Name', 'your-text-domain'),
  54.                         'id'   => 'course_name',
  55.                         'type' => 'post',
  56.                         'post_type' => 'course',
  57.                         'field_type' => 'select_advanced',
  58.                         'columns' => 6,
  59.                         'placeholder' => __('Select an Item', 'your-text-domain'),
  60.                         'query_args' => array(
  61.                             'relationship' => array(
  62.                                 'id'   => 'event-to-course-relationship',
  63.                                 'from' => $post_id,
  64.                             ),
  65.                             'post_status' => 'publish',
  66.                             'posts_per_page' => -1,
  67.                             'order' => 'ASC',
  68.                             'orderby' => 'name',
  69.                         )
  70.                     ),
  71.  
  72.                     array(
  73.                         'name' => __('Scholar Name', 'your-text-domain'),
  74.                         'id'   => 'scholar_name',
  75.                         'type' => 'post',
  76.                         'post_type' => 'scholar',
  77.                         'field_type' => 'select_advanced',
  78.                         'multiple' => true,
  79.                         'columns' => 6,
  80.                         'placeholder' => __('Select an Item', 'your-text-domain'),
  81.                         'query_args' => array(
  82.                             'relationship' => array(
  83.                                 'id'   => 'from-course-to-scholar',
  84.                                 'from' => $course_post_id,
  85.                             ),
  86.                             'post_status' => 'publish',
  87.                             'posts_per_page' => -1,
  88.                             'order' => 'ASC',
  89.                             'orderby' => 'name',
  90.                         )
  91.                     )
  92.                 )
  93.             ],
  94.             [
  95.                 'name'       => __('Schedule Block 2', 'your-text-domain'),
  96.                 'id'         => 'schedule_block_2a',
  97.                 'type'       => 'group',
  98.                 'clone'      => true,
  99.                 'sort_clone' => true,
  100.                 'fields'     => array(
  101.                     array(
  102.                         'name' => __('Course Name', 'your-text-domain'),
  103.                         'id'   => 'course_name_2a',
  104.                         'type' => 'post',
  105.                         'post_type' => 'course',
  106.                         'field_type' => 'select_advanced',
  107.                         'columns' => 6,
  108.                         'placeholder' => __('Select an Item', 'your-text-domain'),
  109.                         'query_args' => array(
  110.                             'relationship' => array(
  111.                                 'id'   => 'event-to-course-relationship',
  112.                                 'from' => $post_id,
  113.                             ),
  114.                             'post_status' => 'publish',
  115.                             'posts_per_page' => -1,
  116.                             'order' => 'ASC',
  117.                             'orderby' => 'name',
  118.                         )
  119.                     ),
  120.  
  121.                     array(
  122.                         'name' => __('Scholar Name', 'your-text-domain'),
  123.                         'id'   => 'scholar_name_2',
  124.                         'type' => 'post',
  125.                         'post_type' => 'scholar',
  126.                         'field_type' => 'select_advanced',
  127.                         'multiple' => true,
  128.                         'columns' => 6,
  129.                         'placeholder' => __('Select an Item', 'your-text-domain'),
  130.                         'query_args' => array(
  131.                             'relationship' => array(
  132.                                 'id'   => 'from-course-to-scholar',
  133.                                 'from' => $course_post_id,
  134.                             ),
  135.                             'post_status' => 'publish',
  136.                             'posts_per_page' => -1,
  137.                             'order' => 'ASC',
  138.                             'orderby' => 'name',
  139.                         )
  140.                     )
  141.                 )
  142.             ],
  143.             [
  144.                 'name'       => __('Schedule Block 3', 'your-text-domain'),
  145.                 'id'         => 'schedule_block_3',
  146.                 'type'       => 'group',
  147.                 'clone'      => true,
  148.                 'sort_clone' => true,
  149.                 'fields'     => array(
  150.                     array(
  151.                         'name' => __('Course Name', 'your-text-domain'),
  152.                         'id'   => 'course_name_3',
  153.                         'type' => 'post',
  154.                         'post_type' => 'course',
  155.                         'field_type' => 'select_advanced',
  156.                         'columns' => 6,
  157.                         'placeholder' => __('Select an Item', 'your-text-domain'),
  158.                         'query_args' => array(
  159.                             'relationship' => array(
  160.                                 'id'   => 'event-to-course-relationship',
  161.                                 'from' => $post_id,
  162.                             ),
  163.                             'post_status' => 'publish',
  164.                             'posts_per_page' => -1,
  165.                             'order' => 'ASC',
  166.                             'orderby' => 'name',
  167.                         )
  168.                     ),
  169.  
  170.                     array(
  171.                         'name' => __('Scholar Name', 'your-text-domain'),
  172.                         'id'   => 'scholar_name_3',
  173.                         'type' => 'post',
  174.                         'post_type' => 'scholar',
  175.                         'field_type' => 'select_advanced',
  176.                         'multiple' => true,
  177.                         'columns' => 6,
  178.                         'placeholder' => __('Select an Item', 'your-text-domain'),
  179.                         'query_args' => array(
  180.                             'relationship' => array(
  181.                                 'id'   => 'from-course-to-scholar',
  182.                                 'from' => $course_post_id,
  183.                             ),
  184.                             'post_status' => 'publish',
  185.                             'posts_per_page' => -1,
  186.                             'order' => 'ASC',
  187.                             'orderby' => 'name',
  188.                         )
  189.                     )
  190.                 )
  191.             ],
  192.             [
  193.                 'name'       => __('Schedule Block 4', 'your-text-domain'),
  194.                 'id'         => 'schedule_block_4',
  195.                 'type'       => 'group',
  196.                 'clone'      => true,
  197.                 'sort_clone' => true,
  198.                 'fields'     => array(
  199.                     array(
  200.                         'name' => __('Course Name', 'your-text-domain'),
  201.                         'id'   => 'course_name_4',
  202.                         'type' => 'post',
  203.                         'post_type' => 'course',
  204.                         'field_type' => 'select_advanced',
  205.                         'columns' => 6,
  206.                         'placeholder' => __('Select an Item', 'your-text-domain'),
  207.                         'query_args' => array(
  208.                             'relationship' => array(
  209.                                 'id'   => 'event-to-course-relationship',
  210.                                 'from' => $post_id,
  211.                             ),
  212.                             'post_status' => 'publish',
  213.                             'posts_per_page' => -1,
  214.                             'order' => 'ASC',
  215.                             'orderby' => 'name',
  216.                         )
  217.                     ),
  218.  
  219.                     array(
  220.                         'name' => __('Scholar Name', 'your-text-domain'),
  221.                         'id'   => 'scholar_name_4',
  222.                         'type' => 'post',
  223.                         'post_type' => 'scholar',
  224.                         'field_type' => 'select_advanced',
  225.                         'multiple' => true,
  226.                         'columns' => 6,
  227.                         'placeholder' => __('Select an Item', 'your-text-domain'),
  228.                         'query_args' => array(
  229.                             'relationship' => array(
  230.                                 'id'   => 'from-course-to-scholar',
  231.                                 'from' => $course_post_id,
  232.                             ),
  233.                             'post_status' => 'publish',
  234.                             'posts_per_page' => -1,
  235.                             'order' => 'ASC',
  236.                             'orderby' => 'name',
  237.                         )
  238.                     )
  239.                 )
  240.             ],
  241.             [
  242.                 'name'       => __('Schedule Block 5', 'your-text-domain'),
  243.                 'id'         => 'schedule_block_5',
  244.                 'type'       => 'group',
  245.                 'clone'      => true,
  246.                 'sort_clone' => true,
  247.                 'fields'     => array(
  248.                     array(
  249.                         'name' => __('Course Name', 'your-text-domain'),
  250.                         'id'   => 'course_name_5',
  251.                         'type' => 'post',
  252.                         'post_type' => 'course',
  253.                         'field_type' => 'select_advanced',
  254.                         'columns' => 6,
  255.                         'placeholder' => __('Select an Item', 'your-text-domain'),
  256.                         'query_args' => array(
  257.                             'relationship' => array(
  258.                                 'id'   => 'event-to-course-relationship',
  259.                                 'from' => $post_id,
  260.                             ),
  261.                             'post_status' => 'publish',
  262.                             'posts_per_page' => -1,
  263.                             'order' => 'ASC',
  264.                             'orderby' => 'name',
  265.                         )
  266.                     ),
  267.  
  268.                     array(
  269.                         'name' => __('Scholar Name', 'your-text-domain'),
  270.                         'id'   => 'scholar_name_5',
  271.                         'type' => 'post',
  272.                         'post_type' => 'scholar',
  273.                         'field_type' => 'select_advanced',
  274.                         'multiple' => true,
  275.                         'columns' => 6,
  276.                         'placeholder' => __('Select an Item', 'your-text-domain'),
  277.                         'query_args' => array(
  278.                             'relationship' => array(
  279.                                 'id'   => 'from-course-to-scholar',
  280.                                 'from' => $course_post_id,
  281.                             ),
  282.                             'post_status' => 'publish',
  283.                             'posts_per_page' => -1,
  284.                             'order' => 'ASC',
  285.                             'orderby' => 'name',
  286.                         )
  287.                     )
  288.                 )
  289.             ],
  290.         ],
  291.  
  292.     ];
  293.  
  294.  
  295.  
  296.     return $meta_boxes;
  297. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement