| | |
| | | <?php |
| | | namespace JVBase\registrar\helpers; |
| | | |
| | | use DateTime; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | use WP_Post; |
| | |
| | | 'label' => 'Make Multi-Day Event', |
| | | 'default' => false, |
| | | ], |
| | | 'date_end' => [ |
| | | 'type' => 'date', |
| | | 'label' => 'Date End', |
| | | 'condition' => [ |
| | | 'field' => 'make_multiple', |
| | | 'operator' => '==', |
| | | 'value' => 1 |
| | | ] |
| | | ], |
| | | // 'date_end' => [ |
| | | // 'type' => 'date', |
| | | // 'label' => 'Date End', |
| | | // 'condition' => [ |
| | | // 'field' => 'make_multiple', |
| | | // 'operator' => '==', |
| | | // 'value' => 1 |
| | | // ] |
| | | // ], |
| | | 'past' => [ |
| | | 'type' => 'true_false', |
| | | 'label' => 'Past Event', |
| | | 'hidden' => true, |
| | | ], |
| | | 'year' => [ |
| | | 'type' => 'number', |
| | | 'type' => 'text', |
| | | 'subtype' => 'number', |
| | | 'label' => 'Year', |
| | | 'hidden' => true, |
| | | ], |
| | | 'month' => [ |
| | | 'type' => 'number', |
| | | 'type' => 'text', |
| | | 'subtype' => 'number', |
| | | 'label' => 'Month', |
| | | 'hidden' => true, |
| | | ], |
| | | 'day' => [ |
| | | 'type' => 'number', |
| | | 'type' => 'text', |
| | | 'subtype' => 'number', |
| | | 'label' => 'Day', |
| | | 'hidden' => true, |
| | | ], |
| | |
| | | 'type' => 'repeater', |
| | | 'label' => 'Daily Schedule', |
| | | 'description' => 'Set specific times for multi-day events', |
| | | 'add_label' => 'Add Day', |
| | | 'row_label' => 'New Day', |
| | | 'condition' => [ |
| | | 'field' => 'make_multiple', |
| | | 'operator' => '==', |
| | |
| | | 'max_participants' => [ |
| | | 'type' => 'number', |
| | | 'label' => 'Maximum Participants', |
| | | 'hint' => 'Leave 0 for no maximum' |
| | | ], |
| | | 'is_free' => [ |
| | | 'type' => 'true_false', |
| | |
| | | 'label' => 'Drop-ins Welcome?', |
| | | 'default' => true, |
| | | ], |
| | | 'recurrence' => [ |
| | | 'type' => 'group', |
| | | 'label' => 'Event Recurrence', |
| | | 'condition' => [ |
| | | 'field' => 'status', |
| | | 'operator' => '==', |
| | | 'value' => 'repeat', |
| | | ], |
| | | 'fields' => [ |
| | | 'recurrence_type' => [ |
| | | 'type' => 'select', |
| | | 'label' => 'Repeats', |
| | | 'options' => [ |
| | | 'daily' => 'Daily', |
| | | 'weekly' => 'Weekly', |
| | | 'monthly' => 'Monthly', |
| | | 'custom' => 'Custom' |
| | | ] |
| | | ], |
| | | 'recurrence_interval' => [ |
| | | 'type' => 'number', |
| | | 'label' => 'Every', |
| | | 'description' => 'Repeat every X days/weeks/months', |
| | | 'default' => 1, |
| | | ], |
| | | 'recurrence_days' => [ |
| | | 'type' => 'set', |
| | | 'label' => 'On These Days', |
| | | 'options' => [ |
| | | 'monday' => 'Monday', |
| | | 'tuesday' => 'Tuesday', |
| | | 'wednesday' => 'Wednesday', |
| | | 'thursday' => 'Thursday', |
| | | 'friday' => 'Friday', |
| | | 'saturday' => 'Saturday', |
| | | 'sunday' => 'Sunday' |
| | | ], |
| | | 'condition' => [ |
| | | 'field' => 'recurrence_type', |
| | | 'operator' => '==', |
| | | 'value' => 'weekly' |
| | | ] |
| | | ], |
| | | 'recurrence_ends' => [ |
| | | 'type' => 'group', |
| | | 'label' => 'Recurrence Ends', |
| | | 'fields' => [ |
| | | 'type' => [ |
| | | 'type' => 'select', |
| | | 'label' => 'Recurrence Ends', |
| | | 'options' => [ |
| | | 'never' => 'Never', |
| | | 'after' => 'After X occurrences', |
| | | 'on' => 'On date' |
| | | ] |
| | | ], |
| | | 'count' => [ |
| | | 'type' => 'number', |
| | | 'label' => 'Number of occurrences', |
| | | 'condition' => [ |
| | | 'field' => 'type', |
| | | 'operator' => '==', |
| | | 'value' => 'after' |
| | | ] |
| | | ], |
| | | 'date' => [ |
| | | 'type' => 'date', |
| | | 'label' => 'End date', |
| | | 'condition' => [ |
| | | 'field' => 'type', |
| | | 'operator' => '==', |
| | | 'value' => 'on' |
| | | ] |
| | | ] |
| | | ], |
| | | ], |
| | | |
| | | 'rsvp_required' => [ |
| | | 'type' => 'true_false', |
| | | 'label' => 'RSVP Required?' |
| | | ], |
| | | 'rsvp_limit' => [ |
| | | 'type' => 'number', |
| | | 'label' => 'RSVP Limit', |
| | | 'condition' => [ |
| | | 'field' => 'rsvp_required', |
| | | 'operator' => '==', |
| | | 'value' => 1 |
| | | ] |
| | | ], |
| | | 'rsvp_deadline' => [ |
| | | 'type' => 'datetime', |
| | | 'label' => 'RSVP Deadline', |
| | | 'condition' => [ |
| | | 'field' => 'rsvp_required', |
| | | 'operator' => '==', |
| | | 'value' => 1 |
| | | ] |
| | | ], |
| | | //TODO |
| | | //RECURRENCE |
| | | // 'make_recurring' => [ |
| | | // 'type' => 'true_false', |
| | | // 'label' => 'Make Repeating Event', |
| | | // 'default' => 0, |
| | | // ], |
| | | // 'recurrence_type' => [ |
| | | // 'type' => 'select', |
| | | // 'label' => 'Repeats', |
| | | // 'options' => [ |
| | | // 'daily' => 'Daily', |
| | | // 'weekly' => 'Weekly', |
| | | // 'monthly' => 'Monthly', |
| | | // 'custom' => 'Custom' |
| | | // ], |
| | | // 'condition' => [ |
| | | // 'field' => 'make_recurring', |
| | | // 'operator' => '==', |
| | | // 'value' => '1', |
| | | // ], |
| | | // ], |
| | | // 'recurrence_interval' => [ |
| | | // 'type' => 'number', |
| | | // 'label' => 'Repeat', |
| | | // 'description' => 'Repeat every X days/weeks/months', |
| | | // 'default' => 1, |
| | | // |
| | | // 'condition' => [ |
| | | // 'field' => 'make_recurring', |
| | | // 'operator' => '==', |
| | | // 'value' => '1', |
| | | // ], |
| | | // ], |
| | | // 'recurrence_days' => [ |
| | | // 'type' => 'set', |
| | | // 'label' => 'On These Days', |
| | | // 'options' => [ |
| | | // 'monday' => 'Monday', |
| | | // 'tuesday' => 'Tuesday', |
| | | // 'wednesday' => 'Wednesday', |
| | | // 'thursday' => 'Thursday', |
| | | // 'friday' => 'Friday', |
| | | // 'saturday' => 'Saturday', |
| | | // 'sunday' => 'Sunday' |
| | | // ], |
| | | // 'condition' => [ |
| | | // 'field' => 'recurrence_type', |
| | | // 'operator' => '==', |
| | | // 'value' => 'weekly' |
| | | // ] |
| | | // ], |
| | | // 'recurrence_ends' => [ |
| | | // 'type' => 'select', |
| | | // 'label' => 'Recurrence Ends', |
| | | // 'options' => [ |
| | | // 'never' => 'Never', |
| | | // 'after' => 'After X occurrences', |
| | | // 'on' => 'On date' |
| | | // ], |
| | | // 'condition' => [ |
| | | // 'field' => 'make_recurring', |
| | | // 'operator' => '==', |
| | | // 'value' => '1', |
| | | // ], |
| | | // ], |
| | | // 'recurrence_ends_number' => [ |
| | | // 'type' => 'number', |
| | | // 'label' => 'Number of occurrences', |
| | | // 'condition' => [ |
| | | // 'field' => 'recurrence_ends', |
| | | // 'operator' => '==', |
| | | // 'value' => 'after', |
| | | // ], |
| | | // ], |
| | | // 'recurrence_ends_date' => [ |
| | | // 'type' => 'date', |
| | | // 'label' => 'End date', |
| | | // 'condition' => [ |
| | | // 'field' => 'recurrence_ends', |
| | | // 'operator' => '==', |
| | | // 'value' => 'on' |
| | | // ] |
| | | // ], |
| | | |
| | | //RSVP |
| | | 'rsvp_required' => [ |
| | | 'type' => 'true_false', |
| | | 'label' => 'RSVP Required?' |
| | | ], |
| | | 'rsvp_limit' => [ |
| | | 'type' => 'number', |
| | | 'label' => 'RSVP Limit', |
| | | 'condition' => [ |
| | | 'field' => 'rsvp_required', |
| | | 'operator' => '==', |
| | | 'value' => 1 |
| | | ] |
| | | ] |
| | | ], |
| | | 'rsvp_deadline' => [ |
| | | 'type' => 'datetime', |
| | | 'label' => 'RSVP Deadline', |
| | | 'condition' => [ |
| | | 'field' => 'rsvp_required', |
| | | 'operator' => '==', |
| | | 'value' => 1 |
| | | ] |
| | | ], |
| | | ]; |
| | | |
| | | foreach ($fields as $name => $config) { |
| | |
| | | if ($post->post_type === $this->postType) { |
| | | $get = ['year', 'month','day']; |
| | | $values = Meta::forPost($post->ID)->getAll($get); |
| | | |
| | | if (empty($values['year']) || empty($values['month']) || empty($values['day'])) { |
| | | $value = Meta::forPost($post->ID)->get('date_start'); |
| | | if (!empty($value)) { |
| | | $date = new DateTime($value, wp_timezone()); |
| | | $year = $date->format('Y'); |
| | | $month = $date->format('m'); |
| | | $day = $date->format('d'); |
| | | |
| | | $values = [ |
| | | 'year' => $year, |
| | | 'month' => $month, |
| | | 'day' => $day |
| | | ]; |
| | | Meta::forPost($post->ID)->setAll($values); |
| | | } |
| | | } |
| | | foreach ($values as $key => $value) { |
| | | if (!empty($value) && $value !== 0) { |
| | | $url = str_replace("%e$key%", $value, $url); |