Event Calendar WD – Responsive Event Calendar plugin - Version 1.1.20

Version Description

  • New: Reset option for settings
  • New: Notices about extensions compatibility (Premium)
  • New: Delete past events
  • Improved: Import/Export menues merged into one (Premium)
  • Improved: Recurring events query with caching for better performance (Premium)
  • Improved: Number of upcoming events uses posts_per_page as default
  • Improved: Better UX when setting Date and time format
  • Changed: Do not allow to delete the last theme (Premium)
  • Changed: Restore themes if all are deleted
  • Changed: Recurring events are added to the slider of related and upcoming events
  • Changed: Other optimizations under the hood
  • Fixed: Calendar theme shouldn't have view (Premium)
  • Fixed: Strip shortcodes from event subscription email (Premium)
  • Fixed: Fatal error when inserting countdown in calendar or event content (Premium)
Download this release

Release Info

Developer webdorado
Plugin Icon 128x128 Event Calendar WD – Responsive Event Calendar plugin
Version 1.1.20
Comparing to
See all releases

Code changes from version 1.1.18 to 1.1.20

changelog.txt CHANGED
@@ -1,11 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  = 1.1.18 =
2
- * Fixed: Security issue
3
 
4
  = 1.1.17 =
5
  * New: Calendar uninstall
6
- * Improved: Importing iCal all day events (Premium)
7
- * New: Respect event timezone when importing iCal (Premium, requires extension update)
8
- * Fixed: New lines in iCal events descriptions (Premium)
9
  * Improved: Default values of events metadata
10
  * Changed: Other optimizations under the hood
11
 
@@ -20,7 +39,6 @@
20
  * Changed: Date inputs hidden from event quick edit params
21
  * Changed: Other optimizations under the hood
22
 
23
-
24
  = 1.1.15 =
25
  * Improved: Fully translatable calendar plugin and extensions. Suggest your translations here: https://translate.wordpress.org/projects/wp-plugins/event-calendar-wd
26
  * Improved: Frontend styles of single event, venue and organizer CPT
1
+ = 1.1.20 =
2
+ * New: Reset option for settings
3
+ * New: Notices about extensions compatibility (Premium)
4
+ * New: Delete past events
5
+ * Improved: Import/Export menues merged into one (Premium)
6
+ * Improved: Recurring events query with caching for better performance (Premium)
7
+ * Improved: Number of upcoming events uses posts_per_page as default
8
+ * Improved: Better UX when setting Date and time format
9
+ * Changed: Do not allow to delete the last theme (Premium)
10
+ * Changed: Restore themes if all are deleted
11
+ * Changed: Recurring events are added to the slider of related and upcoming events
12
+ * Changed: Other optimizations under the hood
13
+ * Fixed: Calendar theme shouldn't have view (Premium)
14
+ * Fixed: Strip shortcodes from event subscription email (Premium)
15
+ ** Fixed: Fatal error when inserting countdown in calendar or event content (Premium)
16
+
17
+ = 1.1.19 =
18
+ * Fixed: Fatal error on PHP 5.4 (Premium)
19
+
20
  = 1.1.18 =
21
+ * Fixed: Security issue
22
 
23
  = 1.1.17 =
24
  * New: Calendar uninstall
25
+ * Improved: Importing iCal all day events
26
+ * New: Respect event timezone when importing iCal (requires extension update)
27
+ * Fixed: New lines in iCal events descriptions
28
  * Improved: Default values of events metadata
29
  * Changed: Other optimizations under the hood
30
 
39
  * Changed: Date inputs hidden from event quick edit params
40
  * Changed: Other optimizations under the hood
41
 
 
42
  = 1.1.15 =
43
  * Improved: Fully translatable calendar plugin and extensions. Suggest your translations here: https://translate.wordpress.org/projects/wp-plugins/event-calendar-wd
44
  * Improved: Frontend styles of single event, venue and organizer CPT
css/admin/admin.css CHANGED
@@ -243,6 +243,7 @@
243
  #ecwd-settings-content .nav-tab-wrapper a {
244
  display: inline-block;
245
  border: 1px solid #A5A5A5;
 
246
  }
247
 
248
  .ecwd-tabs li a,
@@ -341,21 +342,26 @@ span.ecwd_error {
341
  font-size: 17px;
342
  }
343
 
344
- #ecwd-settings a.button:not(.wd_notice_button) {
345
- border: 1px solid #A1A1A1;
346
- padding: 0px 15px;
347
- box-shadow: none;
348
- border-radius: 0;
349
- color: #000;
350
- font-weight: bold;
351
- }
352
 
353
- #ecwd-settings a.button:hover {
354
- border: 1px solid transparent;
355
- color: #fff;
356
- background: #0074A2;
 
 
 
 
357
  }
358
 
 
359
  #ecwd_event_location{
360
  background-image: none !important;
361
  width: 100%;
@@ -470,16 +476,16 @@ span.ecwd_error {
470
  top: 2px;
471
  }
472
 
473
- #ecwd-settings input[type="submit"] {
474
- background: #0074A2;
475
- color: #ffffff;
476
- font-weight: bold;
477
- font-size: 15px;
478
- border: 0;
479
- border-radius: 0;
480
- padding: 5px 25px;
481
- height: auto;
482
- }
483
 
484
  #ecwd_event_meta .checkbox-div label,
485
  #ecwd_event_venue_meta .checkbox-div label,
@@ -1022,4 +1028,48 @@ body.wp-admin.post-type-ecwd_event #posts-filter .alignleft.actions a.button {
1022
  }
1023
  .post-type-ecwd_event fieldset.inline-edit-date {
1024
  display: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1025
  }
243
  #ecwd-settings-content .nav-tab-wrapper a {
244
  display: inline-block;
245
  border: 1px solid #A5A5A5;
246
+ margin-bottom:6px;
247
  }
248
 
249
  .ecwd-tabs li a,
342
  font-size: 17px;
343
  }
344
 
345
+ /*#ecwd-settings a.button:not(.wdi_notice_button) {*/
346
+ /*border: 1px solid #A1A1A1;*/
347
+ /*padding: 0px 15px;*/
348
+ /*box-shadow: none;*/
349
+ /*border-radius: 0;*/
350
+ /*color: #000;*/
351
+ /*font-weight: bold;*/
352
+ /*}*/
353
 
354
+ /*#ecwd-settings a.button:hover {*/
355
+ /*border: 1px solid transparent;*/
356
+ /*color: #fff;*/
357
+ /*background: #0074A2;*/
358
+ /*}*/
359
+
360
+ #ecwd_reset_settings_button{
361
+ margin-left: 4px;
362
  }
363
 
364
+
365
  #ecwd_event_location{
366
  background-image: none !important;
367
  width: 100%;
476
  top: 2px;
477
  }
478
 
479
+ /*#ecwd-settings input[type="submit"] {*/
480
+ /*background: #0074A2;*/
481
+ /*color: #ffffff;*/
482
+ /*font-weight: bold;*/
483
+ /*font-size: 15px;*/
484
+ /*border: 0;*/
485
+ /*border-radius: 0;*/
486
+ /*padding: 5px 25px;*/
487
+ /*height: auto;*/
488
+ /*}*/
489
 
490
  #ecwd_event_meta .checkbox-div label,
491
  #ecwd_event_venue_meta .checkbox-div label,
1028
  }
1029
  .post-type-ecwd_event fieldset.inline-edit-date {
1030
  display: none;
1031
+ }
1032
+
1033
+ .ecwd_event_list_popup_loader, .ecwd_past_event_list_popup_loader{
1034
+ display: none;
1035
+ margin: 0 auto;
1036
+ width: 70px;
1037
+ margin-top: calc(100px - 35px);
1038
+ }
1039
+ .ecwd_add_events_button, .ecwd_delete_events_button{
1040
+ display: none !important;
1041
+ }
1042
+ .ecwd_add_events ,.ecwd_past_events_delete_button{
1043
+ float: left;
1044
+ }
1045
+ #open-popup {padding:20px}
1046
+ .ecwd_event_list_popup, .ecwd_past_event_list_popup {
1047
+ position: relative;
1048
+ background: #FFF;
1049
+ padding: 10px 40px 50px 40px;
1050
+ width: auto;
1051
+ max-width: 800px;
1052
+ margin: 20px auto;
1053
+ text-align: center;
1054
+ min-height: 200px;
1055
+ }
1056
+ .ecwd_popup_notice, .ecwd_popup_title{
1057
+ width: 100%;
1058
+ text-align: left;
1059
+ }
1060
+ .ecwd_popup_notice{
1061
+ margin-bottom: 50px;
1062
+
1063
+ }
1064
+
1065
+ .ecwd_custom_date .checkbox-div-content{
1066
+ width: 170px;
1067
+ display: inline-block;
1068
+ }
1069
+ .ecwd_custom_date input.ecwd_custom_date_el{
1070
+ width: 50px !important;
1071
+ }
1072
+ .ecwd_custom_date {
1073
+ margin-bottom: 5px;
1074
+
1075
  }
ecwd.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Event Calendar WD
4
  * Plugin URI: https://web-dorado.com/products/wordpress-event-calendar-wd.html
5
  * Description: Event Calendar WD is an easy event management and planning tool with advanced features.
6
- * Version: 1.1.18
7
  * Author: WebDorado
8
  * Author URI: https://web-dorado.com/wordpress-plugins-bundle.html
9
  * Text Domain: event-calendar-wd
@@ -25,7 +25,7 @@ if (!defined('ECWD_URL')) {
25
  }
26
 
27
  if (!defined('ECWD_VERSION')) {
28
- define('ECWD_VERSION', "1.1.18");
29
  }
30
 
31
  if (!defined('ECWD_PLUGIN_MAIN_FILE')) {
@@ -40,6 +40,7 @@ if (!defined('ECWD_REST_NAMESPACE')) {
40
  }
41
 
42
  if(get_site_transient('ecwd_uninstall') === false) {
 
43
  add_action('plugins_loaded', array('ECWD', 'get_instance'));
44
  }
45
 
3
  * Plugin Name: Event Calendar WD
4
  * Plugin URI: https://web-dorado.com/products/wordpress-event-calendar-wd.html
5
  * Description: Event Calendar WD is an easy event management and planning tool with advanced features.
6
+ * Version: 1.1.20
7
  * Author: WebDorado
8
  * Author URI: https://web-dorado.com/wordpress-plugins-bundle.html
9
  * Text Domain: event-calendar-wd
25
  }
26
 
27
  if (!defined('ECWD_VERSION')) {
28
+ define('ECWD_VERSION', "1.1.20");
29
  }
30
 
31
  if (!defined('ECWD_PLUGIN_MAIN_FILE')) {
40
  }
41
 
42
  if(get_site_transient('ecwd_uninstall') === false) {
43
+ add_action('plugins_loaded', array('ECWD', 'reset_settings'), 9);
44
  add_action('plugins_loaded', array('ECWD', 'get_instance'));
45
  }
46
 
ecwd_admin_class.php CHANGED
@@ -191,8 +191,10 @@ class ECWD_Admin {
191
  $start_date = date('Y/m/d H:i', strtotime($today . "+1 days"));
192
  $end_date = date('Y/m/d H:i', strtotime($start_date . "+1 hour"));
193
 
 
194
  update_post_meta($post_id, 'ecwd_event_date_from', $start_date);
195
  update_post_meta($post_id, 'ecwd_event_date_to', $end_date);
 
196
  }
197
 
198
 
