Completed
Branch BUG-9042-ics-organizer-email (0077fa)
by
unknown
26:47 queued 15:14
created
core/services/database/TableAnalysis.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -105,29 +105,29 @@
 block discarded – undo
105 105
 
106 106
 
107 107
 
108
-    /**
109
-     * @param $table_name
110
-     * @param $index_name
111
-     * @return array of columns used on that index, Each entry is an object with the following properties {
112
-     *  @type string Table
113
-     *  @type string Non_unique "0" or "1"
114
-     *  @type string Key_name
115
-     *  @type string Seq_in_index
116
-     *  @type string Column_name
117
-     *  @type string Collation
118
-     *  @type string Cardinality
119
-     *  @type string Sub_part on a column, usually this is just the number of characters from this column to use in indexing
120
-     *  @type string|null Packed
121
-     *  @type string Null
122
-     *  @type string Index_type
123
-     *  @type string Comment
124
-     *  @type string Index_comment
125
-     * }
126
-     */
108
+	/**
109
+	 * @param $table_name
110
+	 * @param $index_name
111
+	 * @return array of columns used on that index, Each entry is an object with the following properties {
112
+	 *  @type string Table
113
+	 *  @type string Non_unique "0" or "1"
114
+	 *  @type string Key_name
115
+	 *  @type string Seq_in_index
116
+	 *  @type string Column_name
117
+	 *  @type string Collation
118
+	 *  @type string Cardinality
119
+	 *  @type string Sub_part on a column, usually this is just the number of characters from this column to use in indexing
120
+	 *  @type string|null Packed
121
+	 *  @type string Null
122
+	 *  @type string Index_type
123
+	 *  @type string Comment
124
+	 *  @type string Index_comment
125
+	 * }
126
+	 */
127 127
 	public function showIndexes($table_name, $index_name){
128
-	    global $wpdb;
129
-        $table_name = $this->ensureTableNameHasPrefix($table_name);
130
-        $index_exists_query = "SHOW INDEX FROM {$table_name} WHERE Key_name = '{$index_name}'";
131
-        return $wpdb->get_results($index_exists_query);
132
-    }
128
+		global $wpdb;
129
+		$table_name = $this->ensureTableNameHasPrefix($table_name);
130
+		$index_exists_query = "SHOW INDEX FROM {$table_name} WHERE Key_name = '{$index_name}'";
131
+		return $wpdb->get_results($index_exists_query);
132
+	}
133 133
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 	 * @param string $table_name
25 25
 	 * @return string $tableName, having ensured it has the wpdb prefix on the front
26 26
 	 */
