| | |
| | | <?php |
| | | namespace JVBase\registrar\helpers; |
| | | |
| | | use DateTime; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | use WP_Post; |
| | |
| | | '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, |
| | | ], |
| | |
| | | 'max_participants' => [ |
| | | 'type' => 'number', |
| | | 'label' => 'Maximum Participants', |
| | | 'hint' => 'Leave 0 for no maximum' |
| | | ], |
| | | 'is_free' => [ |
| | | 'type' => 'true_false', |
| | |
| | | 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); |