@@ -250,8 +252,10 @@ class ECWD_Admin {
250
  if($version_option == false){
251
  self::fix_events_locations();
252
  }
253
-
254
- if($version_option == false || version_compare(substr($version_option, 2), '0.83', '<=')) {
 
 
255
  $opt = get_option('ecwd_settings_general');
256
  if (isset($opt['show_events_detail'])) {
257
  $events_opt = get_option('ecwd_settings_events');
@@ -260,11 +264,13 @@ class ECWD_Admin {
260
  }
261
  }
262
 
 
263
  if ($version_option == false || version_compare(substr($version_option, 2), '0.94', '<=')) {
264
  self::update_to_95($calendars);
265
  }
266
 
267
  if ($version_option == false || version_compare(substr($version_option, 2), '1.16', '<')) {
 
268
  $events_opt = get_option('ecwd_settings_events');
269
  if(!isset($events_opt["use_custom_template"])){
270
  $events_opt["use_custom_template"] = ($version_option === false) ? "0" : "1";
@@ -272,6 +278,17 @@ class ECWD_Admin {
272
  }
273
  }
274
 
 
 
 
 
 
 
 
 
 
 
 
275
 
276
  update_option('ecwd_version',ECWD_VERSION);
277
 
@@ -744,8 +761,14 @@ class ECWD_Admin {
744
  ), $scripts_key, true);
745
  $rest_route = add_query_arg(array(
746
  'rest_route' => '/'.ECWD_REST_NAMESPACE . '/'
747
- ), get_home_url()."/");
 
 
 
 
 
748
  wp_localize_script($this->prefix . '-admin-scripts', $this->prefix .'ServerVars', array(
 
749
  'root' => esc_url_raw(rest_url()),
750
  'pluginRestPath' => 'ecwd/v1/',
751
  'rest_route' => $rest_route,
191
  $start_date = date('Y/m/d H:i', strtotime($today . "+1 days"));
192
  $end_date = date('Y/m/d H:i', strtotime($start_date . "+1 hour"));
193
 
194
+ if(empty(get_post_meta($post_id, 'ecwd_event_date_from', true))) {
195
  update_post_meta($post_id, 'ecwd_event_date_from', $start_date);
196
  update_post_meta($post_id, 'ecwd_event_date_to', $end_date);
197
+ }
198
  }
199
 
200
 
252
  if($version_option == false){
253
  self::fix_events_locations();
254
  }
255
+
256
+ $saved_events_opt = get_option('ecwd_settings_events');
257
+
258
+ if($version_option == false || version_compare(substr($version_option, 2), '0.83', '<=')) {
259
  $opt = get_option('ecwd_settings_general');
260
  if (isset($opt['show_events_detail'])) {
261
  $events_opt = get_option('ecwd_settings_events');
264
  }
265
  }
266
 
267
+
268
  if ($version_option == false || version_compare(substr($version_option, 2), '0.94', '<=')) {
269
  self::update_to_95($calendars);
270
  }
271
 
272
  if ($version_option == false || version_compare(substr($version_option, 2), '1.16', '<')) {
273
+
274
  $events_opt = get_option('ecwd_settings_events');
275
  if(!isset($events_opt["use_custom_template"])){
276
  $events_opt["use_custom_template"] = ($version_option === false) ? "0" : "1";
278
  }
279
  }
280
 
281
+ if($version_option == false || version_compare(substr($version_option, 2), '1.18', '<=')) {
282
+ if($saved_events_opt !== false && isset($saved_events_opt['related_events_count'])) {
283
+ if($saved_events_opt['related_events_count'] === "") {
284
+ $events_opt = get_option('ecwd_settings_events');
285
+ $events_opt['related_events_count'] = "100";
286
+ update_option('ecwd_settings_events', $events_opt);
287
+ }
288
+ }
289
+ }
290
+
291
+
292
 
293
  update_option('ecwd_version',ECWD_VERSION);
294
 
761
  ), $scripts_key, true);
762
  $rest_route = add_query_arg(array(
763
  'rest_route' => '/'.ECWD_REST_NAMESPACE . '/'
764
+ ), get_site_url()."/");
765
+ global $post;
766
+ $calendar_id = "";
767
+ if(isset($post->ID)){
768
+ $calendar_id = $post->ID;
769
+ }
770
  wp_localize_script($this->prefix . '-admin-scripts', $this->prefix .'ServerVars', array(
771
+ 'calendar_id' =>$calendar_id,
772
  'root' => esc_url_raw(rest_url()),
773
  'pluginRestPath' => 'ecwd/v1/',
774
  'rest_route' => $rest_route,
ecwd_class.php CHANGED
@@ -41,6 +41,7 @@ class ECWD {
41
  if(!empty($events)) {
42
  usort($events, array($this, 'order_events'));
43
  }
 
44
  $today = date('Y-m-d');
45
  $date_format = 'Y-m-d';
46
  $time_format = 'H:i';
@@ -383,4 +384,13 @@ class ECWD {
383
 
384
  return $timezone_str;
385
  }
 
 
 
 
 
 
 
 
 
386
  }
41
  if(!empty($events)) {
42
  usort($events, array($this, 'order_events'));
43
  }
44
+
45
  $today = date('Y-m-d');
46
  $date_format = 'Y-m-d';
47
  $time_format = 'H:i';
384
 
385
  return $timezone_str;
386
  }
387
+
388
+ public static function reset_settings(){
389
+ if(isset($_POST['ecwd_reset_settings_nonce']) && wp_verify_nonce($_POST['ecwd_reset_settings_nonce'], 'ecwd_reset_settings')) {
390
+ if(isset($_POST['ecwd_reset_settings'])) {
391
+ delete_option($_POST['ecwd_reset_settings']);
392
+ }
393
+ }
394
+ }
395
+
396
  }
includes/ecwd-display-class.php CHANGED
@@ -1470,8 +1470,9 @@ class ECWD_Display {
1470
  if (is_array($array) && !empty($array)) {
1471
  $events_ids = array();
1472
  foreach ($array as $key => $event) {
1473
- if (!in_array($event['id'], $events_ids)) {
1474
- $events_ids[] = $event['id'];
 
1475
  } else {
1476
  unset($array[$key]);
1477
  }
1470
  if (is_array($array) && !empty($array)) {
1471
  $events_ids = array();
1472
  foreach ($array as $key => $event) {
1473
+ $id = $event['id'] . $event['from'] . $event['to'];
1474
+ if (!in_array($id, $events_ids)) {
1475
+ $events_ids[] = $id;
1476
  } else {
1477
  unset($array[$key]);
1478
  }
includes/ecwd-shortcodes.php CHANGED
@@ -10,6 +10,10 @@
10
  include_once(ABSPATH . 'wp-admin/includes/plugin.php');
11
  function ecwd_shortcode($attr) {
12
 
 
 
 
 
13
  extract(shortcode_atts(array(
14
  'id' => null,
15
  'page_items' => '5',
10
  include_once(ABSPATH . 'wp-admin/includes/plugin.php');
11
  function ecwd_shortcode($attr) {
12
 
13
+ if(get_post_type() == "ecwd_event"){
14
+ return "";
15
+ }
16
+
17
  extract(shortcode_atts(array(
18
  'id' => null,
19
  'page_items' => '5',
includes/ecwd_class-rest-api.php CHANGED
@@ -7,305 +7,355 @@
7
  */
8
 
9
  class EcwdRestApi
10
- {
11
 
12
- private static $instance = null;
13
-
14
- private $namespace = ECWD_REST_NAMESPACE;
15
-
16
- private $bases = array(
17
- 'events' => array('/events', true, false, false),//get,post,delete
18
- 'add_event' => array('/add_event', false, true, false),//get,post,delete
19
- );
20
-
21
- /**
22
- * Register the routes for the objects of the controller.
23
- */
24
- public function register_routes()
25
- {
26
- foreach ($this->bases as $key => $route_config) {
27
- $endpoint = $this->get_endpoint($key);
28
-
29
- // readable
30
- if ($route_config[1]) {
31
-
32
- register_rest_route($this->namespace, $endpoint,
33
- array(
34
- 'methods' => \WP_REST_Server::READABLE,
35
- 'callback' => array($this, 'get_item'),
36
- 'permission_callback' => array($this, 'get_items_permissions_check'),
37
- 'args' => array(),
38
- )
39
- );
40
 
41
- }
42
 
43
- // writable
44
- if ($route_config[2]) {
 
 
 
 
45
 
46
- register_rest_route($this->namespace, $endpoint,
47
- array(
48
- 'methods' => \WP_REST_Server::CREATABLE,
49
- 'callback' => array($this, 'update_item'),
50
- 'permission_callback' => array($this, 'create_item_permissions_check'),
51
- 'args' => array(),
52
- )
53
- );
54
 
55
- }
 
56
 
57
- // deletable
58
- if ($route_config[3]) {
 
 
 
 
 
 
59
 
60
- register_rest_route($this->namespace, $endpoint,
61
- array(
62
- 'methods' => \WP_REST_Server::DELETABLE,
63
- 'callback' => array($this, 'delete_item'),
64
- 'permission_callback' => array($this, 'delete_item_permissions_check'),
65
- 'args' => array(),
66
- )
67
- );
 
 
 
 
 
68
 
69
- }
70
  }
71
 
72
- }
 
 
 
 
 
 
 
 
 
 
73
 
74
- /**
75
- * get endpoint route by its key(string identificator )
76
- *
77
- */
78
- private function get_endpoint($key)
79
- {
80
- if (array_key_exists($key, $this->bases)) {
81
- return $this->bases[$key][0];
82
  }
83
- return false;
84
 
 
 
 
 
 
 
 
 
 
 
85
  }
 
86
 
87
- /**
88
- * get endpoint key by its route
89
- *
90
- */
91
- private function parse_endpoint($route)
92
- {
93
- $route_url = substr($route, 6);
94
 
95
- foreach ($this->bases as $key => $value) {
96
- $route_regex = '/' . substr($value[0], 1) . '/';
 
 
 
 
 
97
 
98
- if (preg_match($route_regex, substr($route_url, 1))) {
99
- return $key;
100
- }
 
 
101
  }
 
102
 
103
- return null;
104
 
105
- }
106
- /**
107
- * Get a collection of items
108
- *
109
- * @param \WP_REST_Request $request Full data about the request.
110
- * @return \WP_Error|\WP_REST_Response
111
- */
112
- public function get_item($request)
113
- {
114
- $parameters = self::wp_unslash_conditional($request->get_query_params());
115
- if(wp_verify_nonce($parameters["nonce"] , 'ecwd_rest_nonce')){
116
- $route = $request->get_route();
117
- $endpoint = $this->parse_endpoint($route);
118
- switch ($endpoint) {
119
- case 'events':
120
- $status = 200;
121
- $data_for_response = array(
122
- "code" => "ok",
123
- "data" => self::all_events()
124
- );
125
- return new \WP_REST_Response($data_for_response, $status);
126
- break;
127
- }
 
 
 
 
 
128
  }
 
129
  }
 
130
 
131
- public function update_item($request) {
132
- $parameters = self::wp_unslash_conditional($request->get_body_params());
133
- if(wp_verify_nonce($parameters["nonce"] , 'ecwd_rest_nonce')) {
134
- $route = $request->get_route();
135
- $endpoint = $this->parse_endpoint($route);
136
- switch ($endpoint) {
137
- case 'add_event':
138
- $status = 200;
139
- $data_for_response = array(
140
- "success" => self::add_events($parameters)
141
- );
142
-
143
- return new \WP_REST_Response($data_for_response, $status);
144
- break;
145
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  }
 
147
  }
 
148
 
149
- private static function all_events(){
150
- $args = array(
151
- 'numberposts' => - 1,
152
- 'post_type' => 'ecwd_event',
153
- );
154
- $events = get_posts($args);
155
- self::add_private_posts($events,$args);
156
-
157
- foreach ($events as $key=>$val){
158
- $ecwd_event_date_from = get_post_meta($val->ID, 'ecwd_event_date_from',true);
159
- $ecwd_event_date_to = get_post_meta($val->ID, 'ecwd_event_date_to',true);
160
- $events[$key]->ecwd_event_date_from = $ecwd_event_date_from;
161
- $events[$key]->ecwd_event_date_to = $ecwd_event_date_to;
162
- }
163
- return $events;
164
  }
165
- private static function add_private_posts(&$posts, $args){
166
- if(!current_user_can('read_private_posts')) {
167
- return;
168
- }
 
169
 
170
- $args['post_status'] = 'private';
171
- $private_posts = get_posts($args);
172
- if(!empty($private_posts)) {
173
- foreach($private_posts as $private_post) {
174
- $posts[] = $private_post;
175
- }
176
- }
177
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
- private static function add_events($parameters){
180
- $status = false;
181
- if (isset($parameters["ecwd_data"])) {
182
- $ecwd_events_list = $parameters["ecwd_data"];
183
- foreach ($ecwd_events_list as $val){
184
- if(isset($val['event_id']) && isset($val['calendar_id'])){
185
- $event_id = esc_attr($val['event_id']);
186
- $calendar_id = esc_attr($val['calendar_id']);
187
- $event_calendars = get_post_meta($event_id, ECWD_PLUGIN_PREFIX . '_event_calendars', true);
188
- if (!$event_calendars) {
189
- $event_calendars = array();
190
- }
191
 
192
- if (is_array($event_calendars) && !in_array($calendar_id, $event_calendars)) {
193
- $event_calendars[] = $calendar_id;
194
- $status = true;
195
- }
196
- update_post_meta($event_id, ECWD_PLUGIN_PREFIX . '_event_calendars', $event_calendars);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  }
 
 
 
 
 
 
198
  }
 
199
 
200
 
201
- }
202
- return $status;
203
  }
 
 
204
 
205
- /**
206
- * Check if a given request has access to get items
207
- *
208
- * @param WP_REST_Request $request Full data about the request.
209
- * @return WP_Error|bool
210
- */
211
- public function get_items_permissions_check($request)
212
- {
213
- //return true; <--use to make readable by all
214
- return true; //current_user_can( 'edit_something' );
215
- }
216
 
217
- /**
218
- * Check if a given request has access to get a specific item
219
- *
220
- * @param WP_REST_Request $request Full data about the request.
221
- * @return WP_Error|bool
222
- */
223
- public function get_item_permissions_check($request)
224
- {
225
- return $this->get_items_permissions_check($request);
226
  }
 
 
 
 
 
227
 
228
- /**
229
- * Check if a given request has access to create items
230
- *
231
- * @param WP_REST_Request $request Full data about the request.
232
- * @return WP_Error|bool
233
- */
234
- public function create_item_permissions_check($request)
235
- {
236
- return true; //current_user_can( 'edit_something' );
237
- }
 
238
 
239
- /**
240
- * Check if a given request has access to update a specific item
241
- *
242
- * @param WP_REST_Request $request Full data about the request.
243
- * @return WP_Error|bool
244
- */
245
- public function update_item_permissions_check($request)
246
- {
247
- return $this->create_item_permissions_check($request);
248
- }
249
 
250
- /**
251
- * Check if a given request has access to delete a specific item
252
- *
253
- * @param WP_REST_Request $request Full data about the request.
254
- * @return WP_Error|bool
255
- */
256
- public function delete_item_permissions_check($request)
257
- {
258
- return true;
259
- }
260
 
261
- /**
262
- * Prepare the item for create or update operation
263
- *
264
- * @param WP_REST_Request $request Request object
265
- * @return WP_Error|object $prepared_item
266
- */
267
- protected function prepare_item_for_database($request)
268
- {
269
- return array();
270
- }
271
 
272
- /**
273
- * Prepare the item for the REST response
274
- *
275
- * @param mixed $item WordPress representation of the item.
276
- * @param WP_REST_Request $request Request object.
277
- * @return mixed
278
- */
279
- public function prepare_item_for_response($item, $request)
280
- {
281
- return array();
282
- }
 
 
 
 
 
 
 
 
 
 
283
 
 
 
 
 
 
 
 
 
 
 
 
284
 
285
 
286
- /*
287
- * wp 4.4 adds slashes, removes them
288
- *
289
- * https://core.trac.wordpress.org/ticket/36419
290
- **/
291
- private static function wp_unslash_conditional($data)
292
- {
293
 
294
- global $wp_version;
295
- if ($wp_version < 4.5) {
296
- $data = wp_unslash($data);
297
- }
 
 
 
298
 
299
- return $data;
 
 
300
  }
301
 
302
- public static function get_instance()
303
- {
304
- if (null == self::$instance) {
305
- self::$instance = new self;
306
- self::$instance->register_routes();
307
- }
308
- return self::$instance;
309
- }
310
 
 
 
 
 
 
 
 
311
  }
 
 
7
  */
8
 
9
  class EcwdRestApi
10
+ {
11
 
12
+ private static $instance = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ private $namespace = ECWD_REST_NAMESPACE;
15
 
16
+ private $bases = array(
17
+ 'excluded_event' => array('/excluded_event', true, false, false),//get,post,delete
18
+ 'past_event' => array('/past_event', true, false, false),//get,post,delete
19
+ 'add_event' => array('/add_event', false, true, false),//get,post,delete
20
+ 'delete_event' => array('/delete_event', false, true, false),//get,post,delete
21
+ );
22
 
23
+ /**
24
+ * Register the routes for the objects of the controller.
25
+ */
26
+ public function register_routes()
27
+ {
28
+ foreach ($this->bases as $key => $route_config) {
29
+ $endpoint = $this->get_endpoint($key);
 
30
 
31
+ // readable
32
+ if ($route_config[1]) {
33
 
34
+ register_rest_route($this->namespace, $endpoint,
35
+ array(
36
+ 'methods' => \WP_REST_Server::READABLE,
37
+ 'callback' => array($this, 'get_item'),
38
+ 'permission_callback' => array($this, 'get_items_permissions_check'),
39
+ 'args' => array(),
40
+ )
41
+ );
42
 
43
+ }
44
+
45
+ // writable
46
+ if ($route_config[2]) {
47
+
48
+ register_rest_route($this->namespace, $endpoint,
49
+ array(
50
+ 'methods' => \WP_REST_Server::CREATABLE,
51
+ 'callback' => array($this, 'update_item'),
52
+ 'permission_callback' => array($this, 'create_item_permissions_check'),
53
+ 'args' => array(),
54
+ )
55
+ );
56
 
 
57
  }
58
 
59
+ // deletable
60
+ if ($route_config[3]) {
61
+
62
+ register_rest_route($this->namespace, $endpoint,
63
+ array(
64
+ 'methods' => \WP_REST_Server::DELETABLE,
65
+ 'callback' => array($this, 'delete_item'),
66
+ 'permission_callback' => array($this, 'delete_item_permissions_check'),
67
+ 'args' => array(),
68
+ )
69
+ );
70
 
 
 
 
 
 
 
 
 
71
  }
72
+ }
73
 
74
+ }
75
+
76
+ /**
77
+ * get endpoint route by its key(string identificator )
78
+ *
79
+ */
80
+ private function get_endpoint($key)
81
+ {
82
+ if (array_key_exists($key, $this->bases)) {
83
+ return $this->bases[$key][0];
84
  }
85
+ return false;
86
 
87
+ }
 
 
 
 
 
 
88
 
89
+ /**
90
+ * get endpoint key by its route
91
+ *
92
+ */
93
+ private function parse_endpoint($route)
94
+ {
95
+ $route_url = substr($route, 6);
96
 
97
+ foreach ($this->bases as $key => $value) {
98
+ $route_regex = '/' . substr($value[0], 1) . '/';
99
+
100
+ if (preg_match($route_regex, substr($route_url, 1))) {
101
+ return $key;
102
  }
103
+ }
104
 
105
+ return null;
106
 
107
+ }
108
+ /**
109
+ * Get a collection of items
110
+ *
111
+ * @param \WP_REST_Request $request Full data about the request.
112
+ * @return \WP_Error|\WP_REST_Response
113
+ */
114
+ public function get_item($request)
115
+ {
116
+ $parameters = self::wp_unslash_conditional($request->get_query_params());
117
+ if(wp_verify_nonce($parameters["nonce"] , 'ecwd_rest_nonce')){
118
+ $route = $request->get_route();
119
+ $endpoint = $this->parse_endpoint($route);
120
+ switch ($endpoint) {
121
+ case 'excluded_event':
122
+ $status = 200;
123
+ $data_for_response = array(
124
+ "code" => "ok",
125
+ "data" => self::excluded_events($parameters)
126
+ );
127
+ break;
128
+ case 'past_event':
129
+ $status = 200;
130
+ $data_for_response = array(
131
+ "code" => "ok",
132
+ "data" => self::all_past_events()
133
+ );
134
+ break;
135
  }
136
+ return new \WP_REST_Response($data_for_response, $status);
137
  }
138
+ }
139
 
140
+ public function update_item($request) {
141
+ $parameters = self::wp_unslash_conditional($request->get_body_params());
142
+ if(wp_verify_nonce($parameters["nonce"] , 'ecwd_rest_nonce')) {
143
+ $route = $request->get_route();
144
+ $endpoint = $this->parse_endpoint($route);
145
+ include_once 'events/ecwd-events-controller.php';
146
+ switch ($endpoint) {
147
+ case 'add_event':
148
+ $status = 200;
149
+ $data_for_response = array(
150
+ "success" => self::add_events($parameters),
151
+ "free_events_count" => self::free_events_count($parameters)
152
+ );
153
+
154
+ if(isset($parameters['calendar_id'])){
155
+ ecwd_events_controller::clear_recurring_events_cache(array($parameters['calendar_id']));
156
+ }
157
+
158
+ break;
159
+ case "delete_event";
160
+ $events_id = array();
161
+ if(isset($parameters['events_id']) && is_array($parameters['events_id'])){
162
+ $events_id = $parameters['events_id'];
163
+ }
164
+ $status = 200;
165
+ $data_for_response = array(
166
+ "success" => self::delete_events($events_id)
167
+ );
168
+
169
+ break;
170
  }
171
+ return new \WP_REST_Response($data_for_response, $status);
172
  }
173
+ }
174
 
175
+ private static function excluded_events($parameters){
176
+ if(isset($parameters['calendar_id'])){
177
+ $calendar_id = intval($parameters['calendar_id']);
178
+ }else{
179
+ return false;
 
 
 
 
 
 
 
 
 
 
180
  }
181
+ include_once 'events/ecwd-events-controller.php';
182
+ $controller = new ecwd_events_controller();
183
+ $excluded_events = $controller->get_excluded_events($calendar_id);
184
+ return self::convert_data($excluded_events);
185
+ }
186
 
187
+ private static function all_past_events(){
188
+ include_once 'events/ecwd-events-controller.php';
189
+ $controller = new ecwd_events_controller();
190
+ $past_events = $controller->get_past_events();
191
+ return self::convert_data($past_events);
192
+ }
 
193
 
194
+ private static function convert_data($events){
195
+ $return_data = array();
196
+ foreach ($events as $event){
197
+ $event_data = array(
198
+ 'id' => $event->id,
199
+ 'title' => $event->title,
200
+ 'from' => $event->get_start_date(),
201
+ 'end' => $event->get_end_date(),
202
+ );
203
+ array_push($return_data, $event_data);
204
  }
205
+ return $return_data;
206
+ }
 
 
 
 
 
 
 
 
 
 
207
 
208
+ private static function delete_events($ids){
209
+ include_once 'events/ecwd-events-controller.php';
210
+ $cotroller = new ecwd_events_controller();
211
+ $cotroller->delete_events($ids);
212
+ return true;
213
+ }
214
+
215
+
216
+ private static function add_events($parameters){
217
+ $status = false;
218
+ if (isset($parameters["ecwd_data"])) {
219
+ $ecwd_events_list = $parameters["ecwd_data"];
220
+ $calendar_id = esc_attr($parameters['calendar_id']);
221
+ foreach ($ecwd_events_list as $val){
222
+ if(isset($val['event_id'])){
223
+ $event_id = esc_attr($val['event_id']);
224
+ $event_calendars = get_post_meta($event_id, ECWD_PLUGIN_PREFIX . '_event_calendars', true);
225
+ if (!$event_calendars) {
226
+ $event_calendars = array();
227
  }
228
+
229
+ if (is_array($event_calendars) && !in_array($calendar_id, $event_calendars)) {
230
+ $event_calendars[] = $calendar_id;
231
+ $status = true;
232
+ }
233
+ update_post_meta($event_id, ECWD_PLUGIN_PREFIX . '_event_calendars', $event_calendars);
234
  }
235
+ }
236
 
237
 
 
 
238
  }
239
+ return $status;
240
+ }
241
 
 
 
 
 
 
 
 
 
 
 
 
242
 
243
+ private static function free_events_count($parameters){
244
+ if(isset($parameters['calendar_id'])){
245
+ $calendar_id = intval($parameters['calendar_id']);
246
+ }else{
247
+ return false;
 
 
 
 
248
  }
249
+ include_once 'events/ecwd-events-controller.php';
250
+ $controller = new ecwd_events_controller();
251
+ $excluded_events = $controller->get_excluded_events($calendar_id);
252
+ return count($excluded_events);
253
+ }
254
 
255
+ /**
256
+ * Check if a given request has access to get items
257
+ *
258
+ * @param WP_REST_Request $request Full data about the request.
259
+ * @return WP_Error|bool
260
+ */
261
+ public function get_items_permissions_check($request)
262
+ {
263
+ //return true; <--use to make readable by all
264
+ return true; //current_user_can( 'edit_something' );
265
+ }
266
 
267
+ /**
268
+ * Check if a given request has access to get a specific item
269
+ *
270
+ * @param WP_REST_Request $request Full data about the request.
271
+ * @return WP_Error|bool
272
+ */
273
+ public function get_item_permissions_check($request)
274
+ {
275
+ return $this->get_items_permissions_check($request);
276
+ }
277
 
278
+ /**
279
+ * Check if a given request has access to create items
280
+ *
281
+ * @param WP_REST_Request $request Full data about the request.
282
+ * @return WP_Error|bool
283
+ */
284
+ public function create_item_permissions_check($request)
285
+ {
286
+ return true; //current_user_can( 'edit_something' );
287
+ }
288
 
289
+ /**
290
+ * Check if a given request has access to update a specific item
291
+ *
292
+ * @param WP_REST_Request $request Full data about the request.
293
+ * @return WP_Error|bool
294
+ */
295
+ public function update_item_permissions_check($request)
296
+ {
297
+ return $this->create_item_permissions_check($request);
298
+ }
299
 
300
+ /**
301
+ * Check if a given request has access to delete a specific item
302
+ *
303
+ * @param WP_REST_Request $request Full data about the request.
304
+ * @return WP_Error|bool
305
+ */
306
+ public function delete_item_permissions_check($request)
307
+ {
308
+ return true;
309
+ }
310
+
311
+ /**
312
+ * Prepare the item for create or update operation
313
+ *
314
+ * @param WP_REST_Request $request Request object
315
+ * @return WP_Error|object $prepared_item
316
+ */
317
+ protected function prepare_item_for_database($request)
318
+ {
319
+ return array();
320
+ }
321
 
322
+ /**
323
+ * Prepare the item for the REST response
324
+ *
325
+ * @param mixed $item WordPress representation of the item.
326
+ * @param WP_REST_Request $request Request object.
327
+ * @return mixed
328
+ */
329
+ public function prepare_item_for_response($item, $request)
330
+ {
331
+ return array();
332
+ }
333
 
334
 
 
 
 
 
 
 
 
335
 
336
+ /*
337
+ * wp 4.4 adds slashes, removes them
338
+ *
339
+ * https://core.trac.wordpress.org/ticket/36419
340
+ **/
341
+ private static function wp_unslash_conditional($data)
342
+ {
343
 
344
+ global $wp_version;
345
+ if ($wp_version < 4.5) {
346
+ $data = wp_unslash($data);
347
  }
348
 
349
+ return $data;
350
+ }
 
 
 
 
 
 
351
 
352
+ public static function get_instance()
353
+ {
354
+ if (null == self::$instance) {
355
+ self::$instance = new self;
356
+ self::$instance->register_routes();
357
+ }
358
+ return self::$instance;
359
  }
360
+
361
+ }
includes/events/ecwd-events-controller.php CHANGED
@@ -11,6 +11,8 @@ include_once 'ecwd-single-event.php';
11
 
12
  class ecwd_events_controller {
13
 
 
 
14
  public function __construct(){
15
  }
16
 
@@ -23,6 +25,29 @@ class ecwd_events_controller {
23
  //title, contet, etc
24
  }
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  public function get_events(){
27
  include_once 'ecwd-events-query.php';
28
  $ecwd_query = new ecwd_events_query();
@@ -37,10 +62,589 @@ class ecwd_events_controller {
37
  $ecwd_query->filter_by_date('2018-07-01', '2018-07-31');
38
  //$ecwd_query->meta_query_relation('AND');
39
 
40
- $single_events_list = array();
41
  $events = $ecwd_query->get_posts();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  $events_id = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  foreach($events as $event) {
45
 
46
  $single_event = new ecwd_single_event($event->ID, $event->post_title, $event->post_content);
@@ -53,6 +657,7 @@ class ecwd_events_controller {
53
 
54
  $single_events_list[$event->ID] = $single_event;
55
  }
 
56
  }
57
 
58
  /**
@@ -60,6 +665,9 @@ class ecwd_events_controller {
60
  * */
61
  public function update_meta_values($ev){
62
 
 
 
 
63
  update_post_meta($ev->id, 'ecwd_event_date_from', $this->sanitize_text($ev->get_start_date()));
64
  update_post_meta($ev->id, 'ecwd_event_date_to', $this->sanitize_text($ev->get_end_date()));
65
  if($ev->get_all_day() === true) {
@@ -102,6 +710,24 @@ class ecwd_events_controller {
102
 
103
  }
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  }
106
 
107
  public function sanitize_text($str){
@@ -116,5 +742,19 @@ class ecwd_events_controller {
116
 
117
  }
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
  }
11
 
12
  class ecwd_events_controller {
13
 
14
+ private $week_days = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
15
+
16
  public function __construct(){
17
  }
18
 
25
  //title, contet, etc
26
  }
27
 
28
+ public function get_past_events(){
29
+ include_once 'ecwd-events-query.php';
30
+ $ecwd_query = new ecwd_events_query();
31
+ $ecwd_query->filter_past_events();
32
+ $ecwd_query->filter_by_post_status(['publish','private']);
33
+ $ecwd_query->meta_query_relation('AND');
34
+ $events = $ecwd_query->get_posts();
35
+ $single_events_list = $this->convert_wp_post_to_ecwd_event($events);
36
+ return $single_events_list;
37
+ }
38
+
39
+ public function get_excluded_events($calendar_id){
40
+ include_once 'ecwd-events-query.php';
41
+ $ecwd_query = new ecwd_events_query();
42
+ $ecwd_query->filter_excluded_events($calendar_id);
43
+ $ecwd_query->filter_by_post_status(['publish','private']);
44
+ $ecwd_query->meta_query_relation('AND');
45
+ $events = $ecwd_query->get_posts();
46
+ $single_events_list = $this->convert_wp_post_to_ecwd_event($events);
47
+ return $single_events_list;
48
+
49
+ }
50
+
51
  public function get_events(){
52
  include_once 'ecwd-events-query.php';
53
  $ecwd_query = new ecwd_events_query();
62
  $ecwd_query->filter_by_date('2018-07-01', '2018-07-31');
63
  //$ecwd_query->meta_query_relation('AND');
64
 
65
+
66
  $events = $ecwd_query->get_posts();
67
+ $single_events_list = $this->convert_wp_post_to_ecwd_event($events);
68
+
69
+
70
+ echo '<pre>';
71
+ var_dump($single_events_list);
72
+ die;
73
+
74
+ }
75
+
76
+
77
+ public function get_recurring_events($calendar_id, $start_date, $end_date){
78
+
79
+ $recurring_events = $this->get_recurring_events_from_cache($calendar_id, $start_date, $end_date);
80
+ if($recurring_events !== null) {
81
+ echo "from cache-" . $calendar_id;
82
+ echo "<br/>";
83
+
84
+ if(!empty($recurring_events)){
85
+ foreach($recurring_events as $e){
86
+ foreach($e as $t){
87
+
88
+ echo $t->title.' - '.
89
+ $t->get_start_date() .' - '.
90
+ $t->get_end_date();
91
+ echo "<br/>";
92
+ }
93
+ }
94
+ }
95
+
96
+ return $recurring_events;
97
+ }
98
+
99
+ include_once 'ecwd-events-query.php';
100
+ $ecwd_query = new ecwd_events_query();
101
+ $ecwd_query->filter_recurring($start_date, $end_date);
102
+ $ecwd_query->filter_by_calendars($calendar_id);
103
+ $ecwd_query->meta_query_relation('AND');
104
+
105
+ $events = $ecwd_query->get_posts();
106
+ $ecwd_events_list = array();
107
+ if(!empty($events)) {
108
+ $ecwd_events_list = $this->convert_wp_post_to_ecwd_event($events);
109
+ $ecwd_events_list = $this->calculate_recurring_events($ecwd_events_list, $start_date, $end_date);
110
+ }
111
+
112
+ $this->cache_recurring_events($calendar_id, $ecwd_events_list, $start_date, $end_date);
113
+ echo "no cache-" . $calendar_id;
114
+ echo "<br/>";
115
+
116
+
117
+ if(!empty($ecwd_events_list)){
118
+ foreach($ecwd_events_list as $e){
119
+ foreach($e as $t){
120
+
121
+ echo $t->title.' - '.
122
+ $t->get_start_date() .' - '.
123
+ $t->get_end_date();
124
+ echo "<br/>";
125
+ }
126
+ }
127
+ }
128
+
129
+ return $ecwd_events_list;
130
+ }
131
+
132
+
133
+ public function delete_events($events_id){
134
+ foreach($events_id as $id) {
135
+ wp_delete_post($id, true);
136
+ }
137
+ }
138
+
139
+ /**
140
+ * @param $event array of ecwd_single_event
141
+ * @return array of ecwd_single_event
142
+ * */
143
+ private function calculate_recurring_events($events, $start_date, $end_date){
144
+
145
+ $events_list = array();
146
+ foreach($events as $event) {
147
+
148
+ switch($event->repeat['ecwd_event_repeat_event']) {
149
+
150
+ case "daily":
151
+ $events_list[$event->id] = $this->daily_recurring($event, $start_date, $end_date);
152
+ break;
153
+ case "weekly":
154
+ $events_list[$event->id] = $this->weekly_recurring($event, $start_date, $end_date);
155
+ break;
156
+ case "monthly":
157
+ $events_list[$event->id] = $this->monthly_recurring($event, $start_date, $end_date);
158
+ break;
159
+ case "yearly":
160
+ $events_list[$event->id] = $this->yearly_recurring($event, $start_date, $end_date);
161
+ break;
162
+ default:
163
+ $events_list[$event->id] = $this->no_repeat($event, $start_date, $end_date);
164
+ }
165
+
166
+ }
167
+
168
+ return $events_list;
169
+ }
170
+
171
+ /**
172
+ * @param $event ecwd_single_event
173
+ * @return array of ecwd_single_event
174
+ * */
175
+ private function daily_recurring($event, $start_date, $end_date){
176
+ global $ecwd_options;
177
+
178
+ $until = $event->repeat['ecwd_event_repeat_repeat_until'];
179
+ $how = intval($event->repeat['ecwd_event_repeat_how']);
180
+ $from = $event->get_start_date();
181
+ $to = $event->get_end_date();
182
+
183
+
184
+ if(strtotime($until) > strtotime($end_date)) {
185
+ $until = $end_date;
186
+ }
187
+
188
+ $event_days = $this->get_date_diff($from, $until);
189
+ $event_days_long = $this->get_date_diff($from, $to);
190
+ if($event_days < 0) {
191
+ return array();
192
+ }
193
+
194
+ $from_date = $from;
195
+ $events_date = array();
196
+ for($i = 0; $i <= $event_days; $i++) {
197
+ $date = strtotime(date("Y-m-d", strtotime($from_date)) . " +" . $i . " day");
198
+
199
+ $date = date("Y-n-j", $date);
200
+
201
+ if(strtotime($until) >= strtotime(date('Y-m-d', strtotime($date)))) {
202
+
203
+ $from_date = strtotime((date("Y-m-d", (strtotime($from_date))) . " +" . (($how - 1)) . " days"));
204
+ $from_date = date('Y-m-d', $from_date);
205
+ $from = $date;
206
+ $to = date('Y-m-d', strtotime($from . ' + ' . $event_days_long . ' days'));
207
+
208
+ /*
209
+ if(isset($ecwd_options["long_events"]) && $ecwd_options["long_events"] == '1') {
210
+ $m1 = date('m', strtotime($to));
211
+ $m2 = date('m', strtotime($end_date));
212
+ if(strtotime($to) <= strtotime($end_date) || (strtotime($to) >= strtotime($end_date) && $m1 == $m2)) {
213
+ if(strtotime($from) < strtotime($start_date)) {
214
+ $date = $start_date;
215
+ }
216
+ }
217
+ }
218
+ */
219
+
220
+ if(strtotime($date) <= strtotime($end_date) && strtotime($date) >= strtotime($start_date) && in_array(strtolower(date('l', strtotime($date))), $this->week_days)) {
221
+ $events_date[] = array('start' => $from, 'end' => $to);
222
+ }
223
+ }
224
+ }
225
+
226
+ return $this->clone_event($event, $events_date);
227
+ }
228
+
229
+ /**
230
+ * @param $event ecwd_single_event
231
+ * @return array of ecwd_single_event
232
+ * */
233
+ private function weekly_recurring($event, $start_date, $end_date){
234
+ global $ecwd_options;
235
+
236
+ $until = $event->repeat['ecwd_event_repeat_repeat_until'];
237
+ $how = intval($event->repeat['ecwd_event_repeat_how']);
238
+ $from = $event->get_start_date();
239
+ $to = $event->get_end_date();
240
+
241
+ if(!empty($event->repeat['ecwd_event_day'])) {
242
+ $days = $event->repeat['ecwd_event_day'];
243
+ } else {
244
+ $days = array(strtolower(date('l', strtotime($from))));
245
+ }
246
+
247
+ if(strtotime($until) > strtotime($end_date)) {
248
+ $until = $end_date;
249
+ }
250
+
251
+ $week_start = (isset($ecwd_options['week_starts'])) ? $ecwd_options['week_starts'] : "0";
252
+
253
+ if(count($days)) {
254
+ if($week_start == '0') {
255
+
256
+ if(in_array('saturday', $days)) {
257
+ $event_week_last_day = 'saturday';
258
+ } else {
259
+ $event_week_last_day = $days[count($days) - 1];
260
+ }
261
+ } else {
262
+ $event_week_last_day = $days[count($days) - 1];
263
+ }
264
+
265
+ }
266
+
267
+ $event_days = $this->get_date_diff($from, $until);
268
+ $event_days_long_def = $this->get_date_diff($from, $to);
269
+
270
+ if($event_days < 0) {
271
+ return array();
272
+ }
273
+
274
+ $from_date = $from;
275
+
276
+ $events_date = array();
277
+ for($i = 0; $i <= $event_days; $i++) {
278
+ $event_date = strtotime(date("Y-m-d", strtotime($from_date)) . " +" . $i . " day");
279
+ $week_day = strtolower(date('l', $event_date));
280
+ $event_date = date("Y-n-j", $event_date);
281
+
282
+ if(isset($event_week_last_day) && is_array($days) && in_array($week_day, $days)) {
283
+
284
+ if($how > 1 && $week_day == $event_week_last_day) {
285
+ $from_date = strtotime((date("Y-m-d", (strtotime($from_date))) . " +" . (($how * 7) - 7) . " days"));
286
+ $from_date = date('Y-m-d', $from_date);
287
+ }
288
+
289
+ $from = $event_date;
290
+ $event_days_long = $event_days_long_def;
291
+
292
+ /*
293
+ if(isset($ecwd_options["long_events"]) && $ecwd_options["long_events"] == '1') {
294
+ $m1 = date('m', strtotime($to));
295
+ $m2 = date('m', strtotime($end_date));
296
+ if(strtotime($to) <= strtotime($end_date) || (strtotime($to) >= strtotime($end_date) && $m1 == $m2)) {
297
+ if(strtotime($from) < strtotime($start_date)) {
298
+ $diff = $this->get_date_diff($event_date, $start_date);
299
+ if($diff > 0) {
300
+ $event_days_long -= $diff;
301
+ }
302
+ $event_date = $start_date;
303
+ }
304
+ }
305
+ }*/
306
+
307
+ if(strtotime($until) >= strtotime(date('Y-m-d', strtotime($event_date)))) {
308
+ $to = date('Y-m-d', strtotime($event_date . ' + ' . $event_days_long . ' days'));
309
+ if((strtotime($event_date) <= strtotime($end_date) && strtotime($event_date) >= strtotime($start_date) && in_array(strtolower(date('l', strtotime($event_date))), $this->week_days))) {
310
+ $events_date[] = array('start' => $from, 'end' => $to);
311
+ }
312
+ }
313
+ }
314
+ }
315
+
316
+ return $this->clone_event($event, $events_date);
317
+ }
318
+
319
+ /**
320
+ * @param $event ecwd_single_event
321
+ * @return array of ecwd_single_event
322
+ * */
323
+ private function monthly_recurring($event, $start_date, $end_date){
324
+ global $ecwd_options;
325
+
326
+ $until = $event->repeat['ecwd_event_repeat_repeat_until'];
327
+ $how = intval($event->repeat['ecwd_event_repeat_how']);
328
+ $from = $event->get_start_date();
329
+ $to = $event->get_end_date();
330
+
331
+ if(strtotime($until) > strtotime($end_date)) {
332
+ $until = $end_date;
333
+ }
334
+
335
+ $event_days = $this->get_date_diff($from, $until);
336
+ $event_days_long = $this->get_date_diff($from, $to);
337
+ $event_from = $from;
338
+ $from_date = $from;
339
+ $repeat_days = $event->repeat['ecwd_event_repeat_month_on_days'];
340
+
341
+ $repeat_when = ($event->repeat['ecwd_monthly_list_monthly'] !== null) ? $event->repeat['ecwd_monthly_list_monthly'] : false;
342
+ $repeat_day = ($event->repeat['ecwd_monthly_week_monthly'] !== null) ? $event->repeat['ecwd_monthly_week_monthly'] : false;
343
+
344
+ $min_date = strtotime($event_from);
345
+ $max_date = strtotime("+1 MONTH", strtotime($until));
346
+
347
+ $events_date = array();
348
+ if($max_date >= $min_date) {
349
+ $i = 0;
350
+ $min_date = strtotime(date("Y-m-1", strtotime($event_from)));
351
+ while(($min_date = strtotime("+1 MONTH", $min_date)) <= $max_date) {
352
+ $date = strtotime(date("Y-m-d", strtotime($event_from)) . " +" . $i * $how . " MONTH");
353
+ if($i > 0) {
354
+ if($repeat_days == 2 && $repeat_day && $repeat_when && date('Y-m', strtotime($event_from)) !== date('Y-m', $date)) {
355
+ $date = strtotime(date("Y-m-1", strtotime($event_from)) . " +" . $i * $how . " MONTH");
356
+ $month_year = date("F Y", $date);
357
+
358
+ $repeat_date = date('Y-m-d', strtotime($repeat_when . ' ' . ucfirst($repeat_day) . ' of ' . $month_year));
359
+ if($repeat_date == '1970-01-01' || $repeat_date == '1969-12-31') {
360
+ $repeat_date = date('Y-m-d', strtotime($month_year . ' ' . $repeat_when . ' ' . $repeat_day));
361
+ }
362
+
363
+ //echo $repeat_date1.'-------'.$repeat_date.'<br />';
364
+ $date = strtotime($repeat_date);
365
+ }
366
+ }
367
+ $date = date("Y-n-j", $date);
368
+ $i++;
369
+ if(strtotime($until) >= strtotime(date('Y-m-d', strtotime($date)))) {
370
+ $min_date = $from_date = strtotime((date("Y-m-1", (strtotime($date))) . " +" . (($how)) . " month"));
371
+ $event_days -= 30;
372
+ $from_date = strtotime((date("Y-m-d", $from_date) . " - 1 day"));
373
+
374
+ $from_date = date('Y-m-d', $from_date);
375
+ $from = $date;
376
+ $to = strtotime((date("Y-m-d", (strtotime($from))) . " +" . ($event_days_long) . " days"));
377
+ $to = date('Y-m-d', $to);
378
+
379
+ /*
380
+ if(isset($ecwd_options["long_events"]) && $ecwd_options["long_events"] == '1') {
381
+ $m1 = date('m', strtotime($to));
382
+ $m2 = date('m', strtotime($end_date));
383
+ if(strtotime($to) <= strtotime($end_date) || (strtotime($to) >= strtotime($end_date) && $m1 == $m2)) {
384
+ if(strtotime($from) < strtotime($start_date)) {
385
+ $date = $start_date;
386
+ }
387
+ }
388
+ }
389
+ */
390
+
391
+ if(strtotime($date) <= strtotime($end_date) && strtotime($date) >= strtotime($start_date) && in_array(strtolower(date('l', strtotime($date))), $this->week_days)) {
392
+ $events_date[] = array('start' => $from, 'end' => $to);
393
+ }
394
+ }
395
+ }
396
+ }
397
+
398
+ return $this->clone_event($event, $events_date);
399
+ }
400
+
401
+ /**
402
+ * @param $event ecwd_single_event
403
+ * @return array of ecwd_single_event
404
+ * */
405
+ private function yearly_recurring($event, $start_date, $end_date){
406
+ global $ecwd_options;
407
+
408
+ $until = $event->repeat['ecwd_event_repeat_repeat_until'];
409
+ $how = intval($event->repeat['ecwd_event_repeat_how']);
410
+ $from = $event->get_start_date();
411
+ $to = $event->get_end_date();
412
+
413
+ if(strtotime($until) > strtotime($end_date)) {
414
+ $until = $end_date;
415
+ }
416
+
417
+ $event_days_long = $this->get_date_diff($from, $to);
418
+ $event_from = $from;
419
+ $from_date = $from;
420
+ $repeat_days = $event->repeat['ecwd_event_repeat_year_on_days'];
421
+ $repeat_when = ($event->repeat['ecwd_monthly_list_yearly'] !== null) ? $event->repeat['ecwd_monthly_list_yearly'] : false;
422
+ $repeat_day = ($event->repeat['ecwd_monthly_week_yearly'] !== null) ? $event->repeat['ecwd_monthly_week_yearly'] : false;
423
+
424
+ if($event->repeat['ecwd_event_year_month'] !== null && $repeat_days == 2) {
425
+ $month = $event->repeat['ecwd_event_year_month'];
426
+ $month_name = date('F', strtotime('2015-' . $month . '-1'));
427
+ } else {
428
+ $month_name = date('F', strtotime($from_date));
429
+ }
430
+
431
+ $min_date = strtotime($event_from);
432
+ $max_date = strtotime($until);
433
+ $i = 0;
434
+ $events_date = array();
435
+ while($min_date <= $max_date) {
436
+ $min_date = strtotime("+1 YEAR", $min_date);
437
+ $date = strtotime(date("Y-m-d", strtotime($event_from)) . " +" . $i * $how . " YEAR");
438
+ if($i > 0) {
439
+ if($repeat_days == 1) {
440
+ $month_year = $month_name . ' ' . date("d Y", $date);
441
+ $repeat_date = strtotime(date('Y-m-d', strtotime($month_year)));
442
+ $date = $repeat_date;
443
+ }
444
+ if($repeat_days == 2 && $repeat_day && $repeat_when) {
445
+ $month_year = $month_name . ' ' . date("Y", $date);
446
+ //echo $repeat_when.' '.ucfirst( $repeat_day ).' of '.$month_year.'<br />';
447
+ $repeat_date = date('Y-m-d', strtotime($repeat_when . ' ' . ucfirst($repeat_day) . ' of ' . $month_year));
448
+ if($repeat_date == '1970-01-01' || $repeat_date == '1969-12-31') {
449
+ $repeat_date = date('Y-m-d', strtotime($month_year . ' ' . $repeat_when . ' ' . $repeat_day));
450
+ }
451
+ //$repeat_date = date( 'Y-m-d', strtotime($repeat_when.' '.ucfirst( $repeat_day ).' of '.$month_year) );
452
+ //don't know why, but "last sunday,last monday... returns last s,m of previous month"
453
+ if($repeat_when == 'last') {
454
+ $repeat_date = date('Y-m-d', strtotime($repeat_when . ' ' . ucfirst($repeat_day) . ' of ' . $month_year, strtotime("+1 MONTH", $repeat_date)));
455
+ }
456
+ $date = strtotime($repeat_date);
457
+ }
458
+ }
459
+
460
+ $date = date("Y-n-j", $date);
461
+ $i++;
462
+
463
+ if(strtotime($until) >= strtotime(date('Y-m-d', strtotime($end_date))) && strtotime($date) <= strtotime($until)) {
464
+ $from_date = strtotime((date("Y-m-d", (strtotime($from_date))) . " +" . (($how)) . " year"));
465
+ $from_date = strtotime((date("Y-m-d", $from_date) . " - 1 day"));
466
+ $from_date = date('Y-m-d', $from_date);
467
+ $from = $date;
468
+ $to = strtotime((date("Y-m-d", (strtotime($from))) . " +" . ($event_days_long) . " days"));
469
+ $to = date('Y-m-d', $to);
470
+ /*
471
+ if(isset($ecwd_options["long_events"]) && $ecwd_options["long_events"] == '1') {
472
+ $m1 = date('m', strtotime($to));
473
+ $m2 = date('m', strtotime($end_date));
474
+ if(strtotime($to) <= strtotime($end_date) || (strtotime($to) >= strtotime($end_date) && $m1 == $m2)) {
475
+ if(strtotime($from) < strtotime($start_date)) {
476
+ $date = $start_date;
477
+ }
478
+ }
479
+ }
480
+ */
481
+ if((strtotime($date) <= strtotime($end_date) && strtotime($date) >= strtotime($start_date) && in_array(strtolower(date('l', strtotime($date))), $this->week_days))) {
482
+ $events_date[] = array('start' => $from, 'end' => $to);
483
+ }
484
+ }
485
+ }
486
+
487
+ return $this->clone_event($event, $events_date);
488
+ }
489
+
490
+ /**
491
+ * @param $event ecwd_single_event
492
+ * @return array of ecwd_single_event
493
+ * */
494
+ private function no_repeat($event, $start_date, $end_date){
495
+ global $ecwd_options;
496
+
497
+ $from = $event->get_start_date();
498
+ $to = $event->get_end_date();
499
+
500
+ $date = strtotime(date("Y-m-d", strtotime($from)));
501
+ $date = date("Y-n-j", $date);
502
+
503
+ if(isset($ecwd_options["long_events"]) && $ecwd_options["long_events"] == '1') {
504
+ $m1 = date('m', strtotime($to));
505
+ $m2 = date('m', strtotime($end_date));
506
+ if(strtotime($to) <= strtotime($end_date) || (strtotime($to) >= strtotime($end_date) && $m1 == $m2)) {
507
+ if(strtotime($from) < strtotime($start_date)) {
508
+ $date = $start_date;
509
+ }
510
+ }
511
+ }
512
+
513
+ $events_date = array();
514
+ if(strtotime($date) <= strtotime($end_date) && strtotime($date) >= strtotime($start_date) && in_array(strtolower(date('l', strtotime($date))), $this->week_days)) {
515
+ $events_date[] = array('start' => $from, 'end' => $to);
516
+ }
517
+
518
+ return $this->clone_event($event, $events_date);
519
+ }
520
+
521
+ /**
522
+ * @param $calendar_id string
523
+ * @param $events array of ecwd_single_event
524
+ * */
525
+ private function cache_recurring_events($calendar_id, $ecwd_events, $start_date, $end_date){
526
+
527
+ if(empty($ecwd_events)) {
528
+ return;
529
+ }
530
+
531
  $events_id = array();
532
+ foreach($ecwd_events as $event_id => $events) {
533
+
534
+ foreach($events as $event) {
535
+ $events_id[$event_id][] = array(
536
+ 'start' => $event->get_start_date(),
537
+ 'end' => $event->get_end_date(),
538
+ );
539
+ }
540
+
541
+ }
542
+
543
+ $transient_name = 'ecwd_recurring_events_' . $calendar_id . '-' . $start_date . '-' . $end_date;
544
+ set_site_transient($transient_name, $events_id, 2 * 24 * 60 * 60);//2 day
545
 
546
+ $transients = get_post_meta($calendar_id, 'ecwd_recurring_events_transient', true);
547
+ if(!is_array($transients)) {
548
+ $transients = array();
549
+ }
550
+ $transients[] = $transient_name;
551
+ update_post_meta($calendar_id, 'ecwd_recurring_events_transient', $transients);
552
+ }
553
+
554
+
555
+ private function get_recurring_events_from_cache($calendar_id, $start_date, $end_date){
556
+ $transient_name = 'ecwd_recurring_events_' . $calendar_id . '-' . $start_date . '-' . $end_date;
557
+ $recurring_events = get_site_transient($transient_name);
558
+
559
+ if($recurring_events === false) {
560
+ return null;
561
+ }
562
+
563
+ $ids = array();
564
+ foreach($recurring_events as $event_id => $events_date) {
565
+ $ids[] = $event_id;
566
+ }
567
+
568
+ if(empty($ids)) {
569
+ return array();
570
+ }
571
+
572
+ include_once 'ecwd-events-query.php';
573
+ $ecwd_query = new ecwd_events_query();
574
+ $ecwd_query->filter_by_events_id($ids);
575
+
576
+ $events = $ecwd_query->get_posts();
577
+ if(empty($events) || count($events) !== count($ids)) {
578
+ return null;//clear cache
579
+ }
580
+
581
+ $events = $this->convert_wp_post_to_ecwd_event($events);
582
+
583
+ $events_list = array();
584
+ foreach($events as $event) {
585
+ $events_list[$event->id] = $this->clone_event($event, $recurring_events[$event->id], false);
586
+ }
587
+
588
+ return $events_list;
589
+ }
590
+
591
+ /**
592
+ * @param $event ecwd_single_event
593
+ * @param $events_date array
594
+ * @return array of ecwd_single_event
595
+ **/
596
+ private function clone_event($event, $events_date, $add_time = true){
597
+
598
+ $events_list = array();
599
+ if(empty($events_date)) {
600
+ return $events_list;
601
+ }
602
+
603
+ $start_time = date('H:i', strtotime($event->get_start_date()));
604
+ $end_time = date('H:i', strtotime($event->get_end_date()));
605
+
606
+ foreach($events_date as $i=>$ev_dates) {
607
+ $new_event = clone $event;
608
+
609
+ if($add_time === true) {
610
+
611
+ $ev_dates['start'] = date('Y-m-d', strtotime($ev_dates['start']));
612
+ $ev_dates['end'] = date('Y-m-d', strtotime($ev_dates['end']));
613
+
614
+ $new_event->set_start_date($ev_dates['start'] . ' ' . $start_time);
615
+ $new_event->set_end_date($ev_dates['end'] . ' ' . $end_time);
616
+ } else {
617
+ $new_event->set_start_date($ev_dates['start']);
618
+ $new_event->set_end_date($ev_dates['end']);
619
+ }
620
+ $events_list[] = $new_event;
621
+ }
622
+
623
+ return $events_list;
624
+ }
625
+
626
+ public function get_date_diff($begin_date, $end_date){
627
+ if($end_date == '') {
628
+ return 0;
629
+ }
630
+
631
+ $from_date = date('Y-n-j', strtotime($begin_date));
632
+ $to_date = date('Y-n-j', strtotime($end_date));
633
+ $date_parts1 = explode('-', $from_date);
634
+ $date_parts2 = explode('-', $to_date);
635
+
636
+ $start_date = gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
637
+ $end_date = gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
638
+
639
+ return $end_date - $start_date;
640
+ }
641
+
642
+ /**
643
+ * @param $events array of WP_Post
644
+ * @return array of ecwd_single_event
645
+ * */
646
+ private function convert_wp_post_to_ecwd_event($events){
647
+ $single_events_list = array();
648
  foreach($events as $event) {
649
 
650
  $single_event = new ecwd_single_event($event->ID, $event->post_title, $event->post_content);
657
 
658
  $single_events_list[$event->ID] = $single_event;
659
  }
660
+ return $single_events_list;
661
  }
662
 
663
  /**
665
  * */
666
  public function update_meta_values($ev){
667
 
668
+ $old_ev = $this->convert_wp_post_to_ecwd_event(array(get_post($ev->id)));
669
+ $old_ev = $old_ev[$ev->id];
670
+
671
  update_post_meta($ev->id, 'ecwd_event_date_from', $this->sanitize_text($ev->get_start_date()));
672
  update_post_meta($ev->id, 'ecwd_event_date_to', $this->sanitize_text($ev->get_end_date()));
673
  if($ev->get_all_day() === true) {
710
 
711
  }
712
 
713
+ $events_metas_data = array(
714
+ $ev->get_start_date(),
715
+ $ev->get_end_date(),
716
+ json_encode($ev->calendars),
717
+ json_encode($ev->repeat)
718
+ );
719
+
720
+ $old_events_metas_data = array(
721
+ $old_ev->get_start_date(),
722
+ $old_ev->get_end_date(),
723
+ json_encode($old_ev->calendars),
724
+ json_encode($old_ev->repeat)
725
+ );
726
+
727
+ if(md5(implode(":" , $events_metas_data)) !== md5(implode(":", $old_events_metas_data))) {
728
+ $calendars_id = array_unique(array_merge($ev->calendars, $old_ev->calendars));
729
+ self::clear_recurring_events_cache($calendars_id);
730
+ }
731
  }
732
 
733
  public function sanitize_text($str){
742
 
743
  }
744
 
745
+ /**
746
+ * @param $calendars_id array of calendars id
747
+ * */
748
+ public static function clear_recurring_events_cache($calendars_id){
749
+ foreach($calendars_id as $cal_id) {
750
+ $transients = get_post_meta($cal_id, 'ecwd_recurring_events_transient', true);
751
+ if(is_array($transients) && !empty($transients)) {
752
+ foreach($transients as $transient) {
753
+ delete_site_transient($transient);
754
+ }
755
+ }
756
+ delete_post_meta($cal_id, 'ecwd_recurring_events_transient');
757
+ }
758
+ }
759
 
760
  }
includes/events/ecwd-events-query.php CHANGED
@@ -105,6 +105,120 @@ class ecwd_events_query {
105
  $this->add_query_arg('meta_query', $date_query);
106
  }
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  /**
109
  * @param $calendar_id string|array
110
  * @param $exclude boolean exclude authors no
105
  $this->add_query_arg('meta_query', $date_query);
106
  }
107
 
108
+
109
+
110
+ /**
111
+ * @param $from string date format Y/m/d
112
+ * @param $to string date format Y/m/d
113
+ * */
114
+ public function filter_recurring($from, $to){
115
+
116
+ $date_query = array(
117
+ 'relation' => 'AND',
118
+ array(
119
+ 'key' => 'ecwd_event_date_from',
120
+ 'value' => $to,
121
+ 'compare' => '<=',
122
+ 'type' => 'DATE'
123
+ ),
124
+ array(
125
+ 'relation' => 'OR',
126
+ array(
127
+ 'relation' => 'AND',
128
+ array(
129
+ 'key' => 'ecwd_event_repeat_event',
130
+ 'value' => "no_repeat",
131
+ 'compare' => '=',
132
+ ),
133
+ array(
134
+ 'key' => 'ecwd_event_date_to',
135
+ 'value' => $from,
136
+ 'compare' => '>=',
137
+ 'type' => 'DATE'
138
+ )
139
+ ),
140
+ array(
141
+ 'relation' => 'AND',
142
+ array(
143
+ 'key' => 'ecwd_event_repeat_event',
144
+ 'value' => "no_repeat",
145
+ 'compare' => '!=',
146
+ ),
147
+ array(
148
+ 'key' => 'ecwd_event_repeat_repeat_until',
149
+ 'value' => $from,
150
+ 'compare' => '>=',
151
+ 'type' => 'DATE'
152
+ )
153
+ )
154
+ )
155
+
156
+ );
157
+
158
+ $this->add_query_arg('meta_query', $date_query);
159
+ }
160
+
161
+ public function filter_past_events(){
162
+ $date_query = array(
163
+ array(
164
+ 'relation' => 'AND',
165
+ array(
166
+ 'key' => 'ecwd_event_repeat_event',
167
+ 'value' => "no_repeat",
168
+ 'compare' => '=',
169
+ ),
170
+ array(
171
+ 'key' => 'ecwd_event_date_to',
172
+ 'value' => date('Y/m/d'),
173
+ 'compare' => '<',
174
+ 'type' => 'DATE'
175
+ )
176
+ ),
177
+ );
178
+
179
+ $this->add_query_arg('meta_query', $date_query);
180
+ }
181
+
182
+
183
+
184
+ public function filter_excluded_events($calendar_id){
185
+
186
+ $exclude_query = array(
187
+ 'relation' => 'OR',
188
+ array(
189
+ 'key' => ECWD_PLUGIN_PREFIX . '_event_calendars',
190
+ 'value' => serialize(strval($calendar_id)),
191
+ 'compare' => 'NOT LIKE'
192
+ ),
193
+ array(
194
+ 'key' => ECWD_PLUGIN_PREFIX . '_event_calendars',
195
+ 'compare' => 'NOT EXISTS'
196
+ ),
197
+ array(
198
+ 'key' => ECWD_PLUGIN_PREFIX . '_event_calendars',
199
+ 'value' => '',
200
+ ),
201
+ );
202
+
203
+ $this->add_query_arg('meta_query', $exclude_query);
204
+ }
205
+
206
+
207
+ /**
208
+ * @param $calendar_id string|array
209
+ * @param $exclude boolean exclude authors no
210
+ * */
211
+ public function filter_by_events_id($events_id=array(), $exclude = false){
212
+
213
+ if($exclude === false){
214
+ $this->set_query_arg('post__in', $events_id);
215
+ }else{
216
+ $this->set_query_arg('post__not_in', $events_id);
217
+ }
218
+
219
+ }
220
+
221
+
222
  /**
223
  * @param $calendar_id string|array
224
  * @param $exclude boolean exclude authors no
includes/events/ecwd-single-event.php CHANGED
@@ -292,4 +292,11 @@ class ecwd_single_event {
292
  return $this->is_default_dates;
293
  }
294
 
 
 
 
 
 
 
295
  }
 
292
  return $this->is_default_dates;
293
  }
294
 
295
+
296
+ public function __clone(){
297
+
298
+ }
299
+
300
+
301
  }
302
+
includes/register-settings.php CHANGED
@@ -6,13 +6,13 @@
6
  */
7
  // Exit if accessed directly.
8
  if (!defined('ABSPATH')) {
9
- exit;
10
  }
11
 
12
 
13
  if (isset($_GET[ECWD_PLUGIN_PREFIX . '_clear_cache']) && $_GET[ECWD_PLUGIN_PREFIX . '_clear_cache'] == 1) {
14
- $cpt = ECWD_Cpt::get_instance();
15
- add_action('admin_init', array($cpt, 'ecwd_clear_cache_option'));
16
  }
17
 
18
  if (isset($_GET[ECWD_PLUGIN_PREFIX . '_reset_script_key']) && $_GET[ECWD_PLUGIN_PREFIX . '_reset_script_key'] == 1) {
@@ -48,22 +48,41 @@ if (isset($_GET[ECWD_PLUGIN_PREFIX . '_reset_script_key']) && $_GET[ECWD_PLUGIN_
48
  /**
49
  * Main function to register all of the plugin settings
50
  */
51
- function ecwd_register_settings() {
 
52
 
53
- global $ecwd_settings;
54
- global $ecwd_tabs;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- $ecwd_tabs = array(
57
- 'general' => __('General','event-calendar-wd'),
58
- 'events' => __('Events','event-calendar-wd'),
59
- 'category_archive' => __('Category Page','event-calendar-wd'),
60
- 'custom_css' => __('Custom CSS','event-calendar-wd'),
61
- 'google_map' => __('Google Maps','event-calendar-wd'),
62
- 'fb' => __('FB settings','event-calendar-wd'),
63
- 'gcal' => __('Gcal settings','event-calendar-wd'),
64
- 'ical' => __('Ical settings','event-calendar-wd'),
65
- 'add_event' => __('Add Event','event-calendar-wd')
66
- );
67
  $ecwd_settings = array(
68
  /* General Settings */
69
 
@@ -84,6 +103,15 @@ function ecwd_register_settings() {
84
  // 'type' => 'link',
85
  // 'href' => $_SERVER['REQUEST_URI'] . '&ecwd_clear_autogen=1'
86
  // ),
 
 
 
 
 
 
 
 
 
87
  'time_zone' => array(
88
  'id' => 'time_zone',
89
  'name' => __('TimeZone', 'event-calendar-wd'),
@@ -98,12 +126,22 @@ function ecwd_register_settings() {
98
  'desc' => '',
99
  'type' => 'checkbox'
100
  ),
101
- 'date_format' => array(
102
  'id' => 'date_format',
103
  'name' => __('Date format', 'event-calendar-wd'),
104
  'desc' => __('Set the format for displaying event dates. Ex Y-m-d or Y/m/d', 'event-calendar-wd'),
105
  'size' => 'medium-text',
106
  'type' => 'text'
 
 
 
 
 
 
 
 
 
 
107
  ),
108
  'time_format' => array(
109
  'id' => 'time_format',
@@ -119,13 +157,24 @@ function ecwd_register_settings() {
119
  'size' => 'medium-text',
120
  'type' => 'time_type_select'
121
  ),
122
- 'list_date_format' => array(
 
123
  'id' => 'list_date_format',
124
  'name' => __('List,Week,Day views day format', 'event-calendar-wd'),
125
  'desc' => __('Note: Changed date format will not be translatable', 'event-calendar-wd'),
126
  'default' => 'd.F.l',
127
  'size' => 'medium-text',
128
  'type' => 'text'
 
 
 
 
 
 
 
 
 
 
129
  ),
130
  'week_starts' => array(
131
  'id' => 'week_starts',
@@ -247,7 +296,7 @@ function ecwd_register_settings() {
247
  'name' => __('Related events count', 'event-calendar-wd'),
248
  'desc' => __('empty for all events','event-calendar-wd'),
249
  'type' => 'text',
250
- 'default' => ''
251
  ),
252
  'events_in_popup' => array(
253
  'id' => 'events_in_popup',
@@ -372,7 +421,7 @@ function ecwd_register_settings() {
372
  'type' => 'textarea',
373
  'cols' => '45',
374
  'rows' => '15'
375
- ),
376
  ),
377
  'google_map' => array(
378
  'add_project' => array(
@@ -445,6 +494,7 @@ function ecwd_register_settings() {
445
  )
446
  );
447
 
 
448
  $config = get_option('ecwd_config');
449
  if($config == "on") {
450
  $ecwd_settings['general']['ecwd_reset_script_key'] = array(
@@ -456,25 +506,35 @@ function ecwd_register_settings() {
456
  'href' => $_SERVER['REQUEST_URI'] . '&ecwd_reset_script_key=1'
457
  );
458
  }
459
-
460
- if (1 == get_option('ecwd_old_events')) {
461
- $ecwd_settings['general']['show_repeat_rate'] = array(
462
- 'id' => 'show_repeat_rate',
463
- 'name' => __('Show the repeat rate', 'event-calendar-wd'),
464
- 'desc' => __('Check to show the repeat rate in event page .', 'event-calendar-wd'),
465
- 'type' => 'checkbox'
466
- );
 
 
 
 
 
 
 
 
 
 
 
 
467
  }
468
 
 
469
  /* If the options do not exist then create them for each section */
470
  if (false == get_option(ECWD_PLUGIN_PREFIX . '_settings')) {
471
  add_option(ECWD_PLUGIN_PREFIX . '_settings');
472
  }
473
-
474
-
475
  /* Add the Settings sections */
476
 
477
- //$calendar = get_posts(array('post_type' => 'ecwd_calendar'));
478
  // $settings_init_on_activate = ((strpos($_SERVER['REQUEST_URI'], 'plugins.php')) && ((empty($calendar) && (get_option("activation_page_option") === false)) || isset($_POST['ecwd_settings_general']['week_starts'])));
479
  // if ($settings_init_on_activate) {
480
  // update_option("activation_page_option", "submit");
@@ -484,7 +544,7 @@ function ecwd_register_settings() {
484
  foreach ($ecwd_settings as $key => $settings) {
485
 
486
  add_settings_section(
487
- ECWD_PLUGIN_PREFIX . '_settings_' . $key, __($ecwd_tabs[$key], 'event-calendar-wd'), '__return_false', ECWD_PLUGIN_PREFIX . '_settings_' . $key
488
  );
489
 
490
 
@@ -499,9 +559,55 @@ function ecwd_register_settings() {
499
  /* Register all settings or we will get an error when trying to save */
500
  register_setting(ECWD_PLUGIN_PREFIX . '_settings_' . $key, ECWD_PLUGIN_PREFIX . '_settings_' . $key, ECWD_PLUGIN_PREFIX . '_settings_sanitize');
501
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
502
  foreach ($ecwd_disabled_settings as $key => $settings) {
503
  add_settings_section(
504
- ECWD_PLUGIN_PREFIX . '_settings_' . $key, __($ecwd_tabs[$key], 'event-calendar-wd'), '__return_false', ECWD_PLUGIN_PREFIX . '_settings_' . $key
505
  );
506
 
507
 
@@ -542,6 +648,7 @@ function ecwd_get_settings_field_args($option, $section) {
542
  'rows' => isset($option['rows']) ? $option['rows'] : '',
543
  'labels' => isset($option['labels']) ? $option['labels'] : array(),
544
  'disabled' => isset($option['disabled']) ? $option['disabled'] : false,
 
545
  );
546
 
547
  // Link label to input using 'label_for' argument if text, textarea, password, select, or variations of.
@@ -553,6 +660,10 @@ function ecwd_get_settings_field_args($option, $section) {
553
  return $settings_args;
554
  }
555
 
 
 
 
 
556
  /*
557
  * Week select callback function
558
  */
@@ -763,6 +874,69 @@ function ecwd_custom_radio_callback($args) {
763
  * Multiple checkboxs callback function
764
  */
765
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
766
  function ecwd_cats_checkbox_callback($args) {
767
  global $ecwd_options;
768
  $categories = get_categories(array('taxonomy' => ECWD_PLUGIN_PREFIX . '_event_category'));
@@ -932,6 +1106,10 @@ function ecwd_get_settings() {
932
  'ical' => __('Ical settings','event-calendar-wd'),
933
  'add_event' => __('Add Event','event-calendar-wd')
934
  );
 
 
 
 
935
  // Set default settings
936
  // If this is the first time running we need to set the defaults
937
  if (!get_option(ECWD_PLUGIN_PREFIX . '_upgrade_has_run')) {
@@ -941,11 +1119,87 @@ function ecwd_get_settings() {
941
 
942
  update_option(ECWD_PLUGIN_PREFIX . '_settings_general', $general);
943
  }
944
- $general_settings = array();
945
- foreach ($ecwd_tabs as $key => $settings) {
946
- $general_settings += is_array(get_option(ECWD_PLUGIN_PREFIX . '_settings_' . $key)) ? get_option(ECWD_PLUGIN_PREFIX . '_settings_' . $key) : array();
 
 
 
 
947
  }
948
 
949
 
950
- return $general_settings;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
951
  }
6
  */
7
  // Exit if accessed directly.
8
  if (!defined('ABSPATH')) {
9
+ exit;
10
  }
11
 
12
 
13
  if (isset($_GET[ECWD_PLUGIN_PREFIX . '_clear_cache']) && $_GET[ECWD_PLUGIN_PREFIX . '_clear_cache'] == 1) {
14
+ $cpt = ECWD_Cpt::get_instance();
15
+ add_action('admin_init', array($cpt, 'ecwd_clear_cache_option'));
16
  }
17
 
18
  if (isset($_GET[ECWD_PLUGIN_PREFIX . '_reset_script_key']) && $_GET[ECWD_PLUGIN_PREFIX . '_reset_script_key'] == 1) {
48
  /**
49
  * Main function to register all of the plugin settings
50
  */
51
+ function ecwd_get_settings_params()
52
+ {
53
 
54
+ global $ecwd_settings;
55
+ global $ecwd_tabs;
56
+ $date_format = get_option('date_format');
57
+
58
+
59
+ if(!isset($date_format)){
60
+ $date_format = "F j, Y";
61
+ }
62
+
63
+ $ecwd_tabs = array(
64
+ 'general' => __('General', 'event-calendar-wd'),
65
+ 'events' => __('Events', 'event-calendar-wd'),
66
+ 'category_archive' => __('Category Page','event-calendar-wd'),
67
+ 'custom_css' => __('Custom CSS', 'event-calendar-wd'),
68
+ 'google_map' => __('Google Maps', 'event-calendar-wd'),
69
+ 'fb' => __('FB settings', 'event-calendar-wd'),
70
+ 'gcal' => __('Gcal settings', 'event-calendar-wd'),
71
+ 'ical' => __('Ical settings', 'event-calendar-wd'),
72
+ 'add_event' => __('Frontend Event Management', 'event-calendar-wd'),
73
+ 'countdown' => __('Countdown', 'event-calendar-wd'),
74
+ 'af' => __('Custom Fields', 'event-calendar-wd'),
75
+ 'ecwd_subscribe' => __('Subscribe','event-calendar-wd'),
76
+ 'upcoming_events' => __('Upcoming events', 'event-calendar-wd'),
77
+ 'filter_settings' => __('Filters','event-calendar-wd'),
78
+ 'export' => __('Export to GCal/ICal', 'event-calendar-wd')
79
+ );
80
+
81
+ $related_events_count = intval(get_option('posts_per_page'));
82
+ if($related_events_count === 0){
83
+ $related_events_count = 10;
84
+ }
85
 
 
 
 
 
 
 
 
 
 
 
 
86
  $ecwd_settings = array(
87
  /* General Settings */
88
 
103
  // 'type' => 'link',
104
  // 'href' => $_SERVER['REQUEST_URI'] . '&ecwd_clear_autogen=1'
105
  // ),
106
+ 'ecwd_delete_past_events' => array(
107
+ 'id' => 'ecwd_delete_past_events',
108
+ 'name' => __('Delete past events', 'event-calendar-wd'),
109
+ 'desc' => '',
110
+ 'title' => 'Delete',
111
+ 'type' => 'link',
112
+ 'class'=>'ecwd_delete_past_events',
113
+ 'href' => '#ecwd_past_event_list_popup'
114
+ ),
115
  'time_zone' => array(
116
  'id' => 'time_zone',
117
  'name' => __('TimeZone', 'event-calendar-wd'),
126
  'desc' => '',
127
  'type' => 'checkbox'
128
  ),
129
+ /* 'date_format' => array(
130
  'id' => 'date_format',
131
  'name' => __('Date format', 'event-calendar-wd'),
132
  'desc' => __('Set the format for displaying event dates. Ex Y-m-d or Y/m/d', 'event-calendar-wd'),
133
  'size' => 'medium-text',
134
  'type' => 'text'
135
+ ),*/
136
+
137
+
138
+ 'date_format' => array(
139
+ 'id' => 'date_format',
140
+ 'name' => __('Date format', 'event-calendar-wd'),
141
+ 'desc' => __('Set the format for displaying event dates. Ex Y-m-d or Y/m/d', 'event-calendar-wd'),
142
+ 'type' => 'custom_date_radio',
143
+ 'default' => 'd/m/Y',
144
+ 'labels' => array('F j, Y', 'Y-m-d','m/d/Y','d/m/Y', 'custom')
145
  ),
146
  'time_format' => array(
147
  'id' => 'time_format',
157
  'size' => 'medium-text',
158
  'type' => 'time_type_select'
159
  ),
160
+ /*xxxx*/
161
+ /* 'list_date_format' => array(
162
  'id' => 'list_date_format',
163
  'name' => __('List,Week,Day views day format', 'event-calendar-wd'),
164
  'desc' => __('Note: Changed date format will not be translatable', 'event-calendar-wd'),
165
  'default' => 'd.F.l',
166
  'size' => 'medium-text',
167
  'type' => 'text'
168
+ ),*/
169
+
170
+
171
+ 'list_date_format' => array(
172
+ 'id' => 'list_date_format',
173
+ 'name' => __('List,Week,Day views day format', 'event-calendar-wd'),
174
+ 'desc' => __('Note: Changed date format will not be translatable', 'event-calendar-wd'),
175
+ 'type' => 'custom_date_radio',
176
+ 'default' => $date_format,
177
+ 'labels' => array('F j, Y', 'Y-m-d','m/d/Y','d/m/Y', 'custom')
178
  ),
179
  'week_starts' => array(
180
  'id' => 'week_starts',
296
  'name' => __('Related events count', 'event-calendar-wd'),
297
  'desc' => __('empty for all events','event-calendar-wd'),
298
  'type' => 'text',
299
+ 'default' => $related_events_count
300
  ),
301
  'events_in_popup' => array(
302
  'id' => 'events_in_popup',
421
  'type' => 'textarea',
422
  'cols' => '45',
423
  'rows' => '15'
424
+ )
425
  ),
426
  'google_map' => array(
427
  'add_project' => array(
494
  )
495
  );
496
 
497
+
498
  $config = get_option('ecwd_config');
499
  if($config == "on") {
500
  $ecwd_settings['general']['ecwd_reset_script_key'] = array(
506
  'href' => $_SERVER['REQUEST_URI'] . '&ecwd_reset_script_key=1'
507
  );
508
  }
509
+
510
+ if(1 == get_option('ecwd_old_events')) {
511
+ $ecwd_settings['general']['show_repeat_rate'] = array(
512
+ 'id' => 'show_repeat_rate',
513
+ 'name' => __('Show the repeat rate', 'event-calendar-wd'),
514
+ 'desc' => __('Check to show the repeat rate in event page .', 'event-calendar-wd'),
515
+ 'type' => 'checkbox'
516
+ );
517
+ }
518
+ }
519
+
520
+ /**
521
+ * Main function to register all of the plugin settings
522
+ */
523
+ function ecwd_register_settings() {
524
+ global $ecwd_settings;
525
+ global $ecwd_tabs;
526
+
527
+ if($ecwd_settings === null || $ecwd_tabs === null){
528
+ ecwd_get_settings_params();
529
  }
530
 
531
+
532
  /* If the options do not exist then create them for each section */
533
  if (false == get_option(ECWD_PLUGIN_PREFIX . '_settings')) {
534
  add_option(ECWD_PLUGIN_PREFIX . '_settings');
535
  }
 
 
536
  /* Add the Settings sections */
537
 
 
538
  // $settings_init_on_activate = ((strpos($_SERVER['REQUEST_URI'], 'plugins.php')) && ((empty($calendar) && (get_option("activation_page_option") === false)) || isset($_POST['ecwd_settings_general']['week_starts'])));
539
  // if ($settings_init_on_activate) {
540
  // update_option("activation_page_option", "submit");
544
  foreach ($ecwd_settings as $key => $settings) {
545
 
546
  add_settings_section(
547
+ ECWD_PLUGIN_PREFIX . '_settings_' . $key, $ecwd_tabs[$key], '__return_false', ECWD_PLUGIN_PREFIX . '_settings_' . $key
548
  );
549
 
550
 
559
  /* Register all settings or we will get an error when trying to save */
560
  register_setting(ECWD_PLUGIN_PREFIX . '_settings_' . $key, ECWD_PLUGIN_PREFIX . '_settings_' . $key, ECWD_PLUGIN_PREFIX . '_settings_sanitize');
561
  }
562
+
563
+
564
+ /*disabled options*/
565
+
566
+ $ecwd_disabled_settings = array(
567
+ /* General Settings */
568
+ 'general' => array(
569
+ 'show_repeat_rate' => array(
570
+ 'id' => 'show_repeat_rate',
571
+ 'name' => __('Show the repeat rate', 'event-calendar-wd'),
572
+ 'desc' => __('Check to show the repeat rate in event page .', 'event-calendar-wd'),
573
+ 'type' => 'checkbox'
574
+ ),
575
+ 'posterboard_fixed_height' => array(
576
+ 'id' => 'posterboard_fixed_height',
577
+ 'name' => __('Add fixed height for events in posterboard view', 'event-calendar-wd'),
578
+ 'desc' => '',
579
+ 'type' => 'radio',
580
+ 'default' => 0
581
+ ),
582
+ 'period_for_list' => array(
583
+ 'id' => 'period_for_list',
584
+ 'name' => __('Period for List view', 'event-calendar-wd'),
585
+ 'desc' => __('Period for showing events', 'event-calendar-wd'),
586
+ 'size' => 'medium-text',
587
+ 'type' => 'agenda_select'
588
+ ),
589
+ ),
590
+ 'google_map' => array(
591
+ 'gmap_type' => array(
592
+ 'id' => 'gmap_type',
593
+ 'name' => __('Satellite Gmap Type', 'event-calendar-wd'),
594
+ 'desc' => '',
595
+ 'type' => 'radio',
596
+ 'default' => 0
597
+ ),
598
+ 'gmap_marker_click' => array(
599
+ 'id' => 'gmap_marker_click',
600
+ 'name' => __('Open Google Maps when Marker is clicked', 'event-calendar-wd'),
601
+ 'desc' => '',
602
+ 'type' => 'radio',
603
+ 'default' => 0
604
+ ),
605
+ )
606
+ );
607
+
608
  foreach ($ecwd_disabled_settings as $key => $settings) {
609
  add_settings_section(
610
+ ECWD_PLUGIN_PREFIX . '_settings_' . $key, $ecwd_tabs[$key], '__return_false', ECWD_PLUGIN_PREFIX . '_settings_' . $key
611
  );
612
 
613
 
648
  'rows' => isset($option['rows']) ? $option['rows'] : '',
649
  'labels' => isset($option['labels']) ? $option['labels'] : array(),
650
  'disabled' => isset($option['disabled']) ? $option['disabled'] : false,
651
+ 'title' => isset($option['title']) ? $option['title'] : "",
652
  );
653
 
654
  // Link label to input using 'label_for' argument if text, textarea, password, select, or variations of.
660
  return $settings_args;
661
  }
662
 
663
+ function ecwd_button_callback($args) {
664
+ echo "<a href='#' id='" . $args['id'] . "' class='button'>" . $args['title'] . "</a>";
665
+ }
666
+
667
  /*
668
  * Week select callback function
669
  */
874
  * Multiple checkboxs callback function
875
  */
876
 
877
+
878
+ function ecwd_custom_date_radio_callback($args){
879
+ global $ecwd_options;
880
+ $date_format = get_option( 'date_format' );
881
+ $html = '';
882
+ if(isset($ecwd_options[$args["id"]])){
883
+ $option_data = $ecwd_options[$args["id"]];
884
+ }elseif (isset($args['default'])){
885
+ $option_data = $args['default'];
886
+ }
887
+ $custom_date_input = "F j, Y";
888
+ if(isset($ecwd_options['custom_'.$args['id']]) && !empty($ecwd_options['custom_'.$args['id']])){
889
+ $custom_date_input = $ecwd_options['custom_'.$args['id']];
890
+ }
891
+ $is_checked = true;
892
+ foreach ($args["labels"] as $key => $label){
893
+ $check_text = '';
894
+ $custom_check_text = '';
895
+
896
+ if(((isset($option_data) && $label === $option_data) && $is_checked)){
897
+ $check_text = 'checked';
898
+ $is_checked = false;
899
+ }
900
+ $current_date = date($label);
901
+ if($label === "custom"){
902
+ if($label == end($args["labels"]) && $is_checked) {
903
+ $custom_check_text = 'checked';
904
+ if(isset($option_data)){
905
+ $custom_date_input = $option_data;
906
+ }
907
+ elseif(isset($date_format)){
908
+ $custom_date_input = $date_format;
909
+ }
910
+ }
911
+ $current_date = "Custom";
912
+ $html .= '<div class="ecwd_custom_date">
913
+ <div class="checkbox-div-content">
914
+ <div class="checkbox-div">
915
+ <input type="radio" id="ecwd_settings_' . $args['section'] . '[' . $args['id'] . ']_' . $key . '" name="ecwd_settings_' . $args['section'] . '[' . $args['id'] . ']" value="custom" ' . $custom_check_text . ' /><label for="ecwd_settings_' . $args['section'] . '[' . $args['id'] . ']_' . $key . '"></label>
916
+ </div>
917
+ <label for="ecwd_settings_' . $args['section'] . '[' . $args['id'] . ']_' . $key . '">' . $current_date . '</label>
918
+ </div>
919
+ <input class="ecwd_custom_date_el" type="text" name="ecwd_settings_' . $args['section'] . '[custom_'.$args['id'].']" value="'.$custom_date_input.'" >
920
+ </div>' . "\n";
921
+ }else{
922
+ $html .= '<div class="ecwd_custom_date">
923
+ <div class="checkbox-div-content">
924
+ <div class="checkbox-div">
925
+ <input type="radio" id="ecwd_settings_' . $args['section'] . '[' . $args['id'] . ']_' . $key . '" name="ecwd_settings_' . $args['section'] . '[' . $args['id'] . ']" value="' . $label . '" ' . $check_text . ' /><label for="ecwd_settings_' . $args['section'] . '[' . $args['id'] . ']_' . $key . '"></label>
926
+ </div>
927
+ <label for="ecwd_settings_' . $args['section'] . '[' . $args['id'] . ']_' . $key . '">' . $current_date . '</label>
928
+ </div>
929
+ <code class="ecwd_custom_date_el">'.$label.'</code>
930
+ </div>' . "\n";
931
+ }
932
+
933
+
934
+
935
+ }
936
+ $html .= '<p class="description">' . $args['desc'] . '</p>' . "\n";
937
+ echo $html;
938
+ }
939
+
940
  function ecwd_cats_checkbox_callback($args) {
941
  global $ecwd_options;
942
  $categories = get_categories(array('taxonomy' => ECWD_PLUGIN_PREFIX . '_event_category'));
1106
  'ical' => __('Ical settings','event-calendar-wd'),
1107
  'add_event' => __('Add Event','event-calendar-wd')
1108
  );
1109
+
1110
+
1111
+ ecwd_get_settings_params();
1112
+ global $ecwd_settings;
1113
  // Set default settings
1114
  // If this is the first time running we need to set the defaults
1115
  if (!get_option(ECWD_PLUGIN_PREFIX . '_upgrade_has_run')) {
1119
 
1120
  update_option(ECWD_PLUGIN_PREFIX . '_settings_general', $general);
1121
  }
1122
+
1123
+ $general_settings = array();
1124
+ foreach($ecwd_tabs as $key => $settings) {
1125
+
1126
+ $options = get_option(ECWD_PLUGIN_PREFIX . '_settings_' . $key);
1127
+ if(!is_array($options)) {
1128
+ $options = array();
1129
  }
1130
 
1131
 
1132
+ if(isset($ecwd_settings[$key])) {
1133
+
1134
+ foreach($ecwd_settings[$key] as $i => $setting) {
1135
+
1136
+ if(isset($options[$setting['id']])) {
1137
+ continue;
1138
+ }
1139
+
1140
+ switch($setting['type']) {
1141
+ case "checkbox":
1142
+ if(isset($setting['default']) && $setting['default'] == '1') {
1143
+ $options[$setting['id']] = '1';
1144
+ } else {
1145
+ $options[$setting['id']] = '0';
1146
+ }
1147
+ break;
1148
+ case "time_type_select":
1149
+ $options[$setting['id']] = '';
1150
+ break;
1151
+ case "week_select":
1152
+ $options[$setting['id']] = '0';
1153
+ break;
1154
+ case "radio":
1155
+ if(isset($setting['default']) && $setting['default'] == '1') {
1156
+ $options[$setting['id']] = '1';
1157
+ } else {
1158
+ $options[$setting['id']] = '0';
1159
+ }
1160
+ break;
1161
+ case "order_select":
1162
+ $options[$setting['id']] = 'post_name';
1163
+ break;
1164
+ case "agenda_select":
1165
+ $options[$setting['id']] = '1';
1166
+ break;
1167
+ case "custom_radio":
1168
+ if(isset($setting['default'])) {
1169
+ $options[$setting['id']] = $setting['default'];
1170
+ }else{
1171
+ $options[$setting['id']] = 0;
1172
+ }
1173
+ break;
1174
+ case "status_select"://add-event
1175
+ $options[$setting['id']] = 'draft';
1176
+ break;
1177
+ case "af_text"://custom fields
1178
+ $options[$setting['id']] = array('');
1179
+ break;
1180
+ case "cats_checkbox"://integration addons
1181
+ $options[$setting['id']] = array('');
1182
+ break;
1183
+ case "update_select"://integration addons
1184
+ $options[$setting['id']] = '1';
1185
+ break;
1186
+ case "text":
1187
+ case "textarea":
1188
+ case "number":
1189
+ $options[$setting['id']] = isset($setting['default']) ? $setting['default'] : '';
1190
+ break;
1191
+ }
1192
+
1193
+ }
1194
+
1195
+ }
1196
+ $general_settings += $options;
1197
+ }
1198
+ if(isset($general_settings["date_format"]) && $general_settings["date_format"]==="custom"){
1199
+ $general_settings["date_format"] = $general_settings["custom_date_format"];
1200
+ }
1201
+ if(isset($general_settings["list_date_format"]) && $general_settings["list_date_format"]==="custom"){
1202
+ $general_settings["list_date_format"] = $general_settings["custom_list_date_format"];
1203
+ }
1204
+ return $general_settings;
1205
  }
js/admin/admin.js CHANGED
@@ -879,6 +879,15 @@
879
  return response;
880
  }
881
 
 
 
 
 
 
 
 
 
 
882
  }(jQuery));
883
 
884
  var map;
@@ -1164,10 +1173,11 @@ function loadScript()
1164
 
1165
 
1166
  var ecwd_table;
 
1167
 
1168
 
1169
- $(document).ready(function(){
1170
- var ecwd_events_popup_button = $('.ecwd_events_popup_button');
1171
  if(ecwd_events_popup_button.length>0){
1172
  ecwd_events_popup_button.magnificPopup({
1173
  type:'inline',
@@ -1176,6 +1186,17 @@ $(document).ready(function(){
1176
  }
1177
  });
1178
  }
 
 
 
 
 
 
 
 
 
 
 
1179
  });
1180
 
1181
 
@@ -1186,10 +1207,15 @@ $('body').on('click', '.ecwd_events_popup_button', function (){
1186
  $(".ecwd_event_table").remove();
1187
  ecwd_get_events();
1188
  });
1189
- var ecwd_all_events_count;
1190
  function ecwd_get_events() {
1191
- var url = ecwdServerVars.rest_route+'events';
 
 
 
 
 
1192
  var request_url = ecwd_updateQueryStringParameter(url, 'nonce', ecwdServerVars.ecwdRestNonce);
 
1193
  $(".ecwd_event_list_popup_loader").css({
1194
  'display':'block'
1195
  });
@@ -1204,21 +1230,8 @@ function ecwd_get_events() {
1204
  });
1205
  $(".ecwd_add_events").removeClass('ecwd_add_events_button');
1206
  var ecwd_event_list = "";
1207
- var calendar_event_list = $("#ecwd_calendar_meta table .ecwd-events .ecwd-calendar-event input");
1208
- ecwd_all_events_count = data.data.length;
1209
  $.each(data.data, function (key, value ) {
1210
- var flag = true;
1211
- $.each(calendar_event_list, function (num,val) {
1212
- var event_ides = parseInt(value.ID);
1213
- var calendar_event_ides = parseInt($(val).val());
1214
-
1215
- if(event_ides===calendar_event_ides){
1216
- flag = false;
1217
- }
1218
- });
1219
- if(flag){
1220
- ecwd_event_list+="<tr data-id='"+value.ID+"' data-title='"+value.post_title+"'><td></td><td>"+value.post_title+"</td><td>"+value.ecwd_event_date_from+"</td><td>"+value.ecwd_event_date_to+"</td></tr>";
1221
- }
1222
  });
1223
  var ecwd_event_table = '' +
1224
  '<table class="ecwd_event_table display" style="width:100%">' +
@@ -1292,11 +1305,10 @@ $('body').on('click','.ecwd_add_events',function (e) {
1292
  var main_tr = this.closest("tr");
1293
  var event_id = $(main_tr).data("id");
1294
  var event_title = $(main_tr).data("title");
1295
- var calendar_id = $('#post_ID').val();
1296
 
1297
  ecwd_event_data.push({
1298
  event_id:event_id,
1299
- calendar_id:calendar_id,
1300
  });
1301
  var ecwd_added_event = '<span class="ecwd-calendar-event"> <span>'+event_title+'</span>\n' +
1302
  ' <input type="hidden" name="ecwd-calendar-event-id[]" value="'+event_id+'">\n' +
@@ -1310,19 +1322,19 @@ $('body').on('click','.ecwd_add_events',function (e) {
1310
  });
1311
 
1312
  function ecwd_ajax_add_events(ecwd_event_data ) {
 
1313
  var url = ecwdServerVars.rest_route+'add_event';
1314
  var request_url = ecwd_updateQueryStringParameter(url, 'nonce', ecwdServerVars.ecwdRestNonce);
 
1315
  $.ajax({
1316
  url: request_url,
1317
  type: 'POST',
1318
  dataType: 'json',
1319
- data: { ecwd_data:ecwd_event_data ,nonce: ecwdServerVars.ecwdRestNonce },
1320
  success: function(data) {
1321
  if(data.success){
1322
  ecwd_table.destroy();
1323
- var calendar_event_list = $("#ecwd_calendar_meta table .ecwd-events .ecwd-calendar-event input");
1324
- var calendar_event_list_length = calendar_event_list.length;
1325
- if(ecwd_all_events_count === calendar_event_list_length){
1326
  var new_post_url = $(".ecwd_events_popup_button").data('new_event_url');
1327
  $(".ecwd_events_popup_button").remove();
1328
  $(".ecwd-calendar-event-add").html('<a href="'+new_post_url+'" target="_blank">Create more events</a><a href="\'+new_post_url+\'" target="_blank"><span class="add_event_plus">+</span></a></span>');
@@ -1345,4 +1357,140 @@ function ecwd_updateQueryStringParameter(uri, key, value) {
1345
  else {
1346
  return uri + separator + key + "=" + value;
1347
  }
1348
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
879
  return response;
880
  }
881
 
882
+ jQuery('#ecwd_reset_settings_button').on('click', function (e) {
883
+ e.preventDefault();
884
+
885
+ jQuery('#ecwd_reset_settings_form').submit();
886
+
887
+ return false;
888
+ });
889
+
890
+
891
  }(jQuery));
892
 
893
  var map;
1173
 
1174
 
1175
  var ecwd_table;
1176
+ var ecwd_past_events_table;
1177
 
1178
 
1179
+ jQuery(document).ready(function(){
1180
+ var ecwd_events_popup_button = jQuery('.ecwd_events_popup_button');
1181
  if(ecwd_events_popup_button.length>0){
1182
  ecwd_events_popup_button.magnificPopup({
1183
  type:'inline',
1186
  }
1187
  });
1188
  }
1189
+
1190
+ var ecwd_delete_past_events = jQuery(".ecwd_delete_past_events a");
1191
+ if(ecwd_delete_past_events.length>0){
1192
+ ecwd_delete_past_events.magnificPopup({
1193
+ type:'inline',
1194
+ callbacks: {
1195
+
1196
+ }
1197
+ });
1198
+ }
1199
+
1200
  });
1201
 
1202
 
1207
  $(".ecwd_event_table").remove();
1208
  ecwd_get_events();
1209
  });
 
1210
  function ecwd_get_events() {
1211
+ if(ecwdServerVars.calendar_id != "" && typeof ecwdServerVars.calendar_id != "undefined"){
1212
+ var calendar_id = ecwdServerVars.calendar_id;
1213
+ }else{
1214
+ var calendar_id = jQuery("#post_ID").val();
1215
+ }
1216
+ var url = ecwdServerVars.rest_route+'excluded_event';
1217
  var request_url = ecwd_updateQueryStringParameter(url, 'nonce', ecwdServerVars.ecwdRestNonce);
1218
+ request_url = ecwd_updateQueryStringParameter(request_url, 'calendar_id', calendar_id);
1219
  $(".ecwd_event_list_popup_loader").css({
1220
  'display':'block'
1221
  });
1230
  });
1231
  $(".ecwd_add_events").removeClass('ecwd_add_events_button');
1232
  var ecwd_event_list = "";
 
 
1233
  $.each(data.data, function (key, value ) {
1234
+ ecwd_event_list+="<tr data-id='"+value.id+"' data-title='"+value.title+"'><td></td><td>"+value.title+"</td><td>"+value.from+"</td><td>"+value.end+"</td></tr>";
 
 
 
 
 
 
 
 
 
 
 
1235
  });
1236
  var ecwd_event_table = '' +
1237
  '<table class="ecwd_event_table display" style="width:100%">' +
1305
  var main_tr = this.closest("tr");
1306
  var event_id = $(main_tr).data("id");
1307
  var event_title = $(main_tr).data("title");
1308
+
1309
 
1310
  ecwd_event_data.push({
1311
  event_id:event_id,
 
1312
  });
1313
  var ecwd_added_event = '<span class="ecwd-calendar-event"> <span>'+event_title+'</span>\n' +
1314
  ' <input type="hidden" name="ecwd-calendar-event-id[]" value="'+event_id+'">\n' +
1322
  });
1323
 
1324
  function ecwd_ajax_add_events(ecwd_event_data ) {
1325
+ var calendar_id = $('#post_ID').val();
1326
  var url = ecwdServerVars.rest_route+'add_event';
1327
  var request_url = ecwd_updateQueryStringParameter(url, 'nonce', ecwdServerVars.ecwdRestNonce);
1328
+
1329
  $.ajax({
1330
  url: request_url,
1331
  type: 'POST',
1332
  dataType: 'json',
1333
+ data: {calendar_id:calendar_id, ecwd_data:ecwd_event_data ,nonce: ecwdServerVars.ecwdRestNonce },
1334
  success: function(data) {
1335
  if(data.success){
1336
  ecwd_table.destroy();
1337
+ if(data.free_events_count == 0){
 
 
1338
  var new_post_url = $(".ecwd_events_popup_button").data('new_event_url');
1339
  $(".ecwd_events_popup_button").remove();
1340
  $(".ecwd-calendar-event-add").html('<a href="'+new_post_url+'" target="_blank">Create more events</a><a href="\'+new_post_url+\'" target="_blank"><span class="add_event_plus">+</span></a></span>');
1357
  else {
1358
  return uri + separator + key + "=" + value;
1359
  }
1360
+ }
1361
+
1362
+
1363
+
1364
+
1365
+ $('body').on('click', '.ecwd_delete_past_events a', function (){
1366
+ if(typeof ecwd_past_events_table !== "undefined"){
1367
+ ecwd_past_events_table.destroy();
1368
+ }
1369
+ $(".ecwd_past_event_table").remove();
1370
+ ecwd_get_past_events();
1371
+ });
1372
+ function ecwd_get_past_events() {
1373
+ var url = ecwdServerVars.rest_route+'past_event';
1374
+ var request_url = ecwd_updateQueryStringParameter(url, 'nonce', ecwdServerVars.ecwdRestNonce);
1375
+ $(".ecwd_past_event_list_popup_loader").css({
1376
+ 'display':'block'
1377
+ });
1378
+ $(".ecwd_past_events_delete_button").addClass('ecwd_delete_events_button');
1379
+ $.ajax({
1380
+ url: request_url,
1381
+ type: 'GET',
1382
+ dataType: 'json',
1383
+ success: function(data) {
1384
+ $(".ecwd_past_event_list_popup_loader").css({
1385
+ 'display':'none'
1386
+ });
1387
+ $(".ecwd_past_events_delete_button").removeClass('ecwd_delete_events_button');
1388
+ var ecwd_event_list = "";
1389
+ $.each(data.data, function (key, value ) {
1390
+ ecwd_event_list+="<tr data-id='"+value.id+"' data-title='"+value.title+"'><td></td><td>"+value.title+"</td><td>"+value.from+"</td><td>"+value.end+"</td></tr>";
1391
+ });
1392
+ var ecwd_event_table = '' +
1393
+ '<table class="ecwd_past_event_table display" style="width:100%">' +
1394
+ '<thead>' +
1395
+ '<th><input type="checkbox" name="select_all" value="1" id="ecwd-select-all"></th>'+
1396
+ '<th>Title</th>' +
1397
+ '<th>Start date</th>' +
1398
+ '<th>End date</th>' +
1399
+ '</thead>' +
1400
+ '<tbody>' +
1401
+ ecwd_event_list+
1402
+ '</tbody>' +
1403
+ '<tfoot>' +
1404
+
1405
+ '</tfoot>' +
1406
+ '<th></th>'+
1407
+ '<th>Title</th>' +
1408
+ '<th>Start date</th>' +
1409
+ '<th>End date</th>' +
1410
+ '</tfoot>' +
1411
+ '</table>';
1412
+
1413
+
1414
+
1415
+ $(".ecwd_event_table").remove();
1416
+ $(".ecwd_popup_notice").remove();
1417
+ $(".ecwd_popup_title").remove();
1418
+ $("#ecwd_past_event_list_popup").prepend(ecwd_event_table);
1419
+ $("#ecwd_past_event_list_popup").prepend("<h4 class='ecwd_popup_notice'>Recurring events are excluded from this list</h4>");
1420
+ $("#ecwd_past_event_list_popup").prepend("<h3 class='ecwd_popup_title'>Delete past events</h3>");
1421
+ ecwd_past_events_table = $('.ecwd_past_event_table').DataTable({
1422
+ 'columnDefs': [{
1423
+ 'targets': 0,
1424
+ 'searchable':false,
1425
+ 'orderable':false,
1426
+ 'className': 'dt-body-center',
1427
+ 'render': function (data, type, full, meta){
1428
+ return '<input type="checkbox" name="id[]" value="">';
1429
+ }
1430
+ }],
1431
+ 'order': [[1, 'asc']]
1432
+ });
1433
+
1434
+ $('body').on('click', '#ecwd-select-all', function (){
1435
+ var rows = ecwd_past_events_table.rows({ 'search': 'applied' }).nodes();
1436
+ $('input[type="checkbox"]', rows).prop('checked', this.checked);
1437
+ });
1438
+
1439
+
1440
+ $('.ecwd_event_table tbody').on('change', 'input[type="checkbox"]', function(){
1441
+ if(!this.checked){
1442
+ $('#ecwd-select-all').attr('checked', false);
1443
+ }
1444
+ });
1445
+ },
1446
+ error: function() {
1447
+
1448
+ },
1449
+ beforeSend: setHeader
1450
+ });
1451
+
1452
+ function setHeader(xhr) {
1453
+ xhr.setRequestHeader('X-WP-Nonce', ecwdServerVars.wpRestNonce);
1454
+ }
1455
+ }
1456
+ $('body').on('click','.ecwd_past_events_delete_button',function (e) {
1457
+ e.preventDefault();
1458
+ $('#ecwd_past_event_list_popup').magnificPopup('close');
1459
+ var ecwd_past_event_data = [];
1460
+
1461
+
1462
+ ecwd_past_events_table.$('input[type="checkbox"]').each(function(){
1463
+ if(this.checked){
1464
+ var main_tr = this.closest("tr");
1465
+ var event_id = $(main_tr).data("id");
1466
+ ecwd_past_event_data.push(
1467
+ event_id
1468
+ );
1469
+ }
1470
+ });
1471
+ if(ecwd_past_event_data.length>0){
1472
+ ecwd_ajax_delete_events(ecwd_past_event_data);
1473
+ }
1474
+ });
1475
+
1476
+ function ecwd_ajax_delete_events(data) {
1477
+ var url = ecwdServerVars.rest_route+'delete_event';
1478
+ var request_url = ecwd_updateQueryStringParameter(url, 'nonce', ecwdServerVars.ecwdRestNonce);
1479
+ $.ajax({
1480
+ url: request_url,
1481
+ type: 'POST',
1482
+ dataType: 'json',
1483
+ data: { events_id:data ,nonce: ecwdServerVars.ecwdRestNonce },
1484
+ success: function(data) {
1485
+ if(data.success){
1486
+
1487
+ }
1488
+ },
1489
+ error: function() {},
1490
+ beforeSend: setHeader
1491
+ });
1492
+ function setHeader(xhr) {
1493
+ xhr.setRequestHeader('X-WP-Nonce', ecwdServerVars.wpRestNonce);
1494
+ }
1495
+
1496
+ }
languages/event-calendar-wd-it_IT.mo CHANGED
Binary file
languages/event-calendar-wd-it_IT.po CHANGED
@@ -3,14 +3,14 @@ msgstr ""
3
  "Project-Id-Version: event_calendar_wd\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2018-04-30 15:37+0400\n"
6
- "PO-Revision-Date: 2018-04-30 15:37+0400\n"
7
  "Last-Translator: admin <asd@das.das>\n"
8
  "Language-Team: Italian\n"
9
  "Language: it_IT\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "X-Generator: Poedit 1.8.7.1\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
16
  "X-Poedit-KeywordsList: _e;__\n"
@@ -1216,7 +1216,7 @@ msgstr "Giugno"
1216
  #: event-calendar-wd/includes/texts.php:8
1217
  #: event-calendar-wd/views/admin/ecwd-event-meta.php:366
1218
  msgid "July"
1219
- msgstr "Iuglio"
1220
 
1221
  #: ecwd-frontend-event-management/views/event.php:794
1222
  #: ecwd-frontend-event-management/views/form.php:502
3
  "Project-Id-Version: event_calendar_wd\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2018-04-30 15:37+0400\n"
6
+ "PO-Revision-Date: 2018-09-10 17:14+0400\n"
7
  "Last-Translator: admin <asd@das.das>\n"
8
  "Language-Team: Italian\n"
9
  "Language: it_IT\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 2.0.1\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
16
  "X-Poedit-KeywordsList: _e;__\n"
1216
  #: event-calendar-wd/includes/texts.php:8
1217
  #: event-calendar-wd/views/admin/ecwd-event-meta.php:366
1218
  msgid "July"
1219
+ msgstr "Luglio"
1220
 
1221
  #: ecwd-frontend-event-management/views/event.php:794
1222
  #: ecwd-frontend-event-management/views/form.php:502
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: calendar, date, event, event calendar, events, events calendar, meeting, o
4
  Requires at least: 3.9
5
  Tested up to: 4.9
6
  Requires PHP: 5.2
7
- Stable tag: 1.1.18
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -347,6 +347,22 @@ Event Calendar WD plugin optionally embeds Google Maps on front end to display e
347
 
348
  == Changelog ==
349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  = 1.1.18 =
351
  * Fixed: Security issue
352
 
4
  Requires at least: 3.9
5
  Tested up to: 4.9
6
  Requires PHP: 5.2
7
+ Stable tag: 1.1.20
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
347
 
348
  == Changelog ==
349
 
350
+ = 1.1.20 =
351
+ * New: Reset option for settings
352
+ * New: Notices about extensions compatibility (Premium)
353
+ * New: Delete past events
354
+ * Improved: Import/Export menues merged into one (Premium)
355
+ * Improved: Recurring events query with caching for better performance (Premium)
356
+ * Improved: Number of upcoming events uses posts_per_page as default
357
+ * Improved: Better UX when setting Date and time format
358
+ * Changed: Do not allow to delete the last theme (Premium)
359
+ * Changed: Restore themes if all are deleted
360
+ * Changed: Recurring events are added to the slider of related and upcoming events
361
+ * Changed: Other optimizations under the hood
362
+ * Fixed: Calendar theme shouldn't have view (Premium)
363
+ * Fixed: Strip shortcodes from event subscription email (Premium)
364
+ * Fixed: Fatal error when inserting countdown in calendar or event content (Premium)
365
+
366
  = 1.1.18 =
367
  * Fixed: Security issue
368
 
views/admin/admin.php CHANGED
@@ -40,11 +40,23 @@ global $ecwd_tabs;
40
 
41
  ?>
42
 
43
- <?php submit_button(); ?>
 
44
 
45
  </form>
46
- </div>
47
- <!-- #ecwd-settings-content -->
 
 
 
 
 
 
 
 
 
 
 
48
  </div>
49
  <!-- #ecwd-settings -->
50
  </div><!-- .wrap -->
40
 
41
  ?>
42
 
43
+ <?php submit_button(null,'primary','submit',false); ?>
44
+ <a id="ecwd_reset_settings_button" href="#" class="button">Reset</a>
45
 
46
  </form>
47
+
48
+ <form method="post" id="ecwd_reset_settings_form">
49
+ <?php wp_nonce_field('ecwd_reset_settings', 'ecwd_reset_settings_nonce'); ?>
50
+ <input type="hidden" name="ecwd_reset_settings"
51
+ value="<?php echo ECWD_PLUGIN_PREFIX . '_settings_' . $current_tab; ?>"/>
52
+ </form>
53
+ </div>
54
+ <div id="ecwd_past_event_list_popup" class="ecwd_past_event_list_popup mfp-hide">
55
+ <img class="ecwd_past_event_list_popup_loader" src="<?php echo ECWD_URL;?>/assets/loading.gif">
56
+ <button class="button button-primary button-large ecwd_delete_events ecwd_past_events_delete_button">Delete</button>
57
+ </div>
58
+ <!-- #ecwd-settings-content -->
59
+
60
  </div>
61
  <!-- #ecwd-settings -->
62
  </div><!-- .wrap -->
views/admin/ecwd-calendar-meta.php CHANGED
@@ -122,29 +122,4 @@ $ecwd_calendar_default_theme_color = (isset($ecwd_calendar_theme) && $ecwd_calen
122
  <img class="ecwd_event_list_popup_loader" src="<?php echo ECWD_URL;?>/assets/loading.gif">
123
  <button class="button button-primary button-large ecwd_add_events ecwd_add_events_button">Add</button>
124
  </div>
125
- <style>
126
- .ecwd_event_list_popup_loader{
127
- display: none;
128
- margin: 0 auto;
129
- width: 70px;
130
- margin-top: calc(100px - 35px);
131
- }
132
- .ecwd_add_events_button{
133
- display: none !important;
134
- }
135
- .ecwd_add_events{
136
- float: left;
137
- }
138
- #open-popup {padding:20px}
139
- .ecwd_event_list_popup {
140
- position: relative;
141
- background: #FFF;
142
- padding: 40px;
143
- width: auto;
144
- max-width: 800px;
145
- margin: 20px auto;
146
- text-align: center;
147
- min-height: 200px;
148
- }
149
- </style>
150
  </table>
122
  <img class="ecwd_event_list_popup_loader" src="<?php echo ECWD_URL;?>/assets/loading.gif">
123
  <button class="button button-primary button-large ecwd_add_events ecwd_add_events_button">Add</button>
124
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  </table>
views/admin/ecwd-event-meta.php CHANGED
@@ -24,14 +24,14 @@ if($single_event->get_is_default_dates() === false){
24
  <input type="text" name="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date_from"
25
  id="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date_from"
26
  class="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date"
27
- value="<?php echo $start_date; ?>"/>
28
  <!-- <p class="description">
29
  </p>-->
30
  <?php _e('To', 'event-calendar-wd'); ?>
31
  <input type="text" name="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date_to"
32
  id="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date_to"
33
  class="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date"
34
- value="<?php echo $end_date; ?>"/>
35
 
36
  <!-- <div id="-->
37
  <?php //echo ECWD_PLUGIN_PREFIX; ?><!--_event_pickup_date" class="button" value="">Days</div>-->
@@ -391,7 +391,7 @@ if($single_event->get_is_default_dates() === false){
391
  <label class="repeat_format"><?php _e('Repeat until', 'event-calendar-wd'); ?></label>
392
  <input id='<?php echo ECWD_PLUGIN_PREFIX; ?>_event_repeat_until_input' type="text"
393
  name="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_repeat_repeat_until"
394
- value="<?php echo $single_event->repeat['ecwd_event_repeat_repeat_until']; ?>"/>
395
  </div>
396
  </p>
397
  </div>
24
  <input type="text" name="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date_from"
25
  id="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date_from"
26
  class="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date"
27
+ value="<?php echo $start_date; ?>" autocomplete="off"/>
28
  <!-- <p class="description">
29
  </p>-->
30
  <?php _e('To', 'event-calendar-wd'); ?>
31
  <input type="text" name="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date_to"
32
  id="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date_to"
33
  class="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_date"
34
+ value="<?php echo $end_date; ?>" autocomplete="off"/>
35
 
36
  <!-- <div id="-->
37
  <?php //echo ECWD_PLUGIN_PREFIX; ?><!--_event_pickup_date" class="button" value="">Days</div>-->
391
  <label class="repeat_format"><?php _e('Repeat until', 'event-calendar-wd'); ?></label>
392
  <input id='<?php echo ECWD_PLUGIN_PREFIX; ?>_event_repeat_until_input' type="text"
393
  name="<?php echo ECWD_PLUGIN_PREFIX; ?>_event_repeat_repeat_until"
394
+ value="<?php echo $single_event->repeat['ecwd_event_repeat_repeat_until']; ?>" autocomplete="off"/>
395
  </div>
396
  </p>
397
  </div>