27
-	public function ensureTableNameHasPrefix( $table_name )
27
+	public function ensureTableNameHasPrefix($table_name)
28 28
 	{
29 29
 		global $wpdb;
30
-		return strpos( $table_name, $wpdb->base_prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name;
30
+		return strpos($table_name, $wpdb->base_prefix) === 0 ? $table_name : $wpdb->prefix.$table_name;
31 31
 	}
32 32
 
33 33
 
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	 * @param string $table_name
40 40
 	 * @return bool
41 41
 	 */
42
-	public function tableIsEmpty( $table_name )
42
+	public function tableIsEmpty($table_name)
43 43
 	{
44 44
 		global $wpdb;
45
-		$table_name = $this->ensureTableNameHasPrefix( $table_name );
46
-		if ( $this->tableExists( $table_name ) ) {
47
-			$count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
48
-			return absint( $count ) === 0 ? true : false;
45
+		$table_name = $this->ensureTableNameHasPrefix($table_name);
46
+		if ($this->tableExists($table_name)) {
47
+			$count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
48
+			return absint($count) === 0 ? true : false;
49 49
 		}
50 50
 		return false;
51 51
 	}
@@ -60,24 +60,24 @@  discard block
 block discarded – undo
60 60
 	 * @param $table_name
61 61
 	 * @return bool
62 62
 	 */
63
-	public function tableExists( $table_name )
63
+	public function tableExists($table_name)
64 64
 	{
65 65
 		global $wpdb, $EZSQL_ERROR;
66
-		$table_name = $this->ensureTableNameHasPrefix( $table_name );
66
+		$table_name = $this->ensureTableNameHasPrefix($table_name);
67 67
 		//ignore if this causes an sql error
68 68
 		$old_error = $wpdb->last_error;
69 69
 		$old_suppress_errors = $wpdb->suppress_errors();
70
-		$old_show_errors_value = $wpdb->show_errors( FALSE );
70
+		$old_show_errors_value = $wpdb->show_errors(FALSE);
71 71
 		$ezsql_error_cache = $EZSQL_ERROR;
72
-		$wpdb->get_results( "SELECT * from $table_name LIMIT 1");
73
-		$wpdb->show_errors( $old_show_errors_value );
74
-		$wpdb->suppress_errors( $old_suppress_errors );
72
+		$wpdb->get_results("SELECT * from $table_name LIMIT 1");
73
+		$wpdb->show_errors($old_show_errors_value);
74
+		$wpdb->suppress_errors($old_suppress_errors);
75 75
 		$new_error = $wpdb->last_error;
76 76
 		$wpdb->last_error = $old_error;
77 77
 		$EZSQL_ERROR = $ezsql_error_cache;
78 78
 		//if there was a table doesn't exist error
79
-		if( ! empty( $new_error ) ) {
80
-			if(
79
+		if ( ! empty($new_error)) {
80
+			if (
81 81
 				in_array(
82 82
 					\EEH_Activation::last_wpdb_error_code(),
83 83
 					array(
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
 					)
88 88
 				)
89 89
 				||
90
-				preg_match( '~^Table .* doesn\'t exist~', $new_error ) //in case not using mysql and error codes aren't reliable, just check for this error string
90
+				preg_match('~^Table .* doesn\'t exist~', $new_error) //in case not using mysql and error codes aren't reliable, just check for this error string
91 91
 			) {
92 92
 				return false;
93 93
 			} else {
94 94
 				//log this because that's weird. Just use the normal PHP error log
95 95
 				error_log(
96 96
 					sprintf(
97
-						__( 'Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso' ),
97
+						__('Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso'),
98 98
 					$new_error
99 99
 					)
100 100
 				);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      *  @type string Index_comment
125 125
      * }
126 126
      */
127
-	public function showIndexes($table_name, $index_name){
127
+	public function showIndexes($table_name, $index_name) {
128 128
 	    global $wpdb;
129 129
         $table_name = $this->ensureTableNameHasPrefix($table_name);
130 130
         $index_exists_query = "SHOW INDEX FROM {$table_name} WHERE Key_name = '{$index_name}'";
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -390,43 +390,43 @@
 block discarded – undo
390 390
 			),
391 391
 			'EE_Data_Migration_Class_Base' => array(
392 392
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
393
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
393
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
394 394
 			),
395 395
 			'EE_DMS_Core_4_1_0' => array(
396 396
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
397
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
397
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
398 398
 			),
399 399
 			'EE_DMS_Core_4_2_0' => array(
400 400
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
401
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
401
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
402 402
 			),
403 403
 			'EE_DMS_Core_4_3_0' => array(
404 404
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
405
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
405
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
406 406
 			),
407 407
 			'EE_DMS_Core_4_4_0' => array(
408 408
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
409
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
409
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
410 410
 			),
411 411
 			'EE_DMS_Core_4_5_0' => array(
412 412
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
413
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
413
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
414 414
 			),
415 415
 			'EE_DMS_Core_4_6_0' => array(
416 416
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
417
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
417
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
418 418
 			),
419 419
 			'EE_DMS_Core_4_7_0' => array(
420 420
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
421
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
421
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
422 422
 			),
423 423
 			'EE_DMS_Core_4_8_0' => array(
424 424
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
425
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
425
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
426 426
 			),
427 427
 			'EE_DMS_Core_4_9_0' => array(
428 428
 				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
429
-                'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
429
+				'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache,
430 430
 			),
431 431
 		);
432 432
 	}
Please login to merge, or discard this patch.
core/helpers/EEH_Event_View.helper.php 1 patch
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -40,27 +40,27 @@  discard block
 block discarded – undo
40 40
 	 * @param    int $EVT_ID
41 41
 	 * @return    object
42 42
 	 */
43
-	public static function get_event( $EVT_ID = 0 ) {
44
-		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID );
43
+	public static function get_event($EVT_ID = 0) {
44
+		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint($EVT_ID);
45 45
 		// do we already have the Event  you are looking for?
46
-		if ( EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID ) {
46
+		if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
47 47
 			return EEH_Event_View::$_event;
48 48
 		}
49 49
 		EEH_Event_View::$_event = NULL;
50 50
 		// international newspaper?
51 51
 		global $post;
52 52
 		// if this is being called from an EE_Event post, then we can just grab the attached EE_Event object
53
-		 if ( isset( $post->post_type ) && $post->post_type == 'espresso_events' || $EVT_ID ) {
53
+		 if (isset($post->post_type) && $post->post_type == 'espresso_events' || $EVT_ID) {
54 54
 //			d( $post );
55 55
 			// grab the event we're looking for
56
-			if ( isset( $post->EE_Event ) && ( $EVT_ID == 0 || ( $EVT_ID == $post->ID ))) {
56
+			if (isset($post->EE_Event) && ($EVT_ID == 0 || ($EVT_ID == $post->ID))) {
57 57
 				EEH_Event_View::$_event = $post->EE_Event;
58 58
 //				d( EEH_Event_View::$_event );
59 59
 			}
60 60
 			// now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID...
61
-			if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID ) {
61
+			if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
62 62
 				// sigh... pull it from the db
63
-				EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
63
+				EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
64 64
 //				d( EEH_Event_View::$_event );
65 65
 			}
66 66
 		}
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 * @param    int $EVT_ID
77 77
 	 * @return    boolean
78 78
 	 */
79
-	public static function display_ticket_selector( $EVT_ID = 0 ) {
80
-		$event = EEH_Event_View::get_event( $EVT_ID );
79
+	public static function display_ticket_selector($EVT_ID = 0) {
80
+		$event = EEH_Event_View::get_event($EVT_ID);
81 81
 		return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE;
82 82
 	}
83 83
 
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	 * @param    int $EVT_ID
91 91
 	 * @return    string
92 92
 	 */
93
-	public static function event_status( $EVT_ID = 0 ) {
94
-		$event = EEH_Event_View::get_event( $EVT_ID );
95
-		return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : '';
93
+	public static function event_status($EVT_ID = 0) {
94
+		$event = EEH_Event_View::get_event($EVT_ID);
95
+		return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : '';
96 96
 	}
97 97
 
98 98
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @param    int $EVT_ID
105 105
 	 *  @return 	string
106 106
 	 */
107
-	public static function event_active_status( $EVT_ID = 0 ) {
108
-		$event = EEH_Event_View::get_event( $EVT_ID );
107
+	public static function event_active_status($EVT_ID = 0) {
108
+		$event = EEH_Event_View::get_event($EVT_ID);
109 109
 		return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive';
110 110
 	}
111 111
 
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 	 * @param    int $EVT_ID
119 119
 	 *  @return 	string
120 120
 	 */
121
-	public static function event_has_content_or_excerpt( $EVT_ID = 0 ) {
122
-		$event = EEH_Event_View::get_event( $EVT_ID );
121
+	public static function event_has_content_or_excerpt($EVT_ID = 0) {
122
+		$event = EEH_Event_View::get_event($EVT_ID);
123 123
 		$has_content_or_excerpt = FALSE;
124
-		if ( $event instanceof EE_Event ) {
125
-			$has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE;
124
+		if ($event instanceof EE_Event) {
125
+			$has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE;
126 126
 		}
127
-		if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) {
127
+		if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) {
128 128
 			$has_content_or_excerpt = FALSE;
129 129
 		}
130 130
 		return $has_content_or_excerpt;
@@ -140,34 +140,34 @@  discard block
 block discarded – undo
140 140
 	 * @param null $more
141 141
 	 * @return    string
142 142
 	 */
143
-	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
143
+	public static function event_content_or_excerpt($num_words = NULL, $more = NULL) {
144 144
 		global $post;
145 145
 
146 146
 		ob_start();
147
-		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
147
+		if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) {
148 148
 			// admin has chosen "full description" for the "Event Espresso - Events > Templates > Display Description" option
149 149
 			the_content();
150
-		} else if (( is_archive() && has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() ) ) {
150
+		} else if ((is_archive() && has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) {
151 151
             // admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option
152 152
 			// AND an excerpt actually exists
153 153
 			the_excerpt();
154
-		} else if (( is_archive() && ! has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() )) {
154
+		} else if ((is_archive() && ! has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) {
155 155
             // admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option
156 156
 			// but NO excerpt actually exists, so we need to create one
157
-			if ( ! empty( $num_words )) {
158
-				if ( empty( $more )) {
159
-					$more_link_text = __( '(more…)' );
160
-					$more = ' <a href="' . get_permalink() . '"';
157
+			if ( ! empty($num_words)) {
158
+				if (empty($more)) {
159
+					$more_link_text = __('(more&hellip;)');
160
+					$more = ' <a href="'.get_permalink().'"';
161 161
 					$more .= ' class="more-link"';
162 162
 					$more .= \EED_Events_Archive::link_target();
163
-					$more .= '>' . $more_link_text . '</a>';
164
-                    $more = apply_filters( 'the_content_more_link', $more, $more_link_text );
163
+					$more .= '>'.$more_link_text.'</a>';
164
+                    $more = apply_filters('the_content_more_link', $more, $more_link_text);
165 165
 				}
166
-				$content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
166
+				$content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK'));
167 167
 
168
-				$content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
168
+				$content = wp_trim_words($content, $num_words, ' ').$more;
169 169
             } else {
170
-                $content =  get_the_content();
170
+                $content = get_the_content();
171 171
 			}
172 172
 			global $allowedtags;
173 173
 			// make sure links are allowed
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
             // but get previous value so we can reset it
182 182
             $prev_value = $allowedtags['a']['target'];
183 183
             $allowedtags['a']['target'] = true;
184
-			$content = wp_kses( $content, $allowedtags );
185
-			$content = strip_shortcodes( $content );
186
-			echo apply_filters( 'the_content', $content );
184
+			$content = wp_kses($content, $allowedtags);
185
+			$content = strip_shortcodes($content);
186
+			echo apply_filters('the_content', $content);
187 187
 			$allowedtags['a']['target'] = $prev_value;
188 188
         } else {
189 189
             // admin has chosen "none" for the "Event Espresso - Events > Templates > Display Description" option
190
-			echo apply_filters( 'the_content', '' );
190
+			echo apply_filters('the_content', '');
191 191
 		}
192 192
 		return ob_get_clean();
193 193
 	}
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 	 * @param    int $EVT_ID
202 202
 	 *  @return 	EE_Ticket[]
203 203
 	 */
204
-	public static function event_tickets_available( $EVT_ID = 0 ) {
205
-		$event = EEH_Event_View::get_event( $EVT_ID );
204
+	public static function event_tickets_available($EVT_ID = 0) {
205
+		$event = EEH_Event_View::get_event($EVT_ID);
206 206
 		$tickets_available_for_purchase = array();
207
-		if( $event instanceof EE_Event ) {
208
-			$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE );
209
-			foreach( $datetimes as $datetime ) {
210
-				$tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() );
207
+		if ($event instanceof EE_Event) {
208
+			$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE);
209
+			foreach ($datetimes as $datetime) {
210
+				$tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase());
211 211
 			}
212 212
 		}
213 213
 		return $tickets_available_for_purchase;
@@ -223,17 +223,17 @@  discard block
 block discarded – undo
223 223
 	 * @param 	  bool   $hide_uncategorized
224 224
 	 * @return    string
225 225
 	 */
226
-	public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) {
226
+	public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) {
227 227
 		$category_links = array();
228
-		$event = EEH_Event_View::get_event( $EVT_ID );
229
-		if ( $event instanceof EE_Event ) {
230
-			$event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' );
231
-			if ( $event_categories ) {
228
+		$event = EEH_Event_View::get_event($EVT_ID);
229
+		if ($event instanceof EE_Event) {
230
+			$event_categories = get_the_terms($event->ID(), 'espresso_event_categories');
231
+			if ($event_categories) {
232 232
 				// loop thru terms and create links
233
-				foreach ( $event_categories as $term ) {
234
-					$url = get_term_link( $term, 'espresso_venue_categories' );
235
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
236
-						$category_links[] = '<a href="' . esc_url( $url )
233
+				foreach ($event_categories as $term) {
234
+					$url = get_term_link($term, 'espresso_venue_categories');
235
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
236
+						$category_links[] = '<a href="'.esc_url($url)
237 237
                                             . '" rel="tag"'
238 238
                                             . \EED_Events_Archive::link_target()
239 239
                                             .'>'
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 				}
244 244
 			}
245 245
 		}
246
-		return implode( ', ', $category_links );
246
+		return implode(', ', $category_links);
247 247
 	}
248 248
 
249 249
 
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	 * @param int    $EVT_ID
258 258
 	 * @return    string
259 259
 	 */
260
-	public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
261
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
262
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
263
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) :  '';
260
+	public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
261
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
262
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
263
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
264 264
 	}
265 265
 
266 266
 
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
 	 * @param int    $EVT_ID
275 275
 	 * @return    string
276 276
 	 */
277
-	public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
278
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
279
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
280
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
277
+	public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
278
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
279
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
280
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
281 281
 	}
282 282
 
283 283
 
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
 	 * @param int    $EVT_ID
292 292
 	 * @return    string
293 293
 	 */
294
-	public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
295
-		$datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID );
296
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
297
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : '';
294
+	public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
295
+		$datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
296
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
297
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
298 298
 	}
299 299
 
300 300
 
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 	 * @param int    $EVT_ID
309 309
 	 * @return    string
310 310
 	 */
311
-	public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
312
-		$datetime = EEH_Event_View::get_latest_date_obj( $EVT_ID );
313
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
314
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
311
+	public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
312
+		$datetime = EEH_Event_View::get_latest_date_obj($EVT_ID);
313
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
314
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
315 315
 	}
316 316
 
317 317
 
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
 	 * @param int $EVT_ID
324 324
 	 * @return    string
325 325
 	 */
326
-	public static function event_date_as_calendar_page( $EVT_ID = 0 ) {
327
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
328
-		if ( $datetime instanceof EE_Datetime ) {
326
+	public static function event_date_as_calendar_page($EVT_ID = 0) {
327
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
328
+		if ($datetime instanceof EE_Datetime) {
329 329
 	?>
330 330
 		<div class="event-date-calendar-page-dv">
331
-			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div>
332
-			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div>
331
+			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div>
332
+			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div>
333 333
 		</div>
334 334
 	<?php
335 335
 		}
@@ -344,17 +344,17 @@  discard block
 block discarded – undo
344 344
 	 * @param int $EVT_ID
345 345
 	 * @return    string
346 346
 	 */
347
-	public static function get_primary_date_obj( $EVT_ID = 0 ) {
348
-		$event = EEH_Event_View::get_event( $EVT_ID );
349
-		if ( $event instanceof EE_Event ) {
347
+	public static function get_primary_date_obj($EVT_ID = 0) {
348
+		$event = EEH_Event_View::get_event($EVT_ID);
349
+		if ($event instanceof EE_Event) {
350 350
 			$datetimes = $event->get_many_related(
351 351
 				'Datetime',
352 352
 				array(
353 353
 					'limit' => 1,
354
-					'order_by' => array( 'DTT_order' => 'ASC' )
354
+					'order_by' => array('DTT_order' => 'ASC')
355 355
 				)
356 356
 			);
357
-			return reset( $datetimes );
357
+			return reset($datetimes);
358 358
 		} else {
359 359
 			 return FALSE;
360 360
 		}
@@ -369,17 +369,17 @@  discard block
 block discarded – undo
369 369
 	 * @param int $EVT_ID
370 370
 	 * @return    string
371 371
 	 */
372
-	public static function get_last_date_obj( $EVT_ID = 0 ) {
373
-		$event = EEH_Event_View::get_event( $EVT_ID );
374
-		if ( $event instanceof EE_Event ) {
372
+	public static function get_last_date_obj($EVT_ID = 0) {
373
+		$event = EEH_Event_View::get_event($EVT_ID);
374
+		if ($event instanceof EE_Event) {
375 375
 			$datetimes = $event->get_many_related(
376 376
 				'Datetime',
377 377
 				array(
378 378
 					'limit' => 1,
379
-					'order_by' => array( 'DTT_order' => 'DESC' )
379
+					'order_by' => array('DTT_order' => 'DESC')
380 380
 				)
381 381
 			);
382
-			return end( $datetimes );
382
+			return end($datetimes);
383 383
 		} else {
384 384
 			return FALSE;
385 385
 		}
@@ -394,17 +394,17 @@  discard block
 block discarded – undo
394 394
 	 * @param int $EVT_ID
395 395
 	 * @return    string
396 396
 	 */
397
-	public static function get_earliest_date_obj( $EVT_ID = 0 ) {
398
-		$event = EEH_Event_View::get_event( $EVT_ID );
399
-		if ( $event instanceof EE_Event ) {
397
+	public static function get_earliest_date_obj($EVT_ID = 0) {
398
+		$event = EEH_Event_View::get_event($EVT_ID);
399
+		if ($event instanceof EE_Event) {
400 400
 			$datetimes = $event->get_many_related(
401 401
 				'Datetime',
402 402
 				array(
403 403
 					'limit' => 1,
404
-					'order_by' => array( 'DTT_EVT_start' => 'ASC' )
404
+					'order_by' => array('DTT_EVT_start' => 'ASC')
405 405
 				)
406 406
 			);
407
-			return reset( $datetimes );
407
+			return reset($datetimes);
408 408
 		} else {
409 409
 			 return FALSE;
410 410
 		}
@@ -419,17 +419,17 @@  discard block
 block discarded – undo
419 419
 	 * @param int $EVT_ID
420 420
 	 * @return    string
421 421
 	 */
422
-	public static function get_latest_date_obj( $EVT_ID = 0 ) {
423
-		$event = EEH_Event_View::get_event( $EVT_ID );
424
-		if ( $event instanceof EE_Event ) {
422
+	public static function get_latest_date_obj($EVT_ID = 0) {
423
+		$event = EEH_Event_View::get_event($EVT_ID);
424
+		if ($event instanceof EE_Event) {
425 425
 			$datetimes = $event->get_many_related(
426 426
 				'Datetime',
427 427
 				array(
428 428
 					'limit' => 1,
429
-					'order_by' => array( 'DTT_EVT_start' => 'DESC' )
429
+					'order_by' => array('DTT_EVT_start' => 'DESC')
430 430
 				)
431 431
 			);
432
-			return end( $datetimes );
432
+			return end($datetimes);
433 433
 		} else {
434 434
 			return FALSE;
435 435
 		}
@@ -447,17 +447,17 @@  discard block
 block discarded – undo
447 447
 	 * @param null $limit
448 448
 	 * @return EE_Datetime[]
449 449
 	 */
450
-	public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) {
451
-		$event = EEH_Event_View::get_event( $EVT_ID );
452
-		if($include_expired === null){
453
-			if($event instanceof EE_Event && $event->is_expired()){
450
+	public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) {
451
+		$event = EEH_Event_View::get_event($EVT_ID);
452
+		if ($include_expired === null) {
453
+			if ($event instanceof EE_Event && $event->is_expired()) {
454 454
 				$include_expired = true;
455
-			}else{
455
+			} else {
456 456
 				$include_expired = false;
457 457
 			}
458 458
 		}
459 459
 
460
-		if ( $event instanceof EE_Event ) {
460
+		if ($event instanceof EE_Event) {
461 461
 			return $event->datetimes_ordered($include_expired, $include_deleted, $limit);
462 462
 		} else {
463 463
 			 return array();
@@ -473,11 +473,11 @@  discard block
 block discarded – undo
473 473
 	 * @param int $EVT_ID
474 474
 	 * @return    string
475 475
 	 */
476
-	public static function event_link_url( $EVT_ID = 0 ) {
477
-		$event = EEH_Event_View::get_event( $EVT_ID );
478
-		if ( $event instanceof EE_Event ) {
479
-			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() );
480
-			return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url;
476
+	public static function event_link_url($EVT_ID = 0) {
477
+		$event = EEH_Event_View::get_event($EVT_ID);
478
+		if ($event instanceof EE_Event) {
479
+			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID());
480
+			return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url;
481 481
 		}
482 482
 		return NULL;
483 483
 	}
@@ -491,10 +491,10 @@  discard block
 block discarded – undo
491 491
 	 * @param int $EVT_ID
492 492
 	 * @return    string
493 493
 	 */
494
-	public static function event_phone( $EVT_ID = 0 ) {
495
-		$event = EEH_Event_View::get_event( $EVT_ID );
496
-		if ( $event instanceof EE_Event ) {
497
-			return EEH_Schema::telephone( $event->phone() );
494
+	public static function event_phone($EVT_ID = 0) {
495
+		$event = EEH_Event_View::get_event($EVT_ID);
496
+		if ($event instanceof EE_Event) {
497
+			return EEH_Schema::telephone($event->phone());
498 498
 		}
499 499
 		return NULL;
500 500
 	}
@@ -511,26 +511,26 @@  discard block
 block discarded – undo
511 511
 	 * @param string $after
512 512
 	 * @return    string
513 513
 	 */
514
-	public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) {
515
-		$event = EEH_Event_View::get_event( $EVT_ID );
516
-		if ( $event instanceof EE_Event ) {
514
+	public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') {
515
+		$event = EEH_Event_View::get_event($EVT_ID);
516
+		if ($event instanceof EE_Event) {
517 517
 			// can the user edit this post ?
518
-			if ( current_user_can( 'edit_post', $event->ID() )) {
518
+			if (current_user_can('edit_post', $event->ID())) {
519 519
 				// set link text
520
-				$link_text = ! empty( $link ) ? $link : __('edit this event');
520
+				$link_text = ! empty($link) ? $link : __('edit this event');
521 521
 				// generate nonce
522
-				$nonce = wp_create_nonce( 'edit_nonce' );
522
+				$nonce = wp_create_nonce('edit_nonce');
523 523
 				// generate url to event editor for this event
524
-				$url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() );
524
+				$url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url());
525 525
 				// get edit CPT text
526
-				$post_type_obj = get_post_type_object( 'espresso_events' );
526
+				$post_type_obj = get_post_type_object('espresso_events');
527 527
 				// build final link html
528
-				$link = '<a class="post-edit-link" href="' . $url . '" ';
529
-				$link .= ' title="' . esc_attr( $post_type_obj->labels->edit_item ) . '"';
528
+				$link = '<a class="post-edit-link" href="'.$url.'" ';
529
+				$link .= ' title="'.esc_attr($post_type_obj->labels->edit_item).'"';
530 530
 				$link .= \EED_Events_Archive::link_target();
531
-				$link .='>' . $link_text . '</a>';
531
+				$link .= '>'.$link_text.'</a>';
532 532
 				// put it all together
533
-				return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after;
533
+				return $before.apply_filters('edit_post_link', $link, $event->ID()).$after;
534 534
 			}
535 535
 		}
536 536
 		return '';
Please login to merge, or discard this patch.
core/services/database/TableManager.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
 *@param string $table_name
240 240
      * @param string $index_name
241 241
      * @param string $column_name if none is provided, we assume the column name matches the index (often true in EE)
242
-     * @param string|int $desired_index_size defaults to 191, the max for utf8mb4.
242
+     * @param integer $desired_index_size defaults to 191, the max for utf8mb4.
243 243
      *                   See https://events.codebasehq.com/redirect?https://make.wordpress.org/core/2015/04/02/the-utf8mb4-upgrade/
244 244
      * @return bool
245 245
      * @throws /EE_Error if table analysis object isn't defined
Please login to merge, or discard this patch.
Indentation   +239 added lines, -241 removed lines patch added patch discarded remove patch
@@ -17,249 +17,247 @@
 block discarded – undo
17 17
 class TableManager extends \EE_Base
18 18
 {
19 19
 
20
-    /**
21
-     * @var TableAnalysis $table_analysis
22
-     */
23
-    private $table_analysis;
24
-
25
-
26
-
27
-    /**
28
-     * TableManager constructor.
29
-     *
30
-     * @param TableAnalysis $TableAnalysis
31
-     */
32
-    public function __construct(TableAnalysis $TableAnalysis)
33
-    {
34
-        $this->table_analysis = $TableAnalysis;
35
-    }
36
-
37
-
38
-
39
-    /**
40
-     * Gets the injected table analyzer, or throws an exception
41
-     *
42
-     * @return TableAnalysis
43
-     * @throws \EE_Error
44
-     */
45
-    protected function getTableAnalysis()
46
-    {
47
-        if ($this->table_analysis instanceof TableAnalysis) {
48
-            return $this->table_analysis;
49
-        } else {
50
-            throw new \EE_Error(
51
-                sprintf(
52
-                    __('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
53
-                    get_class($this)
54
-                )
55
-            );
56
-        }
57
-    }
58
-
59
-
60
-
61
-    /**
62
-     * @param string $table_name which can optionally start with $wpdb->prefix or not
63
-     * @param string $column_name
64
-     * @param string $column_info
65
-     * @return bool|false|int
66
-     */
67
-    public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL')
68
-    {
69
-        if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) {
70
-            return false;
71
-        }
72
-        global $wpdb;
73
-        $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
74
-        $columns = $this->getTableColumns($table_name);
75
-        if ( ! in_array($column_name, $columns)) {
76
-            $alter_query = "ALTER TABLE {$full_table_name} ADD {$column_name} {$column_info}";
77
-            return $wpdb->query($alter_query);
78
-        }
79
-        return true;
80
-    }
81
-
82
-
83
-
84
-    /**
85
-     * Gets the name of all columns on the  table. $table_name can
86
-     * optionally start with $wpdb->prefix or not
87
-     *
88
-     * @global \wpdb $wpdb
89
-     * @param string $table_name
90
-     * @return array
91
-     */
92
-    public function getTableColumns($table_name)
93
-    {
94
-        global $wpdb;
95
-        $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
96
-        $field_array = array();
97
-        if ( ! empty($table_name)) {
98
-            $columns = $wpdb->get_results("SHOW COLUMNS FROM {$table_name} ");
99
-            if ($columns !== false) {
100
-                foreach ($columns as $column) {
101
-                    $field_array[] = $column->Field;
102
-                }
103
-            }
104
-        }
105
-        return $field_array;
106
-    }
107
-
108
-
109
-
110
-    /**
111
-     * Drops the specified table from the database. $table_name can
112
-     * optionally start with $wpdb->prefix or not
113
-     *
114
-     * @global \wpdb $wpdb
115
-     * @param string $table_name
116
-     * @return int
117
-     */
118
-    public function dropTable($table_name)
119
-    {
120
-        global $wpdb;
121
-        if ($this->getTableAnalysis()->tableExists($table_name)) {
122
-            $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
123
-            return $wpdb->query("DROP TABLE IF EXISTS {$table_name}");
124
-        }
125
-        return 0;
126
-    }
127
-
128
-
129
-
130
-    /**
131
-     * Drops all the tables mentioned in a single MYSQL query. Double-checks
132
-     * each table name provided has a wpdb prefix attached, and that it exists.
133
-     * Returns the list actually deleted
134
-     *
135
-     * @global WPDB $wpdb
136
-     * @param array $table_names
137
-     * @return array of table names which we deleted
138
-     */
139
-    public function dropTables($table_names)
140
-    {
141
-        $tables_to_delete = array();
142
-        foreach ($table_names as $table_name) {
143
-            $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
144
-            if ($this->getTableAnalysis()->tableExists($table_name)) {
145
-                $tables_to_delete[] = $table_name;
146
-            }
147
-        }
148
-        if( ! empty( $tables_to_delete ) ) {
149
-            global $wpdb;
150
-            $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete));
151
-        }
152
-        return $tables_to_delete;
153
-    }
154
-
155
-
156
-
157
-    /**
158
-     * Drops the specified index from the specified table. $table_name can
159
-     * optionally start with $wpdb->prefix or not
160
-
161
-     *
20
+	/**
21
+	 * @var TableAnalysis $table_analysis
22
+	 */
23
+	private $table_analysis;
24
+
25
+
26
+
27
+	/**
28
+	 * TableManager constructor.
29
+	 *
30
+	 * @param TableAnalysis $TableAnalysis
31
+	 */
32
+	public function __construct(TableAnalysis $TableAnalysis)
33
+	{
34
+		$this->table_analysis = $TableAnalysis;
35
+	}
36
+
37
+
38
+
39
+	/**
40
+	 * Gets the injected table analyzer, or throws an exception
41
+	 *
42
+	 * @return TableAnalysis
43
+	 * @throws \EE_Error
44
+	 */
45
+	protected function getTableAnalysis()
46
+	{
47
+		if ($this->table_analysis instanceof TableAnalysis) {
48
+			return $this->table_analysis;
49
+		} else {
50
+			throw new \EE_Error(
51
+				sprintf(
52
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
53
+					get_class($this)
54
+				)
55
+			);
56
+		}
57
+	}
58
+
59
+
60
+
61
+	/**
62
+	 * @param string $table_name which can optionally start with $wpdb->prefix or not
63
+	 * @param string $column_name
64
+	 * @param string $column_info
65
+	 * @return bool|false|int
66
+	 */
67
+	public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL')
68
+	{
69
+		if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) {
70
+			return false;
71
+		}
72
+		global $wpdb;
73
+		$full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
74
+		$columns = $this->getTableColumns($table_name);
75
+		if ( ! in_array($column_name, $columns)) {
76
+			$alter_query = "ALTER TABLE {$full_table_name} ADD {$column_name} {$column_info}";
77
+			return $wpdb->query($alter_query);
78
+		}
79
+		return true;
80
+	}
81
+
82
+
83
+
84
+	/**
85
+	 * Gets the name of all columns on the  table. $table_name can
86
+	 * optionally start with $wpdb->prefix or not
87
+	 *
88
+	 * @global \wpdb $wpdb
89
+	 * @param string $table_name
90
+	 * @return array
91
+	 */
92
+	public function getTableColumns($table_name)
93
+	{
94
+		global $wpdb;
95
+		$table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
96
+		$field_array = array();
97
+		if ( ! empty($table_name)) {
98
+			$columns = $wpdb->get_results("SHOW COLUMNS FROM {$table_name} ");
99
+			if ($columns !== false) {
100
+				foreach ($columns as $column) {
101
+					$field_array[] = $column->Field;
102
+				}
103
+			}
104
+		}
105
+		return $field_array;
106
+	}
107
+
108
+
109
+
110
+	/**
111
+	 * Drops the specified table from the database. $table_name can
112
+	 * optionally start with $wpdb->prefix or not
113
+	 *
114
+	 * @global \wpdb $wpdb
115
+	 * @param string $table_name
116
+	 * @return int
117
+	 */
118
+	public function dropTable($table_name)
119
+	{
120
+		global $wpdb;
121
+		if ($this->getTableAnalysis()->tableExists($table_name)) {
122
+			$table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
123
+			return $wpdb->query("DROP TABLE IF EXISTS {$table_name}");
124
+		}
125
+		return 0;
126
+	}
127
+
128
+
129
+
130
+	/**
131
+	 * Drops all the tables mentioned in a single MYSQL query. Double-checks
132
+	 * each table name provided has a wpdb prefix attached, and that it exists.
133
+	 * Returns the list actually deleted
134
+	 *
135
+	 * @global WPDB $wpdb
136
+	 * @param array $table_names
137
+	 * @return array of table names which we deleted
138
+	 */
139
+	public function dropTables($table_names)
140
+	{
141
+		$tables_to_delete = array();
142
+		foreach ($table_names as $table_name) {
143
+			$table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
144
+			if ($this->getTableAnalysis()->tableExists($table_name)) {
145
+				$tables_to_delete[] = $table_name;
146
+			}
147
+		}
148
+		if( ! empty( $tables_to_delete ) ) {
149
+			global $wpdb;
150
+			$wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete));
151
+		}
152
+		return $tables_to_delete;
153
+	}
154
+
155
+
156
+
157
+	/**
158
+	 * Drops the specified index from the specified table. $table_name can
159
+	 * optionally start with $wpdb->prefix or not
160
+	 *
162 161
 *@global \wpdb       $wpdb
163
-     * @param string $table_name
164
-     * @param string $index_name
165
-     * @return int
166
-     */
167
-    public function dropIndex($table_name, $index_name)
168
-    {
169
-        if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) {
170
-            return false;
171
-        }
172
-        global $wpdb;
173
-        $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
174
-        $index_exists_query = "SHOW INDEX FROM {$table_name} WHERE key_name = '{$index_name}'";
175
-        if (
176
-            $this->getTableAnalysis()->tableExists($table_name)
177
-            && $wpdb->get_var($index_exists_query)
178
-               === $table_name //using get_var with the $index_exists_query returns the table's name
179
-        ) {
180
-            return $wpdb->query("ALTER TABLE {$table_name} DROP INDEX {$index_name}");
181
-        }
182
-        return 0;
183
-    }
184
-
185
-
186
-
187
-    /**
188
-     * Just creates the requested table. $table_name can
189
-     * optionally start with $wpdb->prefix or not
190
-
191
-     *
162
+	 * @param string $table_name
163
+	 * @param string $index_name
164
+	 * @return int
165
+	 */
166
+	public function dropIndex($table_name, $index_name)
167
+	{
168
+		if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) {
169
+			return false;
170
+		}
171
+		global $wpdb;
172
+		$table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
173
+		$index_exists_query = "SHOW INDEX FROM {$table_name} WHERE key_name = '{$index_name}'";
174
+		if (
175
+			$this->getTableAnalysis()->tableExists($table_name)
176
+			&& $wpdb->get_var($index_exists_query)
177
+			   === $table_name //using get_var with the $index_exists_query returns the table's name
178
+		) {
179
+			return $wpdb->query("ALTER TABLE {$table_name} DROP INDEX {$index_name}");
180
+		}
181
+		return 0;
182
+	}
183
+
184
+
185
+
186
+	/**
187
+	 * Just creates the requested table. $table_name can
188
+	 * optionally start with $wpdb->prefix or not
189
+	 *
192 190
 *@param string       $table_name
193
-     * @param string $create_sql defining the table's columns and indexes
194
-     * @param string $engine     (no need to specify "ENGINE=", that's implied)
195
-     * @return void
196
-     * @throws \EE_Error
197
-     */
198
-    public function createTable($table_name, $create_sql, $engine = 'MyISAM')
199
-    {
200
-        // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns )
201
-        if (preg_match('((((.*?))(,\s))+)', $create_sql, $valid_column_data)) {
202
-            $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
203
-            /** @var \wpdb $wpdb */
204
-            global $wpdb;
205
-            $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate();
206
-
207
-            //get $wpdb to echo errors, but buffer them. This way at least WE know an error
208
-            //happened. And then we can choose to tell the end user
209
-            $old_show_errors_policy = $wpdb->show_errors(true);
210
-            $old_error_suppression_policy = $wpdb->suppress_errors(false);
211
-            ob_start();
212
-            dbDelta($SQL);
213
-            $output = ob_get_contents();
214
-            ob_end_clean();
215
-            $wpdb->show_errors($old_show_errors_policy);
216
-            $wpdb->suppress_errors($old_error_suppression_policy);
217
-            if ( ! empty($output)) {
218
-                throw new \EE_Error($output);
219
-            }
220
-        } else {
221
-            throw new \EE_Error(
222
-                sprintf(
223
-                    __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s',
224
-                        'event_espresso'),
225
-                    '<br />',
226
-                    $create_sql
227
-                )
228
-            );
229
-        }
230
-    }
231
-
232
-
233
-
234
-    /**
235
-     * Drops the specified index if it's size differs from $desired_index_size.
236
-     * WordPress' dbdelta method doesn't automatically change index sizes, so this
237
-     * method can be used to only drop the index if needed, and afterwards dbdelta can be used as normal.
238
-     *
191
+	 * @param string $create_sql defining the table's columns and indexes
192
+	 * @param string $engine     (no need to specify "ENGINE=", that's implied)
193
+	 * @return void
194
+	 * @throws \EE_Error
195
+	 */
196
+	public function createTable($table_name, $create_sql, $engine = 'MyISAM')
197
+	{
198
+		// does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns )
199
+		if (preg_match('((((.*?))(,\s))+)', $create_sql, $valid_column_data)) {
200
+			$table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
201
+			/** @var \wpdb $wpdb */
202
+			global $wpdb;
203
+			$SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate();
204
+
205
+			//get $wpdb to echo errors, but buffer them. This way at least WE know an error
206
+			//happened. And then we can choose to tell the end user
207
+			$old_show_errors_policy = $wpdb->show_errors(true);
208
+			$old_error_suppression_policy = $wpdb->suppress_errors(false);
209
+			ob_start();
210
+			dbDelta($SQL);
211
+			$output = ob_get_contents();
212
+			ob_end_clean();
213
+			$wpdb->show_errors($old_show_errors_policy);
214
+			$wpdb->suppress_errors($old_error_suppression_policy);
215
+			if ( ! empty($output)) {
216
+				throw new \EE_Error($output);
217
+			}
218
+		} else {
219
+			throw new \EE_Error(
220
+				sprintf(
221
+					__('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s',
222
+						'event_espresso'),
223
+					'<br />',
224
+					$create_sql
225
+				)
226
+			);
227
+		}
228
+	}
229
+
230
+
231
+
232
+	/**
233
+	 * Drops the specified index if it's size differs from $desired_index_size.
234
+	 * WordPress' dbdelta method doesn't automatically change index sizes, so this
235
+	 * method can be used to only drop the index if needed, and afterwards dbdelta can be used as normal.
236
+	 *
239 237
 *@param string $table_name
240
-     * @param string $index_name
241
-     * @param string $column_name if none is provided, we assume the column name matches the index (often true in EE)
242
-     * @param string|int $desired_index_size defaults to 191, the max for utf8mb4.
243
-     *                   See https://events.codebasehq.com/redirect?https://make.wordpress.org/core/2015/04/02/the-utf8mb4-upgrade/
244
-     * @return bool
245
-     * @throws /EE_Error if table analysis object isn't defined
246
-     */
247
-    public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = 191)
248
-    {
249
-        if($column_name === null){
250
-            $column_name = $index_name;
251
-        }
252
-        $index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name);
253
-        if(empty($index_entries)){
254
-            return false;
255
-        }
256
-        foreach($index_entries as $index_entry){
257
-            if( $column_name === $index_entry->Column_name
258
-                && (string)$desired_index_size !== $index_entry->Sub_part){
259
-                return $this->dropIndex($table_name,$index_name);
260
-            }
261
-        }
262
-        return false;
263
-    }
238
+	 * @param string $index_name
239
+	 * @param string $column_name if none is provided, we assume the column name matches the index (often true in EE)
240
+	 * @param string|int $desired_index_size defaults to 191, the max for utf8mb4.
241
+	 *                   See https://events.codebasehq.com/redirect?https://make.wordpress.org/core/2015/04/02/the-utf8mb4-upgrade/
242
+	 * @return bool
243
+	 * @throws /EE_Error if table analysis object isn't defined
244
+	 */
245
+	public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = 191)
246
+	{
247
+		if($column_name === null){
248
+			$column_name = $index_name;
249
+		}
250
+		$index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name);
251
+		if(empty($index_entries)){
252
+			return false;
253
+		}
254
+		foreach($index_entries as $index_entry){
255
+			if( $column_name === $index_entry->Column_name
256
+				&& (string)$desired_index_size !== $index_entry->Sub_part){
257
+				return $this->dropIndex($table_name,$index_name);
258
+			}
259
+		}
260
+		return false;
261
+	}
264 262
 
265 263
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
                 $tables_to_delete[] = $table_name;
146 146
             }
147 147
         }
148
-        if( ! empty( $tables_to_delete ) ) {
148
+        if ( ! empty($tables_to_delete)) {
149 149
             global $wpdb;
150
-            $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete));
150
+            $wpdb->query('DROP TABLE '.implode(', ', $tables_to_delete));
151 151
         }
152 152
         return $tables_to_delete;
153 153
     }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name);
203 203
             /** @var \wpdb $wpdb */
204 204
             global $wpdb;
205
-            $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate();
205
+            $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} ".$wpdb->get_charset_collate();
206 206
 
207 207
             //get $wpdb to echo errors, but buffer them. This way at least WE know an error
208 208
             //happened. And then we can choose to tell the end user
@@ -246,17 +246,17 @@  discard block
 block discarded – undo
246 246
      */
247 247
     public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = 191)
248 248
     {
249
-        if($column_name === null){
249
+        if ($column_name === null) {
250 250
             $column_name = $index_name;
251 251
         }
252
-        $index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name);
253
-        if(empty($index_entries)){
252
+        $index_entries = $this->getTableAnalysis()->showIndexes($table_name, $index_name);
253
+        if (empty($index_entries)) {
254 254
             return false;
255 255
         }
256
-        foreach($index_entries as $index_entry){
257
-            if( $column_name === $index_entry->Column_name
258
-                && (string)$desired_index_size !== $index_entry->Sub_part){
259
-                return $this->dropIndex($table_name,$index_name);
256
+        foreach ($index_entries as $index_entry) {
257
+            if ($column_name === $index_entry->Column_name
258
+                && (string) $desired_index_size !== $index_entry->Sub_part) {
259
+                return $this->dropIndex($table_name, $index_name);
260 260
             }
261 261
         }
262 262
         return false;
Please login to merge, or discard this patch.
caffeinated/EE_Caf_Messages.class.php 2 patches
Indentation   +708 added lines, -708 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @since           4.3.2
8 8
  */
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 /**
@@ -22,729 +22,729 @@  discard block
 block discarded – undo
22 22
 {
23 23
     
24 24
     
25
-    /**
26
-     * constructor.
27
-     */
28
-    public function __construct()
29
-    {
30
-        $this->_caf_hooks();
31
-    }
32
-    
33
-    
34
-    /**
35
-     * Contains all the hooks filters for setting up caffeinated messages functionality.
36
-     *
37
-     * @since 4.3.2
38
-     *
39
-     * @return void
40
-     */
41
-    private function _caf_hooks()
42
-    {
43
-        add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
44
-        add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'),
45
-            5, 2);
46
-        add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5,
47
-            2);
48
-        add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5,
49
-            2);
50
-        add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5,
51
-            2);
52
-        add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
53
-        add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5,
54
-            2);
55
-        add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
56
-            array($this, 'new_default_templates'), 5, 7);
57
-        add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5,
58
-            2);
59
-        
60
-        //shortcode parsers
61
-        add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
62
-        add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
63
-        add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes',
64
-            array($this, 'additional_recipient_details_shortcodes'), 5, 2);
65
-        add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after',
66
-            array($this, 'additional_recipient_details_parser'), 5, 5);
67
-        add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
68
-            array($this, 'additional_primary_registration_details_shortcodes'), 5, 2);
69
-        add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
70
-            array($this, 'additional_primary_registration_details_parser'), 5, 5);
71
-        
72
-        /**
73
-         * @since 4.2.0
74
-         */
75
-        add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
76
-        add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
77
-        
78
-        /**
79
-         * @since 4.3.0
80
-         */
81
-        //eat our own dog food!
82
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
83
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
84
-        do_action('EE_Brewing_Regular___messages_caf');
85
-    }
86
-    
87
-    
88
-    /**
89
-     * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
90
-     * messages system.
91
-     *
92
-     * @param  array $dir_ref original array of paths
93
-     *
94
-     * @return array           appended paths
95
-     */
96
-    public function messages_autoload_paths($dir_ref)
97
-    {
98
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
99
-        
100
-        return $dir_ref;
101
-    }
102
-    
103
-    
104
-    public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
105
-    {
106
-        $validator_config['attendee_list'] = array(
107
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
108
-            'required'   => array('[ATTENDEE_LIST]')
109
-        );
110
-        $validator_config['question_list'] = array(
111
-            'shortcodes' => array('question'),
112
-            'required'   => array('[QUESTION_LIST]')
113
-        );
114
-        
115
-        return $validator_config;
116
-    }
117
-    
118
-    
119
-    public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
120
-    {
121
-        $validator_config['attendee_list'] = array(
122
-            'shortcodes' => array('attendee', 'question_list'),
123
-            'required'   => array('[ATTENDEE_LIST]')
124
-        );
125
-        $validator_config['question_list'] = array(
126
-            'shortcodes' => array('question'),
127
-            'required'   => array('[QUESTION_LIST]')
128
-        );
129
-        
130
-        return $validator_config;
131
-    }
132
-    
133
-    
134
-    public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
135
-    {
136
-        $validator_config['attendee_list'] = array(
137
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
138
-            'required'   => array('[ATTENDEE_LIST]')
139
-        );
140
-        $validator_config['question_list'] = array(
141
-            'shortcodes' => array('question'),
142
-            'required'   => array('[QUESTION_LIST]')
143
-        );
144
-        
145
-        return $validator_config;
146
-    }
147
-    
148
-    
149
-    public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
150
-    {
151
-        $template_fields['extra']['content']['question_list'] = array(
152
-            'input'               => 'textarea',
153
-            'label'               => '[QUESTION_LIST]',
154
-            'type'                => 'string',
155
-            'required'            => true,
156
-            'validation'          => true,
157
-            'format'              => '%s',
158
-            'css_class'           => 'large-text',
159
-            'rows'                => '5',
160
-            'shortcodes_required' => array('[QUESTION_LIST]')
161
-        );
162
-        
163
-        return $template_fields;
164
-    }
165
-    
166
-    
167
-    public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
168
-    {
169
-        $template_fields['extra']['content']['question_list'] = array(
170
-            'input'               => 'textarea',
171
-            'label'               => '[QUESTION_LIST]',
172
-            'type'                => 'string',
173
-            'required'            => true,
174
-            'validation'          => true,
175
-            'format'              => '%s',
176
-            'css_class'           => 'large-text',
177
-            'rows'                => '5',
178
-            'shortcodes_required' => array('[QUESTION_LIST]')
179
-        );
180
-        
181
-        return $template_fields;
182
-    }
183
-    
184
-    
185
-    public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
186
-    {
187
-        $template_fields['extra']['content']['question_list'] = array(
188
-            'input'               => 'textarea',
189
-            'label'               => '[QUESTION_LIST]',
190
-            'type'                => 'string',
191
-            'required'            => true,
192
-            'validation'          => true,
193
-            'format'              => '%s',
194
-            'css_class'           => 'large-text',
195
-            'rows'                => '5',
196
-            'shortcodes_required' => array('[QUESTION_LIST]')
197
-        );
198
-        
199
-        return $template_fields;
200
-    }
201
-    
202
-    
203
-    public function new_default_templates(
204
-        $contents,
205
-        $actual_path,
206
-        EE_messenger $messenger,
207
-        EE_message_type $message_type,
208
-        $field,
209
-        $context,
210
-        EE_Messages_Template_Pack $template_pack
211
-    ) {
212
-        
213
-        //we're only modifying templates for the default template pack
214
-        if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
215
-            return $contents;
216
-        }
217
-        
218
-        //the template file name we're replacing contents for.
219
-        $template_file_prefix = $field . '_' . $context;
220
-        $msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
221
-        
222
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
223
-        
224
-        if ($messenger->name == 'email' && $message_type->name == 'registration') {
25
+	/**
26
+	 * constructor.
27
+	 */
28
+	public function __construct()
29
+	{
30
+		$this->_caf_hooks();
31
+	}
32
+    
33
+    
34
+	/**
35
+	 * Contains all the hooks filters for setting up caffeinated messages functionality.
36
+	 *
37
+	 * @since 4.3.2
38
+	 *
39
+	 * @return void
40
+	 */
41
+	private function _caf_hooks()
42
+	{
43
+		add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
44
+		add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'),
45
+			5, 2);
46
+		add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5,
47
+			2);
48
+		add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5,
49
+			2);
50
+		add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5,
51
+			2);
52
+		add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
53
+		add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5,
54
+			2);
55
+		add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
56
+			array($this, 'new_default_templates'), 5, 7);
57
+		add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5,
58
+			2);
59
+        
60
+		//shortcode parsers
61
+		add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
62
+		add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
63
+		add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes',
64
+			array($this, 'additional_recipient_details_shortcodes'), 5, 2);
65
+		add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after',
66
+			array($this, 'additional_recipient_details_parser'), 5, 5);
67
+		add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
68
+			array($this, 'additional_primary_registration_details_shortcodes'), 5, 2);
69
+		add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
70
+			array($this, 'additional_primary_registration_details_parser'), 5, 5);
71
+        
72
+		/**
73
+		 * @since 4.2.0
74
+		 */
75
+		add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
76
+		add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
77
+        
78
+		/**
79
+		 * @since 4.3.0
80
+		 */
81
+		//eat our own dog food!
82
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
83
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
84
+		do_action('EE_Brewing_Regular___messages_caf');
85
+	}
86
+    
87
+    
88
+	/**
89
+	 * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
90
+	 * messages system.
91
+	 *
92
+	 * @param  array $dir_ref original array of paths
93
+	 *
94
+	 * @return array           appended paths
95
+	 */
96
+	public function messages_autoload_paths($dir_ref)
97
+	{
98
+		$dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
99
+        
100
+		return $dir_ref;
101
+	}
102
+    
103
+    
104
+	public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
105
+	{
106
+		$validator_config['attendee_list'] = array(
107
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
108
+			'required'   => array('[ATTENDEE_LIST]')
109
+		);
110
+		$validator_config['question_list'] = array(
111
+			'shortcodes' => array('question'),
112
+			'required'   => array('[QUESTION_LIST]')
113
+		);
114
+        
115
+		return $validator_config;
116
+	}
117
+    
118
+    
119
+	public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
120
+	{
121
+		$validator_config['attendee_list'] = array(
122
+			'shortcodes' => array('attendee', 'question_list'),
123
+			'required'   => array('[ATTENDEE_LIST]')
124
+		);
125
+		$validator_config['question_list'] = array(
126
+			'shortcodes' => array('question'),
127
+			'required'   => array('[QUESTION_LIST]')
128
+		);
129
+        
130
+		return $validator_config;
131
+	}
132
+    
133
+    
134
+	public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
135
+	{
136
+		$validator_config['attendee_list'] = array(
137
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
138
+			'required'   => array('[ATTENDEE_LIST]')
139
+		);
140
+		$validator_config['question_list'] = array(
141
+			'shortcodes' => array('question'),
142
+			'required'   => array('[QUESTION_LIST]')
143
+		);
144
+        
145
+		return $validator_config;
146
+	}
147
+    
148
+    
149
+	public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
150
+	{
151
+		$template_fields['extra']['content']['question_list'] = array(
152
+			'input'               => 'textarea',
153
+			'label'               => '[QUESTION_LIST]',
154
+			'type'                => 'string',
155
+			'required'            => true,
156
+			'validation'          => true,
157
+			'format'              => '%s',
158
+			'css_class'           => 'large-text',
159
+			'rows'                => '5',
160
+			'shortcodes_required' => array('[QUESTION_LIST]')
161
+		);
162
+        
163
+		return $template_fields;
164
+	}
165
+    
166
+    
167
+	public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
168
+	{
169
+		$template_fields['extra']['content']['question_list'] = array(
170
+			'input'               => 'textarea',
171
+			'label'               => '[QUESTION_LIST]',
172
+			'type'                => 'string',
173
+			'required'            => true,
174
+			'validation'          => true,
175
+			'format'              => '%s',
176
+			'css_class'           => 'large-text',
177
+			'rows'                => '5',
178
+			'shortcodes_required' => array('[QUESTION_LIST]')
179
+		);
180
+        
181
+		return $template_fields;
182
+	}
183
+    
184
+    
185
+	public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
186
+	{
187
+		$template_fields['extra']['content']['question_list'] = array(
188
+			'input'               => 'textarea',
189
+			'label'               => '[QUESTION_LIST]',
190
+			'type'                => 'string',
191
+			'required'            => true,
192
+			'validation'          => true,
193
+			'format'              => '%s',
194
+			'css_class'           => 'large-text',
195
+			'rows'                => '5',
196
+			'shortcodes_required' => array('[QUESTION_LIST]')
197
+		);
198
+        
199
+		return $template_fields;
200
+	}
201
+    
202
+    
203
+	public function new_default_templates(
204
+		$contents,
205
+		$actual_path,
206
+		EE_messenger $messenger,
207
+		EE_message_type $message_type,
208
+		$field,
209
+		$context,
210
+		EE_Messages_Template_Pack $template_pack
211
+	) {
212
+        
213
+		//we're only modifying templates for the default template pack
214
+		if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
215
+			return $contents;
216
+		}
217
+        
218
+		//the template file name we're replacing contents for.
219
+		$template_file_prefix = $field . '_' . $context;
220
+		$msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
221
+        
222
+		$base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
223
+        
224
+		if ($messenger->name == 'email' && $message_type->name == 'registration') {
225 225
             
226
-            switch ($template_file_prefix) {
226
+			switch ($template_file_prefix) {
227 227
                 
228
-                case 'question_list_admin' :
229
-                case 'question_list_attendee' :
230
-                case 'question_list_primary_attendee' :
231
-                    $path     = $base_path . $msg_prefix . 'question_list.template.php';
232
-                    $contents = EEH_Template::display_template($path, array(), true);
233
-                    break;
228
+				case 'question_list_admin' :
229
+				case 'question_list_attendee' :
230
+				case 'question_list_primary_attendee' :
231
+					$path     = $base_path . $msg_prefix . 'question_list.template.php';
232
+					$contents = EEH_Template::display_template($path, array(), true);
233
+					break;
234 234
                 
235
-                case 'attendee_list_primary_attendee' :
236
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
237
-                    $contents = EEH_Template::display_template($path, array(), true);
238
-                    break;
235
+				case 'attendee_list_primary_attendee' :
236
+					$path     = $base_path . $msg_prefix . 'attendee_list.template.php';
237
+					$contents = EEH_Template::display_template($path, array(), true);
238
+					break;
239 239
                 
240
-                case 'attendee_list_admin' :
241
-                    $path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
242
-                    $contents = EEH_Template::display_template($path,
243
-                        array(), true);
244
-                    break;
240
+				case 'attendee_list_admin' :
241
+					$path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
242
+					$contents = EEH_Template::display_template($path,
243
+						array(), true);
244
+					break;
245 245
                 
246
-                case 'attendee_list_attendee' :
247
-                    $contents = '';
248
-                    break;
246
+				case 'attendee_list_attendee' :
247
+					$contents = '';
248
+					break;
249 249
                 
250
-                case 'event_list_attendee' :
251
-                    $path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
252
-                    $contents = EEH_Template::display_template($path, array(), true);
253
-                    break;
254
-            }
255
-        } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
256
-            switch ($template_file_prefix) {
250
+				case 'event_list_attendee' :
251
+					$path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
252
+					$contents = EEH_Template::display_template($path, array(), true);
253
+					break;
254
+			}
255
+		} elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
256
+			switch ($template_file_prefix) {
257 257
                 
258
-                case 'content_attendee' :
259
-                    $path     = $base_path . $msg_prefix . 'content.template.php';
260
-                    $contents = EEH_Template::display_template($path, array(), true);
261
-                    break;
258
+				case 'content_attendee' :
259
+					$path     = $base_path . $msg_prefix . 'content.template.php';
260
+					$contents = EEH_Template::display_template($path, array(), true);
261
+					break;
262 262
                 
263
-                case 'newsletter_content_attendee' :
264
-                    $path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
265
-                    $contents = EEH_Template::display_template($path, array(), true);
266
-                    break;
263
+				case 'newsletter_content_attendee' :
264
+					$path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
265
+					$contents = EEH_Template::display_template($path, array(), true);
266
+					break;
267 267
                 
268
-                case 'newsletter_subject_attendee' :
269
-                    $path     = $base_path . $msg_prefix . 'subject.template.php';
270
-                    $contents = EEH_Template::display_template($path, array(), true);
271
-                    break;
272
-            }
273
-        } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274
-            switch ($template_file_prefix) {
275
-                case 'attendee_list_purchaser' :
276
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
277
-                    $contents = EEH_Template::display_template($path, array(), true);
278
-                    break;
279
-            }
280
-        }
281
-        
282
-        return $contents;
283
-        
284
-    }
285
-    
286
-    
287
-    public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
288
-    {
289
-        //make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
290
-        $include_with = array(
291
-            'registration',
292
-            'cancelled_registration',
293
-            'declined_registration',
294
-            'not_approved_registration',
295
-            'payment_declined',
296
-            'payment_failed',
297
-            'payment_cancelled',
298
-            'payment',
299
-            'payment_reminder',
300
-            'pending_approval',
301
-            'registration_summary',
302
-            'invoice',
303
-            'receipt'
304
-        );
305
-        if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
306
-            $contexts = array_keys($msg->get_contexts());
307
-            foreach ($contexts as $context) {
308
-                $valid_shortcodes[$context][] = 'question_list';
309
-                $valid_shortcodes[$context][] = 'question';
310
-            }
311
-        }
312
-        
313
-        return $valid_shortcodes;
314
-    }
315
-    
316
-    
317
-    public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
318
-    {
319
-        $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
320
-            'event_espresso');
321
-        
322
-        return $shortcodes;
323
-    }
324
-    
325
-    
326
-    public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
327
-    {
328
-        
329
-        if (strpos($shortcode,
330
-                '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations)
331
-        ) {
332
-            return $parsed;
333
-        }
334
-        
335
-        //let's get the question from the code.
336
-        $shortcode = str_replace('[ANSWER_*', '', $shortcode);
337
-        $shortcode = trim(str_replace(']', '', $shortcode));
338
-        
339
-        $registration = $data instanceof EE_Registration ? $data : null;
340
-        $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
341
-        
342
-        $aee = $data instanceof EE_Messages_Addressee ? $data : null;
343
-        $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
344
-        
345
-        if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
346
-            return $parsed;
347
-        }
348
-        
349
-        //now let's figure out which question has this text.
350
-        foreach ($aee->questions as $ansid => $question) {
351
-            if (
352
-                $question instanceof EE_Question
353
-                && trim($question->display_text()) == trim($shortcode)
354
-                && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid])
355
-            ) {
356
-                return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value',
357
-                    'no_wpautop');
358
-            }
359
-        }
360
-        
361
-        //nothing!
362
-        return $parsed;
363
-    }
364
-    
365
-    
366
-    /**
367
-     * Callback for additional shortcodes filter for adding additional datetime shortcodes.
368
-     *
369
-     * @since  4.2
370
-     *
371
-     * @param  array                  $shortcodes         array of shortcodes and
372
-     *                                                    descriptions
373
-     * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
374
-     *
375
-     * @return array                                        array of shortcodes and
376
-     *                                                        descriptions
377
-     */
378
-    public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
379
-    {
380
-        $shortcodes['[DTT_NAME]']          = __('This will be parsed to the Title given for a Datetime',
381
-            'event_espresso');
382
-        $shortcodes['[DTT_DESCRIPTION]']   = __('This will be parsed to the description for a Datetime',
383
-            'event_espresso');
384
-        $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
385
-            'event_espresso');
386
-        
387
-        return $shortcodes;
388
-    }
389
-    
390
-    
391
-    /**
392
-     * Callback for additional shortcodes parser filter used for adding parser for new
393
-     * Datetime shortcodes
394
-     *
395
-     * @since  4.2
396
-     *
397
-     * @param  string                 $parsed     The finished parsed string for the given shortcode.
398
-     * @param  string                 $shortcode  The shortcode being parsed.
399
-     * @param  object                 $data       The incoming data object for the Shortcode Parser.
400
-     * @param  object                 $extra_data The incoming extra date object for the Shortcode
401
-     *                                            Parser.
402
-     * @param  EE_Datetime_Shortcodes $shortcode_parser
403
-     *
404
-     * @return string                   The new parsed string.
405
-     */
406
-    public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
407
-    {
408
-        
409
-        if ( ! $data instanceof EE_Datetime) {
410
-            return ''; //get out because we can only parse with the datetime object.
411
-        }
412
-        
413
-        switch ($shortcode) {
414
-            case '[DTT_NAME]' :
415
-                return $data->name();
416
-                break;
417
-            case '[DTT_DESCRIPTION]' :
418
-                return $data->description();
419
-                break;
420
-            case '[DTT_NAME_OR_DATES]' :
421
-                return $data->get_dtt_display_name(true);
422
-                break;
423
-            default :
424
-                return $parsed;
425
-                break;
426
-        }
427
-    }
428
-    
429
-    
430
-    public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
431
-    {
432
-        $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
433
-            'event_espresso');
434
-        
435
-        return $shortcodes;
436
-    }
437
-    
438
-    
439
-    /**
440
-     * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
441
-     *
442
-     * @param string         $parsed           The original parsed content for the shortcode
443
-     * @param string         $shortcode        The shortcode being parsed
444
-     * @param array          $data             The shortcode parser data array
445
-     * @param array          $extra_data       The shortcode parser extra data array
446
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
447
-     *
448
-     * @return string
449
-     */
450
-    public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
451
-    {
452
-        
453
-        if (array($data) && ! isset($data['data'])) {
454
-            return $parsed;
455
-        }
456
-        
457
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
458
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
459
-        
460
-        if ( ! $recipient instanceof EE_Messages_Addressee) {
461
-            return $parsed;
462
-        }
463
-        
464
-        switch ($shortcode) {
465
-            case '[RECIPIENT_QUESTION_LIST]' :
466
-                $att                       = $recipient->att_obj;
467
-                $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array();
468
-                $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
469
-                $answers                   = array();
268
+				case 'newsletter_subject_attendee' :
269
+					$path     = $base_path . $msg_prefix . 'subject.template.php';
270
+					$contents = EEH_Template::display_template($path, array(), true);
271
+					break;
272
+			}
273
+		} elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274
+			switch ($template_file_prefix) {
275
+				case 'attendee_list_purchaser' :
276
+					$path     = $base_path . $msg_prefix . 'attendee_list.template.php';
277
+					$contents = EEH_Template::display_template($path, array(), true);
278
+					break;
279
+			}
280
+		}
281
+        
282
+		return $contents;
283
+        
284
+	}
285
+    
286
+    
287
+	public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
288
+	{
289
+		//make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
290
+		$include_with = array(
291
+			'registration',
292
+			'cancelled_registration',
293
+			'declined_registration',
294
+			'not_approved_registration',
295
+			'payment_declined',
296
+			'payment_failed',
297
+			'payment_cancelled',
298
+			'payment',
299
+			'payment_reminder',
300
+			'pending_approval',
301
+			'registration_summary',
302
+			'invoice',
303
+			'receipt'
304
+		);
305
+		if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
306
+			$contexts = array_keys($msg->get_contexts());
307
+			foreach ($contexts as $context) {
308
+				$valid_shortcodes[$context][] = 'question_list';
309
+				$valid_shortcodes[$context][] = 'question';
310
+			}
311
+		}
312
+        
313
+		return $valid_shortcodes;
314
+	}
315
+    
316
+    
317
+	public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
318
+	{
319
+		$shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
320
+			'event_espresso');
321
+        
322
+		return $shortcodes;
323
+	}
324
+    
325
+    
326
+	public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
327
+	{
328
+        
329
+		if (strpos($shortcode,
330
+				'[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations)
331
+		) {
332
+			return $parsed;
333
+		}
334
+        
335
+		//let's get the question from the code.
336
+		$shortcode = str_replace('[ANSWER_*', '', $shortcode);
337
+		$shortcode = trim(str_replace(']', '', $shortcode));
338
+        
339
+		$registration = $data instanceof EE_Registration ? $data : null;
340
+		$registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
341
+        
342
+		$aee = $data instanceof EE_Messages_Addressee ? $data : null;
343
+		$aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
344
+        
345
+		if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
346
+			return $parsed;
347
+		}
348
+        
349
+		//now let's figure out which question has this text.
350
+		foreach ($aee->questions as $ansid => $question) {
351
+			if (
352
+				$question instanceof EE_Question
353
+				&& trim($question->display_text()) == trim($shortcode)
354
+				&& isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid])
355
+			) {
356
+				return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value',
357
+					'no_wpautop');
358
+			}
359
+		}
360
+        
361
+		//nothing!
362
+		return $parsed;
363
+	}
364
+    
365
+    
366
+	/**
367
+	 * Callback for additional shortcodes filter for adding additional datetime shortcodes.
368
+	 *
369
+	 * @since  4.2
370
+	 *
371
+	 * @param  array                  $shortcodes         array of shortcodes and
372
+	 *                                                    descriptions
373
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
374
+	 *
375
+	 * @return array                                        array of shortcodes and
376
+	 *                                                        descriptions
377
+	 */
378
+	public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
379
+	{
380
+		$shortcodes['[DTT_NAME]']          = __('This will be parsed to the Title given for a Datetime',
381
+			'event_espresso');
382
+		$shortcodes['[DTT_DESCRIPTION]']   = __('This will be parsed to the description for a Datetime',
383
+			'event_espresso');
384
+		$shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
385
+			'event_espresso');
386
+        
387
+		return $shortcodes;
388
+	}
389
+    
390
+    
391
+	/**
392
+	 * Callback for additional shortcodes parser filter used for adding parser for new
393
+	 * Datetime shortcodes
394
+	 *
395
+	 * @since  4.2
396
+	 *
397
+	 * @param  string                 $parsed     The finished parsed string for the given shortcode.
398
+	 * @param  string                 $shortcode  The shortcode being parsed.
399
+	 * @param  object                 $data       The incoming data object for the Shortcode Parser.
400
+	 * @param  object                 $extra_data The incoming extra date object for the Shortcode
401
+	 *                                            Parser.
402
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser
403
+	 *
404
+	 * @return string                   The new parsed string.
405
+	 */
406
+	public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
407
+	{
408
+        
409
+		if ( ! $data instanceof EE_Datetime) {
410
+			return ''; //get out because we can only parse with the datetime object.
411
+		}
412
+        
413
+		switch ($shortcode) {
414
+			case '[DTT_NAME]' :
415
+				return $data->name();
416
+				break;
417
+			case '[DTT_DESCRIPTION]' :
418
+				return $data->description();
419
+				break;
420
+			case '[DTT_NAME_OR_DATES]' :
421
+				return $data->get_dtt_display_name(true);
422
+				break;
423
+			default :
424
+				return $parsed;
425
+				break;
426
+		}
427
+	}
428
+    
429
+    
430
+	public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
431
+	{
432
+		$shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
433
+			'event_espresso');
434
+        
435
+		return $shortcodes;
436
+	}
437
+    
438
+    
439
+	/**
440
+	 * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
441
+	 *
442
+	 * @param string         $parsed           The original parsed content for the shortcode
443
+	 * @param string         $shortcode        The shortcode being parsed
444
+	 * @param array          $data             The shortcode parser data array
445
+	 * @param array          $extra_data       The shortcode parser extra data array
446
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
447
+	 *
448
+	 * @return string
449
+	 */
450
+	public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
451
+	{
452
+        
453
+		if (array($data) && ! isset($data['data'])) {
454
+			return $parsed;
455
+		}
456
+        
457
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
458
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
459
+        
460
+		if ( ! $recipient instanceof EE_Messages_Addressee) {
461
+			return $parsed;
462
+		}
463
+        
464
+		switch ($shortcode) {
465
+			case '[RECIPIENT_QUESTION_LIST]' :
466
+				$att                       = $recipient->att_obj;
467
+				$registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array();
468
+				$registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
469
+				$answers                   = array();
470 470
                 
471
-                $template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
472
-                $valid_shortcodes = array('question');
471
+				$template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
472
+				$valid_shortcodes = array('question');
473 473
                 
474
-                //if the context is main_content then get all answers for all registrations on this attendee
475
-                if ($data['data'] instanceof EE_Messages_Addressee) {
474
+				//if the context is main_content then get all answers for all registrations on this attendee
475
+				if ($data['data'] instanceof EE_Messages_Addressee) {
476 476
                     
477
-                    foreach ($registrations_on_attendee as $reg) {
478
-                        if ($reg instanceof EE_Registration) {
479
-                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
480
-                            foreach ($anss as $ans) {
481
-                                if ($ans instanceof EE_Answer) {
482
-                                    $answers[$ans->ID()] = $ans;
483
-                                }
484
-                            }
485
-                        }
486
-                    }
487
-                }
477
+					foreach ($registrations_on_attendee as $reg) {
478
+						if ($reg instanceof EE_Registration) {
479
+							$anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
480
+							foreach ($anss as $ans) {
481
+								if ($ans instanceof EE_Answer) {
482
+									$answers[$ans->ID()] = $ans;
483
+								}
484
+							}
485
+						}
486
+					}
487
+				}
488 488
                 
489
-                //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
490
-                if ($data['data'] instanceof EE_Event) {
491
-                    $event = $data['data'];
492
-                    foreach ($registrations_on_attendee as $reg) {
493
-                        if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
494
-                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
495
-                            foreach ($anss as $ans) {
496
-                                if ($ans instanceof EE_Answer) {
497
-                                    $answers[$ans->ID()] = $ans;
498
-                                }
499
-                            }
500
-                        }
501
-                    }
502
-                }
489
+				//if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
490
+				if ($data['data'] instanceof EE_Event) {
491
+					$event = $data['data'];
492
+					foreach ($registrations_on_attendee as $reg) {
493
+						if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
494
+							$anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array();
495
+							foreach ($anss as $ans) {
496
+								if ($ans instanceof EE_Answer) {
497
+									$answers[$ans->ID()] = $ans;
498
+								}
499
+							}
500
+						}
501
+					}
502
+				}
503 503
                 
