| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: Event Post |
| 4 | 4 | * Plugin URI: https://event-post.com?mtm_campaign=wp-plugin&mtm_kwd=event-post&mtm_medium=dashboard&mtm_source=plugin-uri |
| 5 | 5 | * Description: Add calendar and/or geolocation metadata on any posts. |
| 6 | - * Version: 6.1.0 | |
| 6 | + * Version: 6.1.2 | |
| 7 | 7 | * Author: N.O.U.S. Open Useful and Simple |
| 8 | 8 | * Contributors: bastho, sabrinaleroy, unecologeek, agencenous |
| 9 | 9 | * Author URI: https://apps.avecnous.eu/?mtm_campaign=wp-plugin&mtm_kwd=event-post&mtm_medium=dashboard&mtm_source=author |
| 10 | 10 | * License: GPLv2 |
| @@ -43,12 +43,15 @@ | ||
| 43 | 43 | */ |
| 44 | 44 | class EventPost { |
| 45 | 45 | /** |
| 46 | 46 | * The current version |
| 47 | - * | |
| 48 | - * @var array | |
| 47 | + * | |
| 48 | + * Must be kept in sync with the `Version:` plugin header above: `bin/bump` | |
| 49 | + * only rewrites header-style declarations, not this literal. | |
| 50 | + * | |
| 51 | + * @var string | |
| 49 | 52 | */ |
| 50 | - public $version = '5.9.2'; | |
| 53 | + public $version = '6.1.2'; | |
| 51 | 54 | |
| 52 | 55 | // -------------------------------------------------------------------------------- |
| 53 | 56 | // Post metas |
| 54 | 57 | |
| @@ -1521,10 +1524,10 @@ | ||
| 1521 | 1524 | $datas_cat = $this->print_categories($post, $context); |
| 1522 | 1525 | $datas_loc = $this->print_location($post, $context); |
| 1523 | 1526 | $classes = array( |
| 1524 | 1527 | 'event_data', |
| 1525 | - 'status-'.strtolower(str_replace('Event', '', $event->status)), | |
| 1526 | - 'location-type-'.strtolower(str_replace('EventAttendanceMode', '', $event->attendance_mode)), | |
| 1528 | + 'status-'.strtolower(str_replace('Event', '', $post->status)), | |
| 1529 | + 'location-type-'.strtolower(str_replace('EventAttendanceMode', '', $post->attendance_mode)), | |
| 1527 | 1530 | $class |
| 1528 | 1531 | ); |
| 1529 | 1532 | if ($datas_date != '' || $datas_loc != '') { |
| 1530 | 1533 | $rgb = $this->hex2dec($post->color); |
| @@ -1781,16 +1784,18 @@ | ||
| 1781 | 1784 | $previous_month = $atts['separate_months'] ? true : false; |
| 1782 | 1785 | } |
| 1783 | 1786 | |
| 1784 | 1787 | foreach ($events as $event) { |
| 1785 | - if($previous_year && $previous_year !== date('Y', $event->time_start)){ | |
| 1786 | - $html.= '<div class="event-timeline-separator event-timeline-year"><span class="event-timeline-year-text">'.date_i18n('Y', $event->time_start).'</span></div>'; | |
| 1787 | - $previous_year = date('Y', $event->time_start); | |
| 1788 | + if($id === 'event_timeline'){ | |
| 1789 | + if($previous_year && $previous_year !== date('Y', $event->time_start)){ | |
| 1790 | + $html.= '<div class="event-timeline-separator event-timeline-year"><span class="event-timeline-year-text">'.date_i18n('Y', $event->time_start).'</span></div>'; | |
| 1791 | + $previous_year = date('Y', $event->time_start); | |
| 1792 | + } | |
| 1793 | + if($previous_month && $previous_month !== date('Ym', $event->time_start)){ | |
| 1794 | + $html.= '<div class="event-timeline-separator event-timeline-month"><span class="event-timeline-month-text">'.date_i18n('F', $event->time_start).'</span>'.($previous_year ? '' : ' <span class="event-timeline-year-text">'.date_i18n('Y', $event->time_start).'</span>').'</div>'; | |
| 1795 | + $previous_month = date('Ym', $event->time_start); | |
| 1796 | + } | |
| 1788 | 1797 | } |
| 1789 | - if($previous_month && $previous_month !== date('Ym', $event->time_start)){ | |
| 1790 | - $html.= '<div class="event-timeline-separator event-timeline-month"><span class="event-timeline-month-text">'.date_i18n('F', $event->time_start).'</span>'.($previous_year ? '' : ' <span class="event-timeline-year-text">'.date_i18n('Y', $event->time_start).'</span>').'</div>'; | |
| 1791 | - $previous_month = date('Ym', $event->time_start); | |
| 1792 | - } | |
| 1793 | 1798 | $text_price = $this->get_price($event,true); |
| 1794 | 1799 | $class_item = array( |
| 1795 | 1800 | $this->is_future($event) ? 'event_future' : 'event_past', |
| 1796 | 1801 | 'status-'.strtolower(str_replace('Event', '', $event->status)), |
| @@ -1887,9 +1892,9 @@ | ||
| 1887 | 1892 | ]; |
| 1888 | 1893 | if(!empty($align)){ |
| 1889 | 1894 | $classes[] = 'align'.esc_attr($align); |
| 1890 | 1895 | } |
| 1891 | - if($previous_year || $previous_month){ | |
| 1896 | + if($id === 'event_timeline' && ($previous_year || $previous_month)){ | |
| 1892 | 1897 | $classes[] = 'has-time-separators'; |
| 1893 | 1898 | } |
| 1894 | 1899 | $ret.=str_replace( |
| 1895 | 1900 | array( |
| @@ -2497,9 +2502,9 @@ | ||
| 2497 | 2502 | * |
| 2498 | 2503 | * @return void |
| 2499 | 2504 | */ |
| 2500 | 2505 | function inline_save(){ |
| 2501 | - $post_id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT); | |
| 2506 | + $post_id = absint(filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT)); | |
| 2502 | 2507 | $this->save_postdata($post_id); |
| 2503 | 2508 | } |
| 2504 | 2509 | /** |
| 2505 | 2510 | * When the post is saved, saves our custom data |
| @@ -2512,12 +2517,17 @@ | ||
| 2512 | 2517 | if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){ |
| 2513 | 2518 | return; |
| 2514 | 2519 | } |
| 2515 | 2520 | |
| 2516 | - if (!wp_verify_nonce(filter_input(INPUT_POST, 'eventpost_nonce'), plugin_basename(__FILE__))){ | |
| 2521 | + if (!wp_verify_nonce((string) filter_input(INPUT_POST, 'eventpost_nonce'), plugin_basename(__FILE__))){ | |
| 2517 | 2522 | return; |
| 2518 | 2523 | } |
| 2519 | 2524 | |
| 2525 | + $post_id = absint($post_id); | |
| 2526 | + if (!$post_id || !current_user_can('edit_post', $post_id)) { | |
| 2527 | + return; | |
| 2528 | + } | |
| 2529 | + | |
| 2520 | 2530 | // Clean color or no color |
| 2521 | 2531 | if (false !== $color = filter_input(INPUT_POST, $this->META_COLOR)) { |
| 2522 | 2532 | update_post_meta($post_id, $this->META_COLOR, sanitize_text_field($color)); |
| 2523 | 2533 | } |
| @@ -3204,13 +3214,16 @@ | ||
| 3204 | 3214 | if (in_array($format, $allowed_formats)) { |
| 3205 | 3215 | $export_file = plugin_dir_path(__FILE__) . 'inc/export/' . $format . '.php'; |
| 3206 | 3216 | if (is_numeric($event_id) && file_exists($export_file)) { |
| 3207 | 3217 | $event = $this->retreive($event_id); |
| 3218 | + if($event->post_status != 'publish'){ | |
| 3219 | + wp_die(esc_html__('Event not found.', 'event-post'), 404); | |
| 3220 | + } | |
| 3208 | 3221 | include $export_file; |
| 3209 | 3222 | exit; |
| 3210 | 3223 | } |
| 3211 | 3224 | } |
| 3212 | - wp_die(esc_html__('Invalid request.', 'event-post')); | |
| 3225 | + wp_die(esc_html__('Invalid request.', 'event-post'), 400); | |
| 3213 | 3226 | } |
| 3214 | 3227 | |
| 3215 | 3228 | |
| 3216 | 3229 | public function parse_request(){ |