504
-                $questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
504
+				$questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
505 505
                 
506
-                //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507
-                //object on it.
508
-                if ( ! isset( $extra_data['data'] ) ) {
509
-                    $extra_data['data'] = $recipient;
510
-                }
506
+				//if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507
+				//object on it.
508
+				if ( ! isset( $extra_data['data'] ) ) {
509
+					$extra_data['data'] = $recipient;
510
+				}
511 511
                 
512
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
513
-                    $shortcode_parser,
514
-                    $questions,
515
-                    $answers,
516
-                    $template,
517
-                    $valid_shortcodes,
518
-                    $extra_data
519
-                );
520
-                break;
512
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
513
+					$shortcode_parser,
514
+					$questions,
515
+					$answers,
516
+					$template,
517
+					$valid_shortcodes,
518
+					$extra_data
519
+				);
520
+				break;
521 521
             
522
-            default :
523
-                return $parsed;
524
-                break;
525
-        }
526
-    }
527
-    
528
-    
529
-    public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
530
-    {
531
-        $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
532
-            'event_espresso');
533
-        
534
-        return $shortcodes;
535
-    }
536
-    
537
-    
538
-    /**
539
-     * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
540
-     *
541
-     * @param string         $parsed           The original parsed content for the shortcode
542
-     * @param string         $shortcode        The shortcode being parsed
543
-     * @param array          $data             The shortcode parser data array
544
-     * @param array          $extra_data       The shortcode parser extra data array
545
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
546
-     *
547
-     * @return string
548
-     */
549
-    public function additional_primary_registration_details_parser(
550
-        $parsed,
551
-        $shortcode,
552
-        $data,
553
-        $extra_data,
554
-        $shortcode_parser
555
-    ) {
556
-        if (array($data) && ! isset($data['data'])) {
557
-            return $parsed;
558
-        }
559
-        
560
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
561
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
562
-        
563
-        if ( ! $recipient instanceof EE_Messages_Addressee) {
564
-            return $parsed;
565
-        }
566
-        
567
-        switch ($shortcode) {
568
-            case '[PRIMARY_REGISTRANT_QUESTION_LIST]' :
569
-                if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
570
-                    return '';
571
-                }
572
-                $registration     = $recipient->primary_reg_obj;
573
-                $template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
574
-                $valid_shortcodes = array('question');
575
-                $answers          = $recipient->registrations[$registration->ID()]['ans_objs'];
576
-                $questions = isset($recipient->questions) ? $recipient->questions : array();
577
-                //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
578
-                //object on it.
579
-                if ( ! isset( $extra_data['data'] ) ){
580
-                    $extra_data['data'] = $recipient;
581
-                }
582
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
583
-                    $shortcode_parser,
584
-                    $questions,
585
-                    $answers,
586
-                    $template,
587
-                    $valid_shortcodes,
588
-                    $extra_data
589
-                );
590
-                break;
522
+			default :
523
+				return $parsed;
524
+				break;
525
+		}
526
+	}
527
+    
528
+    
529
+	public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
530
+	{
531
+		$shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
532
+			'event_espresso');
533
+        
534
+		return $shortcodes;
535
+	}
536
+    
537
+    
538
+	/**
539
+	 * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
540
+	 *
541
+	 * @param string         $parsed           The original parsed content for the shortcode
542
+	 * @param string         $shortcode        The shortcode being parsed
543
+	 * @param array          $data             The shortcode parser data array
544
+	 * @param array          $extra_data       The shortcode parser extra data array
545
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
546
+	 *
547
+	 * @return string
548
+	 */
549
+	public function additional_primary_registration_details_parser(
550
+		$parsed,
551
+		$shortcode,
552
+		$data,
553
+		$extra_data,
554
+		$shortcode_parser
555
+	) {
556
+		if (array($data) && ! isset($data['data'])) {
557
+			return $parsed;
558
+		}
559
+        
560
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
561
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
562
+        
563
+		if ( ! $recipient instanceof EE_Messages_Addressee) {
564
+			return $parsed;
565
+		}
566
+        
567
+		switch ($shortcode) {
568
+			case '[PRIMARY_REGISTRANT_QUESTION_LIST]' :
569
+				if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
570
+					return '';
571
+				}
572
+				$registration     = $recipient->primary_reg_obj;
573
+				$template         = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list'];
574
+				$valid_shortcodes = array('question');
575
+				$answers          = $recipient->registrations[$registration->ID()]['ans_objs'];
576
+				$questions = isset($recipient->questions) ? $recipient->questions : array();
577
+				//if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
578
+				//object on it.
579
+				if ( ! isset( $extra_data['data'] ) ){
580
+					$extra_data['data'] = $recipient;
581
+				}
582
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
583
+					$shortcode_parser,
584
+					$questions,
585
+					$answers,
586
+					$template,
587
+					$valid_shortcodes,
588
+					$extra_data
589
+				);
590
+				break;
591 591
             
592
-            default :
593
-                return $parsed;
594
-                break;
595
-        }
596
-    }
597
-    
598
-    
599
-    /**
600
-     * Takes care of registering the  message types that are only available in caffeinated EE.
601
-     *
602
-     * @since   4.3.2
603
-     *
604
-     * @return  void
605
-     */
606
-    public function register_caf_message_types()
607
-    {
608
-        //register newsletter message type
609
-        $setup_args = array(
610
-            'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
611
-            'autoloadpaths'               => array(
612
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
613
-            ),
614
-            'messengers_to_activate_with' => array('email'),
615
-            'messengers_to_validate_with' => array('email'),
616
-            'messengers_supporting_default_template_pack_with' => array('email')
617
-        );
618
-        EE_Register_Message_Type::register('newsletter', $setup_args);
619
-        
620
-        //register payment reminder message type
621
-        $setup_args = array(
622
-            'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
623
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
624
-            'messengers_to_activate_with' => array('email'),
625
-            'messengers_to_validate_with' => array('email'),
626
-            'messengers_supporting_default_template_pack_with' => array('email')
627
-        );
628
-        EE_Register_Message_Type::register('payment_reminder', $setup_args);
629
-        
630
-        //register payment declined message type
631
-        $setup_args = array(
632
-            'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
633
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
634
-            'messengers_to_activate_with' => array('email'),
635
-            'messengers_to_validate_with' => array('email'),
636
-            'messengers_supporting_default_template_pack_with' => array('email')
637
-        );
638
-        EE_Register_Message_Type::register('payment_declined', $setup_args);
639
-        
640
-        //register registration declined message type
641
-        $setup_args = array(
642
-            'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
643
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
644
-            'messengers_to_activate_with' => array('email'),
645
-            'messengers_to_validate_with' => array('email'),
646
-            'messengers_supporting_default_template_pack_with' => array('email')
647
-        );
648
-        EE_Register_Message_Type::register('declined_registration', $setup_args);
649
-        
650
-        //register registration cancelled message type
651
-        $setup_args = array(
652
-            'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
653
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
654
-            'messengers_to_activate_with' => array('email'),
655
-            'messengers_to_validate_with' => array('email'),
656
-            'messengers_supporting_default_template_pack_with' => array('email')
657
-        );
658
-        EE_Register_Message_Type::register('cancelled_registration', $setup_args);
659
-        
660
-        
661
-        //register payment failed message type
662
-        $setup_args = array(
663
-            'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
664
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
665
-            'messengers_to_activate_with' => array('email'),
666
-            'messengers_to_validate_with' => array('email'),
667
-            'messengers_supporting_default_template_pack_with' => array('email')
668
-        );
669
-        EE_Register_Message_Type::register('payment_failed', $setup_args);
670
-        
671
-        //register payment declined message type
672
-        $setup_args = array(
673
-            'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
674
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
675
-            'messengers_to_activate_with' => array('email'),
676
-            'messengers_to_validate_with' => array('email'),
677
-            'messengers_supporting_default_template_pack_with' => array('email')
678
-        );
679
-        EE_Register_Message_Type::register('payment_cancelled', $setup_args);
680
-    }
681
-    
682
-    
683
-    /**
684
-     * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
685
-     *
686
-     * @since   4.3.2
687
-     *
688
-     * @return void
689
-     */
690
-    public function register_caf_shortcodes()
691
-    {
692
-        $setup_args = array(
693
-            'autoloadpaths'                 => array(
694
-                EE_CAF_LIBRARIES . 'shortcodes/'
695
-            ),
696
-            'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
697
-            'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
698
-            'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]')
699
-        );
700
-        EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
701
-    }
702
-    
703
-    
704
-    /**
705
-     * Parses a question list shortcode using given data and template
706
-     *
707
-     * @param \EE_Shortcodes $shortcode_parser
708
-     * @param EE_Question[]  $questions        An array of questions indexed by answer id.
709
-     * @param EE_Answer[]    $answers          An array of answer objects
710
-     * @param string         $template         Template content to be parsed.
711
-     * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
712
-     * @param array          $extra_data       Extra data that might be used when parsing the template.
713
-     */
714
-    protected function _parse_question_list_for_primary_or_recipient_registration(
715
-        $shortcode_parser,
716
-        $questions,
717
-        $answers,
718
-        $template,
719
-        $valid_shortcodes,
720
-        $extra_data
721
-    ) {
722
-        $question_list = '';
723
-        /** @var EEH_Parse_Shortcodes $shortcode_helper */
724
-        $shortcode_helper = $shortcode_parser->get_shortcode_helper();
725
-        foreach ($answers as $answer) {
726
-            if ($answer instanceof EE_Answer) {
727
-                //first see if the question is in our $questions array. If not then try to get from answer object.
728
-                $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
729
-                $question = ! $question instanceof EE_Question ? $answer->question() : $question;
730
-                if (
731
-                    ! $question instanceof EE_Question
732
-                    || (
733
-                        $question instanceof EE_Question
734
-                        && $question->admin_only()
735
-                    )
736
-                ) {
737
-                    continue;
738
-                }
739
-                $question_list .= $shortcode_helper->parse_question_list_template(
740
-                    $template,
741
-                    $answer,
742
-                    $valid_shortcodes,
743
-                    $extra_data
744
-                );
745
-            }
746
-        }
747
-        
748
-        return $question_list;
749
-    }
592
+			default :
593
+				return $parsed;
594
+				break;
595
+		}
596
+	}
597
+    
598
+    
599
+	/**
600
+	 * Takes care of registering the  message types that are only available in caffeinated EE.
601
+	 *
602
+	 * @since   4.3.2
603
+	 *
604
+	 * @return  void
605
+	 */
606
+	public function register_caf_message_types()
607
+	{
608
+		//register newsletter message type
609
+		$setup_args = array(
610
+			'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
611
+			'autoloadpaths'               => array(
612
+				EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
613
+			),
614
+			'messengers_to_activate_with' => array('email'),
615
+			'messengers_to_validate_with' => array('email'),
616
+			'messengers_supporting_default_template_pack_with' => array('email')
617
+		);
618
+		EE_Register_Message_Type::register('newsletter', $setup_args);
619
+        
620
+		//register payment reminder message type
621
+		$setup_args = array(
622
+			'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
623
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
624
+			'messengers_to_activate_with' => array('email'),
625
+			'messengers_to_validate_with' => array('email'),
626
+			'messengers_supporting_default_template_pack_with' => array('email')
627
+		);
628
+		EE_Register_Message_Type::register('payment_reminder', $setup_args);
629
+        
630
+		//register payment declined message type
631
+		$setup_args = array(
632
+			'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
633
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
634
+			'messengers_to_activate_with' => array('email'),
635
+			'messengers_to_validate_with' => array('email'),
636
+			'messengers_supporting_default_template_pack_with' => array('email')
637
+		);
638
+		EE_Register_Message_Type::register('payment_declined', $setup_args);
639
+        
640
+		//register registration declined message type
641
+		$setup_args = array(
642
+			'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
643
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
644
+			'messengers_to_activate_with' => array('email'),
645
+			'messengers_to_validate_with' => array('email'),
646
+			'messengers_supporting_default_template_pack_with' => array('email')
647
+		);
648
+		EE_Register_Message_Type::register('declined_registration', $setup_args);
649
+        
650
+		//register registration cancelled message type
651
+		$setup_args = array(
652
+			'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
653
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
654
+			'messengers_to_activate_with' => array('email'),
655
+			'messengers_to_validate_with' => array('email'),
656
+			'messengers_supporting_default_template_pack_with' => array('email')
657
+		);
658
+		EE_Register_Message_Type::register('cancelled_registration', $setup_args);
659
+        
660
+        
661
+		//register payment failed message type
662
+		$setup_args = array(
663
+			'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
664
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
665
+			'messengers_to_activate_with' => array('email'),
666
+			'messengers_to_validate_with' => array('email'),
667
+			'messengers_supporting_default_template_pack_with' => array('email')
668
+		);
669
+		EE_Register_Message_Type::register('payment_failed', $setup_args);
670
+        
671
+		//register payment declined message type
672
+		$setup_args = array(
673
+			'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
674
+			'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
675
+			'messengers_to_activate_with' => array('email'),
676
+			'messengers_to_validate_with' => array('email'),
677
+			'messengers_supporting_default_template_pack_with' => array('email')
678
+		);
679
+		EE_Register_Message_Type::register('payment_cancelled', $setup_args);
680
+	}
681
+    
682
+    
683
+	/**
684
+	 * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
685
+	 *
686
+	 * @since   4.3.2
687
+	 *
688
+	 * @return void
689
+	 */
690
+	public function register_caf_shortcodes()
691
+	{
692
+		$setup_args = array(
693
+			'autoloadpaths'                 => array(
694
+				EE_CAF_LIBRARIES . 'shortcodes/'
695
+			),
696
+			'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
697
+			'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
698
+			'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]')
699
+		);
700
+		EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
701
+	}
702
+    
703
+    
704
+	/**
705
+	 * Parses a question list shortcode using given data and template
706
+	 *
707
+	 * @param \EE_Shortcodes $shortcode_parser
708
+	 * @param EE_Question[]  $questions        An array of questions indexed by answer id.
709
+	 * @param EE_Answer[]    $answers          An array of answer objects
710
+	 * @param string         $template         Template content to be parsed.
711
+	 * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
712
+	 * @param array          $extra_data       Extra data that might be used when parsing the template.
713
+	 */
714
+	protected function _parse_question_list_for_primary_or_recipient_registration(
715
+		$shortcode_parser,
716
+		$questions,
717
+		$answers,
718
+		$template,
719
+		$valid_shortcodes,
720
+		$extra_data
721
+	) {
722
+		$question_list = '';
723
+		/** @var EEH_Parse_Shortcodes $shortcode_helper */
724
+		$shortcode_helper = $shortcode_parser->get_shortcode_helper();
725
+		foreach ($answers as $answer) {
726
+			if ($answer instanceof EE_Answer) {
727
+				//first see if the question is in our $questions array. If not then try to get from answer object.
728
+				$question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
729
+				$question = ! $question instanceof EE_Question ? $answer->question() : $question;
730
+				if (
731
+					! $question instanceof EE_Question
732
+					|| (
733
+						$question instanceof EE_Question
734
+						&& $question->admin_only()
735
+					)
736
+				) {
737
+					continue;
738
+				}
739
+				$question_list .= $shortcode_helper->parse_question_list_template(
740
+					$template,
741
+					$answer,
742
+					$valid_shortcodes,
743
+					$extra_data
744
+				);
745
+			}
746
+		}
747
+        
748
+		return $question_list;
749
+	}
750 750
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function messages_autoload_paths($dir_ref)
97 97
     {
98
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
98
+        $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/';
99 99
         
100 100
         return $dir_ref;
101 101
     }
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
         }
217 217
         
218 218
         //the template file name we're replacing contents for.
219
-        $template_file_prefix = $field . '_' . $context;
220
-        $msg_prefix           = $messenger->name . '_' . $message_type->name . '_';
219
+        $template_file_prefix = $field.'_'.$context;
220
+        $msg_prefix           = $messenger->name.'_'.$message_type->name.'_';
221 221
         
222
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
222
+        $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/';
223 223
         
224 224
         if ($messenger->name == 'email' && $message_type->name == 'registration') {
225 225
             
@@ -228,17 +228,17 @@  discard block
 block discarded – undo
228 228
                 case 'question_list_admin' :
229 229
                 case 'question_list_attendee' :
230 230
                 case 'question_list_primary_attendee' :
231
-                    $path     = $base_path . $msg_prefix . 'question_list.template.php';
231
+                    $path     = $base_path.$msg_prefix.'question_list.template.php';
232 232
                     $contents = EEH_Template::display_template($path, array(), true);
233 233
                     break;
234 234
                 
235 235
                 case 'attendee_list_primary_attendee' :
236
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
236
+                    $path     = $base_path.$msg_prefix.'attendee_list.template.php';
237 237
                     $contents = EEH_Template::display_template($path, array(), true);
238 238
                     break;
239 239
                 
240 240
                 case 'attendee_list_admin' :
241
-                    $path     = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
241
+                    $path     = $base_path.$msg_prefix.'attendee_list_admin.template.php';
242 242
                     $contents = EEH_Template::display_template($path,
243 243
                         array(), true);
244 244
                     break;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                     break;
249 249
                 
250 250
                 case 'event_list_attendee' :
251
-                    $path     = $base_path . $msg_prefix . 'event_list_attendee.template.php';
251
+                    $path     = $base_path.$msg_prefix.'event_list_attendee.template.php';
252 252
                     $contents = EEH_Template::display_template($path, array(), true);
253 253
                     break;
254 254
             }
@@ -256,24 +256,24 @@  discard block
 block discarded – undo
256 256
             switch ($template_file_prefix) {
257 257
                 
258 258
                 case 'content_attendee' :
259
-                    $path     = $base_path . $msg_prefix . 'content.template.php';
259
+                    $path     = $base_path.$msg_prefix.'content.template.php';
260 260
                     $contents = EEH_Template::display_template($path, array(), true);
261 261
                     break;
262 262
                 
263 263
                 case 'newsletter_content_attendee' :
264
-                    $path     = $base_path . $msg_prefix . 'newsletter_content.template.php';
264
+                    $path     = $base_path.$msg_prefix.'newsletter_content.template.php';
265 265
                     $contents = EEH_Template::display_template($path, array(), true);
266 266
                     break;
267 267
                 
268 268
                 case 'newsletter_subject_attendee' :
269
-                    $path     = $base_path . $msg_prefix . 'subject.template.php';
269
+                    $path     = $base_path.$msg_prefix.'subject.template.php';
270 270
                     $contents = EEH_Template::display_template($path, array(), true);
271 271
                     break;
272 272
             }
273 273
         } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
274 274
             switch ($template_file_prefix) {
275 275
                 case 'attendee_list_purchaser' :
276
-                    $path     = $base_path . $msg_prefix . 'attendee_list.template.php';
276
+                    $path     = $base_path.$msg_prefix.'attendee_list.template.php';
277 277
                     $contents = EEH_Template::display_template($path, array(), true);
278 278
                     break;
279 279
             }
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
                 
506 506
                 //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
507 507
                 //object on it.
508
-                if ( ! isset( $extra_data['data'] ) ) {
508
+                if ( ! isset($extra_data['data'])) {
509 509
                     $extra_data['data'] = $recipient;
510 510
                 }
511 511
                 
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
                 $questions = isset($recipient->questions) ? $recipient->questions : array();
577 577
                 //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
578 578
                 //object on it.
579
-                if ( ! isset( $extra_data['data'] ) ){
579
+                if ( ! isset($extra_data['data'])) {
580 580
                     $extra_data['data'] = $recipient;
581 581
                 }
582 582
                 return $this->_parse_question_list_for_primary_or_recipient_registration(
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
         $setup_args = array(
610 610
             'mtfilename'                  => 'EE_Newsletter_message_type.class.php',
611 611
             'autoloadpaths'               => array(
612
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/'
612
+                EE_CAF_LIBRARIES.'messages/message_type/newsletter/'
613 613
             ),
614 614
             'messengers_to_activate_with' => array('email'),
615 615
             'messengers_to_validate_with' => array('email'),
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
         //register payment reminder message type
621 621
         $setup_args = array(
622 622
             'mtfilename'                  => 'EE_Payment_Reminder_message_type.class.php',
623
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
623
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'),
624 624
             'messengers_to_activate_with' => array('email'),
625 625
             'messengers_to_validate_with' => array('email'),
626 626
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
         //register payment declined message type
631 631
         $setup_args = array(
632 632
             'mtfilename'                  => 'EE_Payment_Declined_message_type.class.php',
633
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
633
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'),
634 634
             'messengers_to_activate_with' => array('email'),
635 635
             'messengers_to_validate_with' => array('email'),
636 636
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
         //register registration declined message type
641 641
         $setup_args = array(
642 642
             'mtfilename'                  => 'EE_Declined_Registration_message_type.class.php',
643
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
643
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'),
644 644
             'messengers_to_activate_with' => array('email'),
645 645
             'messengers_to_validate_with' => array('email'),
646 646
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         //register registration cancelled message type
651 651
         $setup_args = array(
652 652
             'mtfilename'                  => 'EE_Cancelled_Registration_message_type.class.php',
653
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
653
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'),
654 654
             'messengers_to_activate_with' => array('email'),
655 655
             'messengers_to_validate_with' => array('email'),
656 656
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
         //register payment failed message type
662 662
         $setup_args = array(
663 663
             'mtfilename'                  => 'EE_Payment_Failed_message_type.class.php',
664
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
664
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'),
665 665
             'messengers_to_activate_with' => array('email'),
666 666
             'messengers_to_validate_with' => array('email'),
667 667
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
         //register payment declined message type
672 672
         $setup_args = array(
673 673
             'mtfilename'                  => 'EE_Payment_Cancelled_message_type.class.php',
674
-            'autoloadpaths'               => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
674
+            'autoloadpaths'               => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'),
675 675
             'messengers_to_activate_with' => array('email'),
676 676
             'messengers_to_validate_with' => array('email'),
677 677
             'messengers_supporting_default_template_pack_with' => array('email')
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
     {
692 692
         $setup_args = array(
693 693
             'autoloadpaths'                 => array(
694
-                EE_CAF_LIBRARIES . 'shortcodes/'
694
+                EE_CAF_LIBRARIES.'shortcodes/'
695 695
             ),
696 696
             'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
697 697
             'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
Please login to merge, or discard this patch.
core/db_models/EEM_Attendee.model.php 2 patches
Indentation   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 require_once(EE_MODELS . 'EEM_Base.model.php');
5 5
 
@@ -15,329 +15,329 @@  discard block
 block discarded – undo
15 15
 class EEM_Attendee extends EEM_CPT_Base
16 16
 {
17 17
 
18
-    // private instance of the Attendee object
19
-    protected static $_instance = null;
18
+	// private instance of the Attendee object
19
+	protected static $_instance = null;
20 20
 
21
-    /**
22
-     * QST_system for questions are strings not ints now,
23
-     * so these constants are deprecated.
24
-     * Please instead use the EEM_Attendee::system_question_* constants
25
-     *
26
-     * @deprecated
27
-     */
28
-    const fname_question_id = 1;
21
+	/**
22
+	 * QST_system for questions are strings not ints now,
23
+	 * so these constants are deprecated.
24
+	 * Please instead use the EEM_Attendee::system_question_* constants
25
+	 *
26
+	 * @deprecated
27
+	 */
28
+	const fname_question_id = 1;
29 29
 
30
-    /**
31
-     * @deprecated
32
-     */
33
-    const lname_question_id = 2;
30
+	/**
31
+	 * @deprecated
32
+	 */
33
+	const lname_question_id = 2;
34 34
 
35 35
 
36
-    /**
37
-     * @deprecated
38
-     */
39
-    const email_question_id = 3;
36
+	/**
37
+	 * @deprecated
38
+	 */
39
+	const email_question_id = 3;
40 40
 
41 41
 
42
-    /**
43
-     * @deprecated
44
-     */
45
-    const address_question_id = 4;
42
+	/**
43
+	 * @deprecated
44
+	 */
45
+	const address_question_id = 4;
46 46
 
47 47
 
48
-    /**
49
-     * @deprecated
50
-     */
51
-    const address2_question_id = 5;
52
-
53
-
54
-    /**
55
-     * @deprecated
56
-     */
57
-    const city_question_id = 6;
58
-
59
-
60
-    /**
61
-     * @deprecated
62
-     */
63
-    const state_question_id = 7;
64
-
65
-
66
-    /**
67
-     * @deprecated
68
-     */
69
-    const country_question_id = 8;
70
-
71
-
72
-    /**
73
-     * @deprecated
74
-     */
75
-    const zip_question_id = 9;
76
-
77
-
78
-    /**
79
-     * @deprecated
80
-     */
81
-    const phone_question_id = 10;
82
-
83
-    /**
84
-     * When looking for questions that correspond to attendee fields,
85
-     * look for the question with this QST_system value.
86
-     * These replace the old constants like EEM_Attendee::*_question_id
87
-     */
88
-    const system_question_fname    = 'fname';
89
-
90
-    const system_question_lname    = 'lname';
91
-
92
-    const system_question_email    = 'email';
93
-
94
-    const system_question_address  = 'address';
95
-
96
-    const system_question_address2 = 'address2';
97
-
98
-    const system_question_city     = 'city';
99
-
100
-    const system_question_state    = 'state';
101
-
102
-    const system_question_country  = 'country';
103
-
104
-    const system_question_zip      = 'zip';
105
-
106
-    const system_question_phone    = 'phone';
107
-
108
-    /**
109
-     * Keys are all the EEM_Attendee::system_question_* constants, which are
110
-     * also all the values of QST_system in the questions table, and values
111
-     * are their corresponding Attendee field names
112
-     *
113
-     * @var array
114
-     */
115
-    protected $_system_question_to_attendee_field_name = array(
116
-        EEM_Attendee::system_question_fname    => 'ATT_fname',
117
-        EEM_Attendee::system_question_lname    => 'ATT_lname',
118
-        EEM_Attendee::system_question_email    => 'ATT_email',
119
-        EEM_Attendee::system_question_address  => 'ATT_address',
120
-        EEM_Attendee::system_question_address2 => 'ATT_address2',
121
-        EEM_Attendee::system_question_city     => 'ATT_city',
122
-        EEM_Attendee::system_question_state    => 'STA_ID',
123
-        EEM_Attendee::system_question_country  => 'CNT_ISO',
124
-        EEM_Attendee::system_question_zip      => 'ATT_zip',
125
-        EEM_Attendee::system_question_phone    => 'ATT_phone',
126
-    );
127
-
128
-
129
-
130
-    /**
131
-     *        private constructor to prevent direct creation
132
-     *
133
-     * @Constructor
134
-     * @access protected
135
-     * @param null $timezone
136
-     */
137
-    protected function __construct($timezone = null)
138
-    {
139
-        $this->singular_item = __('Attendee', 'event_espresso');
140
-        $this->plural_item = __('Attendees', 'event_espresso');
141
-        $this->_tables = array(
142
-            'Attendee_CPT'  => new EE_Primary_Table('posts', 'ID'),
143
-            'Attendee_Meta' => new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID'),
144
-        );
145
-        $this->_fields = array(
146
-            'Attendee_CPT'  => array(
147
-                'ATT_ID'        => new EE_Primary_Key_Int_Field('ID', __("Attendee ID", "event_espresso")),
148
-                'ATT_full_name' => new EE_Plain_Text_Field('post_title', __("Attendee Full Name", "event_espresso"),
149
-                    false, __("Unknown", "event_espresso")),
150
-                'ATT_bio'       => new EE_Post_Content_Field('post_content', __("Attendee Biography", "event_espresso"),
151
-                    false, __("No Biography Provided", "event_espresso")),
152
-                'ATT_slug'      => new EE_Slug_Field('post_name', __("Attendee URL Slug", "event_espresso"), false),
153
-                'ATT_created'   => new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"),
154
-                    false, EE_Datetime_Field::now),
155
-                'ATT_short_bio' => new EE_Simple_HTML_Field('post_excerpt',
156
-                    __("Attendee Short Biography", "event_espresso"), true,
157
-                    __("No Biography Provided", "event_espresso")),
158
-                'ATT_modified'  => new EE_Datetime_Field('post_modified',
159
-                    __("Time Attendee Last Modified", "event_espresso"), false, EE_Datetime_Field::now),
160
-                'ATT_author'    => new EE_WP_User_Field('post_author',
161
-                    __("Creator ID of the first Event attended", "event_espresso"), false),
162
-                'ATT_parent'    => new EE_DB_Only_Int_Field('post_parent',
163
-                    __("Parent Attendee (unused)", "event_espresso"), false, 0),
164
-                'post_type'     => new EE_WP_Post_Type_Field('espresso_attendees'),
165
-                // EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'),
166
-                'status'        => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'),
167
-                    false, 'publish'),
168
-            ),
169
-            'Attendee_Meta' => array(
170
-                'ATTM_ID'      => new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'),
171
-                    false),
172
-                'ATT_ID_fk'    => new EE_DB_Only_Int_Field('ATT_ID',
173
-                    __("Foreign Key to Attendee in Post Table", "event_espresso"), false),
174
-                'ATT_fname'    => new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''),
175
-                'ATT_lname'    => new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''),
176
-                'ATT_address'  => new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true,
177
-                    ''),
178
-                'ATT_address2' => new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true,
179
-                    ''),
180
-                'ATT_city'     => new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''),
181
-                'STA_ID'       => new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0,
182
-                    'State'),
183
-                'CNT_ISO'      => new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '',
184
-                    'Country'),
185
-                'ATT_zip'      => new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''),
186
-                'ATT_email'    => new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''),
187
-                'ATT_phone'    => new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, ''),
188
-            ),
189
-        );
190
-        $this->_model_relations = array(
191
-            'Registration'      => new EE_Has_Many_Relation(),
192
-            'State'             => new EE_Belongs_To_Relation(),
193
-            'Country'           => new EE_Belongs_To_Relation(),
194
-            'Event'             => new EE_HABTM_Relation('Registration', false),
195
-            'WP_User'           => new EE_Belongs_To_Relation(),
196
-            'Message'           => new EE_Has_Many_Any_Relation(false),
197
-            //allow deletion of attendees even if they have messages in the queue for them.
198
-            'Term_Relationship' => new EE_Has_Many_Relation(),
199
-            'Term_Taxonomy'     => new EE_HABTM_Relation('Term_Relationship'),
200
-        );
201
-        $this->_caps_slug = 'contacts';
202
-        parent::__construct($timezone);
203
-    }
204
-
205
-
206
-
207
-    /**
208
-     * Gets the name of the field on the attendee model corresponding to the system question string
209
-     * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name
210
-     *
211
-     * @param string $system_question_string
212
-     * @return string|null if not found
213
-     */
214
-    public function get_attendee_field_for_system_question($system_question_string)
215
-    {
216
-        return isset($this->_system_question_to_attendee_field_name[$system_question_string])
217
-            ? $this->_system_question_to_attendee_field_name[$system_question_string] : null;
218
-    }
219
-
220
-
221
-
222
-    /**
223
-     * Gets mapping from esp_question.QST_system values to their corresponding attendee field names
224
-     * @return array
225
-     */
226
-    public function system_question_to_attendee_field_mapping(){
227
-        return $this->_system_question_to_attendee_field_name;
228
-    }
229
-
230
-
231
-
232
-    /**
233
-     * Gets all the attendees for a transaction (by using the esp_registration as a join table)
234
-     *
235
-     * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID
236
-     * @return EE_Attendee[]
237
-     */
238
-    public function get_attendees_for_transaction($transaction_id_or_obj)
239
-    {
240
-        return $this->get_all(array(
241
-            array(
242
-                'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction
243
-                    ? $transaction_id_or_obj->ID() : $transaction_id_or_obj,
244
-            ),
245
-        ));
246
-    }
247
-
248
-
249
-
250
-    /**
251
-     *        retrieve  a single attendee from db via their ID
252
-     *
253
-     * @access        public
254
-     * @param        $ATT_ID
255
-     * @return        mixed        array on success, FALSE on fail
256
-     * @deprecated
257
-     */
258
-    public function get_attendee_by_ID($ATT_ID = false)
259
-    {
260
-        // retrieve a particular EE_Attendee
261
-        return $this->get_one_by_ID($ATT_ID);
262
-    }
263
-
264
-
265
-
266
-    /**
267
-     *        retrieve  a single attendee from db via their ID
268
-     *
269
-     * @access        public
270
-     * @param        array $where_cols_n_values
271
-     * @return        mixed        array on success, FALSE on fail
272
-     */
273
-    public function get_attendee($where_cols_n_values = array())
274
-    {
275
-        if (empty($where_cols_n_values)) {
276
-            return false;
277
-        }
278
-        $attendee = $this->get_all(array($where_cols_n_values));
279
-        if ( ! empty($attendee)) {
280
-            return array_shift($attendee);
281
-        } else {
282
-            return false;
283
-        }
284
-    }
285
-
286
-
287
-
288
-    /**
289
-     *        Search for an existing Attendee record in the DB
290
-     *
291
-     * @access        public
292
-     * @param array $where_cols_n_values
293
-     * @return bool|mixed
294
-     */
295
-    public function find_existing_attendee($where_cols_n_values = null)
296
-    {
297
-        // search by combo of first and last names plus the email address
298
-        $attendee_data_keys = array(
299
-            'ATT_fname' => $this->_ATT_fname,
300
-            'ATT_lname' => $this->_ATT_lname,
301
-            'ATT_email' => $this->_ATT_email,
302
-        );
303
-        // no search params means attendee object already exists.
304
-        $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) ? $where_cols_n_values
305
-            : $attendee_data_keys;
306
-        $valid_data = true;
307
-        // check for required values
308
-        $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname'])
309
-            ? $valid_data : false;
310
-        $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname'])
311
-            ? $valid_data : false;
312
-        $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email'])
313
-            ? $valid_data : false;
314
-        if ($valid_data) {
315
-            $attendee = $this->get_attendee($where_cols_n_values);
316
-            if ($attendee instanceof EE_Attendee) {
317
-                return $attendee;
318
-            }
319
-        }
320
-        return false;
321
-    }
322
-
323
-
324
-
325
-    /**
326
-     * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate
327
-     * EE_Attendee objects.
328
-     *
329
-     * @since    4.3.0
330
-     * @param  array $ids array of EE_Registration ids
331
-     * @return  EE_Attendee[]
332
-     */
333
-    public function get_array_of_contacts_from_reg_ids($ids)
334
-    {
335
-        $ids = (array)$ids;
336
-        $_where = array(
337
-            'Registration.REG_ID' => array('in', $ids),
338
-        );
339
-        return $this->get_all(array($_where));
340
-    }
48
+	/**
49
+	 * @deprecated
50
+	 */
51
+	const address2_question_id = 5;
52
+
53
+
54
+	/**
55
+	 * @deprecated
56
+	 */
57
+	const city_question_id = 6;
58
+
59
+
60
+	/**
61
+	 * @deprecated
62
+	 */
63
+	const state_question_id = 7;
64
+
65
+
66
+	/**
67
+	 * @deprecated
68
+	 */
69
+	const country_question_id = 8;
70
+
71
+
72
+	/**
73
+	 * @deprecated
74
+	 */
75
+	const zip_question_id = 9;
76
+
77
+
78
+	/**
79
+	 * @deprecated
80
+	 */
81
+	const phone_question_id = 10;
82
+
83
+	/**
84
+	 * When looking for questions that correspond to attendee fields,
85
+	 * look for the question with this QST_system value.
86
+	 * These replace the old constants like EEM_Attendee::*_question_id
87
+	 */
88
+	const system_question_fname    = 'fname';
89
+
90
+	const system_question_lname    = 'lname';
91
+
92
+	const system_question_email    = 'email';
93
+
94
+	const system_question_address  = 'address';
95
+
96
+	const system_question_address2 = 'address2';
97
+
98
+	const system_question_city     = 'city';
99
+
100
+	const system_question_state    = 'state';
101
+
102
+	const system_question_country  = 'country';
103
+
104
+	const system_question_zip      = 'zip';
105
+
106
+	const system_question_phone    = 'phone';
107
+
108
+	/**
109
+	 * Keys are all the EEM_Attendee::system_question_* constants, which are
110
+	 * also all the values of QST_system in the questions table, and values
111
+	 * are their corresponding Attendee field names
112
+	 *
113
+	 * @var array
114
+	 */
115
+	protected $_system_question_to_attendee_field_name = array(
116
+		EEM_Attendee::system_question_fname    => 'ATT_fname',
117
+		EEM_Attendee::system_question_lname    => 'ATT_lname',
118
+		EEM_Attendee::system_question_email    => 'ATT_email',
119
+		EEM_Attendee::system_question_address  => 'ATT_address',
120
+		EEM_Attendee::system_question_address2 => 'ATT_address2',
121
+		EEM_Attendee::system_question_city     => 'ATT_city',
122
+		EEM_Attendee::system_question_state    => 'STA_ID',
123
+		EEM_Attendee::system_question_country  => 'CNT_ISO',
124
+		EEM_Attendee::system_question_zip      => 'ATT_zip',
125
+		EEM_Attendee::system_question_phone    => 'ATT_phone',
126
+	);
127
+
128
+
129
+
130
+	/**
131
+	 *        private constructor to prevent direct creation
132
+	 *
133
+	 * @Constructor
134
+	 * @access protected
135
+	 * @param null $timezone
136
+	 */
137
+	protected function __construct($timezone = null)
138
+	{
139
+		$this->singular_item = __('Attendee', 'event_espresso');
140
+		$this->plural_item = __('Attendees', 'event_espresso');
141
+		$this->_tables = array(
142
+			'Attendee_CPT'  => new EE_Primary_Table('posts', 'ID'),
143
+			'Attendee_Meta' => new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID'),
144
+		);
145
+		$this->_fields = array(
146
+			'Attendee_CPT'  => array(
147
+				'ATT_ID'        => new EE_Primary_Key_Int_Field('ID', __("Attendee ID", "event_espresso")),
148
+				'ATT_full_name' => new EE_Plain_Text_Field('post_title', __("Attendee Full Name", "event_espresso"),
149
+					false, __("Unknown", "event_espresso")),
150
+				'ATT_bio'       => new EE_Post_Content_Field('post_content', __("Attendee Biography", "event_espresso"),
151
+					false, __("No Biography Provided", "event_espresso")),
152
+				'ATT_slug'      => new EE_Slug_Field('post_name', __("Attendee URL Slug", "event_espresso"), false),
153
+				'ATT_created'   => new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"),
154
+					false, EE_Datetime_Field::now),
155
+				'ATT_short_bio' => new EE_Simple_HTML_Field('post_excerpt',
156
+					__("Attendee Short Biography", "event_espresso"), true,
157
+					__("No Biography Provided", "event_espresso")),
158
+				'ATT_modified'  => new EE_Datetime_Field('post_modified',
159
+					__("Time Attendee Last Modified", "event_espresso"), false, EE_Datetime_Field::now),
160
+				'ATT_author'    => new EE_WP_User_Field('post_author',
161
+					__("Creator ID of the first Event attended", "event_espresso"), false),
162
+				'ATT_parent'    => new EE_DB_Only_Int_Field('post_parent',
163
+					__("Parent Attendee (unused)", "event_espresso"), false, 0),
164
+				'post_type'     => new EE_WP_Post_Type_Field('espresso_attendees'),
165
+				// EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'),
166
+				'status'        => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'),
167
+					false, 'publish'),
168
+			),
169
+			'Attendee_Meta' => array(
170
+				'ATTM_ID'      => new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'),
171
+					false),
172
+				'ATT_ID_fk'    => new EE_DB_Only_Int_Field('ATT_ID',
173
+					__("Foreign Key to Attendee in Post Table", "event_espresso"), false),
174
+				'ATT_fname'    => new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''),
175
+				'ATT_lname'    => new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''),
176
+				'ATT_address'  => new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true,
177
+					''),
178
+				'ATT_address2' => new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true,
179
+					''),
180
+				'ATT_city'     => new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''),
181
+				'STA_ID'       => new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0,
182
+					'State'),
183
+				'CNT_ISO'      => new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '',
184
+					'Country'),
185
+				'ATT_zip'      => new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''),
186
+				'ATT_email'    => new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''),
187
+				'ATT_phone'    => new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, ''),
188
+			),
189
+		);
190
+		$this->_model_relations = array(
191
+			'Registration'      => new EE_Has_Many_Relation(),
192
+			'State'             => new EE_Belongs_To_Relation(),
193
+			'Country'           => new EE_Belongs_To_Relation(),
194
+			'Event'             => new EE_HABTM_Relation('Registration', false),
195
+			'WP_User'           => new EE_Belongs_To_Relation(),
196
+			'Message'           => new EE_Has_Many_Any_Relation(false),
197
+			//allow deletion of attendees even if they have messages in the queue for them.
198
+			'Term_Relationship' => new EE_Has_Many_Relation(),
199
+			'Term_Taxonomy'     => new EE_HABTM_Relation('Term_Relationship'),
200
+		);
201
+		$this->_caps_slug = 'contacts';
202
+		parent::__construct($timezone);
203
+	}
204
+
205
+
206
+
207
+	/**
208
+	 * Gets the name of the field on the attendee model corresponding to the system question string
209
+	 * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name
210
+	 *
211
+	 * @param string $system_question_string
212
+	 * @return string|null if not found
213
+	 */
214
+	public function get_attendee_field_for_system_question($system_question_string)
215
+	{
216
+		return isset($this->_system_question_to_attendee_field_name[$system_question_string])
217
+			? $this->_system_question_to_attendee_field_name[$system_question_string] : null;
218
+	}
219
+
220
+
221
+
222
+	/**
223
+	 * Gets mapping from esp_question.QST_system values to their corresponding attendee field names
224
+	 * @return array
225
+	 */
226
+	public function system_question_to_attendee_field_mapping(){
227
+		return $this->_system_question_to_attendee_field_name;
228
+	}
229
+
230
+
231
+
232
+	/**
233
+	 * Gets all the attendees for a transaction (by using the esp_registration as a join table)
234
+	 *
235
+	 * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID
236
+	 * @return EE_Attendee[]
237
+	 */
238
+	public function get_attendees_for_transaction($transaction_id_or_obj)
239
+	{
240
+		return $this->get_all(array(
241
+			array(
242
+				'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction
243
+					? $transaction_id_or_obj->ID() : $transaction_id_or_obj,
244
+			),
245
+		));
246
+	}
247
+
248
+
249
+
250
+	/**
251
+	 *        retrieve  a single attendee from db via their ID
252
+	 *
253
+	 * @access        public
254
+	 * @param        $ATT_ID
255
+	 * @return        mixed        array on success, FALSE on fail
256
+	 * @deprecated
257
+	 */
258
+	public function get_attendee_by_ID($ATT_ID = false)
259
+	{
260
+		// retrieve a particular EE_Attendee
261
+		return $this->get_one_by_ID($ATT_ID);
262
+	}
263
+
264
+
265
+
266
+	/**
267
+	 *        retrieve  a single attendee from db via their ID
268
+	 *
269
+	 * @access        public
270
+	 * @param        array $where_cols_n_values
271
+	 * @return        mixed        array on success, FALSE on fail
272
+	 */
273
+	public function get_attendee($where_cols_n_values = array())
274
+	{
275
+		if (empty($where_cols_n_values)) {
276
+			return false;
277
+		}
278
+		$attendee = $this->get_all(array($where_cols_n_values));
279
+		if ( ! empty($attendee)) {
280
+			return array_shift($attendee);
281
+		} else {
282
+			return false;
283
+		}
284
+	}
285
+
286
+
287
+
288
+	/**
289
+	 *        Search for an existing Attendee record in the DB
290
+	 *
291
+	 * @access        public
292
+	 * @param array $where_cols_n_values
293
+	 * @return bool|mixed
294
+	 */
295
+	public function find_existing_attendee($where_cols_n_values = null)
296
+	{
297
+		// search by combo of first and last names plus the email address
298
+		$attendee_data_keys = array(
299
+			'ATT_fname' => $this->_ATT_fname,
300
+			'ATT_lname' => $this->_ATT_lname,
301
+			'ATT_email' => $this->_ATT_email,
302
+		);
303
+		// no search params means attendee object already exists.
304
+		$where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) ? $where_cols_n_values
305
+			: $attendee_data_keys;
306
+		$valid_data = true;
307
+		// check for required values
308
+		$valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname'])
309
+			? $valid_data : false;
310
+		$valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname'])
311
+			? $valid_data : false;
312
+		$valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email'])
313
+			? $valid_data : false;
314
+		if ($valid_data) {
315
+			$attendee = $this->get_attendee($where_cols_n_values);
316
+			if ($attendee instanceof EE_Attendee) {
317
+				return $attendee;
318
+			}
319
+		}
320
+		return false;
321
+	}
322
+
323
+
324
+
325
+	/**
326
+	 * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate
327
+	 * EE_Attendee objects.
328
+	 *
329
+	 * @since    4.3.0
330
+	 * @param  array $ids array of EE_Registration ids
331
+	 * @return  EE_Attendee[]
332
+	 */
333
+	public function get_array_of_contacts_from_reg_ids($ids)
334
+	{
335
+		$ids = (array)$ids;
336
+		$_where = array(
337
+			'Registration.REG_ID' => array('in', $ids),
338
+		);
339
+		return $this->get_all(array($_where));
340
+	}
341 341
 
342 342
 
343 343
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4
-require_once(EE_MODELS . 'EEM_Base.model.php');
4
+require_once(EE_MODELS.'EEM_Base.model.php');
5 5
 
6 6
 
7 7
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      * Gets mapping from esp_question.QST_system values to their corresponding attendee field names
224 224
      * @return array
225 225
      */
226
-    public function system_question_to_attendee_field_mapping(){
226
+    public function system_question_to_attendee_field_mapping() {
227 227
         return $this->_system_question_to_attendee_field_name;
228 228
     }
229 229
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
      */
333 333
     public function get_array_of_contacts_from_reg_ids($ids)
334 334
     {
335
-        $ids = (array)$ids;
335
+        $ids = (array) $ids;
336 336
         $_where = array(
337 337
             'Registration.REG_ID' => array('in', $ids),
338 338
         );
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 2 patches
Indentation   +398 added lines, -399 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
18 18
 
19 19
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
20
-    exit('No direct script access allowed');
20
+	exit('No direct script access allowed');
21 21
 }
22 22
 
23 23
 
@@ -25,427 +25,426 @@  discard block
 block discarded – undo
25 25
 class RegistrationsReport extends JobHandlerFile
26 26
 {
27 27
 
28
-    /**
29
-     * Performs any necessary setup for starting the job. This is also a good
30
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
31
-     * when continue_job will be called
32
-     *
33
-     * @param JobParameters $job_parameters
34
-     * @throws BatchRequestException
35
-     * @return JobStepResponse
36
-     */
37
-    public function create_job(JobParameters $job_parameters)
38
-    {
39
-        $event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
40
-        if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
41
-            throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
42
-        }
43
-        $filepath = $this->create_file_from_job_with_name($job_parameters->job_id(),
44
-            $this->get_filename($event_id));
45
-        $job_parameters->add_extra_data('filepath', $filepath);
46
-        if ($job_parameters->request_datum('use_filters', false)) {
47
-            $query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
48
-        } else {
49
-            $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
50
-                array(
51
-                    'OR'                 => array(
52
-                        //don't include registrations from failed or abandoned transactions...
53
-                        'Transaction.STS_ID' => array(
54
-                            'NOT IN',
55
-                            array(
56
-                                \EEM_Transaction::failed_status_code,
57
-                                \EEM_Transaction::abandoned_status_code,
58
-                            ),
59
-                        ),
60
-                        //unless the registration is approved, in which case include it regardless of transaction status
61
-                        'STS_ID'             => \EEM_Registration::status_id_approved,
62
-                    ),
63
-                    'Ticket.TKT_deleted' => array('IN', array(true, false)),
64
-                ),
65
-                'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
66
-                'force_join' => array('Transaction', 'Ticket', 'Attendee'),
67
-                'caps'       => \EEM_Base::caps_read_admin,
68
-            ), $event_id);
69
-            if ($event_id) {
70
-                $query_params[0]['EVT_ID'] = $event_id;
71
-            } else {
72
-                $query_params['force_join'][] = 'Event';
73
-            }
74
-        }
75
-        if ( ! isset($query_params['force_join'])) {
76
-            $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
77
-        }
78
-        $job_parameters->add_extra_data('query_params', $query_params);
79
-        $question_labels = $this->_get_question_labels($query_params);
80
-        $job_parameters->add_extra_data('question_labels', $question_labels);
81
-        $job_parameters->set_job_size(
82
-            \EEM_Registration::instance()->count(
83
-                array_diff_key(
84
-                    $query_params,
85
-                    array_flip(
86
-                        array( 'limit' )
87
-                    )
88
-                )
89
-            )
90
-        );
91
-        //we should also set the header columns
92
-        $csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('question_labels'),
93
-            $job_parameters->extra_datum('query_params'));
94
-        \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
95
-        //if we actually processed a row there, record it
96
-        if ($job_parameters->job_size()) {
97
-            $job_parameters->mark_processed(1);
98
-        }
99
-        return new JobStepResponse($job_parameters,
100
-            __('Registrations report started successfully...', 'event_espresso'));
101
-    }
28
+	/**
29
+	 * Performs any necessary setup for starting the job. This is also a good
30
+	 * place to setup the $job_arguments which will be used for subsequent HTTP requests
31
+	 * when continue_job will be called
32
+	 *
33
+	 * @param JobParameters $job_parameters
34
+	 * @throws BatchRequestException
35
+	 * @return JobStepResponse
36
+	 */
37
+	public function create_job(JobParameters $job_parameters)
38
+	{
39
+		$event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
40
+		if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
41
+			throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
42
+		}
43
+		$filepath = $this->create_file_from_job_with_name($job_parameters->job_id(),
44
+			$this->get_filename($event_id));
45
+		$job_parameters->add_extra_data('filepath', $filepath);
46
+		if ($job_parameters->request_datum('use_filters', false)) {
47
+			$query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
48
+		} else {
49
+			$query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
50
+				array(
51
+					'OR'                 => array(
52
+						//don't include registrations from failed or abandoned transactions...
53
+						'Transaction.STS_ID' => array(
54
+							'NOT IN',
55
+							array(
56
+								\EEM_Transaction::failed_status_code,
57
+								\EEM_Transaction::abandoned_status_code,
58
+							),
59
+						),
60
+						//unless the registration is approved, in which case include it regardless of transaction status
61
+						'STS_ID'             => \EEM_Registration::status_id_approved,
62
+					),
63
+					'Ticket.TKT_deleted' => array('IN', array(true, false)),
64
+				),
65
+				'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
66
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
67
+				'caps'       => \EEM_Base::caps_read_admin,
68
+			), $event_id);
69
+			if ($event_id) {
70
+				$query_params[0]['EVT_ID'] = $event_id;
71
+			} else {
72
+				$query_params['force_join'][] = 'Event';
73
+			}
74
+		}
75
+		if ( ! isset($query_params['force_join'])) {
76
+			$query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
77
+		}
78
+		$job_parameters->add_extra_data('query_params', $query_params);
79
+		$question_labels = $this->_get_question_labels($query_params);
80
+		$job_parameters->add_extra_data('question_labels', $question_labels);
81
+		$job_parameters->set_job_size(
82
+			\EEM_Registration::instance()->count(
83
+				array_diff_key(
84
+					$query_params,
85
+					array_flip(
86
+						array( 'limit' )
87
+					)
88
+				)
89
+			)
90
+		);
91
+		//we should also set the header columns
92
+		$csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('question_labels'),
93
+			$job_parameters->extra_datum('query_params'));
94
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
95
+		//if we actually processed a row there, record it
96
+		if ($job_parameters->job_size()) {
97
+			$job_parameters->mark_processed(1);
98
+		}
99
+		return new JobStepResponse($job_parameters,
100
+			__('Registrations report started successfully...', 'event_espresso'));
101
+	}
102 102
 
103 103
 
104 104
 
105
-    /**
106
-     * Gets the filename
107
-     * @return string
108
-     */
109
-    protected function get_filename()
110
-    {
111
-        return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql')));
112
-    }
105
+	/**
106
+	 * Gets the filename
107
+	 * @return string
108
+	 */
109
+	protected function get_filename()
110
+	{
111
+		return sprintf("event-espresso-registrations-%s.csv", str_replace(':', '-', current_time('mysql')));
112
+	}
113 113
 
114 114
 
115 115
 
116
-    /**
117
-     * Gets the questions which are to be used for this report, so they
118
-     * can be remembered for later
119
-     *
120
-     * @param array $registration_query_params
121
-     * @return array question admin labels to be used for this report
122
-     */
123
-    protected function _get_question_labels($registration_query_params)
124
-    {
125
-        $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
126
-        $question_query_params = array();
127
-        if ($where !== null) {
128
-            $question_query_params = array(
129
-                $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
130
-            );
131
-        }
132
-        $question_query_params[0]['QST_system'] = array('NOT_IN', array_keys(\EEM_Attendee::instance()->system_question_to_attendee_field_mapping()));
133
-        if(apply_filters('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', false, $registration_query_params)) {
134
-            $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
135
-        }
136
-        $question_query_params['group_by'] = array( 'QST_ID' );
137
-        return array_unique( \EEM_Question::instance()->get_col( $question_query_params, 'QST_admin_label' ) );
138
-    }
116
+	/**
117
+	 * Gets the questions which are to be used for this report, so they
118
+	 * can be remembered for later
119
+	 *
120
+	 * @param array $registration_query_params
121
+	 * @return array question admin labels to be used for this report
122
+	 */
123
+	protected function _get_question_labels($registration_query_params)
124
+	{
125
+		$where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
126
+		$question_query_params = array();
127
+		if ($where !== null) {
128
+			$question_query_params = array(
129
+				$this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
130
+			);
131
+		}
132
+		$question_query_params[0]['QST_system'] = array('NOT_IN', array_keys(\EEM_Attendee::instance()->system_question_to_attendee_field_mapping()));
133
+		if(apply_filters('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', false, $registration_query_params)) {
134
+			$question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
135
+		}
136
+		$question_query_params['group_by'] = array( 'QST_ID' );
137
+		return array_unique( \EEM_Question::instance()->get_col( $question_query_params, 'QST_admin_label' ) );
138
+	}
139 139
 
140 140
 
141 141
 
142
-    /**
143
-     * Takes where params meant for registrations and changes them to work for questions
144
-     *
145
-     * @param array $reg_where_params
146
-     * @return array
147
-     */
148
-    protected function _change_registration_where_params_to_question_where_params($reg_where_params)
149
-    {
150
-        $question_where_params = array();
151
-        foreach ($reg_where_params as $key => $val) {
152
-            if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
153
-                $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val);
154
-            } else {
155
-                //it's a normal where condition
156
-                $question_where_params['Question_Group.Event.Registration.' . $key] = $val;
157
-            }
158
-        }
159
-        return $question_where_params;
160
-    }
142
+	/**
143
+	 * Takes where params meant for registrations and changes them to work for questions
144
+	 *
145
+	 * @param array $reg_where_params
146
+	 * @return array
147
+	 */
148
+	protected function _change_registration_where_params_to_question_where_params($reg_where_params)
149
+	{
150
+		$question_where_params = array();
151
+		foreach ($reg_where_params as $key => $val) {
152
+			if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
153
+				$question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val);
154
+			} else {
155
+				//it's a normal where condition
156
+				$question_where_params['Question_Group.Event.Registration.' . $key] = $val;
157
+			}
158
+		}
159
+		return $question_where_params;
160
+	}
161 161
 
162 162
 
163 163
 
164
-    /**
165
-     * Performs another step of the job
166
-     *
167
-     * @param JobParameters $job_parameters
168
-     * @param int           $batch_size
169
-     * @return JobStepResponse
170
-     * @throws \EE_Error
171
-     */
172
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
173
-    {
174
-        if( $job_parameters->units_processed() < $job_parameters->job_size() ) {
175
-            $csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'),
176
-                $job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('question_labels'),
177
-                $job_parameters->extra_datum('query_params'));
178
-            \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
179
-            $units_processed = count($csv_data);
180
-        }else{
181
-            $units_processed = 0;
182
-        }
183
-        $job_parameters->mark_processed($units_processed);
184
-        $extra_response_data = array(
185
-            'file_url' => '',
186
-        );
187
-        if ($units_processed < $batch_size) {
188
-            $job_parameters->set_status(JobParameters::status_complete);
189
-            $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
190
-        }
164
+	/**
165
+	 * Performs another step of the job
166
+	 *
167
+	 * @param JobParameters $job_parameters
168
+	 * @param int           $batch_size
169
+	 * @return JobStepResponse
170
+	 * @throws \EE_Error
171
+	 */
172
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
173
+	{
174
+		if( $job_parameters->units_processed() < $job_parameters->job_size() ) {
175
+			$csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'),
176
+				$job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('question_labels'),
177
+				$job_parameters->extra_datum('query_params'));
178
+			\EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
179
+			$units_processed = count($csv_data);
180
+		}else{
181
+			$units_processed = 0;
182
+		}
183
+		$job_parameters->mark_processed($units_processed);
184
+		$extra_response_data = array(
185
+			'file_url' => '',
186
+		);
187
+		if ($units_processed < $batch_size) {
188
+			$job_parameters->set_status(JobParameters::status_complete);
189
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
190
+		}
191 191
 
192
-        return new JobStepResponse($job_parameters,
193
-            sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)),
194
-            $extra_response_data);
195
-    }
192
+		return new JobStepResponse($job_parameters,
193
+			sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)),
194
+			$extra_response_data);
195
+	}
196 196
 
197 197
 
198 198
 
199
-    /**
200
-     * Gets the csv data for a batch of registrations
201
-
202
-     *
199
+	/**
200
+	 * Gets the csv data for a batch of registrations
201
+	 *
203 202
 *@param int|null    $event_id
204
-     * @param int   $offset
205
-     * @param int   $limit
206
-     * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
207
-     * @param array $query_params    for using where querying the model
208
-     * @return array top-level keys are numeric, next-level keys are column headers
209
-     */
210
-    function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
211
-    {
212
-        $reg_fields_to_include = array(
213
-            'TXN_ID',
214
-            'ATT_ID',
215
-            'REG_ID',
216
-            'REG_date',
217
-            'REG_code',
218
-            'REG_count',
219
-            'REG_final_price',
220
-        );
221
-        $att_fields_to_include = array(
222
-            'ATT_fname',
223
-            'ATT_lname',
224
-            'ATT_email',
225
-            'ATT_address',
226
-            'ATT_address2',
227
-            'ATT_city',
228
-            'STA_ID',
229
-            'CNT_ISO',
230
-            'ATT_zip',
231
-            'ATT_phone',
232
-        );
233
-        $registrations_csv_ready_array = array();
234
-        $reg_model = \EE_Registry::instance()->load_model('Registration');
235
-        $query_params['limit'] = array($offset, $limit);
236
-        $registration_rows = $reg_model->get_all_wpdb_results($query_params);
237
-        $registration_ids = array();
238
-        foreach ($registration_rows as $reg_row) {
239
-            $registration_ids[] = intval($reg_row['Registration.REG_ID']);
240
-        }
241
-        foreach ($registration_rows as $reg_row) {
242
-            if (is_array($reg_row)) {
243
-                $reg_csv_array = array();
244
-                if ( ! $event_id) {
245
-                    //get the event's name and Id
246
-                    $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'),
247
-                        \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name',
248
-                            $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
249
-                }
250
-                $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
251
-                /*@var $reg_row EE_Registration */
252
-                foreach ($reg_fields_to_include as $field_name) {
253
-                    $field = $reg_model->field_settings_for($field_name);
254
-                    if ($field_name == 'REG_final_price') {
255
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
256
-                            $reg_row['Registration.REG_final_price'], 'localized_float');
257
-                    } elseif ($field_name == 'REG_count') {
258
-                        $value = sprintf(__('%s of %s', 'event_espresso'),
259
-                            \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count',
260
-                                $reg_row['Registration.REG_count']),
261
-                            \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size',
262
-                                $reg_row['Registration.REG_group_size']));
263
-                    } elseif ($field_name == 'REG_date') {
264
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
265
-                            $reg_row['Registration.REG_date'], 'no_html');
266
-                    } else {
267
-                        $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
268
-                            $reg_row[$field->get_qualified_column()]);
269
-                    }
270
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
271
-                    if ($field_name == 'REG_final_price') {
272
-                        //add a column named Currency after the final price
273
-                        $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
274
-                    }
275
-                }
276
-                //get pretty status
277
-                $stati = \EEM_Status::instance()->localized_status(array(
278
-                    $reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
279
-                    $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
280
-                ), false, 'sentence');
281
-                $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
282
-                //get pretty transaction status
283
-                $reg_csv_array[__("Transaction Status",
284
-                    'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
285
-                $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg
286
-                    ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total',
287
-                        $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00';
288
-                $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg
289
-                    ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid',
290
-                        $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00';
291
-                $payment_methods = array();
292
-                $gateway_txn_ids_etc = array();
293
-                $payment_times = array();
294
-                if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
295
-                    $payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array(
296
-                        array(
297
-                            'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
298
-                            'STS_ID' => \EEM_Payment::status_id_approved,
299
-                        ),
300
-                        'force_join' => array('Payment_Method'),
301
-                    ), ARRAY_A,
302
-                        'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time');
303
-                    foreach ($payments_info as $payment_method_and_gateway_txn_id) {
304
-                        $payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
305
-                            ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
306
-                        $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
307
-                            ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
308
-                        $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
309
-                            ? $payment_method_and_gateway_txn_id['payment_time'] : '';
310
-                    }
311
-                }
312
-                $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
313
-                $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
314
-                $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
315
-                //get whether or not the user has checked in
316
-                $reg_csv_array[__("Check-Ins",
317
-                    "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
318
-                //get ticket of registration and its price
319
-                $ticket_model = \EE_Registry::instance()->load_model('Ticket');
320
-                if ($reg_row['Ticket.TKT_ID']) {
321
-                    $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name',
322
-                        $reg_row['Ticket.TKT_name']);
323
-                    $datetimes_strings = array();
324
-                    foreach (
325
-                        \EEM_Datetime::instance()->get_all_wpdb_results(array(
326
-                            array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
327
-                            'order_by'                 => array('DTT_EVT_start' => 'ASC'),
328
-                            'default_where_conditions' => 'none',
329
-                        )) as $datetime
330
-                    ) {
331
-                        $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(),
332
-                            'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
333
-                    }
334
-                } else {
335
-                    $ticket_name = __('Unknown', 'event_espresso');
336
-                    $datetimes_strings = array(__('Unknown', 'event_espresso'));
337
-                }
338
-                $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
339
-                $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
340
-                //get datetime(s) of registration
341
-                //add attendee columns
342
-                foreach ($att_fields_to_include as $att_field_name) {
343
-                    $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
344
-                    if ($reg_row['Attendee_CPT.ID']) {
345
-                        if ($att_field_name == 'STA_ID') {
346
-                            $value = \EEM_State::instance()
347
-                                               ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
348
-                                                   'STA_name');
349
-                        } elseif ($att_field_name == 'CNT_ISO') {
350
-                            $value = \EEM_Country::instance()
351
-                                                 ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
352
-                                                     'CNT_name');
353
-                        } else {
354
-                            $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(),
355
-                                $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
356
-                        }
357
-                    } else {
358
-                        $value = '';
359
-                    }
360
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
361
-                }
362
-                //make sure each registration has the same questions in the same order
363
-                foreach ($question_labels as $question_label) {
364
-                    if ( ! isset($reg_csv_array[$question_label])) {
365
-                        $reg_csv_array[$question_label] = null;
366
-                    }
367
-                }
368
-                $answers = \EEM_Answer::instance()->get_all_wpdb_results(array(
369
-                    array('REG_ID' => $reg_row['Registration.REG_ID']),
370
-                    'force_join' => array('Question'),
371
-                ));
372
-                //now fill out the questions THEY answered
373
-                foreach ($answers as $answer_row) {
374
-                    if ($answer_row['Question.QST_ID']) {
375
-                        $question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(),
376
-                            'QST_admin_label', $answer_row['Question.QST_admin_label']);
377
-                    } else {
378
-                        $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
379
-                    }
380
-                    if (isset($answer_row['Question.QST_type'])
381
-                        && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
382
-                    ) {
383
-                        $reg_csv_array[$question_label] = \EEM_State::instance()
384
-                                                                    ->get_state_name_by_ID($answer_row['Answer.ANS_value']);
385
-                    } else {
386
-                        //this isn't for html, so don't show html entities
387
-                        $reg_csv_array[$question_label] = html_entity_decode(\EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(),
388
-                            'ANS_value', $answer_row['Answer.ANS_value']));
389
-                    }
390
-                }
391
-                $registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array',
392
-                    $reg_csv_array, $reg_row);
393
-            }
394
-        }
395
-        //if we couldn't export anything, we want to at least show the column headers
396
-        if (empty($registrations_csv_ready_array)) {
397
-            $reg_csv_array = array();
398
-            $model_and_fields_to_include = array(
399
-                'Registration' => $reg_fields_to_include,
400
-                'Attendee'     => $att_fields_to_include,
401
-            );
402
-            foreach ($model_and_fields_to_include as $model_name => $field_list) {
403
-                $model = \EE_Registry::instance()->load_model($model_name);
404
-                foreach ($field_list as $field_name) {
405
-                    $field = $model->field_settings_for($field_name);
406
-                    $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
407
-                }
408
-            }
409
-            $registrations_csv_ready_array[] = $reg_csv_array;
410
-        }
411
-        return $registrations_csv_ready_array;
412
-    }
203
+	 * @param int   $offset
204
+	 * @param int   $limit
205
+	 * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
206
+	 * @param array $query_params    for using where querying the model
207
+	 * @return array top-level keys are numeric, next-level keys are column headers
208
+	 */
209
+	function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
210
+	{
211
+		$reg_fields_to_include = array(
212
+			'TXN_ID',
213
+			'ATT_ID',
214
+			'REG_ID',
215
+			'REG_date',
216
+			'REG_code',
217
+			'REG_count',
218
+			'REG_final_price',
219
+		);
220
+		$att_fields_to_include = array(
221
+			'ATT_fname',
222
+			'ATT_lname',
223
+			'ATT_email',
224
+			'ATT_address',
225
+			'ATT_address2',
226
+			'ATT_city',
227
+			'STA_ID',
228
+			'CNT_ISO',
229
+			'ATT_zip',
230
+			'ATT_phone',
231
+		);
232
+		$registrations_csv_ready_array = array();
233
+		$reg_model = \EE_Registry::instance()->load_model('Registration');
234
+		$query_params['limit'] = array($offset, $limit);
235
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
236
+		$registration_ids = array();
237
+		foreach ($registration_rows as $reg_row) {
238
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
239
+		}
240
+		foreach ($registration_rows as $reg_row) {
241
+			if (is_array($reg_row)) {
242
+				$reg_csv_array = array();
243
+				if ( ! $event_id) {
244
+					//get the event's name and Id
245
+					$reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'),
246
+						\EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name',
247
+							$reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
248
+				}
249
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
250
+				/*@var $reg_row EE_Registration */
251
+				foreach ($reg_fields_to_include as $field_name) {
252
+					$field = $reg_model->field_settings_for($field_name);
253
+					if ($field_name == 'REG_final_price') {
254
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
255
+							$reg_row['Registration.REG_final_price'], 'localized_float');
256
+					} elseif ($field_name == 'REG_count') {
257
+						$value = sprintf(__('%s of %s', 'event_espresso'),
258
+							\EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count',
259
+								$reg_row['Registration.REG_count']),
260
+							\EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size',
261
+								$reg_row['Registration.REG_group_size']));
262
+					} elseif ($field_name == 'REG_date') {
263
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
264
+							$reg_row['Registration.REG_date'], 'no_html');
265
+					} else {
266
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name,
267
+							$reg_row[$field->get_qualified_column()]);
268
+					}
269
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
270
+					if ($field_name == 'REG_final_price') {
271
+						//add a column named Currency after the final price
272
+						$reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
273
+					}
274
+				}
275
+				//get pretty status
276
+				$stati = \EEM_Status::instance()->localized_status(array(
277
+					$reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
278
+					$reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
279
+				), false, 'sentence');
280
+				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
281
+				//get pretty transaction status
282
+				$reg_csv_array[__("Transaction Status",
283
+					'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
284
+				$reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg
285
+					? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total',
286
+						$reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00';
287
+				$reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg
288
+					? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid',
289
+						$reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00';
290
+				$payment_methods = array();
291
+				$gateway_txn_ids_etc = array();
292
+				$payment_times = array();
293
+				if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
294
+					$payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array(
295
+						array(
296
+							'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
297
+							'STS_ID' => \EEM_Payment::status_id_approved,
298
+						),
299
+						'force_join' => array('Payment_Method'),
300
+					), ARRAY_A,
301
+						'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time');
302
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
303
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
304
+							? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
305
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
306
+							? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
307
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
308
+							? $payment_method_and_gateway_txn_id['payment_time'] : '';
309
+					}
310
+				}
311
+				$reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
312
+				$reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
313
+				$reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
314
+				//get whether or not the user has checked in
315
+				$reg_csv_array[__("Check-Ins",
316
+					"event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
317
+				//get ticket of registration and its price
318
+				$ticket_model = \EE_Registry::instance()->load_model('Ticket');
319
+				if ($reg_row['Ticket.TKT_ID']) {
320
+					$ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name',
321
+						$reg_row['Ticket.TKT_name']);
322
+					$datetimes_strings = array();
323
+					foreach (
324
+						\EEM_Datetime::instance()->get_all_wpdb_results(array(
325
+							array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
326
+							'order_by'                 => array('DTT_EVT_start' => 'ASC'),
327
+							'default_where_conditions' => 'none',
328
+						)) as $datetime
329
+					) {
330
+						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(),
331
+							'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
332
+					}
333
+				} else {
334
+					$ticket_name = __('Unknown', 'event_espresso');
335
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
336
+				}
337
+				$reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
338
+				$reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
339
+				//get datetime(s) of registration
340
+				//add attendee columns
341
+				foreach ($att_fields_to_include as $att_field_name) {
342
+					$field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
343
+					if ($reg_row['Attendee_CPT.ID']) {
344
+						if ($att_field_name == 'STA_ID') {
345
+							$value = \EEM_State::instance()
346
+											   ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
347
+												   'STA_name');
348
+						} elseif ($att_field_name == 'CNT_ISO') {
349
+							$value = \EEM_Country::instance()
350
+												 ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
351
+													 'CNT_name');
352
+						} else {
353
+							$value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(),
354
+								$att_field_name, $reg_row[$field_obj->get_qualified_column()]);
355
+						}
356
+					} else {
357
+						$value = '';
358
+					}
359
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
360
+				}
361
+				//make sure each registration has the same questions in the same order
362
+				foreach ($question_labels as $question_label) {
363
+					if ( ! isset($reg_csv_array[$question_label])) {
364
+						$reg_csv_array[$question_label] = null;
365
+					}
366
+				}
367
+				$answers = \EEM_Answer::instance()->get_all_wpdb_results(array(
368
+					array('REG_ID' => $reg_row['Registration.REG_ID']),
369
+					'force_join' => array('Question'),
370
+				));
371
+				//now fill out the questions THEY answered
372
+				foreach ($answers as $answer_row) {
373
+					if ($answer_row['Question.QST_ID']) {
374
+						$question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(),
375
+							'QST_admin_label', $answer_row['Question.QST_admin_label']);
376
+					} else {
377
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
378
+					}
379
+					if (isset($answer_row['Question.QST_type'])
380
+						&& $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
381
+					) {
382
+						$reg_csv_array[$question_label] = \EEM_State::instance()
383
+																	->get_state_name_by_ID($answer_row['Answer.ANS_value']);
384
+					} else {
385
+						//this isn't for html, so don't show html entities
386
+						$reg_csv_array[$question_label] = html_entity_decode(\EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(),
387
+							'ANS_value', $answer_row['Answer.ANS_value']));
388
+					}
389
+				}
390
+				$registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array',
391
+					$reg_csv_array, $reg_row);
392
+			}
393
+		}
394
+		//if we couldn't export anything, we want to at least show the column headers
395
+		if (empty($registrations_csv_ready_array)) {
396
+			$reg_csv_array = array();
397
+			$model_and_fields_to_include = array(
398
+				'Registration' => $reg_fields_to_include,
399
+				'Attendee'     => $att_fields_to_include,
400
+			);
401
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
402
+				$model = \EE_Registry::instance()->load_model($model_name);
403
+				foreach ($field_list as $field_name) {
404
+					$field = $model->field_settings_for($field_name);
405
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
406
+				}
407
+			}
408
+			$registrations_csv_ready_array[] = $reg_csv_array;
409
+		}
410
+		return $registrations_csv_ready_array;
411
+	}
413 412
 
414 413
 
415 414
 
416
-    /**
417
-     * Counts total unit to process
418
-     *
419
-     * @deprecated since 4.9.19
420
-     * @param int|array $event_id
421
-     * @return int
422
-     */
423
-    public function count_units_to_process($event_id)
424
-    {
425
-        //use the legacy filter
426
-        if ($event_id) {
427
-            $query_params[0]['EVT_ID'] = $event_id;
428
-        } else {
429
-            $query_params['force_join'][] = 'Event';
430
-        }
431
-        return \EEM_Registration::instance()->count($query_params);
432
-    }
415
+	/**
416
+	 * Counts total unit to process
417
+	 *
418
+	 * @deprecated since 4.9.19
419
+	 * @param int|array $event_id
420
+	 * @return int
421
+	 */
422
+	public function count_units_to_process($event_id)
423
+	{
424
+		//use the legacy filter
425
+		if ($event_id) {
426
+			$query_params[0]['EVT_ID'] = $event_id;
427
+		} else {
428
+			$query_params['force_join'][] = 'Event';
429
+		}
430
+		return \EEM_Registration::instance()->count($query_params);
431
+	}
433 432
 
434 433
 
435 434
 
436
-    /**
437
-     * Performs any clean-up logic when we know the job is completed.
438
-     * In this case, we delete the temporary file
439
-     *
440
-     * @param JobParameters $job_parameters
441
-     * @return boolean
442
-     */
443
-    public function cleanup_job(JobParameters $job_parameters)
444
-    {
445
-        $this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
446
-            true, 'd');
447
-        return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
448
-    }
435
+	/**
436
+	 * Performs any clean-up logic when we know the job is completed.
437
+	 * In this case, we delete the temporary file
438
+	 *
439
+	 * @param JobParameters $job_parameters
440
+	 * @return boolean
441
+	 */
442
+	public function cleanup_job(JobParameters $job_parameters)
443
+	{
444
+		$this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
445
+			true, 'd');
446
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
447
+	}
449 448
 }
450 449
 
451 450
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                 array_diff_key(
84 84
                     $query_params,
85 85
                     array_flip(
86
-                        array( 'limit' )
86
+                        array('limit')
87 87
                     )
88 88
                 )
89 89
             )
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
             );
131 131
         }
132 132
         $question_query_params[0]['QST_system'] = array('NOT_IN', array_keys(\EEM_Attendee::instance()->system_question_to_attendee_field_mapping()));
133
-        if(apply_filters('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', false, $registration_query_params)) {
133
+        if (apply_filters('FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', false, $registration_query_params)) {
134 134
             $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
135 135
         }
136
-        $question_query_params['group_by'] = array( 'QST_ID' );
137
-        return array_unique( \EEM_Question::instance()->get_col( $question_query_params, 'QST_admin_label' ) );
136
+        $question_query_params['group_by'] = array('QST_ID');
137
+        return array_unique(\EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
138 138
     }
139 139
 
140 140
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val);
154 154
             } else {
155 155
                 //it's a normal where condition
156
-                $question_where_params['Question_Group.Event.Registration.' . $key] = $val;
156
+                $question_where_params['Question_Group.Event.Registration.'.$key] = $val;
157 157
             }
158 158
         }
159 159
         return $question_where_params;
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function continue_job(JobParameters $job_parameters, $batch_size = 50)
173 173
     {
174
-        if( $job_parameters->units_processed() < $job_parameters->job_size() ) {
174
+        if ($job_parameters->units_processed() < $job_parameters->job_size()) {
175 175
             $csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'),
176 176
                 $job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('question_labels'),
177 177
                 $job_parameters->extra_datum('query_params'));
178 178
             \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
179 179
             $units_processed = count($csv_data);
180
-        }else{
180
+        } else {
181 181
             $units_processed = 0;
182 182
         }
183 183
         $job_parameters->mark_processed($units_processed);
Please login to merge, or discard this patch.
core/helpers/EEH_DTT_Helper.helper.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -944,7 +944,7 @@
 block discarded – undo
944 944
      * this method will add that "1" into your date regardless of the format.
945 945
      *
946 946
      * @param string $month
947
-     * @return string
947
+     * @return integer
948 948
      */
949 949
     public static function first_of_month_timestamp($month = '')
950 950
     {
Please login to merge, or discard this patch.
Indentation   +912 added lines, -912 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -26,233 +26,233 @@  discard block
 block discarded – undo
26 26
 {
27 27
 
28 28
 
29
-    /**
30
-     * return the timezone set for the WP install
31
-     *
32
-     * @return string valid timezone string for PHP DateTimeZone() class
33
-     */
34
-    public static function get_timezone()
35
-    {
36
-        return EEH_DTT_Helper::get_valid_timezone_string();
37
-    }
38
-
39
-
40
-    /**
41
-     * get_valid_timezone_string
42
-     *    ensures that a valid timezone string is returned
43
-     *
44
-     * @access protected
45
-     * @param string $timezone_string
46
-     * @return string
47
-     * @throws \EE_Error
48
-     */
49
-    public static function get_valid_timezone_string($timezone_string = '')
50
-    {
51
-        // if passed a value, then use that, else get WP option
52
-        $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
53
-        // value from above exists, use that, else get timezone string from gmt_offset
54
-        $timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset();
55
-        EEH_DTT_Helper::validate_timezone($timezone_string);
56
-        return $timezone_string;
57
-    }
58
-
59
-
60
-    /**
61
-     * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
62
-     *
63
-     * @static
64
-     * @access public
65
-     * @param  string $timezone_string Timezone string to check
66
-     * @param bool    $throw_error
67
-     * @return bool
68
-     * @throws \EE_Error
69
-     */
70
-    public static function validate_timezone($timezone_string, $throw_error = true)
71
-    {
72
-        // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it
73
-        try {
74
-            new DateTimeZone($timezone_string);
75
-        } catch (Exception $e) {
76
-            // sometimes we take exception to exceptions
77
-            if (! $throw_error) {
78
-                return false;
79
-            }
80
-            throw new EE_Error(
81
-                sprintf(
82
-                    __('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
83
-                        'event_espresso'),
84
-                    $timezone_string,
85
-                    '<a href="http://www.php.net/manual/en/timezones.php">',
86
-                    '</a>'
87
-                )
88
-            );
89
-        }
90
-        return true;
91
-    }
92
-
93
-
94
-    /**
95
-     * _create_timezone_object_from_timezone_name
96
-     *
97
-     * @access protected
98
-     * @param string $gmt_offset
99
-     * @return string
100
-     */
101
-    public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
102
-    {
103
-        $timezone_string = 'UTC';
104
-        $gmt_offset      = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset');
105
-        if ($gmt_offset !== '') {
106
-            // convert GMT offset to seconds
107
-            $gmt_offset = $gmt_offset * HOUR_IN_SECONDS;
108
-            // account for WP offsets that aren't valid UTC
109
-            $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset);
110
-            // although we don't know the TZ abbreviation, we know the UTC offset
111
-            $timezone_string = timezone_name_from_abbr(null, $gmt_offset);
112
-        }
113
-        // better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()...
114
-        $timezone_string = $timezone_string !== false
115
-            ? $timezone_string
116
-            : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset);
117
-        return $timezone_string;
118
-    }
119
-
120
-    /**
121
-     * Gets the site's GMT offset based on either the timezone string
122
-     * (in which case teh gmt offset will vary depending on the location's
123
-     * observance of daylight savings time) or the gmt_offset wp option
124
-     *
125
-     * @return int seconds offset
126
-     */
127
-    public static function get_site_timezone_gmt_offset()
128
-    {
129
-        $timezone_string = get_option('timezone_string');
130
-        if ($timezone_string) {
131
-            try {
132
-                $timezone = new DateTimeZone($timezone_string);
133
-                return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC
134
-            } catch (Exception $e) {
135
-            }
136
-        }
137
-        $offset = get_option('gmt_offset');
138
-        return (int)($offset * HOUR_IN_SECONDS);
139
-    }
140
-
141
-
142
-    /**
143
-     * _create_timezone_object_from_timezone_name
144
-     *
145
-     * @access public
146
-     * @param int $gmt_offset
147
-     * @return int
148
-     */
149
-    public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
150
-    {
151
-        //make sure $gmt_offset is int
152
-        $gmt_offset = (int)$gmt_offset;
153
-        switch ($gmt_offset) {
154
-
155
-            //			case -30600 :
156
-            //				$gmt_offset = -28800;
157
-            //				break;
158
-
159
-            case -27000 :
160
-                $gmt_offset = -25200;
161
-                break;
162
-
163
-            case -23400 :
164
-                $gmt_offset = -21600;
165
-                break;
166
-
167
-            case -19800 :
168
-                $gmt_offset = -18000;
169
-                break;
170
-
171
-            case -9000 :
172
-                $gmt_offset = -7200;
173
-                break;
174
-
175
-            case -5400 :
176
-                $gmt_offset = -3600;
177
-                break;
178
-
179
-            case -1800 :
180
-                $gmt_offset = 0;
181
-                break;
182
-
183
-            case 1800 :
184
-                $gmt_offset = 3600;
185
-                break;
186
-
187
-            case 49500 :
188
-                $gmt_offset = 50400;
189
-                break;
190
-
191
-        }
192
-        return $gmt_offset;
193
-    }
194
-
195
-
196
-    /**
197
-     * get_timezone_string_from_abbreviations_list
198
-     *
199
-     * @access public
200
-     * @param int $gmt_offset
201
-     * @return string
202
-     * @throws \EE_Error
203
-     */
204
-    public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0)
205
-    {
206
-        $abbreviations = timezone_abbreviations_list();
207
-        foreach ($abbreviations as $abbreviation) {
208
-            foreach ($abbreviation as $city) {
209
-                if ($city['offset'] === $gmt_offset && $city['dst'] === false) {
210
-                    // check if the timezone is valid but don't throw any errors if it isn't
211
-                    if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) {
212
-                        return $city['timezone_id'];
213
-                    }
214
-                }
215
-            }
216
-        }
217
-        throw new EE_Error(
218
-            sprintf(
219
-                __('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
220
-                    'event_espresso'),
221
-                $gmt_offset,
222
-                '<a href="http://www.php.net/manual/en/timezones.php">',
223
-                '</a>'
224
-            )
225
-        );
226
-    }
227
-
228
-
229
-    /**
230
-     * @access public
231
-     * @param string $timezone_string
232
-     */
233
-    public static function timezone_select_input($timezone_string = '')
234
-    {
235
-        // get WP date time format
236
-        $datetime_format = get_option('date_format') . ' ' . get_option('time_format');
237
-        // if passed a value, then use that, else get WP option
238
-        $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
239
-        // check if the timezone is valid but don't throw any errors if it isn't
240
-        $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false);
241
-        $gmt_offset      = get_option('gmt_offset');
242
-
243
-        $check_zone_info = true;
244
-        if (empty($timezone_string)) {
245
-            // Create a UTC+- zone if no timezone string exists
246
-            $check_zone_info = false;
247
-            if ($gmt_offset > 0) {
248
-                $timezone_string = 'UTC+' . $gmt_offset;
249
-            } elseif ($gmt_offset < 0) {
250
-                $timezone_string = 'UTC' . $gmt_offset;
251
-            } else {
252
-                $timezone_string = 'UTC';
253
-            }
254
-        }
255
-        ?>
29
+	/**
30
+	 * return the timezone set for the WP install
31
+	 *
32
+	 * @return string valid timezone string for PHP DateTimeZone() class
33
+	 */
34
+	public static function get_timezone()
35
+	{
36
+		return EEH_DTT_Helper::get_valid_timezone_string();
37
+	}
38
+
39
+
40
+	/**
41
+	 * get_valid_timezone_string
42
+	 *    ensures that a valid timezone string is returned
43
+	 *
44
+	 * @access protected
45
+	 * @param string $timezone_string
46
+	 * @return string
47
+	 * @throws \EE_Error
48
+	 */
49
+	public static function get_valid_timezone_string($timezone_string = '')
50
+	{
51
+		// if passed a value, then use that, else get WP option
52
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
53
+		// value from above exists, use that, else get timezone string from gmt_offset
54
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset();
55
+		EEH_DTT_Helper::validate_timezone($timezone_string);
56
+		return $timezone_string;
57
+	}
58
+
59
+
60
+	/**
61
+	 * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
62
+	 *
63
+	 * @static
64
+	 * @access public
65
+	 * @param  string $timezone_string Timezone string to check
66
+	 * @param bool    $throw_error
67
+	 * @return bool
68
+	 * @throws \EE_Error
69
+	 */
70
+	public static function validate_timezone($timezone_string, $throw_error = true)
71
+	{
72
+		// easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it
73
+		try {
74
+			new DateTimeZone($timezone_string);
75
+		} catch (Exception $e) {
76
+			// sometimes we take exception to exceptions
77
+			if (! $throw_error) {
78
+				return false;
79
+			}
80
+			throw new EE_Error(
81
+				sprintf(
82
+					__('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
83
+						'event_espresso'),
84
+					$timezone_string,
85
+					'<a href="http://www.php.net/manual/en/timezones.php">',
86
+					'</a>'
87
+				)
88
+			);
89
+		}
90
+		return true;
91
+	}
92
+
93
+
94
+	/**
95
+	 * _create_timezone_object_from_timezone_name
96
+	 *
97
+	 * @access protected
98
+	 * @param string $gmt_offset
99
+	 * @return string
100
+	 */
101
+	public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
102
+	{
103
+		$timezone_string = 'UTC';
104
+		$gmt_offset      = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset');
105
+		if ($gmt_offset !== '') {
106
+			// convert GMT offset to seconds
107
+			$gmt_offset = $gmt_offset * HOUR_IN_SECONDS;
108
+			// account for WP offsets that aren't valid UTC
109
+			$gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset);
110
+			// although we don't know the TZ abbreviation, we know the UTC offset
111
+			$timezone_string = timezone_name_from_abbr(null, $gmt_offset);
112
+		}
113
+		// better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()...
114
+		$timezone_string = $timezone_string !== false
115
+			? $timezone_string
116
+			: EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset);
117
+		return $timezone_string;
118
+	}
119
+
120
+	/**
121
+	 * Gets the site's GMT offset based on either the timezone string
122
+	 * (in which case teh gmt offset will vary depending on the location's
123
+	 * observance of daylight savings time) or the gmt_offset wp option
124
+	 *
125
+	 * @return int seconds offset
126
+	 */
127
+	public static function get_site_timezone_gmt_offset()
128
+	{
129
+		$timezone_string = get_option('timezone_string');
130
+		if ($timezone_string) {
131
+			try {
132
+				$timezone = new DateTimeZone($timezone_string);
133
+				return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC
134
+			} catch (Exception $e) {
135
+			}
136
+		}
137
+		$offset = get_option('gmt_offset');
138
+		return (int)($offset * HOUR_IN_SECONDS);
139
+	}
140
+
141
+
142
+	/**
143
+	 * _create_timezone_object_from_timezone_name
144
+	 *
145
+	 * @access public
146
+	 * @param int $gmt_offset
147
+	 * @return int
148
+	 */
149
+	public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
150
+	{
151
+		//make sure $gmt_offset is int
152
+		$gmt_offset = (int)$gmt_offset;
153
+		switch ($gmt_offset) {
154
+
155
+			//			case -30600 :
156
+			//				$gmt_offset = -28800;
157
+			//				break;
158
+
159
+			case -27000 :
160
+				$gmt_offset = -25200;
161
+				break;
162
+
163
+			case -23400 :
164
+				$gmt_offset = -21600;
165
+				break;
166
+
167
+			case -19800 :
168
+				$gmt_offset = -18000;
169
+				break;
170
+
171
+			case -9000 :
172
+				$gmt_offset = -7200;
173
+				break;
174
+
175
+			case -5400 :
176
+				$gmt_offset = -3600;
177
+				break;
178
+
179
+			case -1800 :
180
+				$gmt_offset = 0;
181
+				break;
182
+
183
+			case 1800 :
184
+				$gmt_offset = 3600;
185
+				break;
186
+
187
+			case 49500 :
188
+				$gmt_offset = 50400;
189
+				break;
190
+
191
+		}
192
+		return $gmt_offset;
193
+	}
194
+
195
+
196
+	/**
197
+	 * get_timezone_string_from_abbreviations_list
198
+	 *
199
+	 * @access public
200
+	 * @param int $gmt_offset
201
+	 * @return string
202
+	 * @throws \EE_Error
203
+	 */
204
+	public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0)
205
+	{
206
+		$abbreviations = timezone_abbreviations_list();
207
+		foreach ($abbreviations as $abbreviation) {
208
+			foreach ($abbreviation as $city) {
209
+				if ($city['offset'] === $gmt_offset && $city['dst'] === false) {
210
+					// check if the timezone is valid but don't throw any errors if it isn't
211
+					if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) {
212
+						return $city['timezone_id'];
213
+					}
214
+				}
215
+			}
216
+		}
217
+		throw new EE_Error(
218
+			sprintf(
219
+				__('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
220
+					'event_espresso'),
221
+				$gmt_offset,
222
+				'<a href="http://www.php.net/manual/en/timezones.php">',
223
+				'</a>'
224
+			)
225
+		);
226
+	}
227
+
228
+
229
+	/**
230
+	 * @access public
231
+	 * @param string $timezone_string
232
+	 */
233
+	public static function timezone_select_input($timezone_string = '')
234
+	{
235
+		// get WP date time format
236
+		$datetime_format = get_option('date_format') . ' ' . get_option('time_format');
237
+		// if passed a value, then use that, else get WP option
238
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
239
+		// check if the timezone is valid but don't throw any errors if it isn't
240
+		$timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false);
241
+		$gmt_offset      = get_option('gmt_offset');
242
+
243
+		$check_zone_info = true;
244
+		if (empty($timezone_string)) {
245
+			// Create a UTC+- zone if no timezone string exists
246
+			$check_zone_info = false;
247
+			if ($gmt_offset > 0) {
248
+				$timezone_string = 'UTC+' . $gmt_offset;
249
+			} elseif ($gmt_offset < 0) {
250
+				$timezone_string = 'UTC' . $gmt_offset;
251
+			} else {
252
+				$timezone_string = 'UTC';
253
+			}
254
+		}
255
+		?>
256 256
 
257 257
         <p>
258 258
             <label for="timezone_string"><?php _e('timezone'); ?></label>
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 
266 266
         <p>
267 267
         <span><?php
268
-            printf(
269
-                __('%1$sUTC%2$s time is %3$s'),
270
-                '<abbr title="Coordinated Universal Time">',
271
-                '</abbr>',
272
-                '<code>' . date_i18n($datetime_format, false, true) . '</code>'
273
-            );
274
-            ?></span>
268
+			printf(
269
+				__('%1$sUTC%2$s time is %3$s'),
270
+				'<abbr title="Coordinated Universal Time">',
271
+				'</abbr>',
272
+				'<code>' . date_i18n($datetime_format, false, true) . '</code>'
273
+			);
274
+			?></span>
275 275
         <?php if (! empty($timezone_string) || ! empty($gmt_offset)) : ?>
276 276
         <br/><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n($datetime_format) . '</code>'); ?></span>
277 277
     <?php endif; ?>
@@ -280,687 +280,687 @@  discard block
 block discarded – undo
280 280
         <br/>
281 281
         <span>
282 282
 					<?php
283
-                    // Set TZ so localtime works.
284
-                    date_default_timezone_set($timezone_string);
285
-                    $now = localtime(time(), true);
286
-                    if ($now['tm_isdst']) {
287
-                        _e('This timezone is currently in daylight saving time.');
288
-                    } else {
289
-                        _e('This timezone is currently in standard time.');
290
-                    }
291
-                    ?>
283
+					// Set TZ so localtime works.
284
+					date_default_timezone_set($timezone_string);
285
+					$now = localtime(time(), true);
286
+					if ($now['tm_isdst']) {
287
+						_e('This timezone is currently in daylight saving time.');
288
+					} else {
289
+						_e('This timezone is currently in standard time.');
290
+					}
291
+					?>
292 292
             <br/>
293 293
             <?php
294
-            if (function_exists('timezone_transitions_get')) {
295
-                $found                   = false;
296
-                $date_time_zone_selected = new DateTimeZone($timezone_string);
297
-                $tz_offset               = timezone_offset_get($date_time_zone_selected, date_create());
298
-                $right_now               = time();
299
-                $tr['isdst']             = false;
300
-                foreach (timezone_transitions_get($date_time_zone_selected) as $tr) {
301
-                    if ($tr['ts'] > $right_now) {
302
-                        $found = true;
303
-                        break;
304
-                    }
305
-                }
306
-
307
-                if ($found) {
308
-                    $message = $tr['isdst'] ?
309
-                        __(' Daylight saving time begins on: %s.') :
310
-                        __(' Standard time begins  on: %s.');
311
-                    // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
312
-                    printf($message,
313
-                        '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >');
314
-                } else {
315
-                    _e('This timezone does not observe daylight saving time.');
316
-                }
317
-            }
318
-            // Set back to UTC.
319
-            date_default_timezone_set('UTC');
320
-            ?>
294
+			if (function_exists('timezone_transitions_get')) {
295
+				$found                   = false;
296
+				$date_time_zone_selected = new DateTimeZone($timezone_string);
297
+				$tz_offset               = timezone_offset_get($date_time_zone_selected, date_create());
298
+				$right_now               = time();
299
+				$tr['isdst']             = false;
300
+				foreach (timezone_transitions_get($date_time_zone_selected) as $tr) {
301
+					if ($tr['ts'] > $right_now) {
302
+						$found = true;
303
+						break;
304
+					}
305
+				}
306
+
307
+				if ($found) {
308
+					$message = $tr['isdst'] ?
309
+						__(' Daylight saving time begins on: %s.') :
310
+						__(' Standard time begins  on: %s.');
311
+					// Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
312
+					printf($message,
313
+						'<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >');
314
+				} else {
315
+					_e('This timezone does not observe daylight saving time.');
316
+				}
317
+			}
318
+			// Set back to UTC.
319
+			date_default_timezone_set('UTC');
320
+			?>
321 321
 				</span></p>
322 322
         <?php
323
-    endif;
324
-    }
325
-
326
-
327
-    /**
328
-     * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
329
-     * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
330
-     * the site is used.
331
-     * This is used typically when using a Unix timestamp any core WP functions that expect their specially
332
-     * computed timestamp (i.e. date_i18n() )
333
-     *
334
-     * @param int    $unix_timestamp                  if 0, then time() will be used.
335
-     * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
336
-     *                                                site will be used.
337
-     * @return int      $unix_timestamp with the offset applied for the given timezone.
338
-     */
339
-    public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
340
-    {
341
-        $unix_timestamp  = $unix_timestamp === 0 ? time() : (int)$unix_timestamp;
342
-        $timezone_string = self::get_valid_timezone_string($timezone_string);
343
-        $TimeZone        = new DateTimeZone($timezone_string);
344
-
345
-        $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone);
346
-        $offset   = timezone_offset_get($TimeZone, $DateTime);
347
-        return (int)$DateTime->format('U') + (int)$offset;
348
-    }
349
-
350
-
351
-    /**
352
-     *    _set_date_time_field
353
-     *    modifies EE_Base_Class EE_Datetime_Field objects
354
-     *
355
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
356
-     * @param    DateTime    $DateTime            PHP DateTime object
357
-     * @param  string        $datetime_field_name the datetime fieldname to be manipulated
358
-     * @return    EE_Base_Class
359
-     */
360
-    protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
361
-    {
362
-        // grab current datetime format
363
-        $current_format = $obj->get_format();
364
-        // set new full timestamp format
365
-        $obj->set_date_format(EE_Datetime_Field::mysql_date_format);
366
-        $obj->set_time_format(EE_Datetime_Field::mysql_time_format);
367
-        // set the new date value using a full timestamp format so that no data is lost
368
-        $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
369
-        // reset datetime formats
370
-        $obj->set_date_format($current_format[0]);
371
-        $obj->set_time_format($current_format[1]);
372
-        return $obj;
373
-    }
374
-
375
-
376
-    /**
377
-     *    date_time_add
378
-     *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
379
-     *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
380
-     *
381
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
382
-     * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
383
-     * @param  string        $period              what you are adding. The options are (years, months, days, hours,
384
-     *                                            minutes, seconds) defaults to years
385
-     * @param  integer       $value               what you want to increment the time by
386
-     * @return EE_Base_Class           return the EE_Base_Class object so right away you can do something with it
387
-     *                                 (chaining)
388
-     */
389
-    public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
390
-    {
391
-        //get the raw UTC date.
392
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
393
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
394
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
395
-    }
396
-
397
-
398
-    /**
399
-     *    date_time_subtract
400
-     *    same as date_time_add except subtracting value instead of adding.
401
-     *
402
-     * @param \EE_Base_Class $obj
403
-     * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
404
-     * @param string         $period
405
-     * @param int            $value
406
-     * @return \EE_Base_Class
407
-     */
408
-    public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
409
-    {
410
-        //get the raw UTC date
411
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
412
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
413
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
414
-    }
415
-
416
-
417
-    /**
418
-     * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
419
-     *
420
-     * @param  DateTime $DateTime DateTime object
421
-     * @param  string   $period   a value to indicate what interval is being used in the calculation. The options are
422
-     *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
423
-     * @param  integer  $value    What you want to increment the date by
424
-     * @param  string   $operand  What operand you wish to use for the calculation
425
-     * @return \DateTime return whatever type came in.
426
-     * @throws \EE_Error
427
-     */
428
-    protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
429
-    {
430
-        if (! $DateTime instanceof DateTime) {
431
-            throw new EE_Error(
432
-                sprintf(
433
-                    __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
434
-                    print_r($DateTime, true)
435
-                )
436
-            );
437
-        }
438
-        switch ($period) {
439
-            case 'years' :
440
-                $value = 'P' . $value . 'Y';
441
-                break;
442
-            case 'months' :
443
-                $value = 'P' . $value . 'M';
444
-                break;
445
-            case 'weeks' :
446
-                $value = 'P' . $value . 'W';
447
-                break;
448
-            case 'days' :
449
-                $value = 'P' . $value . 'D';
450
-                break;
451
-            case 'hours' :
452
-                $value = 'PT' . $value . 'H';
453
-                break;
454
-            case 'minutes' :
455
-                $value = 'PT' . $value . 'M';
456
-                break;
457
-            case 'seconds' :
458
-                $value = 'PT' . $value . 'S';
459
-                break;
460
-        }
461
-        switch ($operand) {
462
-            case '+':
463
-                $DateTime->add(new DateInterval($value));
464
-                break;
465
-            case '-':
466
-                $DateTime->sub(new DateInterval($value));
467
-                break;
468
-        }
469
-        return $DateTime;
470
-    }
471
-
472
-
473
-    /**
474
-     * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
475
-     *
476
-     * @param  int     $timestamp Unix timestamp
477
-     * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
478
-     *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
479
-     * @param  integer $value     What you want to increment the date by
480
-     * @param  string  $operand   What operand you wish to use for the calculation
481
-     * @return \DateTime return whatever type came in.
482
-     * @throws \EE_Error
483
-     */
484
-    protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
485
-    {
486
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
487
-            throw new EE_Error(
488
-                sprintf(
489
-                    __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
490
-                    print_r($timestamp, true)
491
-                )
492
-            );
493
-        }
494
-        switch ($period) {
495
-            case 'years' :
496
-                $value = YEAR_IN_SECONDS * $value;
497
-                break;
498
-            case 'months' :
499
-                $value = YEAR_IN_SECONDS / 12 * $value;
500
-                break;
501
-            case 'weeks' :
502
-                $value = WEEK_IN_SECONDS * $value;
503
-                break;
504
-            case 'days' :
505
-                $value = DAY_IN_SECONDS * $value;
506
-                break;
507
-            case 'hours' :
508
-                $value = HOUR_IN_SECONDS * $value;
509
-                break;
510
-            case 'minutes' :
511
-                $value = MINUTE_IN_SECONDS * $value;
512
-                break;
513
-        }
514
-        switch ($operand) {
515
-            case '+':
516
-                $timestamp += $value;
517
-                break;
518
-            case '-':
519
-                $timestamp -= $value;
520
-                break;
521
-        }
522
-        return $timestamp;
523
-    }
524
-
525
-
526
-    /**
527
-     * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
528
-     * parameters and returns the new timestamp or DateTime.
529
-     *
530
-     * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
531
-     * @param  string         $period                a value to indicate what interval is being used in the
532
-     *                                               calculation. The options are 'years', 'months', 'days', 'hours',
533
-     *                                               'minutes', 'seconds'. Defaults to years.
534
-     * @param  integer        $value                 What you want to increment the date by
535
-     * @param  string         $operand               What operand you wish to use for the calculation
536
-     * @return mixed string|DateTime          return whatever type came in.
537
-     */
538
-    public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
539
-    {
540
-        if ($DateTime_or_timestamp instanceof DateTime) {
541
-            return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand);
542
-        } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
543
-            return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand);
544
-        } else {
545
-            //error
546
-            return $DateTime_or_timestamp;
547
-        }
548
-    }
549
-
550
-
551
-    /**
552
-     * The purpose of this helper method is to receive an incoming format string in php date/time format
553
-     * and spit out the js and moment.js equivalent formats.
554
-     * Note, if no format string is given, then it is assumed the user wants what is set for WP.
555
-     * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
556
-     * time picker.
557
-     *
558
-     * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
559
-     * @param null $date_format_string
560
-     * @param null $time_format_string
561
-     * @return array
562
-     *                array(
563
-     *                'js' => array (
564
-     *                'date' => //date format
565
-     *                'time' => //time format
566
-     *                ),
567
-     *                'moment' => //date and time format.
568
-     *                )
569
-     */
570
-    public static function convert_php_to_js_and_moment_date_formats(
571
-        $date_format_string = null,
572
-        $time_format_string = null
573
-    ) {
574
-        if ($date_format_string === null) {
575
-            $date_format_string = get_option('date_format');
576
-        }
577
-
578
-        if ($time_format_string === null) {
579
-            $time_format_string = get_option('time_format');
580
-        }
581
-
582
-        $date_format = self::_php_to_js_moment_converter($date_format_string);
583
-        $time_format = self::_php_to_js_moment_converter($time_format_string);
584
-
585
-        return array(
586
-            'js'     => array(
587
-                'date' => $date_format['js'],
588
-                'time' => $time_format['js'],
589
-            ),
590
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
591
-        );
592
-    }
593
-
594
-
595
-    /**
596
-     * This converts incoming format string into js and moment variations.
597
-     *
598
-     * @param string $format_string incoming php format string
599
-     * @return array js and moment formats.
600
-     */
601
-    protected static function _php_to_js_moment_converter($format_string)
602
-    {
603
-        /**
604
-         * This is a map of symbols for formats.
605
-         * The index is the php symbol, the equivalent values are in the array.
606
-         *
607
-         * @var array
608
-         */
609
-        $symbols_map      = array(
610
-            // Day
611
-            //01
612
-            'd' => array(
613
-                'js'     => 'dd',
614
-                'moment' => 'DD',
615
-            ),
616
-            //Mon
617
-            'D' => array(
618
-                'js'     => 'D',
619
-                'moment' => 'ddd',
620
-            ),
621
-            //1,2,...31
622
-            'j' => array(
623
-                'js'     => 'd',
624
-                'moment' => 'D',
625
-            ),
626
-            //Monday
627
-            'l' => array(
628
-                'js'     => 'DD',
629
-                'moment' => 'dddd',
630
-            ),
631
-            //ISO numeric representation of the day of the week (1-6)
632
-            'N' => array(
633
-                'js'     => '',
634
-                'moment' => 'E',
635
-            ),
636
-            //st,nd.rd
637
-            'S' => array(
638
-                'js'     => '',
639
-                'moment' => 'o',
640
-            ),
641
-            //numeric representation of day of week (0-6)
642
-            'w' => array(
643
-                'js'     => '',
644
-                'moment' => 'd',
645
-            ),
646
-            //day of year starting from 0 (0-365)
647
-            'z' => array(
648
-                'js'     => 'o',
649
-                'moment' => 'DDD' //note moment does not start with 0 so will need to modify by subtracting 1
650
-            ),
651
-            // Week
652
-            //ISO-8601 week number of year (weeks starting on monday)
653
-            'W' => array(
654
-                'js'     => '',
655
-                'moment' => 'w',
656
-            ),
657
-            // Month
658
-            // January...December
659
-            'F' => array(
660
-                'js'     => 'MM',
661
-                'moment' => 'MMMM',
662
-            ),
663
-            //01...12
664
-            'm' => array(
665
-                'js'     => 'mm',
666
-                'moment' => 'MM',
667
-            ),
668
-            //Jan...Dec
669
-            'M' => array(
670
-                'js'     => 'M',
671
-                'moment' => 'MMM',
672
-            ),
673
-            //1-12
674
-            'n' => array(
675
-                'js'     => 'm',
676
-                'moment' => 'M',
677
-            ),
678
-            //number of days in given month
679
-            't' => array(
680
-                'js'     => '',
681
-                'moment' => '',
682
-            ),
683
-            // Year
684
-            //whether leap year or not 1/0
685
-            'L' => array(
686
-                'js'     => '',
687
-                'moment' => '',
688
-            ),
689
-            //ISO-8601 year number
690
-            'o' => array(
691
-                'js'     => '',
692
-                'moment' => 'GGGG',
693
-            ),
694
-            //1999...2003
695
-            'Y' => array(
696
-                'js'     => 'yy',
697
-                'moment' => 'YYYY',
698
-            ),
699
-            //99...03
700
-            'y' => array(
701
-                'js'     => 'y',
702
-                'moment' => 'YY',
703
-            ),
704
-            // Time
705
-            // am/pm
706
-            'a' => array(
707
-                'js'     => 'tt',
708
-                'moment' => 'a',
709
-            ),
710
-            // AM/PM
711
-            'A' => array(
712
-                'js'     => 'TT',
713
-                'moment' => 'A',
714
-            ),
715
-            // Swatch Internet Time?!?
716
-            'B' => array(
717
-                'js'     => '',
718
-                'moment' => '',
719
-            ),
720
-            //1...12
721
-            'g' => array(
722
-                'js'     => 'h',
723
-                'moment' => 'h',
724
-            ),
725
-            //0...23
726
-            'G' => array(
727
-                'js'     => 'H',
728
-                'moment' => 'H',
729
-            ),
730
-            //01...12
731
-            'h' => array(
732
-                'js'     => 'hh',
733
-                'moment' => 'hh',
734
-            ),
735
-            //00...23
736
-            'H' => array(
737
-                'js'     => 'HH',
738
-                'moment' => 'HH',
739
-            ),
740
-            //00..59
741
-            'i' => array(
742
-                'js'     => 'mm',
743
-                'moment' => 'mm',
744
-            ),
745
-            //seconds... 00...59
746
-            's' => array(
747
-                'js'     => 'ss',
748
-                'moment' => 'ss',
749
-            ),
750
-            //microseconds
751
-            'u' => array(
752
-                'js'     => '',
753
-                'moment' => '',
754
-            ),
755
-        );
756
-        $jquery_ui_format = "";
757
-        $moment_format    = "";
758
-        $escaping         = false;
759
-        for ($i = 0; $i < strlen($format_string); $i++) {
760
-            $char = $format_string[$i];
761
-            if ($char === '\\') { // PHP date format escaping character
762
-                $i++;
763
-                if ($escaping) {
764
-                    $jquery_ui_format .= $format_string[$i];
765
-                    $moment_format .= $format_string[$i];
766
-                } else {
767
-                    $jquery_ui_format .= '\'' . $format_string[$i];
768
-                    $moment_format .= $format_string[$i];
769
-                }
770
-                $escaping = true;
771
-            } else {
772
-                if ($escaping) {
773
-                    $jquery_ui_format .= "'";
774
-                    $moment_format .= "'";
775
-                    $escaping = false;
776
-                }
777
-                if (isset($symbols_map[$char])) {
778
-                    $jquery_ui_format .= $symbols_map[$char]['js'];
779
-                    $moment_format .= $symbols_map[$char]['moment'];
780
-                } else {
781
-                    $jquery_ui_format .= $char;
782
-                    $moment_format .= $char;
783
-                }
784
-            }
785
-        }
786
-        return array('js' => $jquery_ui_format, 'moment' => $moment_format);
787
-    }
788
-
789
-
790
-    /**
791
-     * This takes an incoming format string and validates it to ensure it will work fine with PHP.
792
-     *
793
-     * @param string $format_string   Incoming format string for php date().
794
-     * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
795
-     *                                errors is returned.  So for client code calling, check for is_array() to
796
-     *                                indicate failed validations.
797
-     */
798
-    public static function validate_format_string($format_string)
799
-    {
800
-        $error_msg = array();
801
-        //time format checks
802
-        switch (true) {
803
-            case   strpos($format_string, 'h') !== false  :
804
-            case   strpos($format_string, 'g') !== false :
805
-                /**
806
-                 * if the time string has a lowercase 'h' which == 12 hour time format and there
807
-                 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
808
-                 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
809
-                 */
810
-                if (strpos(strtoupper($format_string), 'A') === false) {
811
-                    $error_msg[] = __('There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
812
-                        'event_espresso');
813
-                }
814
-                break;
815
-
816
-        }
817
-
818
-        return empty($error_msg) ? true : $error_msg;
819
-    }
820
-
821
-
822
-    /**
823
-     *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
824
-     *     very next day then this method will return true.
825
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
826
-     *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
827
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
828
-     *
829
-     * @param mixed $date_1
830
-     * @param mixed $date_2
831
-     * @return bool
832
-     */
833
-    public static function dates_represent_one_24_hour_date($date_1, $date_2)
834
-    {
835
-
836
-        if (
837
-            (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) ||
838
-            ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00')
839
-        ) {
840
-            return false;
841
-        }
842
-        return $date_2->format('U') - $date_1->format('U') == 86400 ? true : false;
843
-    }
844
-
845
-
846
-    /**
847
-     * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
848
-     * Functions.
849
-     *
850
-     * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
851
-     * @param string $field_for_interval The Database field that is the interval is applied to in the query.
852
-     * @return string
853
-     */
854
-    public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
855
-    {
856
-        try {
857
-            /** need to account for timezone offset on the selects */
858
-            $DateTimeZone = new DateTimeZone($timezone_string);
859
-        } catch (Exception $e) {
860
-            $DateTimeZone = null;
861
-        }
862
-
863
-        /**
864
-         * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
865
-         * Hence we do the calc for DateTimeZone::getOffset.
866
-         */
867
-        $offset         = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset');
868
-        $query_interval = $offset < 0
869
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
870
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
871
-        return $query_interval;
872
-    }
873
-
874
-    /**
875
-     * Retrieves the site's default timezone and returns it formatted so it's ready for display
876
-     * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
877
-     * and 'gmt_offset' WordPress options directly; or use the filter
878
-     * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
879
-     * (although note that we remove any HTML that may be added)
880
-     *
881
-     * @return string
882
-     */
883
-    public static function get_timezone_string_for_display()
884
-    {
885
-        $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
886
-        if (! empty($pretty_timezone)) {
887
-            return esc_html($pretty_timezone);
888
-        }
889
-        $timezone_string = get_option('timezone_string');
890
-        if ($timezone_string) {
891
-            static $mo_loaded = false;
892
-            // Load translations for continents and cities just like wp_timezone_choice does
893
-            if (! $mo_loaded) {
894
-                $locale = get_locale();
895
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
896
-                load_textdomain('continents-cities', $mofile);
897
-                $mo_loaded = true;
898
-            }
899
-            //well that was easy.
900
-            $parts = explode('/', $timezone_string);
901
-            //remove the continent
902
-            unset($parts[0]);
903
-            $t_parts = array();
904
-            foreach ($parts as $part) {
905
-                $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
906
-            }
907
-            return implode(' - ', $t_parts);
908
-        }
909
-        //they haven't set the timezone string, so let's return a string like "UTC+1"
910
-        $gmt_offset = get_option('gmt_offset');
911
-        if (intval($gmt_offset) >= 0) {
912
-            $prefix = '+';
913
-        } else {
914
-            $prefix = '';
915
-        }
916
-        $parts = explode('.', (string)$gmt_offset);
917
-        if (count($parts) === 1) {
918
-            $parts[1] = '00';
919
-        } else {
920
-            //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
921
-            //to minutes, eg 30 or 15, respectively
922
-            $hour_fraction = (float)('0.' . $parts[1]);
923
-            $parts[1]      = (string)$hour_fraction * 60;
924
-        }
925
-        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
926
-    }
927
-
928
-
929
-
930
-    /**
931
-     * So PHP does this awesome thing where if you are trying to get a timestamp
932
-     * for a month using a string like "February" or "February 2017",
933
-     * and you don't specify a day as part of your string,
934
-     * then PHP will use whatever the current day of the month is.
935
-     * IF the current day of the month happens to be the 30th or 31st,
936
-     * then PHP gets really confused by a date like February 30,
937
-     * so instead of saying
938
-     *      "Hey February only has 28 days (this year)...
939
-     *      ...you must have meant the last day of the month!"
940
-     * PHP does the next most logical thing, and bumps the date up to March 2nd,
941
-     * because someone requesting February 30th obviously meant March 1st!
942
-     * The way around this is to always set the day to the first,
943
-     * so that the month will stay on the month you wanted.
944
-     * this method will add that "1" into your date regardless of the format.
945
-     *
946
-     * @param string $month
947
-     * @return string
948
-     */
949
-    public static function first_of_month_timestamp($month = '')
950
-    {
951
-        $month = (string)$month;
952
-        $year = '';
953
-        // check if the incoming string has a year in it or not
954
-       if (preg_match('/\b\d{4}\b/', $month, $matches)) {
955
-           $year = $matches[0];
956
-           // ten remove that from the month string as well as any spaces
957
-           $month = trim(str_replace($year, '', $month));
958
-           // add a space before the year
959
-           $year = " {$year}";
960
-        }
961
-        // return timestamp for something like "February 1 2017"
962
-        return strtotime("{$month} 1{$year}");
963
-    }
323
+	endif;
324
+	}
325
+
326
+
327
+	/**
328
+	 * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
329
+	 * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
330
+	 * the site is used.
331
+	 * This is used typically when using a Unix timestamp any core WP functions that expect their specially
332
+	 * computed timestamp (i.e. date_i18n() )
333
+	 *
334
+	 * @param int    $unix_timestamp                  if 0, then time() will be used.
335
+	 * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
336
+	 *                                                site will be used.
337
+	 * @return int      $unix_timestamp with the offset applied for the given timezone.
338
+	 */
339
+	public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
340
+	{
341
+		$unix_timestamp  = $unix_timestamp === 0 ? time() : (int)$unix_timestamp;
342
+		$timezone_string = self::get_valid_timezone_string($timezone_string);
343
+		$TimeZone        = new DateTimeZone($timezone_string);
344
+
345
+		$DateTime = new DateTime('@' . $unix_timestamp, $TimeZone);
346
+		$offset   = timezone_offset_get($TimeZone, $DateTime);
347
+		return (int)$DateTime->format('U') + (int)$offset;
348
+	}
349
+
350
+
351
+	/**
352
+	 *    _set_date_time_field
353
+	 *    modifies EE_Base_Class EE_Datetime_Field objects
354
+	 *
355
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
356
+	 * @param    DateTime    $DateTime            PHP DateTime object
357
+	 * @param  string        $datetime_field_name the datetime fieldname to be manipulated
358
+	 * @return    EE_Base_Class
359
+	 */
360
+	protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
361
+	{
362
+		// grab current datetime format
363
+		$current_format = $obj->get_format();
364
+		// set new full timestamp format
365
+		$obj->set_date_format(EE_Datetime_Field::mysql_date_format);
366
+		$obj->set_time_format(EE_Datetime_Field::mysql_time_format);
367
+		// set the new date value using a full timestamp format so that no data is lost
368
+		$obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
369
+		// reset datetime formats
370
+		$obj->set_date_format($current_format[0]);
371
+		$obj->set_time_format($current_format[1]);
372
+		return $obj;
373
+	}
374
+
375
+
376
+	/**
377
+	 *    date_time_add
378
+	 *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
379
+	 *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
380
+	 *
381
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
382
+	 * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
383
+	 * @param  string        $period              what you are adding. The options are (years, months, days, hours,
384
+	 *                                            minutes, seconds) defaults to years
385
+	 * @param  integer       $value               what you want to increment the time by
386
+	 * @return EE_Base_Class           return the EE_Base_Class object so right away you can do something with it
387
+	 *                                 (chaining)
388
+	 */
389
+	public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
390
+	{
391
+		//get the raw UTC date.
392
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
393
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
394
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
395
+	}
396
+
397
+
398
+	/**
399
+	 *    date_time_subtract
400
+	 *    same as date_time_add except subtracting value instead of adding.
401
+	 *
402
+	 * @param \EE_Base_Class $obj
403
+	 * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
404
+	 * @param string         $period
405
+	 * @param int            $value
406
+	 * @return \EE_Base_Class
407
+	 */
408
+	public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
409
+	{
410
+		//get the raw UTC date
411
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
412
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
413
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
414
+	}
415
+
416
+
417
+	/**
418
+	 * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
419
+	 *
420
+	 * @param  DateTime $DateTime DateTime object
421
+	 * @param  string   $period   a value to indicate what interval is being used in the calculation. The options are
422
+	 *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
423
+	 * @param  integer  $value    What you want to increment the date by
424
+	 * @param  string   $operand  What operand you wish to use for the calculation
425
+	 * @return \DateTime return whatever type came in.
426
+	 * @throws \EE_Error
427
+	 */
428
+	protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
429
+	{
430
+		if (! $DateTime instanceof DateTime) {
431
+			throw new EE_Error(
432
+				sprintf(
433
+					__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
434
+					print_r($DateTime, true)
435
+				)
436
+			);
437
+		}
438
+		switch ($period) {
439
+			case 'years' :
440
+				$value = 'P' . $value . 'Y';
441
+				break;
442
+			case 'months' :
443
+				$value = 'P' . $value . 'M';
444
+				break;
445
+			case 'weeks' :
446
+				$value = 'P' . $value . 'W';
447
+				break;
448
+			case 'days' :
449
+				$value = 'P' . $value . 'D';
450
+				break;
451
+			case 'hours' :
452
+				$value = 'PT' . $value . 'H';
453
+				break;
454
+			case 'minutes' :
455
+				$value = 'PT' . $value . 'M';
456
+				break;
457
+			case 'seconds' :
458
+				$value = 'PT' . $value . 'S';
459
+				break;
460
+		}
461
+		switch ($operand) {
462
+			case '+':
463
+				$DateTime->add(new DateInterval($value));
464
+				break;
465
+			case '-':
466
+				$DateTime->sub(new DateInterval($value));
467
+				break;
468
+		}
469
+		return $DateTime;
470
+	}
471
+
472
+
473
+	/**
474
+	 * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
475
+	 *
476
+	 * @param  int     $timestamp Unix timestamp
477
+	 * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
478
+	 *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
479
+	 * @param  integer $value     What you want to increment the date by
480
+	 * @param  string  $operand   What operand you wish to use for the calculation
481
+	 * @return \DateTime return whatever type came in.
482
+	 * @throws \EE_Error
483
+	 */
484
+	protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
485
+	{
486
+		if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
487
+			throw new EE_Error(
488
+				sprintf(
489
+					__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
490
+					print_r($timestamp, true)
491
+				)
492
+			);
493
+		}
494
+		switch ($period) {
495
+			case 'years' :
496
+				$value = YEAR_IN_SECONDS * $value;
497
+				break;
498
+			case 'months' :
499
+				$value = YEAR_IN_SECONDS / 12 * $value;
500
+				break;
501
+			case 'weeks' :
502
+				$value = WEEK_IN_SECONDS * $value;
503
+				break;
504
+			case 'days' :
505
+				$value = DAY_IN_SECONDS * $value;
506
+				break;
507
+			case 'hours' :
508
+				$value = HOUR_IN_SECONDS * $value;
509
+				break;
510
+			case 'minutes' :
511
+				$value = MINUTE_IN_SECONDS * $value;
512
+				break;
513
+		}
514
+		switch ($operand) {
515
+			case '+':
516
+				$timestamp += $value;
517
+				break;
518
+			case '-':
519
+				$timestamp -= $value;
520
+				break;
521
+		}
522
+		return $timestamp;
523
+	}
524
+
525
+
526
+	/**
527
+	 * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
528
+	 * parameters and returns the new timestamp or DateTime.
529
+	 *
530
+	 * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
531
+	 * @param  string         $period                a value to indicate what interval is being used in the
532
+	 *                                               calculation. The options are 'years', 'months', 'days', 'hours',
533
+	 *                                               'minutes', 'seconds'. Defaults to years.
534
+	 * @param  integer        $value                 What you want to increment the date by
535
+	 * @param  string         $operand               What operand you wish to use for the calculation
536
+	 * @return mixed string|DateTime          return whatever type came in.
537
+	 */
538
+	public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
539
+	{
540
+		if ($DateTime_or_timestamp instanceof DateTime) {
541
+			return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand);
542
+		} else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
543
+			return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand);
544
+		} else {
545
+			//error
546
+			return $DateTime_or_timestamp;
547
+		}
548
+	}
549
+
550
+
551
+	/**
552
+	 * The purpose of this helper method is to receive an incoming format string in php date/time format
553
+	 * and spit out the js and moment.js equivalent formats.
554
+	 * Note, if no format string is given, then it is assumed the user wants what is set for WP.
555
+	 * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
556
+	 * time picker.
557
+	 *
558
+	 * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
559
+	 * @param null $date_format_string
560
+	 * @param null $time_format_string
561
+	 * @return array
562
+	 *                array(
563
+	 *                'js' => array (
564
+	 *                'date' => //date format
565
+	 *                'time' => //time format
566
+	 *                ),
567
+	 *                'moment' => //date and time format.
568
+	 *                )
569
+	 */
570
+	public static function convert_php_to_js_and_moment_date_formats(
571
+		$date_format_string = null,
572
+		$time_format_string = null
573
+	) {
574
+		if ($date_format_string === null) {
575
+			$date_format_string = get_option('date_format');
576
+		}
577
+
578
+		if ($time_format_string === null) {
579
+			$time_format_string = get_option('time_format');
580
+		}
581
+
582
+		$date_format = self::_php_to_js_moment_converter($date_format_string);
583
+		$time_format = self::_php_to_js_moment_converter($time_format_string);
584
+
585
+		return array(
586
+			'js'     => array(
587
+				'date' => $date_format['js'],
588
+				'time' => $time_format['js'],
589
+			),
590
+			'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
591
+		);
592
+	}
593
+
594
+
595
+	/**
596
+	 * This converts incoming format string into js and moment variations.
597
+	 *
598
+	 * @param string $format_string incoming php format string
599
+	 * @return array js and moment formats.
600
+	 */
601
+	protected static function _php_to_js_moment_converter($format_string)
602
+	{
603
+		/**
604
+		 * This is a map of symbols for formats.
605
+		 * The index is the php symbol, the equivalent values are in the array.
606
+		 *
607
+		 * @var array
608
+		 */
609
+		$symbols_map      = array(
610
+			// Day
611
+			//01
612
+			'd' => array(
613
+				'js'     => 'dd',
614
+				'moment' => 'DD',
615
+			),
616
+			//Mon
617
+			'D' => array(
618
+				'js'     => 'D',
619
+				'moment' => 'ddd',
620
+			),
621
+			//1,2,...31
622
+			'j' => array(
623
+				'js'     => 'd',
624
+				'moment' => 'D',
625
+			),
626
+			//Monday
627
+			'l' => array(
628
+				'js'     => 'DD',
629
+				'moment' => 'dddd',
630
+			),
631
+			//ISO numeric representation of the day of the week (1-6)
632
+			'N' => array(
633
+				'js'     => '',
634
+				'moment' => 'E',
635
+			),
636
+			//st,nd.rd
637
+			'S' => array(
638
+				'js'     => '',
639
+				'moment' => 'o',
640
+			),
641
+			//numeric representation of day of week (0-6)
642
+			'w' => array(
643
+				'js'     => '',
644
+				'moment' => 'd',
645
+			),
646
+			//day of year starting from 0 (0-365)
647
+			'z' => array(
648
+				'js'     => 'o',
649
+				'moment' => 'DDD' //note moment does not start with 0 so will need to modify by subtracting 1
650
+			),
651
+			// Week
652
+			//ISO-8601 week number of year (weeks starting on monday)
653
+			'W' => array(
654
+				'js'     => '',
655
+				'moment' => 'w',
656
+			),
657
+			// Month
658
+			// January...December
659
+			'F' => array(
660
+				'js'     => 'MM',
661
+				'moment' => 'MMMM',
662
+			),
663
+			//01...12
664
+			'm' => array(
665
+				'js'     => 'mm',
666
+				'moment' => 'MM',
667
+			),
668
+			//Jan...Dec
669
+			'M' => array(
670
+				'js'     => 'M',
671
+				'moment' => 'MMM',
672
+			),
673
+			//1-12
674
+			'n' => array(
675
+				'js'     => 'm',
676
+				'moment' => 'M',
677
+			),
678
+			//number of days in given month
679
+			't' => array(
680
+				'js'     => '',
681
+				'moment' => '',
682
+			),
683
+			// Year
684
+			//whether leap year or not 1/0
685
+			'L' => array(
686
+				'js'     => '',
687
+				'moment' => '',
688
+			),
689
+			//ISO-8601 year number
690
+			'o' => array(
691
+				'js'     => '',
692
+				'moment' => 'GGGG',
693
+			),
694
+			//1999...2003
695
+			'Y' => array(
696
+				'js'     => 'yy',
697
+				'moment' => 'YYYY',
698
+			),
699
+			//99...03
700
+			'y' => array(
701
+				'js'     => 'y',
702
+				'moment' => 'YY',
703
+			),
704
+			// Time
705
+			// am/pm
706
+			'a' => array(
707
+				'js'     => 'tt',
708
+				'moment' => 'a',
709
+			),
710
+			// AM/PM
711
+			'A' => array(
712
+				'js'     => 'TT',
713
+				'moment' => 'A',
714
+			),
715
+			// Swatch Internet Time?!?
716
+			'B' => array(
717
+				'js'     => '',
718
+				'moment' => '',
719
+			),
720
+			//1...12
721
+			'g' => array(
722
+				'js'     => 'h',
723
+				'moment' => 'h',
724
+			),
725
+			//0...23
726
+			'G' => array(
727
+				'js'     => 'H',
728
+				'moment' => 'H',
729
+			),
730
+			//01...12
731
+			'h' => array(
732
+				'js'     => 'hh',
733
+				'moment' => 'hh',
734
+			),
735
+			//00...23
736
+			'H' => array(
737
+				'js'     => 'HH',
738
+				'moment' => 'HH',
739
+			),
740
+			//00..59
741
+			'i' => array(
742
+				'js'     => 'mm',
743
+				'moment' => 'mm',
744
+			),
745
+			//seconds... 00...59
746
+			's' => array(
747
+				'js'     => 'ss',
748
+				'moment' => 'ss',
749
+			),
750
+			//microseconds
751
+			'u' => array(
752
+				'js'     => '',
753
+				'moment' => '',
754
+			),
755
+		);
756
+		$jquery_ui_format = "";
757
+		$moment_format    = "";
758
+		$escaping         = false;
759
+		for ($i = 0; $i < strlen($format_string); $i++) {
760
+			$char = $format_string[$i];
761
+			if ($char === '\\') { // PHP date format escaping character
762
+				$i++;
763
+				if ($escaping) {
764
+					$jquery_ui_format .= $format_string[$i];
765
+					$moment_format .= $format_string[$i];
766
+				} else {
767
+					$jquery_ui_format .= '\'' . $format_string[$i];
768
+					$moment_format .= $format_string[$i];
769
+				}
770
+				$escaping = true;
771
+			} else {
772
+				if ($escaping) {
773
+					$jquery_ui_format .= "'";
774
+					$moment_format .= "'";
775
+					$escaping = false;
776
+				}
777
+				if (isset($symbols_map[$char])) {
778
+					$jquery_ui_format .= $symbols_map[$char]['js'];
779
+					$moment_format .= $symbols_map[$char]['moment'];
780
+				} else {
781
+					$jquery_ui_format .= $char;
782
+					$moment_format .= $char;
783
+				}
784
+			}
785
+		}
786
+		return array('js' => $jquery_ui_format, 'moment' => $moment_format);
787
+	}
788
+
789
+
790
+	/**
791
+	 * This takes an incoming format string and validates it to ensure it will work fine with PHP.
792
+	 *
793
+	 * @param string $format_string   Incoming format string for php date().
794
+	 * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
795
+	 *                                errors is returned.  So for client code calling, check for is_array() to
796
+	 *                                indicate failed validations.
797
+	 */
798
+	public static function validate_format_string($format_string)
799
+	{
800
+		$error_msg = array();
801
+		//time format checks
802
+		switch (true) {
803
+			case   strpos($format_string, 'h') !== false  :
804
+			case   strpos($format_string, 'g') !== false :
805
+				/**
806
+				 * if the time string has a lowercase 'h' which == 12 hour time format and there
807
+				 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
808
+				 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
809
+				 */
810
+				if (strpos(strtoupper($format_string), 'A') === false) {
811
+					$error_msg[] = __('There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
812
+						'event_espresso');
813
+				}
814
+				break;
815
+
816
+		}
817
+
818
+		return empty($error_msg) ? true : $error_msg;
819
+	}
820
+
821
+
822
+	/**
823
+	 *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
824
+	 *     very next day then this method will return true.
825
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
826
+	 *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
827
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
828
+	 *
829
+	 * @param mixed $date_1
830
+	 * @param mixed $date_2
831
+	 * @return bool
832
+	 */
833
+	public static function dates_represent_one_24_hour_date($date_1, $date_2)
834
+	{
835
+
836
+		if (
837
+			(! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) ||
838
+			($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00')
839
+		) {
840
+			return false;
841
+		}
842
+		return $date_2->format('U') - $date_1->format('U') == 86400 ? true : false;
843
+	}
844
+
845
+
846
+	/**
847
+	 * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
848
+	 * Functions.
849
+	 *
850
+	 * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
851
+	 * @param string $field_for_interval The Database field that is the interval is applied to in the query.
852
+	 * @return string
853
+	 */
854
+	public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
855
+	{
856
+		try {
857
+			/** need to account for timezone offset on the selects */
858
+			$DateTimeZone = new DateTimeZone($timezone_string);
859
+		} catch (Exception $e) {
860
+			$DateTimeZone = null;
861
+		}
862
+
863
+		/**
864
+		 * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
865
+		 * Hence we do the calc for DateTimeZone::getOffset.
866
+		 */
867
+		$offset         = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset');
868
+		$query_interval = $offset < 0
869
+			? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
870
+			: 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
871
+		return $query_interval;
872
+	}
873
+
874
+	/**
875
+	 * Retrieves the site's default timezone and returns it formatted so it's ready for display
876
+	 * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
877
+	 * and 'gmt_offset' WordPress options directly; or use the filter
878
+	 * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
879
+	 * (although note that we remove any HTML that may be added)
880
+	 *
881
+	 * @return string
882
+	 */
883
+	public static function get_timezone_string_for_display()
884
+	{
885
+		$pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
886
+		if (! empty($pretty_timezone)) {
887
+			return esc_html($pretty_timezone);
888
+		}
889
+		$timezone_string = get_option('timezone_string');
890
+		if ($timezone_string) {
891
+			static $mo_loaded = false;
892
+			// Load translations for continents and cities just like wp_timezone_choice does
893
+			if (! $mo_loaded) {
894
+				$locale = get_locale();
895
+				$mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
896
+				load_textdomain('continents-cities', $mofile);
897
+				$mo_loaded = true;
898
+			}
899
+			//well that was easy.
900
+			$parts = explode('/', $timezone_string);
901
+			//remove the continent
902
+			unset($parts[0]);
903
+			$t_parts = array();
904
+			foreach ($parts as $part) {
905
+				$t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
906
+			}
907
+			return implode(' - ', $t_parts);
908
+		}
909
+		//they haven't set the timezone string, so let's return a string like "UTC+1"
910
+		$gmt_offset = get_option('gmt_offset');
911
+		if (intval($gmt_offset) >= 0) {
912
+			$prefix = '+';
913
+		} else {
914
+			$prefix = '';
915
+		}
916
+		$parts = explode('.', (string)$gmt_offset);
917
+		if (count($parts) === 1) {
918
+			$parts[1] = '00';
919
+		} else {
920
+			//convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
921
+			//to minutes, eg 30 or 15, respectively
922
+			$hour_fraction = (float)('0.' . $parts[1]);
923
+			$parts[1]      = (string)$hour_fraction * 60;
924
+		}
925
+		return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
926
+	}
927
+
928
+
929
+
930
+	/**
931
+	 * So PHP does this awesome thing where if you are trying to get a timestamp
932
+	 * for a month using a string like "February" or "February 2017",
933
+	 * and you don't specify a day as part of your string,
934
+	 * then PHP will use whatever the current day of the month is.
935
+	 * IF the current day of the month happens to be the 30th or 31st,
936
+	 * then PHP gets really confused by a date like February 30,
937
+	 * so instead of saying
938
+	 *      "Hey February only has 28 days (this year)...
939
+	 *      ...you must have meant the last day of the month!"
940
+	 * PHP does the next most logical thing, and bumps the date up to March 2nd,
941
+	 * because someone requesting February 30th obviously meant March 1st!
942
+	 * The way around this is to always set the day to the first,
943
+	 * so that the month will stay on the month you wanted.
944
+	 * this method will add that "1" into your date regardless of the format.
945
+	 *
946
+	 * @param string $month
947
+	 * @return string
948
+	 */
949
+	public static function first_of_month_timestamp($month = '')
950
+	{
951
+		$month = (string)$month;
952
+		$year = '';
953
+		// check if the incoming string has a year in it or not
954
+	   if (preg_match('/\b\d{4}\b/', $month, $matches)) {
955
+		   $year = $matches[0];
956
+		   // ten remove that from the month string as well as any spaces
957
+		   $month = trim(str_replace($year, '', $month));
958
+		   // add a space before the year
959
+		   $year = " {$year}";
960
+		}
961
+		// return timestamp for something like "February 1 2017"
962
+		return strtotime("{$month} 1{$year}");
963
+	}
964 964
 
965 965
 
966 966
 }// end class EEH_DTT_Helper
967 967
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +38 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             new DateTimeZone($timezone_string);
75 75
         } catch (Exception $e) {
76 76
             // sometimes we take exception to exceptions
77
-            if (! $throw_error) {
77
+            if ( ! $throw_error) {
78 78
                 return false;
79 79
             }
80 80
             throw new EE_Error(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             }
136 136
         }
137 137
         $offset = get_option('gmt_offset');
138
-        return (int)($offset * HOUR_IN_SECONDS);
138
+        return (int) ($offset * HOUR_IN_SECONDS);
139 139
     }
140 140
 
141 141
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
150 150
     {
151 151
         //make sure $gmt_offset is int
152
-        $gmt_offset = (int)$gmt_offset;
152
+        $gmt_offset = (int) $gmt_offset;
153 153
         switch ($gmt_offset) {
154 154
 
155 155
             //			case -30600 :
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     public static function timezone_select_input($timezone_string = '')
234 234
     {
235 235
         // get WP date time format
236
-        $datetime_format = get_option('date_format') . ' ' . get_option('time_format');
236
+        $datetime_format = get_option('date_format').' '.get_option('time_format');
237 237
         // if passed a value, then use that, else get WP option
238 238
         $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
239 239
         // check if the timezone is valid but don't throw any errors if it isn't
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
             // Create a UTC+- zone if no timezone string exists
246 246
             $check_zone_info = false;
247 247
             if ($gmt_offset > 0) {
248
-                $timezone_string = 'UTC+' . $gmt_offset;
248
+                $timezone_string = 'UTC+'.$gmt_offset;
249 249
             } elseif ($gmt_offset < 0) {
250
-                $timezone_string = 'UTC' . $gmt_offset;
250
+                $timezone_string = 'UTC'.$gmt_offset;
251 251
             } else {
252 252
                 $timezone_string = 'UTC';
253 253
             }
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
                 __('%1$sUTC%2$s time is %3$s'),
270 270
                 '<abbr title="Coordinated Universal Time">',
271 271
                 '</abbr>',
272
-                '<code>' . date_i18n($datetime_format, false, true) . '</code>'
272
+                '<code>'.date_i18n($datetime_format, false, true).'</code>'
273 273
             );
274 274
             ?></span>
275
-        <?php if (! empty($timezone_string) || ! empty($gmt_offset)) : ?>
276
-        <br/><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n($datetime_format) . '</code>'); ?></span>
275
+        <?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?>
276
+        <br/><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span>
277 277
     <?php endif; ?>
278 278
 
279 279
         <?php if ($check_zone_info && $timezone_string) : ?>
@@ -306,11 +306,10 @@  discard block
 block discarded – undo
306 306
 
307 307
                 if ($found) {
308 308
                     $message = $tr['isdst'] ?
309
-                        __(' Daylight saving time begins on: %s.') :
310
-                        __(' Standard time begins  on: %s.');
309
+                        __(' Daylight saving time begins on: %s.') : __(' Standard time begins  on: %s.');
311 310
                     // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
312 311
                     printf($message,
313
-                        '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >');
312
+                        '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >');
314 313
                 } else {
315 314
                     _e('This timezone does not observe daylight saving time.');
316 315
                 }
@@ -338,13 +337,13 @@  discard block
 block discarded – undo
338 337
      */
339 338
     public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
340 339
     {
341
-        $unix_timestamp  = $unix_timestamp === 0 ? time() : (int)$unix_timestamp;
340
+        $unix_timestamp  = $unix_timestamp === 0 ? time() : (int) $unix_timestamp;
342 341
         $timezone_string = self::get_valid_timezone_string($timezone_string);
343 342
         $TimeZone        = new DateTimeZone($timezone_string);
344 343
 
345
-        $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone);
344
+        $DateTime = new DateTime('@'.$unix_timestamp, $TimeZone);
346 345
         $offset   = timezone_offset_get($TimeZone, $DateTime);
347
-        return (int)$DateTime->format('U') + (int)$offset;
346
+        return (int) $DateTime->format('U') + (int) $offset;
348 347
     }
349 348
 
350 349
 
@@ -427,7 +426,7 @@  discard block
 block discarded – undo
427 426
      */
428 427
     protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
429 428
     {
430
-        if (! $DateTime instanceof DateTime) {
429
+        if ( ! $DateTime instanceof DateTime) {
431 430
             throw new EE_Error(
432 431
                 sprintf(
433 432
                     __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
@@ -437,25 +436,25 @@  discard block
 block discarded – undo
437 436
         }
438 437
         switch ($period) {
439 438
             case 'years' :
440
-                $value = 'P' . $value . 'Y';
439
+                $value = 'P'.$value.'Y';
441 440
                 break;
442 441
             case 'months' :
443
-                $value = 'P' . $value . 'M';
442
+                $value = 'P'.$value.'M';
444 443
                 break;
445 444
             case 'weeks' :
446
-                $value = 'P' . $value . 'W';
445
+                $value = 'P'.$value.'W';
447 446
                 break;
448 447
             case 'days' :
449
-                $value = 'P' . $value . 'D';
448
+                $value = 'P'.$value.'D';
450 449
                 break;
451 450
             case 'hours' :
452
-                $value = 'PT' . $value . 'H';
451
+                $value = 'PT'.$value.'H';
453 452
                 break;
454 453
             case 'minutes' :
455
-                $value = 'PT' . $value . 'M';
454
+                $value = 'PT'.$value.'M';
456 455
                 break;
457 456
             case 'seconds' :
458
-                $value = 'PT' . $value . 'S';
457
+                $value = 'PT'.$value.'S';
459 458
                 break;
460 459
         }
461 460
         switch ($operand) {
@@ -483,7 +482,7 @@  discard block
 block discarded – undo
483 482
      */
484 483
     protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
485 484
     {
486
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
485
+        if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
487 486
             throw new EE_Error(
488 487
                 sprintf(
489 488
                     __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
@@ -587,7 +586,7 @@  discard block
 block discarded – undo
587 586
                 'date' => $date_format['js'],
588 587
                 'time' => $time_format['js'],
589 588
             ),
590
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
589
+            'moment' => $date_format['moment'].' '.$time_format['moment'],
591 590
         );
592 591
     }
593 592
 
@@ -606,7 +605,7 @@  discard block
 block discarded – undo
606 605
          *
607 606
          * @var array
608 607
          */
609
-        $symbols_map      = array(
608
+        $symbols_map = array(
610 609
             // Day
611 610
             //01
612 611
             'd' => array(
@@ -764,7 +763,7 @@  discard block
 block discarded – undo
764 763
                     $jquery_ui_format .= $format_string[$i];
765 764
                     $moment_format .= $format_string[$i];
766 765
                 } else {
767
-                    $jquery_ui_format .= '\'' . $format_string[$i];
766
+                    $jquery_ui_format .= '\''.$format_string[$i];
768 767
                     $moment_format .= $format_string[$i];
769 768
                 }
770 769
                 $escaping = true;
@@ -834,7 +833,7 @@  discard block
 block discarded – undo
834 833
     {
835 834
 
836 835
         if (
837
-            (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) ||
836
+            ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) ||
838 837
             ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00')
839 838
         ) {
840 839
             return false;
@@ -866,8 +865,8 @@  discard block
 block discarded – undo
866 865
          */
867 866
         $offset         = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset');
868 867
         $query_interval = $offset < 0
869
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
870
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
868
+            ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)'
869
+            : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)';
871 870
         return $query_interval;
872 871
     }
873 872
 
@@ -883,16 +882,16 @@  discard block
 block discarded – undo
883 882
     public static function get_timezone_string_for_display()
884 883
     {
885 884
         $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
886
-        if (! empty($pretty_timezone)) {
885
+        if ( ! empty($pretty_timezone)) {
887 886
             return esc_html($pretty_timezone);
888 887
         }
889 888
         $timezone_string = get_option('timezone_string');
890 889
         if ($timezone_string) {
891 890
             static $mo_loaded = false;
892 891
             // Load translations for continents and cities just like wp_timezone_choice does
893
-            if (! $mo_loaded) {
892
+            if ( ! $mo_loaded) {
894 893
                 $locale = get_locale();
895
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
894
+                $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo';
896 895
                 load_textdomain('continents-cities', $mofile);
897 896
                 $mo_loaded = true;
898 897
             }
@@ -913,16 +912,16 @@  discard block
 block discarded – undo
913 912
         } else {
914 913
             $prefix = '';
915 914
         }
916
-        $parts = explode('.', (string)$gmt_offset);
915
+        $parts = explode('.', (string) $gmt_offset);
917 916
         if (count($parts) === 1) {
918 917
             $parts[1] = '00';
919 918
         } else {
920 919
             //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
921 920
             //to minutes, eg 30 or 15, respectively
922
-            $hour_fraction = (float)('0.' . $parts[1]);
923
-            $parts[1]      = (string)$hour_fraction * 60;
921
+            $hour_fraction = (float) ('0.'.$parts[1]);
922
+            $parts[1]      = (string) $hour_fraction * 60;
924 923
         }
925
-        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
924
+        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts));
926 925
     }
927 926
 
928 927
 
@@ -948,7 +947,7 @@  discard block
 block discarded – undo
948 947
      */
949 948
     public static function first_of_month_timestamp($month = '')
950 949
     {
951
-        $month = (string)$month;
950
+        $month = (string) $month;
952 951
         $year = '';
953 952
         // check if the incoming string has a year in it or not
954 953
        if (preg_match('/\b\d{4}\b/', $month, $matches)) {
Please login to merge, or discard this patch.
modules/events_archive_filters/EED_Events_Archive_Filters.module.php 1 patch
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @return EED_Events_Archive_Filters
30 30
 	 */
31 31
 	public static function instance() {
32
-		return parent::get_instance( __CLASS__ );
32
+		return parent::get_instance(__CLASS__);
33 33
 	}
34 34
 
35 35
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *	@var 	$_types
72 72
 	 * 	@access 	protected
73 73
 	 */
74
-	protected static $_types = array( 'grid', 'text', 'dates' );
74
+	protected static $_types = array('grid', 'text', 'dates');
75 75
 
76 76
 
77 77
 //	public static $espresso_event_list_ID = 0;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 *  @access 	public
126 126
 	 *  @return 	void
127 127
 	 */
128
-	public function run( $WP ) {
128
+	public function run($WP) {
129 129
 //		do_action( 'AHEE__EED_Events_Archive_Filters__before_run' );
130 130
 //		// set config
131 131
 //		if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters ) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters instanceof EE_Events_Archive_Config ) {
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	private function _filter_query_parts() {
172 172
 		// build event list query
173
-		add_filter( 'posts_join', array( $this, 'posts_join' ), 1, 2 );
174
-		add_filter( 'posts_where', array( $this, 'posts_where' ), 1, 2 );
175
-		add_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1, 2 );
173
+		add_filter('posts_join', array($this, 'posts_join'), 1, 2);
174
+		add_filter('posts_where', array($this, 'posts_where'), 1, 2);
175
+		add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2);
176 176
 	}
177 177
 
178 178
 	/**
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	 *  @return 	string
183 183
 	 */
184 184
 	public static function set_type() {
185
-		do_action( 'AHEE__EED_Events_Archive_Filters__before_set_type' );
186
-		EED_Events_Archive_Filters::$_types = apply_filters( 'EED_Events_Archive_Filters__set_type__types', EED_Events_Archive_Filters::$_types );
187
-		$view = isset( EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type'] ) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type'] : 'grid';
188
-		$elf_type = EE_Registry::instance()->REQ->is_set( 'elf_type' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'elf_type' )) : '';
189
-		$view = ! empty( $elf_type ) ? $elf_type : $view;
190
-		$view = apply_filters( 'EED_Events_Archive_Filters__set_type__type', $view );
191
-		if ( ! empty( $view ) && in_array( $view, EED_Events_Archive_Filters::$_types )) {
185
+		do_action('AHEE__EED_Events_Archive_Filters__before_set_type');
186
+		EED_Events_Archive_Filters::$_types = apply_filters('EED_Events_Archive_Filters__set_type__types', EED_Events_Archive_Filters::$_types);
187
+		$view = isset(EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type']) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type'] : 'grid';
188
+		$elf_type = EE_Registry::instance()->REQ->is_set('elf_type') ? sanitize_text_field(EE_Registry::instance()->REQ->get('elf_type')) : '';
189
+		$view = ! empty($elf_type) ? $elf_type : $view;
190
+		$view = apply_filters('EED_Events_Archive_Filters__set_type__type', $view);
191
+		if ( ! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) {
192 192
 			self::$_type = $view;
193 193
 		}
194 194
 	}
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
 	 *  @param	boolean	$req_only if TRUE, then ignore defaults and only return $_POST value
201 201
 	 *  @return 	boolean
202 202
 	 */
203
-	private static function _show_expired( $req_only = FALSE ) {
203
+	private static function _show_expired($req_only = FALSE) {
204 204
 		// get default value for "display_expired_events" as set in the EE General Settings > Templates > Event Listings
205
-		$show_expired = ! $req_only && isset( EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] ) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] : FALSE;
205
+		$show_expired = ! $req_only && isset(EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events']) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] : FALSE;
206 206
 		// override default expired option if set via filter
207
-		$show_expired = EE_Registry::instance()->REQ->is_set( 'elf_expired_chk' ) ? absint( EE_Registry::instance()->REQ->get( 'elf_expired_chk' )) : $show_expired;
207
+		$show_expired = EE_Registry::instance()->REQ->is_set('elf_expired_chk') ? absint(EE_Registry::instance()->REQ->get('elf_expired_chk')) : $show_expired;
208 208
 		return $show_expired ? TRUE : FALSE;
209 209
 	}
210 210
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 *  @return 	string
216 216
 	 */
217 217
 	private static function _event_category_slug() {
218
-		return EE_Registry::instance()->REQ->is_set( 'elf_category_dd' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'elf_category_dd' )) : '';
218
+		return EE_Registry::instance()->REQ->is_set('elf_category_dd') ? sanitize_text_field(EE_Registry::instance()->REQ->get('elf_category_dd')) : '';
219 219
 	}
220 220
 
221 221
 	/**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 *  @return 	string
226 226
 	 */
227 227
 	private static function _display_month() {
228
-		return EE_Registry::instance()->REQ->is_set( 'elf_month_dd' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'elf_month_dd' )) : '';
228
+		return EE_Registry::instance()->REQ->is_set('elf_month_dd') ? sanitize_text_field(EE_Registry::instance()->REQ->get('elf_month_dd')) : '';
229 229
 	}
230 230
 
231 231
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	public function get_post_data() {
240 240
 		$this->_elf_month = EED_Events_Archive_Filters::_display_month();
241 241
 		$this->_elf_category = EED_Events_Archive_Filters::_event_category_slug();
242
-		$this->_show_expired = EED_Events_Archive_Filters::_show_expired( TRUE );
242
+		$this->_show_expired = EED_Events_Archive_Filters::_show_expired(TRUE);
243 243
 //		EEH_Debug_Tools::printr( EE_Registry::instance()->REQ, 'EE_Registry::instance()->REQ  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
244 244
 //		echo '<h4>$this->_elf_month : ' . $this->_elf_month . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
245 245
 //		echo '<h4>$this->_elf_category : ' . $this->_elf_category . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 	 *  @access 	public
257 257
 	 *  @return 	void
258 258
 	 */
259
-	public function posts_join( $SQL, WP_Query $wp_query ) {
260
-		if ( isset( $wp_query->query ) && isset( $wp_query->query['post_type'] ) && $wp_query->query['post_type'] == 'espresso_events' ) {
259
+	public function posts_join($SQL, WP_Query $wp_query) {
260
+		if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
261 261
 			// Category
262 262
 //			$elf_category = EE_Registry::instance()->REQ->is_set( 'elf_category_dd' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'elf_category_dd' )) : '';
263
-			$SQL .= EED_Events_Archive_Filters::posts_join_sql_for_terms( EED_Events_Archive_Filters::_event_category_slug() );
263
+			$SQL .= EED_Events_Archive_Filters::posts_join_sql_for_terms(EED_Events_Archive_Filters::_event_category_slug());
264 264
 		}
265 265
 		return $SQL;
266 266
 	}
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
 	 *  @param	mixed boolean|string	$join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet
274 274
 	 *  @return 	string
275 275
 	 */
276
-	public static function posts_join_sql_for_terms( $join_terms = NULL ) {
277
-		$SQL= '';
278
-		if ( ! empty( $join_terms )) {
276
+	public static function posts_join_sql_for_terms($join_terms = NULL) {
277
+		$SQL = '';
278
+		if ( ! empty($join_terms)) {
279 279
 			global $wpdb;
280 280
 			$SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
281 281
 			$SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
@@ -293,28 +293,28 @@  discard block
 block discarded – undo
293 293
 	 *  @param	array	$orderby_params
294 294
 	 *  @return 	string
295 295
 	 */
296
-	public static function posts_join_for_orderby( $orderby_params = array() ) {
296
+	public static function posts_join_for_orderby($orderby_params = array()) {
297 297
 		global $wpdb;
298
-		$SQL= '';
299
-		$orderby_params = is_array( $orderby_params ) ? $orderby_params : array( $orderby_params );
300
-		foreach( $orderby_params as $orderby ) {
301
-			switch ( $orderby ) {
298
+		$SQL = '';
299
+		$orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
300
+		foreach ($orderby_params as $orderby) {
301
+			switch ($orderby) {
302 302
 
303 303
 				case 'ticket_start' :
304 304
 				case 'ticket_end' :
305
-					$SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON (' . EEM_Datetime::instance()->table() . '.DTT_ID = ' . EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )';
306
-					$SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = ' . EEM_Ticket::instance()->table() . '.TKT_ID )';
305
+					$SQL .= ' LEFT JOIN '.EEM_Datetime_Ticket::instance()->table().' ON ('.EEM_Datetime::instance()->table().'.DTT_ID = '.EEM_Datetime_Ticket::instance()->table().'.DTT_ID )';
306
+					$SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('.EEM_Datetime_Ticket::instance()->table().'.TKT_ID = '.EEM_Ticket::instance()->table().'.TKT_ID )';
307 307
 					break;
308 308
 
309 309
 				case 'venue_title' :
310 310
 				case 'city' :
311
-					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = ' . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
312
-					$SQL .= ' LEFT JOIN ' . EEM_Venue::instance()->table() . ' ON (' . EEM_Event_Venue::instance()->table() . '.VNU_ID = ' . EEM_Venue::instance()->table() . '.VNU_ID )';
311
+					$SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->table().' ON ('.$wpdb->posts.'.ID = '.EEM_Event_Venue::instance()->table().'.EVT_ID )';
312
+					$SQL .= ' LEFT JOIN '.EEM_Venue::instance()->table().' ON ('.EEM_Event_Venue::instance()->table().'.VNU_ID = '.EEM_Venue::instance()->table().'.VNU_ID )';
313 313
 					break;
314 314
 
315 315
 				case 'state' :
316
-					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = ' . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
317
-					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->second_table() . ' ON (' . EEM_Event_Venue::instance()->table() . '.VNU_ID = ' . EEM_Event_Venue::instance()->second_table() . '.VNU_ID )';
316
+					$SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->table().' ON ('.$wpdb->posts.'.ID = '.EEM_Event_Venue::instance()->table().'.EVT_ID )';
317
+					$SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->second_table().' ON ('.EEM_Event_Venue::instance()->table().'.VNU_ID = '.EEM_Event_Venue::instance()->second_table().'.VNU_ID )';
318 318
 					break;
319 319
 
320 320
 				break;
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 	 *  @access 	public
332 332
 	 *  @return 	void
333 333
 	 */
334
-	public function posts_where( $SQL, WP_Query $wp_query ) {
335
-		if ( isset( $wp_query->query_vars ) && isset( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'espresso_events'  ) {
334
+	public function posts_where($SQL, WP_Query $wp_query) {
335
+		if (isset($wp_query->query_vars) && isset($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'espresso_events') {
336 336
 			// Show Expired ?
337
-			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_show_expired( EED_Events_Archive_Filters::_show_expired() );
337
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_show_expired(EED_Events_Archive_Filters::_show_expired());
338 338
 			// Category
339 339
 			//$elf_category = EED_Events_Archive_Filters::_event_category_slug();
340
-			$SQL .=  EED_Events_Archive_Filters::posts_where_sql_for_event_category_slug( EED_Events_Archive_Filters::_event_category_slug() );
340
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_category_slug(EED_Events_Archive_Filters::_event_category_slug());
341 341
 			// Start Date
342 342
 			//$elf_month = EED_Events_Archive_Filters::_display_month();
343
-			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_list_month( EED_Events_Archive_Filters::_display_month() );
343
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_list_month(EED_Events_Archive_Filters::_display_month());
344 344
 		}
345 345
 		return $SQL;
346 346
 	}
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 	 *  @param	boolean	$show_expired if TRUE, then displayed past events
354 354
 	 *  @return 	string
355 355
 	 */
356
-	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
357
-		return  ! $show_expired ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . date('Y-m-d H:s:i') . '" ' : '';
356
+	public static function posts_where_sql_for_show_expired($show_expired = FALSE) {
357
+		return  ! $show_expired ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.date('Y-m-d H:s:i').'" ' : '';
358 358
 	}
359 359
 
360 360
 
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
 	 *  @param	boolean	$event_category_slug
366 366
 	 *  @return 	string
367 367
 	 */
368
-	public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) {
368
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) {
369 369
 		global $wpdb;
370
-		return  ! empty( $event_category_slug ) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : '';
370
+		return  ! empty($event_category_slug) ? ' AND '.$wpdb->terms.'.slug = "'.$event_category_slug.'" ' : '';
371 371
 	}
372 372
 
373 373
 	/**
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
 	 *  @param	boolean	$month
378 378
 	 *  @return 	string
379 379
 	 */
380
-	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
381
-		$SQL= '';
382
-		if ( ! empty( $month )) {
380
+	public static function posts_where_sql_for_event_list_month($month = NULL) {
381
+		$SQL = '';
382
+		if ( ! empty($month)) {
383 383
 			// event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
384
-			$SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start';
385
-			$SQL .= ' <= "' . date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '"';
384
+			$SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start';
385
+			$SQL .= ' <= "'.date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)).'"';
386 386
 			// event end date is GREATER than the start of the month ( so nothing that ended before this month )
387
-			$SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end';
388
-			$SQL .= ' >= "' . date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '" ';
387
+			$SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end';
388
+			$SQL .= ' >= "'.date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)).'" ';
389 389
 		}
390 390
 		return $SQL;
391 391
 	}
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
 	 *  @access 	public
398 398
 	 *  @return 	void
399 399
 	 */
400
-	public function posts_orderby( $SQL, WP_Query $wp_query ) {
401
-		if ( isset( $wp_query->query ) && isset( $wp_query->query['post_type'] ) && $wp_query->query['post_type'] == 'espresso_events' ) {
402
-			$SQL = EED_Events_Archive_Filters::posts_orderby_sql( array( 'start_date' ));
400
+	public function posts_orderby($SQL, WP_Query $wp_query) {
401
+		if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
402
+			$SQL = EED_Events_Archive_Filters::posts_orderby_sql(array('start_date'));
403 403
 		}
404 404
 		return $SQL;
405 405
 	}
@@ -428,54 +428,54 @@  discard block
 block discarded – undo
428 428
 	 *  @param	boolean	$orderby_params
429 429
 	 *  @return 	string
430 430
 	 */
431
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
431
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
432 432
 		global $wpdb;
433 433
 		$SQL = '';
434 434
 		$cntr = 1;
435
-		$orderby_params = is_array( $orderby_params ) ? $orderby_params : array( $orderby_params );
436
-		foreach( $orderby_params as $orderby ) {
437
-			$glue = $cntr == 1 || $cntr == count( $orderby_params ) ? ' ' : ', ';
438
-			switch ( $orderby ) {
435
+		$orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
436
+		foreach ($orderby_params as $orderby) {
437
+			$glue = $cntr == 1 || $cntr == count($orderby_params) ? ' ' : ', ';
438
+			switch ($orderby) {
439 439
 
440 440
 				case 'id' :
441 441
 				case 'ID' :
442
-					$SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
442
+					$SQL .= $glue.$wpdb->posts.'.ID '.$sort;
443 443
 					break;
444 444
 
445 445
 				case 'start_date' :
446
-					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort;
446
+					$SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_start '.$sort;
447 447
 					break;
448 448
 
449 449
 				case 'end_date' :
450
-					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
450
+					$SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort;
451 451
 					break;
452 452
 
453 453
 				case 'event_name' :
454
-					$SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
454
+					$SQL .= $glue.$wpdb->posts.'.post_title '.$sort;
455 455
 					break;
456 456
 
457 457
 				case 'category_slug' :
458
-					$SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
458
+					$SQL .= $glue.$wpdb->terms.'.slug '.$sort;
459 459
 					break;
460 460
 
461 461
 				case 'ticket_start' :
462
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
462
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort;
463 463
 					break;
464 464
 
465 465
 				case 'ticket_end' :
466
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
466
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort;
467 467
 					break;
468 468
 
469 469
 				case 'venue_title' :
470
-					$SQL .= $glue . 'venue_title ' . $sort;
470
+					$SQL .= $glue.'venue_title '.$sort;
471 471
 					break;
472 472
 
473 473
 				case 'city' :
474
-					$SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
474
+					$SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort;
475 475
 				break;
476 476
 
477 477
 				case 'state' :
478
-					$SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
478
+					$SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort;
479 479
 				break;
480 480
 
481 481
 			}
@@ -495,26 +495,26 @@  discard block
 block discarded – undo
495 495
 	 */
496 496
 	public function template_redirect() {
497 497
 		// add event list filters
498
-		add_action( 'loop_start', array( $this, 'event_list_template_filters' ));
498
+		add_action('loop_start', array($this, 'event_list_template_filters'));
499 499
 		// and pagination
500
-		add_action( 'loop_start', array( $this, 'event_list_pagination' ));
501
-		add_action( 'loop_end', array( $this, 'event_list_pagination' ));
500
+		add_action('loop_start', array($this, 'event_list_pagination'));
501
+		add_action('loop_end', array($this, 'event_list_pagination'));
502 502
 		// if NOT a custom template
503
-		if ( EE_Registry::instance()->load_core( 'Front_Controller', array(), false, true )->get_selected_template() != 'archive-espresso_events.php' ) {
503
+		if (EE_Registry::instance()->load_core('Front_Controller', array(), false, true)->get_selected_template() != 'archive-espresso_events.php') {
504 504
 			// don't know if theme uses the_excerpt
505
-			add_filter( 'the_excerpt', array( $this, 'event_details' ), 100 );
506
-			add_filter( 'the_excerpt', array( $this, 'event_tickets' ), 110 );
507
-			add_filter( 'the_excerpt', array( $this, 'event_datetimes' ), 120 );
508
-			add_filter( 'the_excerpt', array( $this, 'event_venues' ), 130 );
505
+			add_filter('the_excerpt', array($this, 'event_details'), 100);
506
+			add_filter('the_excerpt', array($this, 'event_tickets'), 110);
507
+			add_filter('the_excerpt', array($this, 'event_datetimes'), 120);
508
+			add_filter('the_excerpt', array($this, 'event_venues'), 130);
509 509
 			// or the_content
510
-			add_filter( 'the_content', array( $this, 'event_details' ), 100 );
511
-			add_filter( 'the_content', array( $this, 'event_tickets' ), 110 );
512
-			add_filter( 'the_content', array( $this, 'event_datetimes' ), 120 );
513
-			add_filter( 'the_content', array( $this, 'event_venues' ), 130 );
510
+			add_filter('the_content', array($this, 'event_details'), 100);
511
+			add_filter('the_content', array($this, 'event_tickets'), 110);
512
+			add_filter('the_content', array($this, 'event_datetimes'), 120);
513
+			add_filter('the_content', array($this, 'event_venues'), 130);
514 514
 		} else {
515
-			remove_all_filters( 'excerpt_length' );
516
-			add_filter( 'excerpt_length', array( $this, 'excerpt_length' ), 10 );
517
-			add_filter( 'excerpt_more', array( $this, 'excerpt_more' ), 10 );
515
+			remove_all_filters('excerpt_length');
516
+			add_filter('excerpt_length', array($this, 'excerpt_length'), 10);
517
+			add_filter('excerpt_more', array($this, 'excerpt_more'), 10);
518 518
 		}
519 519
 	}
520 520
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 	 *  	@return 		void
528 528
 	 */
529 529
 	public function event_list_pagination() {
530
-		echo '<div class="ee-pagination-dv clear">' . espresso_event_list_pagination() . '</div>';
530
+		echo '<div class="ee-pagination-dv clear">'.espresso_event_list_pagination().'</div>';
531 531
 	}
532 532
 
533 533
 
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 	 * 	@param		string 	$content
539 539
 	 *  	@return 		void
540 540
 	 */
541
-	public function event_details( $content ) {
542
-		return EEH_Template::display_template( EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-details.php', array( 'the_content' => $content ), TRUE );
541
+	public function event_details($content) {
542
+		return EEH_Template::display_template(EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-details.php', array('the_content' => $content), TRUE);
543 543
 	}
544 544
 
545 545
 
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
 	 * 	@param		string 	$content
551 551
 	 *  	@return 		void
552 552
 	 */
553
-	public function event_tickets( $content ) {
554
-		return $content . EEH_Template::display_template( EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-tickets.php', array(), TRUE );
553
+	public function event_tickets($content) {
554
+		return $content.EEH_Template::display_template(EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-tickets.php', array(), TRUE);
555 555
 	}
556 556
 
557 557
 	/**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * 	@param		string 	$content
562 562
 	 *  	@return 		void
563 563
 	 */
564
-	public function event_datetimes( $content ) {
565
-		return $content . EEH_Template::display_template( EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-datetimes.php', array(), TRUE );
564
+	public function event_datetimes($content) {
565
+		return $content.EEH_Template::display_template(EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-datetimes.php', array(), TRUE);
566 566
 	}
567 567
 
568 568
 	/**
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	 * 	@param		string 	$content
573 573
 	 *  	@return 		void
574 574
 	 */
575
-	public function event_venues( $content ) {
576
-		return $content . EEH_Template::display_template( EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-venues.php', array(), TRUE );
575
+	public function event_venues($content) {
576
+		return $content.EEH_Template::display_template(EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-venues.php', array(), TRUE);
577 577
 	}
578 578
 
579 579
 
@@ -588,12 +588,12 @@  discard block
 block discarded – undo
588 588
 	 *  @return 	void
589 589
 	 */
590 590
 	private function _load_assests() {
591
-		do_action( 'AHEE__EED_Events_Archive_Filters__before_load_assests' );
592
-		add_filter( 'FHEE_load_css', '__return_true' );
593
-		add_filter( 'FHEE_load_EE_Session', '__return_true' );
594
-		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
595
-		if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) {
596
-			add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 );
591
+		do_action('AHEE__EED_Events_Archive_Filters__before_load_assests');
592
+		add_filter('FHEE_load_css', '__return_true');
593
+		add_filter('FHEE_load_EE_Session', '__return_true');
594
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
595
+		if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
596
+			add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
597 597
 		}
598 598
 		//add_filter( 'the_excerpt', array( $this, 'the_excerpt' ), 999 );
599 599
 	}
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 	 *  @access 	private
609 609
 	 *  @return 	string
610 610
 	 */
611
-	private function _get_template( $which = 'part' ) {
612
-		return EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php';
611
+	private function _get_template($which = 'part') {
612
+		return EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events.php';
613 613
 	}
614 614
 
615 615
 
@@ -620,13 +620,13 @@  discard block
 block discarded – undo
620 620
 	 *  @access 	public
621 621
 	 *  @return 	void
622 622
 	 */
623
-	public function excerpt_length( $length ) {
623
+	public function excerpt_length($length) {
624 624
 
625
-		if ( self::$_type == 'grid' ) {
625
+		if (self::$_type == 'grid') {
626 626
 			return 36;
627 627
 		}
628 628
 
629
-		switch ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size ) {
629
+		switch (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) {
630 630
 			case 'tiny' :
631 631
 				return 12;
632 632
 				break;
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	 *  @access 	public
651 651
 	 *  @return 	void
652 652
 	 */
653
-	public function excerpt_more( $more ) {
653
+	public function excerpt_more($more) {
654 654
 		return '&hellip;';
655 655
 	}
656 656
 
@@ -680,22 +680,22 @@  discard block
 block discarded – undo
680 680
 	 */
681 681
 	public function wp_enqueue_scripts() {
682 682
 		// get some style
683
-		if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) {
683
+		if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) {
684 684
 			// first check uploads folder
685
-			if ( is_readable( get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css' )) {
686
-				wp_register_style( 'archive-espresso_events', get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css', array( 'dashicons', 'espresso_default' ));
685
+			if (is_readable(get_stylesheet_directory().EE_Config::get_current_theme().DS.'archive-espresso_events.css')) {
686
+				wp_register_style('archive-espresso_events', get_stylesheet_directory_uri().EE_Config::get_current_theme().DS.'archive-espresso_events.css', array('dashicons', 'espresso_default'));
687 687
 			} else {
688
-				wp_register_style( 'archive-espresso_events', EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css', array( 'dashicons', 'espresso_default' ));
688
+				wp_register_style('archive-espresso_events', EE_TEMPLATES_URL.EE_Config::get_current_theme().DS.'archive-espresso_events.css', array('dashicons', 'espresso_default'));
689 689
 			}
690
-			if ( is_readable( get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.js' )) {
691
-				wp_register_script( 'archive-espresso_events', get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.js', array( 'jquery-masonry' ), '1.0', TRUE  );
690
+			if (is_readable(get_stylesheet_directory().EE_Config::get_current_theme().DS.'archive-espresso_events.js')) {
691
+				wp_register_script('archive-espresso_events', get_stylesheet_directory_uri().EE_Config::get_current_theme().DS.'archive-espresso_events.js', array('jquery-masonry'), '1.0', TRUE);
692 692
 			} else {
693
-				wp_register_script( 'archive-espresso_events', EVENTS_ARCHIVE_ASSETS_URL . 'archive-espresso_events.js', array( 'jquery-masonry' ), '1.0', TRUE );
693
+				wp_register_script('archive-espresso_events', EVENTS_ARCHIVE_ASSETS_URL.'archive-espresso_events.js', array('jquery-masonry'), '1.0', TRUE);
694 694
 			}
695
-			wp_enqueue_style( 'archive-espresso_events' );
696
-			wp_enqueue_script( 'jquery-masonry' );
697
-			wp_enqueue_script( 'archive-espresso_events' );
698
-			add_action( 'wp_footer', array( 'EED_Events_Archive_Filters', 'localize_grid_event_lists' ), 1 );
695
+			wp_enqueue_style('archive-espresso_events');
696
+			wp_enqueue_script('jquery-masonry');
697
+			wp_enqueue_script('archive-espresso_events');
698
+			add_action('wp_footer', array('EED_Events_Archive_Filters', 'localize_grid_event_lists'), 1);
699 699
 		}
700 700
 	}
701 701
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 	 *  @return 	void
711 711
 	 */
712 712
 	public static function localize_grid_event_lists() {
713
-		wp_localize_script( 'archive-espresso_events', 'espresso_grid_event_lists', EED_Events_Archive_Filters::$espresso_grid_event_lists );
713
+		wp_localize_script('archive-espresso_events', 'espresso_grid_event_lists', EED_Events_Archive_Filters::$espresso_grid_event_lists);
714 714
 	}
715 715
 
716 716
 
@@ -725,9 +725,9 @@  discard block
 block discarded – undo
725 725
 	 */
726 726
 	public static function template_settings_form() {
727 727
 		$EE = EE_Registry::instance();
728
-		$EE->CFG->template_settings->EED_Events_Archive_Filters = isset( $EE->CFG->template_settings->EED_Events_Archive_Filters ) ? $EE->CFG->template_settings->EED_Events_Archive_Filters : new EE_Events_Archive_Config();
729
-		$EE->CFG->template_settings->EED_Events_Archive_Filters = apply_filters( 'FHEE__Event_List__template_settings_form__event_list_config', $EE->CFG->template_settings->EED_Events_Archive_Filters );
730
-		EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $EE->CFG->template_settings->EED_Events_Archive_Filters );
728
+		$EE->CFG->template_settings->EED_Events_Archive_Filters = isset($EE->CFG->template_settings->EED_Events_Archive_Filters) ? $EE->CFG->template_settings->EED_Events_Archive_Filters : new EE_Events_Archive_Config();
729
+		$EE->CFG->template_settings->EED_Events_Archive_Filters = apply_filters('FHEE__Event_List__template_settings_form__event_list_config', $EE->CFG->template_settings->EED_Events_Archive_Filters);
730
+		EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $EE->CFG->template_settings->EED_Events_Archive_Filters);
731 731
 	}
732 732
 
733 733
 
@@ -741,16 +741,16 @@  discard block
 block discarded – undo
741 741
 	 *  @static
742 742
 	 *  @return 	void
743 743
 	 */
744
-	public static function set_default_settings( $CFG ) {
744
+	public static function set_default_settings($CFG) {
745 745
 		//EEH_Debug_Tools::printr( $CFG, '$CFG  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
746
-		$CFG->display_description = isset( $CFG->display_description ) && ! empty( $CFG->display_description ) ? $CFG->display_description : 1;
747
-		$CFG->display_address = isset( $CFG->display_address ) && ! empty( $CFG->display_address ) ? $CFG->display_address : TRUE;
748
-		$CFG->display_venue_details = isset( $CFG->display_venue_details ) && ! empty( $CFG->display_venue_details ) ? $CFG->display_venue_details : TRUE;
749
-		$CFG->display_expired_events = isset( $CFG->display_expired_events ) && ! empty( $CFG->display_expired_events ) ? $CFG->display_expired_events : FALSE;
750
-		$CFG->default_type = isset( $CFG->default_type ) && ! empty( $CFG->default_type ) ? $CFG->default_type : 'grid';
751
-		$CFG->event_list_grid_size = isset( $CFG->event_list_grid_size ) && ! empty( $CFG->event_list_grid_size ) ? $CFG->event_list_grid_size : 'medium';
752
-		$CFG->templates['full'] = isset( $CFG->templates['full'] ) && ! empty( $CFG->templates['full'] ) ? $CFG->templates['full'] : EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php';
753
-		$CFG->templates['part'] = isset( $CFG->templates['part'] ) && ! empty( $CFG->templates['part'] ) ? $CFG->templates['part'] : EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-grid-view.php';
746
+		$CFG->display_description = isset($CFG->display_description) && ! empty($CFG->display_description) ? $CFG->display_description : 1;
747
+		$CFG->display_address = isset($CFG->display_address) && ! empty($CFG->display_address) ? $CFG->display_address : TRUE;
748
+		$CFG->display_venue_details = isset($CFG->display_venue_details) && ! empty($CFG->display_venue_details) ? $CFG->display_venue_details : TRUE;
749
+		$CFG->display_expired_events = isset($CFG->display_expired_events) && ! empty($CFG->display_expired_events) ? $CFG->display_expired_events : FALSE;
750
+		$CFG->default_type = isset($CFG->default_type) && ! empty($CFG->default_type) ? $CFG->default_type : 'grid';
751
+		$CFG->event_list_grid_size = isset($CFG->event_list_grid_size) && ! empty($CFG->event_list_grid_size) ? $CFG->event_list_grid_size : 'medium';
752
+		$CFG->templates['full'] = isset($CFG->templates['full']) && ! empty($CFG->templates['full']) ? $CFG->templates['full'] : EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events.php';
753
+		$CFG->templates['part'] = isset($CFG->templates['part']) && ! empty($CFG->templates['part']) ? $CFG->templates['part'] : EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-grid-view.php';
754 754
 		return $CFG;
755 755
 	}
756 756
 
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 	 *  @access 	public
763 763
 	 *  @return 	void
764 764
 	 */
765
-	public function filter_config( $CFG ) {
765
+	public function filter_config($CFG) {
766 766
 		return $CFG;
767 767
 	}
768 768
 
@@ -775,32 +775,32 @@  discard block
 block discarded – undo
775 775
 	 *  @access 	public
776 776
 	 *  @return 	void
777 777
 	 */
778
-	public static function update_template_settings( $CFG, $REQ ) {
778
+	public static function update_template_settings($CFG, $REQ) {
779 779
 //		EEH_Debug_Tools::printr( $REQ, '$REQ  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
780 780
 //		EEH_Debug_Tools::printr( $CFG, '$CFG  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
781 781
 		//$CFG->template_settings->EED_Events_Archive_Filters = new stdClass();
782
-		$CFG->EED_Events_Archive_Filters->display_description = isset( $REQ['display_description_in_event_list'] ) ? absint( $REQ['display_description_in_event_list'] ) : 1;
783
-		$CFG->EED_Events_Archive_Filters->display_address = isset( $REQ['display_address_in_event_list'] ) ? absint( $REQ['display_address_in_event_list'] ) : TRUE;
784
-		$CFG->EED_Events_Archive_Filters->display_venue_details = isset( $REQ['display_venue_details_in_event_list'] ) ? absint( $REQ['display_venue_details_in_event_list'] ) : TRUE;
785
-		$CFG->EED_Events_Archive_Filters->display_expired_events = isset( $REQ['display_expired_events'] ) ? absint( $REQ['display_expired_events'] ) : FALSE;
786
-		$CFG->EED_Events_Archive_Filters->default_type = isset( $REQ['default_type'] ) ? sanitize_text_field( $REQ['default_type'] ) : 'grid';
787
-		$CFG->EED_Events_Archive_Filters->event_list_grid_size = isset( $REQ['event_list_grid_size'] ) ? sanitize_text_field( $REQ['event_list_grid_size'] ) : 'medium';
782
+		$CFG->EED_Events_Archive_Filters->display_description = isset($REQ['display_description_in_event_list']) ? absint($REQ['display_description_in_event_list']) : 1;
783
+		$CFG->EED_Events_Archive_Filters->display_address = isset($REQ['display_address_in_event_list']) ? absint($REQ['display_address_in_event_list']) : TRUE;
784
+		$CFG->EED_Events_Archive_Filters->display_venue_details = isset($REQ['display_venue_details_in_event_list']) ? absint($REQ['display_venue_details_in_event_list']) : TRUE;
785
+		$CFG->EED_Events_Archive_Filters->display_expired_events = isset($REQ['display_expired_events']) ? absint($REQ['display_expired_events']) : FALSE;
786
+		$CFG->EED_Events_Archive_Filters->default_type = isset($REQ['default_type']) ? sanitize_text_field($REQ['default_type']) : 'grid';
787
+		$CFG->EED_Events_Archive_Filters->event_list_grid_size = isset($REQ['event_list_grid_size']) ? sanitize_text_field($REQ['event_list_grid_size']) : 'medium';
788 788
 		$CFG->EED_Events_Archive_Filters->templates = array(
789
-				'full'  => EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php'
789
+				'full'  => EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events.php'
790 790
 			);
791 791
 
792
-		switch ( $CFG->EED_Events_Archive_Filters->default_type ) {
792
+		switch ($CFG->EED_Events_Archive_Filters->default_type) {
793 793
 			case 'dates' :
794
-					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-dates-view.php';
794
+					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-dates-view.php';
795 795
 				break;
796 796
 			case 'text' :
797
-					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-text-view.php';
797
+					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-text-view.php';
798 798
 				break;
799 799
 			default :
800
-					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-grid-view.php';
800
+					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-grid-view.php';
801 801
 		}
802 802
 
803
-		$CFG->EED_Events_Archive_Filters = isset( $REQ['reset_event_list_settings'] ) && absint( $REQ['reset_event_list_settings'] ) == 1 ? new EE_Events_Archive_Config() : $CFG->EED_Events_Archive_Filters;
803
+		$CFG->EED_Events_Archive_Filters = isset($REQ['reset_event_list_settings']) && absint($REQ['reset_event_list_settings']) == 1 ? new EE_Events_Archive_Config() : $CFG->EED_Events_Archive_Filters;
804 804
 		return $CFG;
805 805
 	}
806 806
 
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 	 *  @return 	void
816 816
 	 */
817 817
 	public static function get_template_part() {
818
-		switch ( self::$_type ) {
818
+		switch (self::$_type) {
819 819
 			case 'dates' :
820 820
 					return 'archive-espresso_events-dates-view.php';
821 821
 				break;
@@ -839,13 +839,13 @@  discard block
 block discarded – undo
839 839
 	 */
840 840
 	public function event_list_template_filters() {
841 841
 		$args = array(
842
-			'form_url' => get_post_type_archive_link( 'espresso_events' ), //add_query_arg( array( 'post_type' => 'espresso_events' ), home_url() ),
842
+			'form_url' => get_post_type_archive_link('espresso_events'), //add_query_arg( array( 'post_type' => 'espresso_events' ), home_url() ),
843 843
 			'elf_month' => EED_Events_Archive_Filters::_display_month(),
844 844
 			'elf_category' => EED_Events_Archive_Filters::_event_category_slug(),
845 845
 			'elf_show_expired' => EED_Events_Archive_Filters::_show_expired(),
846 846
 			'elf_type' => self::$_type
847 847
 		);
848
-		EEH_Template::display_template( EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-filters.php', $args );
848
+		EEH_Template::display_template(EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-filters.php', $args);
849 849
 	}
850 850
 
851 851
 
@@ -858,16 +858,16 @@  discard block
 block discarded – undo
858 858
 	 *  @access 	public
859 859
 	 *  @return 	void
860 860
 	 */
861
-	public static function event_list_css( $extra_class = '' ) {
861
+	public static function event_list_css($extra_class = '') {
862 862
 		$EE = EE_Registry::instance();
863
-		$event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array();
863
+		$event_list_css = ! empty($extra_class) ? array($extra_class) : array();
864 864
 		$event_list_css[] = 'espresso-event-list-event';
865
-		if ( self::$_type == 'grid' ) {
866
-			$event_list_grid_size = isset( $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size ) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium';
867
-			$event_list_css[] = $event_list_grid_size . '-event-list-grid';
865
+		if (self::$_type == 'grid') {
866
+			$event_list_grid_size = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium';
867
+			$event_list_css[] = $event_list_grid_size.'-event-list-grid';
868 868
 		}
869
-		$event_list_css = apply_filters( 'EED_Events_Archive_Filters__event_list_css__event_list_css_array', $event_list_css );
870
-		return implode( ' ', $event_list_css );
869
+		$event_list_css = apply_filters('EED_Events_Archive_Filters__event_list_css__event_list_css_array', $event_list_css);
870
+		return implode(' ', $event_list_css);
871 871
 	}
872 872
 
873 873
 
@@ -893,9 +893,9 @@  discard block
 block discarded – undo
893 893
 	 *  @access 	public
894 894
 	 *  @return 	void
895 895
 	 */
896
-	public static function display_description( $value ) {
896
+	public static function display_description($value) {
897 897
 		$EE = EE_Registry::instance();
898
-		$display_description= isset( $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description ) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description : 1;
898
+		$display_description = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_description) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description : 1;
899 899
 		return $display_description === $value ? TRUE : FALSE;
900 900
 	}
901 901
 
@@ -909,9 +909,9 @@  discard block
 block discarded – undo
909 909
 	 */
910 910
 	public static function display_venue_details() {
911 911
 		$EE = EE_Registry::instance();
912
-		$display_venue_details= isset( $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details ) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details : TRUE;
912
+		$display_venue_details = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details : TRUE;
913 913
 		$venue_name = EEH_Venue_View::venue_name();
914
-		return $display_venue_details && ! empty( $venue_name ) ? TRUE : FALSE;
914
+		return $display_venue_details && ! empty($venue_name) ? TRUE : FALSE;
915 915
 	}
916 916
 
917 917
 
@@ -923,9 +923,9 @@  discard block
 block discarded – undo
923 923
 	 */
924 924
 	public static function display_address() {
925 925
 		$EE = EE_Registry::instance();
926
-		$display_address= isset( $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address ) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address : FALSE;
926
+		$display_address = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_address) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address : FALSE;
927 927
 		$venue_name = EEH_Venue_View::venue_name();
928
-		return $display_address && ! empty( $venue_name ) ? TRUE : FALSE;
928
+		return $display_address && ! empty($venue_name) ? TRUE : FALSE;
929 929
 	}
930 930
 
931 931
 
@@ -939,22 +939,22 @@  discard block
 block discarded – undo
939 939
 	public static function pagination() {
940 940
 		global $wp_query;
941 941
 		$big = 999999999; // need an unlikely integer
942
-		$pagination = paginate_links( array(
943
-			'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
942
+		$pagination = paginate_links(array(
943
+			'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
944 944
 			'format' => '?paged=%#%',
945
-			'current' => max( 1, get_query_var('paged') ),
945
+			'current' => max(1, get_query_var('paged')),
946 946
 			'total' => $wp_query->max_num_pages,
947 947
 			'show_all'     => TRUE,
948 948
 			'end_size'     => 10,
949 949
 			'mid_size'     => 6,
950 950
 			'prev_next'    => TRUE,
951
-			'prev_text'    => __( '&lsaquo; PREV', 'event_espresso' ),
952
-			'next_text'    => __( 'NEXT &rsaquo;', 'event_espresso' ),
951
+			'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
952
+			'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
953 953
 			'type'         => 'plain',
954 954
 			'add_args'     => FALSE,
955 955
 			'add_fragment' => ''
956 956
 		));
957
-		return ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
957
+		return ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : '';
958 958
 	}
959 959
 
960 960
 
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 	 *  @return 	void
969 969
 	 */
970 970
 	public static function event_list_title() {
971
-		return apply_filters( 'EED_Events_Archive_Filters__event_list_title__event_list_title', __( 'Upcoming Events', 'event_espresso' ));
971
+		return apply_filters('EED_Events_Archive_Filters__event_list_title__event_list_title', __('Upcoming Events', 'event_espresso'));
972 972
 	}
973 973
 
974 974
 
Please login to merge, or discard this patch.