Completed
Branch FET-10416-autoload-b4-bootstra... (42a01c)
by
unknown
13:17
created
help_tours/Registration_Form_Questions_Overview_Help_Tour.class.php 1 patch
Spacing   +11 added lines, -11 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
 /**
@@ -116,42 +116,42 @@  discard block
 block discarded – undo
116 116
 
117 117
 
118 118
 	protected function _start() {
119
-		$content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>';
120
-		$content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', 'event_espresso') . '</p>';
119
+		$content = '<h3>'.__('Questions Overview', 'event_espresso').'</h3>';
120
+		$content .= '<p>'.__('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', 'event_espresso').'</p>';
121 121
 
122 122
 		return $content;
123 123
 	}
124 124
 
125 125
 	protected function _display_text_stop() {
126
-		return '<p>' . __('View available questions.', 'event_espresso') . '</p>';
126
+		return '<p>'.__('View available questions.', 'event_espresso').'</p>';
127 127
 	}
128 128
 
129 129
 	protected function _admin_label_stop() {
130
-		return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>';
130
+		return '<p>'.__('View the admin label for your questions.', 'event_espresso').'</p>';
131 131
 	}
132 132
 
133 133
 	protected function _type_stop() {
134
-		return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', 'event_espresso') . '</p>';
134
+		return '<p>'.__('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', 'event_espresso').'</p>';
135 135
 	}
136 136
 
137 137
 	protected function _values_stop() {
138
-		return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', 'event_espresso') . '</p>';
138
+		return '<p>'.__('View stored values for checkboxes, radio buttons, and select boxes.', 'event_espresso').'</p>';
139 139
 	}
140 140
 
141 141
 	protected function _required_stop() {
142
-		return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>';
142
+		return '<p>'.__('View if a question is required.', 'event_espresso').'</p>';
143 143
 	}
144 144
 
145 145
 	protected function _bulk_actions_stop() {
146
-		return '<p>' . __('Perform bulk actions to multiple questions.', 'event_espresso') . '</p>';
146
+		return '<p>'.__('Perform bulk actions to multiple questions.', 'event_espresso').'</p>';
147 147
 	}
148 148
 
149 149
 	protected function _search_stop() {
150
-		return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', 'event_espresso') . '</p>';
150
+		return '<p>'.__('Search through questions. The following sources will be searched: Name of Question (display text).', 'event_espresso').'</p>';
151 151
 	}
152 152
 
153 153
 	protected function _add_new_question_stop() {
154
-		return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>';
154
+		return '<p>'.__('Click here to add a new question.', 'event_espresso').'</p>';
155 155
 	}
156 156
 
157 157
 }
158 158
\ No newline at end of file
Please login to merge, or discard this patch.
help_tours/Registration_Form_Questions_Overview_Help_Tour.class.php 2 patches
Indentation   +117 added lines, -117 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
 /**
@@ -18,64 +18,64 @@  discard block
 block discarded – undo
18 18
 class Registration_Form_Questions_Overview_Help_Tour extends EE_Help_Tour
19 19
 {
20 20
     
21
-    protected function _set_tour_properties()
22
-    {
23
-        $this->_label = __('Questions Overview Tour', 'event_espresso');
24
-        $this->_slug  = $this->_is_caf ? 'questions-overview-caf-joyride' : 'questions-overview-joyride';
25
-    }
21
+	protected function _set_tour_properties()
22
+	{
23
+		$this->_label = __('Questions Overview Tour', 'event_espresso');
24
+		$this->_slug  = $this->_is_caf ? 'questions-overview-caf-joyride' : 'questions-overview-joyride';
25
+	}
26 26
     
27
-    protected function _set_tour_stops()
28
-    {
29
-        $this->_stops = array(
30
-            10  => array(
31
-                'content' => $this->_start(),
32
-            ),
33
-            30  => array(
34
-                'id'      => 'display_text',
35
-                'content' => $this->_display_text_stop(),
36
-                'options' => array(
37
-                    'tipLocation'    => 'top',
38
-                    'tipAdjustmentX' => -5,
39
-                    'tipAdjustmentY' => -25
40
-                )
41
-            ),
42
-            40  => array(
43
-                'id'      => 'admin_label',
44
-                'content' => $this->_admin_label_stop(),
45
-                'options' => array(
46
-                    'tipLocation'    => 'top',
47
-                    'tipAdjustmentX' => 20,
48
-                    'tipAdjustmentY' => -25
49
-                )
50
-            ),
51
-            50  => array(
52
-                'id'      => 'type',
53
-                'content' => $this->_type_stop(),
54
-                'options' => array(
55
-                    'tipLocation'    => 'top',
56
-                    'tipAdjustmentX' => -5,
57
-                    'tipAdjustmentY' => -25
58
-                )
59
-            ),
60
-            60  => array(
61
-                'id'      => 'values',
62
-                'content' => $this->_values_stop(),
63
-                'options' => array(
64
-                    'tipLocation'    => 'top',
65
-                    'tipAdjustmentX' => -5,
66
-                    'tipAdjustmentY' => -25
67
-                )
68
-            ),
69
-            70  => array(
70
-                'id'      => 'required',
71
-                'content' => $this->_required_stop(),
72
-                'options' => array(
73
-                    'tipLocation'    => 'top',
74
-                    'tipAdjustmentY' => -20,
75
-                    'tipAdjustmentX' => -15
76
-                )
77
-            ),
78
-            /*80 => array(
27
+	protected function _set_tour_stops()
28
+	{
29
+		$this->_stops = array(
30
+			10  => array(
31
+				'content' => $this->_start(),
32
+			),
33
+			30  => array(
34
+				'id'      => 'display_text',
35
+				'content' => $this->_display_text_stop(),
36
+				'options' => array(
37
+					'tipLocation'    => 'top',
38
+					'tipAdjustmentX' => -5,
39
+					'tipAdjustmentY' => -25
40
+				)
41
+			),
42
+			40  => array(
43
+				'id'      => 'admin_label',
44
+				'content' => $this->_admin_label_stop(),
45
+				'options' => array(
46
+					'tipLocation'    => 'top',
47
+					'tipAdjustmentX' => 20,
48
+					'tipAdjustmentY' => -25
49
+				)
50
+			),
51
+			50  => array(
52
+				'id'      => 'type',
53
+				'content' => $this->_type_stop(),
54
+				'options' => array(
55
+					'tipLocation'    => 'top',
56
+					'tipAdjustmentX' => -5,
57
+					'tipAdjustmentY' => -25
58
+				)
59
+			),
60
+			60  => array(
61
+				'id'      => 'values',
62
+				'content' => $this->_values_stop(),
63
+				'options' => array(
64
+					'tipLocation'    => 'top',
65
+					'tipAdjustmentX' => -5,
66
+					'tipAdjustmentY' => -25
67
+				)
68
+			),
69
+			70  => array(
70
+				'id'      => 'required',
71
+				'content' => $this->_required_stop(),
72
+				'options' => array(
73
+					'tipLocation'    => 'top',
74
+					'tipAdjustmentY' => -20,
75
+					'tipAdjustmentX' => -15
76
+				)
77
+			),
78
+			/*80 => array(
79 79
                 'class' => 'bulkactions',
80 80
                 'content' => $this->_bulk_actions_stop(),
81 81
                 'options' => array(
@@ -84,77 +84,77 @@  discard block
 block discarded – undo
84 84
                     'tipAdjustmentX' => -15
85 85
                     )
86 86
                 ),*/
87
-            90  => array(
88
-                'id'      => 'event-espresso_page_espresso_registration_form-search-input',
89
-                'content' => $this->_search_stop(),
90
-                'options' => array(
91
-                    'tipLocation'    => 'left',
92
-                    'tipAdjustmentY' => -50,
93
-                    'tipAdjustmentX' => -15
94
-                )
95
-            ),
96
-            100 => array(
97
-                'id'      => 'add-new-question',
98
-                'content' => $this->_add_new_question_stop(),
99
-                'options' => array(
100
-                    'tipLocation'    => 'right',
101
-                    'tipAdjustmentY' => -50,
102
-                    'tipAdjustmentX' => 15
103
-                )
104
-            ),
105
-        );
106
-    }
87
+			90  => array(
88
+				'id'      => 'event-espresso_page_espresso_registration_form-search-input',
89
+				'content' => $this->_search_stop(),
90
+				'options' => array(
91
+					'tipLocation'    => 'left',
92
+					'tipAdjustmentY' => -50,
93
+					'tipAdjustmentX' => -15
94
+				)
95
+			),
96
+			100 => array(
97
+				'id'      => 'add-new-question',
98
+				'content' => $this->_add_new_question_stop(),
99
+				'options' => array(
100
+					'tipLocation'    => 'right',
101
+					'tipAdjustmentY' => -50,
102
+					'tipAdjustmentX' => 15
103
+				)
104
+			),
105
+		);
106
+	}
107 107
     
108 108
     
109
-    protected function _start()
110
-    {
111
-        $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>';
112
-        $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.',
113
-                'event_espresso') . '</p>';
109
+	protected function _start()
110
+	{
111
+		$content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>';
112
+		$content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.',
113
+				'event_espresso') . '</p>';
114 114
         
115
-        return $content;
116
-    }
115
+		return $content;
116
+	}
117 117
     
118
-    protected function _display_text_stop()
119
-    {
120
-        return '<p>' . __('View available questions.', 'event_espresso') . '</p>';
121
-    }
118
+	protected function _display_text_stop()
119
+	{
120
+		return '<p>' . __('View available questions.', 'event_espresso') . '</p>';
121
+	}
122 122
     
123
-    protected function _admin_label_stop()
124
-    {
125
-        return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>';
126
-    }
123
+	protected function _admin_label_stop()
124
+	{
125
+		return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>';
126
+	}
127 127
     
128
-    protected function _type_stop()
129
-    {
130
-        return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.',
131
-            'event_espresso') . '</p>';
132
-    }
128
+	protected function _type_stop()
129
+	{
130
+		return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.',
131
+			'event_espresso') . '</p>';
132
+	}
133 133
     
134
-    protected function _values_stop()
135
-    {
136
-        return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.',
137
-            'event_espresso') . '</p>';
138
-    }
134
+	protected function _values_stop()
135
+	{
136
+		return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.',
137
+			'event_espresso') . '</p>';
138
+	}
139 139
     
140
-    protected function _required_stop()
141
-    {
142
-        return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>';
143
-    }
140
+	protected function _required_stop()
141
+	{
142
+		return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>';
143
+	}
144 144
     
145
-    /* protected function _bulk_actions_stop() {
145
+	/* protected function _bulk_actions_stop() {
146 146
         return '<p>' . __('Perform bulk actions to multiple questions.', 'event_espresso') . '</p>';
147 147
     } */
148 148
     
149
-    protected function _search_stop()
150
-    {
151
-        return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).',
152
-            'event_espresso') . '</p>';
153
-    }
149
+	protected function _search_stop()
150
+	{
151
+		return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).',
152
+			'event_espresso') . '</p>';
153
+	}
154 154
     
155
-    protected function _add_new_question_stop()
156
-    {
157
-        return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>';
158
-    }
155
+	protected function _add_new_question_stop()
156
+	{
157
+		return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>';
158
+	}
159 159
     
160 160
 }
161 161
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -108,38 +108,38 @@  discard block
 block discarded – undo
108 108
     
109 109
     protected function _start()
110 110
     {
111
-        $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>';
112
-        $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.',
113
-                'event_espresso') . '</p>';
111
+        $content = '<h3>'.__('Questions Overview', 'event_espresso').'</h3>';
112
+        $content .= '<p>'.__('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.',
113
+                'event_espresso').'</p>';
114 114
         
115 115
         return $content;
116 116
     }
117 117
     
118 118
     protected function _display_text_stop()
119 119
     {
120
-        return '<p>' . __('View available questions.', 'event_espresso') . '</p>';
120
+        return '<p>'.__('View available questions.', 'event_espresso').'</p>';
121 121
     }
122 122
     
123 123
     protected function _admin_label_stop()
124 124
     {
125
-        return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>';
125
+        return '<p>'.__('View the admin label for your questions.', 'event_espresso').'</p>';
126 126
     }
127 127
     
128 128
     protected function _type_stop()
129 129
     {
130
-        return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.',
131
-            'event_espresso') . '</p>';
130
+        return '<p>'.__('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.',
131
+            'event_espresso').'</p>';
132 132
     }
133 133
     
134 134
     protected function _values_stop()
135 135
     {
136
-        return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.',
137
-            'event_espresso') . '</p>';
136
+        return '<p>'.__('View stored values for checkboxes, radio buttons, and select boxes.',
137
+            'event_espresso').'</p>';
138 138
     }
139 139
     
140 140
     protected function _required_stop()
141 141
     {
142
-        return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>';
142
+        return '<p>'.__('View if a question is required.', 'event_espresso').'</p>';
143 143
     }
144 144
     
145 145
     /* protected function _bulk_actions_stop() {
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
     
149 149
     protected function _search_stop()
150 150
     {
151
-        return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).',
152
-            'event_espresso') . '</p>';
151
+        return '<p>'.__('Search through questions. The following sources will be searched: Name of Question (display text).',
152
+            'event_espresso').'</p>';
153 153
     }
154 154
     
155 155
     protected function _add_new_question_stop()
156 156
     {
157
-        return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>';
157
+        return '<p>'.__('Click here to add a new question.', 'event_espresso').'</p>';
158 158
     }
159 159
     
160 160
 }
161 161
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/EEM_Transaction.model.php 2 patches
Spacing   +14 added lines, -14 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
  *
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                     __('Registration Steps', 'event_espresso'), false, array()),
106 106
             )
107 107
         );
108
-        $this->_model_relations        = array(
108
+        $this->_model_relations = array(
109 109
             'Registration'   => new EE_Has_Many_Relation(),
110 110
             'Payment'        => new EE_Has_Many_Relation(),
111 111
             'Status'         => new EE_Belongs_To_Relation(),
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             ),
168 168
             OBJECT,
169 169
             array(
170
-                'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
170
+                'txnDate' => array('DATE('.$query_interval.')', '%s'),
171 171
                 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
172 172
             )
173 173
         );
@@ -187,17 +187,17 @@  discard block
 block discarded – undo
187 187
     public function get_revenue_per_event_report($period = '-1 month')
188 188
     {
189 189
         global $wpdb;
190
-        $transaction_table          = $wpdb->prefix . 'esp_transaction';
191
-        $registration_table         = $wpdb->prefix . 'esp_registration';
192
-        $registration_payment_table = $wpdb->prefix . 'esp_registration_payment';
190
+        $transaction_table          = $wpdb->prefix.'esp_transaction';
191
+        $registration_table         = $wpdb->prefix.'esp_registration';
192
+        $registration_payment_table = $wpdb->prefix.'esp_registration_payment';
193 193
         $event_table                = $wpdb->posts;
194
-        $payment_table              = $wpdb->prefix . 'esp_payment';
194
+        $payment_table              = $wpdb->prefix.'esp_payment';
195 195
         $sql_date                   = date('Y-m-d H:i:s', strtotime($period));
196 196
         $approved_payment_status    = EEM_Payment::status_id_approved;
197 197
         $extra_event_on_join        = '';
198 198
         //exclude events not authored by user if permissions in effect
199 199
         if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
200
-            $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
200
+            $extra_event_on_join = ' AND Event.post_author = '.get_current_user_id();
201 201
         }
202 202
         
203 203
         return $wpdb->get_results(
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
269 269
     {
270 270
         EE_Error::doing_it_wrong(
271
-            __CLASS__ . '::' . __FUNCTION__,
271
+            __CLASS__.'::'.__FUNCTION__,
272 272
             sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
273 273
                 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
274 274
             '4.6.0'
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
             array(
317 317
                 0 => array(
318 318
                     'STS_ID'        => EEM_Transaction::failed_status_code,
319
-                    'Payment.PAY_ID' => array( 'IS NULL' ),
319
+                    'Payment.PAY_ID' => array('IS NULL'),
320 320
                     'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
321 321
                 )
322 322
             ),
@@ -334,18 +334,18 @@  discard block
 block discarded – undo
334 334
             $time_to_leave_alone
335 335
         );
336 336
         //now that we have the ids to delete
337
-        if (! empty($txn_ids) && is_array($txn_ids)) {
337
+        if ( ! empty($txn_ids) && is_array($txn_ids)) {
338 338
             // first, make sure these TXN's are removed the "ee_locked_transactions" array
339 339
             EEM_Transaction::unset_locked_transactions($txn_ids);
340 340
             // let's get deletin'...
341 341
             // Why no wpdb->prepare?  Because the data is trusted.
342 342
             // We got the ids from the original query to get them FROM
343 343
             // the db (which is sanitized) so no need to prepare them again.
344
-            $query   = '
344
+            $query = '
345 345
 				DELETE
346
-				FROM ' . $this->table() . '
346
+				FROM ' . $this->table().'
347 347
 				WHERE
348
-					TXN_ID IN ( ' . implode(",", $txn_ids) . ')';
348
+					TXN_ID IN ( ' . implode(",", $txn_ids).')';
349 349
             $deleted = $wpdb->query($query);
350 350
         }
351 351
         if ($deleted) {
Please login to merge, or discard this patch.
Indentation   +363 added lines, -363 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,193 +15,193 @@  discard block
 block discarded – undo
15 15
 class EEM_Transaction extends EEM_Base
16 16
 {
17 17
 
18
-    // private instance of the Transaction object
19
-    protected static $_instance;
20
-
21
-    /**
22
-     * Status ID(STS_ID on esp_status table) to indicate the transaction is complete,
23
-     * but payment is pending. This is the state for transactions where payment is promised
24
-     * from an offline gateway.
25
-     */
26
-    //	const open_status_code = 'TPN';
27
-
28
-    /**
29
-     * Status ID(STS_ID on esp_status table) to indicate the transaction failed,
30
-     * either due to a technical reason (server or computer crash during registration),
31
-     *  or some other reason that prevent the collection of any useful contact information from any of the registrants
32
-     */
33
-    const failed_status_code = 'TFL';
34
-
35
-    /**
36
-     * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned,
37
-     * either due to a technical reason (server or computer crash during registration),
38
-     * or due to an abandoned cart after registrant chose not to complete the registration process
39
-     * HOWEVER...
40
-     * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one
41
-     * registrant
42
-     */
43
-    const abandoned_status_code = 'TAB';
44
-
45
-    /**
46
-     * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction,
47
-     * meaning that monies are still owing: TXN_paid < TXN_total
48
-     */
49
-    const incomplete_status_code = 'TIN';
50
-
51
-    /**
52
-     * Status ID (STS_ID on esp_status table) to indicate a complete transaction.
53
-     * meaning that NO monies are owing: TXN_paid == TXN_total
54
-     */
55
-    const complete_status_code = 'TCM';
56
-
57
-    /**
58
-     *  Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid.
59
-     *  This is the same as complete, but site admins actually owe clients the moneys!  TXN_paid > TXN_total
60
-     */
61
-    const overpaid_status_code = 'TOP';
62
-
63
-
64
-    /**
65
-     *    private constructor to prevent direct creation
66
-     *
67
-     * @Constructor
68
-     * @access protected
69
-     *
70
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
71
-     *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
72
-     *                         date time model field objects.  Default is NULL (and will be assumed using the set
73
-     *                         timezone in the 'timezone_string' wp option)
74
-     *
75
-     * @return EEM_Transaction
76
-     * @throws \EE_Error
77
-     */
78
-    protected function __construct($timezone)
79
-    {
80
-        $this->singular_item = __('Transaction', 'event_espresso');
81
-        $this->plural_item   = __('Transactions', 'event_espresso');
82
-
83
-        $this->_tables                 = array(
84
-            'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID')
85
-        );
86
-        $this->_fields                 = array(
87
-            'TransactionTable' => array(
88
-                'TXN_ID'           => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
89
-                'TXN_timestamp'    => new EE_Datetime_Field('TXN_timestamp',
90
-                    __('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now,
91
-                    $timezone),
92
-                'TXN_total'        => new EE_Money_Field('TXN_total',
93
-                    __('Total value of Transaction', 'event_espresso'), false, 0),
94
-                'TXN_paid'         => new EE_Money_Field('TXN_paid',
95
-                    __('Amount paid towards transaction to date', 'event_espresso'), false, 0),
96
-                'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
97
-                    false, EEM_Transaction::failed_status_code, 'Status'),
98
-                'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data',
99
-                    __('Serialized session data', 'event_espresso'), true, ''),
100
-                'TXN_hash_salt'    => new EE_Plain_Text_Field('TXN_hash_salt',
101
-                    __('Transaction Hash Salt', 'event_espresso'), true, ''),
102
-                'PMD_ID'           => new EE_Foreign_Key_Int_Field('PMD_ID',
103
-                    __("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'),
104
-                'TXN_reg_steps'    => new EE_Serialized_Text_Field('TXN_reg_steps',
105
-                    __('Registration Steps', 'event_espresso'), false, array()),
106
-            )
107
-        );
108
-        $this->_model_relations        = array(
109
-            'Registration'   => new EE_Has_Many_Relation(),
110
-            'Payment'        => new EE_Has_Many_Relation(),
111
-            'Status'         => new EE_Belongs_To_Relation(),
112
-            'Line_Item'      => new EE_Has_Many_Relation(false),
113
-            //you can delete a transaction without needing to delete its line items
114
-            'Payment_Method' => new EE_Belongs_To_Relation(),
115
-            'Message'        => new EE_Has_Many_Relation()
116
-        );
117
-        $this->_model_chain_to_wp_user = 'Registration.Event';
118
-        parent::__construct($timezone);
119
-
120
-    }
121
-
122
-
123
-    /**
124
-     *    txn_status_array
125
-     * get list of transaction statuses
126
-     *
127
-     * @access public
128
-     * @return array
129
-     */
130
-    public static function txn_status_array()
131
-    {
132
-        return apply_filters(
133
-            'FHEE__EEM_Transaction__txn_status_array',
134
-            array(
135
-                EEM_Transaction::overpaid_status_code,
136
-                EEM_Transaction::complete_status_code,
137
-                EEM_Transaction::incomplete_status_code,
138
-                EEM_Transaction::abandoned_status_code,
139
-                EEM_Transaction::failed_status_code,
140
-            )
141
-        );
142
-    }
143
-
144
-    /**
145
-     *        get the revenue per day  for the Transaction Admin page Reports Tab
146
-     *
147
-     * @access        public
148
-     *
149
-     * @param string $period
150
-     *
151
-     * @return \stdClass[]
152
-     */
153
-    public function get_revenue_per_day_report($period = '-1 month')
154
-    {
155
-        $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)),
156
-            'Y-m-d H:i:s', 'UTC');
157
-
158
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
159
-
160
-        return $this->_get_all_wpdb_results(
161
-            array(
162
-                array(
163
-                    'TXN_timestamp' => array('>=', $sql_date)
164
-                ),
165
-                'group_by' => 'txnDate',
166
-                'order_by' => array('TXN_timestamp' => 'ASC')
167
-            ),
168
-            OBJECT,
169
-            array(
170
-                'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
171
-                'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
172
-            )
173
-        );
174
-    }
175
-
176
-
177
-    /**
178
-     *        get the revenue per event  for the Transaction Admin page Reports Tab
179
-     *
180
-     * @access        public
181
-     *
182
-     * @param string $period
183
-     *
184
-     * @throws \EE_Error
185
-     * @return mixed
186
-     */
187
-    public function get_revenue_per_event_report($period = '-1 month')
188
-    {
189
-        global $wpdb;
190
-        $transaction_table          = $wpdb->prefix . 'esp_transaction';
191
-        $registration_table         = $wpdb->prefix . 'esp_registration';
192
-        $registration_payment_table = $wpdb->prefix . 'esp_registration_payment';
193
-        $event_table                = $wpdb->posts;
194
-        $payment_table              = $wpdb->prefix . 'esp_payment';
195
-        $sql_date                   = date('Y-m-d H:i:s', strtotime($period));
196
-        $approved_payment_status    = EEM_Payment::status_id_approved;
197
-        $extra_event_on_join        = '';
198
-        //exclude events not authored by user if permissions in effect
199
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
200
-            $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
201
-        }
202
-
203
-        return $wpdb->get_results(
204
-            "SELECT
18
+	// private instance of the Transaction object
19
+	protected static $_instance;
20
+
21
+	/**
22
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction is complete,
23
+	 * but payment is pending. This is the state for transactions where payment is promised
24
+	 * from an offline gateway.
25
+	 */
26
+	//	const open_status_code = 'TPN';
27
+
28
+	/**
29
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction failed,
30
+	 * either due to a technical reason (server or computer crash during registration),
31
+	 *  or some other reason that prevent the collection of any useful contact information from any of the registrants
32
+	 */
33
+	const failed_status_code = 'TFL';
34
+
35
+	/**
36
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned,
37
+	 * either due to a technical reason (server or computer crash during registration),
38
+	 * or due to an abandoned cart after registrant chose not to complete the registration process
39
+	 * HOWEVER...
40
+	 * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one
41
+	 * registrant
42
+	 */
43
+	const abandoned_status_code = 'TAB';
44
+
45
+	/**
46
+	 * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction,
47
+	 * meaning that monies are still owing: TXN_paid < TXN_total
48
+	 */
49
+	const incomplete_status_code = 'TIN';
50
+
51
+	/**
52
+	 * Status ID (STS_ID on esp_status table) to indicate a complete transaction.
53
+	 * meaning that NO monies are owing: TXN_paid == TXN_total
54
+	 */
55
+	const complete_status_code = 'TCM';
56
+
57
+	/**
58
+	 *  Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid.
59
+	 *  This is the same as complete, but site admins actually owe clients the moneys!  TXN_paid > TXN_total
60
+	 */
61
+	const overpaid_status_code = 'TOP';
62
+
63
+
64
+	/**
65
+	 *    private constructor to prevent direct creation
66
+	 *
67
+	 * @Constructor
68
+	 * @access protected
69
+	 *
70
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
71
+	 *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
72
+	 *                         date time model field objects.  Default is NULL (and will be assumed using the set
73
+	 *                         timezone in the 'timezone_string' wp option)
74
+	 *
75
+	 * @return EEM_Transaction
76
+	 * @throws \EE_Error
77
+	 */
78
+	protected function __construct($timezone)
79
+	{
80
+		$this->singular_item = __('Transaction', 'event_espresso');
81
+		$this->plural_item   = __('Transactions', 'event_espresso');
82
+
83
+		$this->_tables                 = array(
84
+			'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID')
85
+		);
86
+		$this->_fields                 = array(
87
+			'TransactionTable' => array(
88
+				'TXN_ID'           => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
89
+				'TXN_timestamp'    => new EE_Datetime_Field('TXN_timestamp',
90
+					__('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now,
91
+					$timezone),
92
+				'TXN_total'        => new EE_Money_Field('TXN_total',
93
+					__('Total value of Transaction', 'event_espresso'), false, 0),
94
+				'TXN_paid'         => new EE_Money_Field('TXN_paid',
95
+					__('Amount paid towards transaction to date', 'event_espresso'), false, 0),
96
+				'STS_ID'           => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'),
97
+					false, EEM_Transaction::failed_status_code, 'Status'),
98
+				'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data',
99
+					__('Serialized session data', 'event_espresso'), true, ''),
100
+				'TXN_hash_salt'    => new EE_Plain_Text_Field('TXN_hash_salt',
101
+					__('Transaction Hash Salt', 'event_espresso'), true, ''),
102
+				'PMD_ID'           => new EE_Foreign_Key_Int_Field('PMD_ID',
103
+					__("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'),
104
+				'TXN_reg_steps'    => new EE_Serialized_Text_Field('TXN_reg_steps',
105
+					__('Registration Steps', 'event_espresso'), false, array()),
106
+			)
107
+		);
108
+		$this->_model_relations        = array(
109
+			'Registration'   => new EE_Has_Many_Relation(),
110
+			'Payment'        => new EE_Has_Many_Relation(),
111
+			'Status'         => new EE_Belongs_To_Relation(),
112
+			'Line_Item'      => new EE_Has_Many_Relation(false),
113
+			//you can delete a transaction without needing to delete its line items
114
+			'Payment_Method' => new EE_Belongs_To_Relation(),
115
+			'Message'        => new EE_Has_Many_Relation()
116
+		);
117
+		$this->_model_chain_to_wp_user = 'Registration.Event';
118
+		parent::__construct($timezone);
119
+
120
+	}
121
+
122
+
123
+	/**
124
+	 *    txn_status_array
125
+	 * get list of transaction statuses
126
+	 *
127
+	 * @access public
128
+	 * @return array
129
+	 */
130
+	public static function txn_status_array()
131
+	{
132
+		return apply_filters(
133
+			'FHEE__EEM_Transaction__txn_status_array',
134
+			array(
135
+				EEM_Transaction::overpaid_status_code,
136
+				EEM_Transaction::complete_status_code,
137
+				EEM_Transaction::incomplete_status_code,
138
+				EEM_Transaction::abandoned_status_code,
139
+				EEM_Transaction::failed_status_code,
140
+			)
141
+		);
142
+	}
143
+
144
+	/**
145
+	 *        get the revenue per day  for the Transaction Admin page Reports Tab
146
+	 *
147
+	 * @access        public
148
+	 *
149
+	 * @param string $period
150
+	 *
151
+	 * @return \stdClass[]
152
+	 */
153
+	public function get_revenue_per_day_report($period = '-1 month')
154
+	{
155
+		$sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)),
156
+			'Y-m-d H:i:s', 'UTC');
157
+
158
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
159
+
160
+		return $this->_get_all_wpdb_results(
161
+			array(
162
+				array(
163
+					'TXN_timestamp' => array('>=', $sql_date)
164
+				),
165
+				'group_by' => 'txnDate',
166
+				'order_by' => array('TXN_timestamp' => 'ASC')
167
+			),
168
+			OBJECT,
169
+			array(
170
+				'txnDate' => array('DATE(' . $query_interval . ')', '%s'),
171
+				'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d')
172
+			)
173
+		);
174
+	}
175
+
176
+
177
+	/**
178
+	 *        get the revenue per event  for the Transaction Admin page Reports Tab
179
+	 *
180
+	 * @access        public
181
+	 *
182
+	 * @param string $period
183
+	 *
184
+	 * @throws \EE_Error
185
+	 * @return mixed
186
+	 */
187
+	public function get_revenue_per_event_report($period = '-1 month')
188
+	{
189
+		global $wpdb;
190
+		$transaction_table          = $wpdb->prefix . 'esp_transaction';
191
+		$registration_table         = $wpdb->prefix . 'esp_registration';
192
+		$registration_payment_table = $wpdb->prefix . 'esp_registration_payment';
193
+		$event_table                = $wpdb->posts;
194
+		$payment_table              = $wpdb->prefix . 'esp_payment';
195
+		$sql_date                   = date('Y-m-d H:i:s', strtotime($period));
196
+		$approved_payment_status    = EEM_Payment::status_id_approved;
197
+		$extra_event_on_join        = '';
198
+		//exclude events not authored by user if permissions in effect
199
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
200
+			$extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
201
+		}
202
+
203
+		return $wpdb->get_results(
204
+			"SELECT
205 205
 			Transaction_Event.event_name AS event_name,
206 206
 			SUM(Transaction_Event.paid) AS revenue
207 207
 			FROM
@@ -228,185 +228,185 @@  discard block
 block discarded – undo
228 228
 					$extra_event_on_join
229 229
 				) AS Transaction_Event
230 230
 			GROUP BY event_name",
231
-            OBJECT
232
-        );
233
-    }
234
-
235
-
236
-    /**
237
-     * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the
238
-     * $_REQUEST global variable. Either way, tries to find the current transaction (through
239
-     * the registration pointed to by reg_url_link), if not returns null
240
-     *
241
-     * @param string $reg_url_link
242
-     *
243
-     * @return EE_Transaction
244
-     */
245
-    public function get_transaction_from_reg_url_link($reg_url_link = '')
246
-    {
247
-        return $this->get_one(array(
248
-            array(
249
-                'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link',
250
-                    '')
251
-            )
252
-        ));
253
-    }
254
-
255
-
256
-    /**
257
-     * Updates the provided EE_Transaction with all the applicable payments
258
-     * (or fetch the EE_Transaction from its ID)
259
-     *
260
-     * @deprecated
261
-     *
262
-     * @param EE_Transaction|int $transaction_obj_or_id
263
-     * @param boolean            $save_txn whether or not to save the transaction during this function call
264
-     *
265
-     * @return boolean
266
-     * @throws \EE_Error
267
-     */
268
-    public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
269
-    {
270
-        EE_Error::doing_it_wrong(
271
-            __CLASS__ . '::' . __FUNCTION__,
272
-            sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
273
-                'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
274
-            '4.6.0'
275
-        );
276
-        /** @type EE_Transaction_Processor $transaction_processor */
277
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
278
-
279
-        return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
280
-            $this->ensure_is_obj($transaction_obj_or_id)
281
-        );
282
-    }
283
-
284
-    /**
285
-     * Deletes "junk" transactions that were probably added by bots. There might be TONS
286
-     * of these, so we are very careful to NOT select (which the models do even when deleting),
287
-     * and so we only use wpdb directly and only do minimal joins.
288
-     * Transactions are considered "junk" if they're failed for longer than a week.
289
-     * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on
290
-     * it, it's probably not junk (regardless of what status it has).
291
-     * The downside to this approach is that is addons are listening for object deletions
292
-     * on EEM_Base::delete() they won't be notified of this.  However, there is an action that plugins can hook into
293
-     * to catch these types of deletions.
294
-     *
295
-     * @global WPDB $wpdb
296
-     * @return mixed
297
-     */
298
-    public function delete_junk_transactions()
299
-    {
300
-        /** @type WPDB $wpdb */
301
-        global $wpdb;
302
-        $deleted             = false;
303
-        $time_to_leave_alone = apply_filters(
304
-            'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone'
305
-            , WEEK_IN_SECONDS
306
-        );
307
-
308
-
309
-        /**
310
-         * This allows code to filter the query arguments used for retrieving the transaction IDs to delete.
311
-         * Useful for plugins that want to exclude transactions matching certain query parameters.
312
-         * The query parameters should be in the format accepted by the EEM_Base model queries.
313
-         */
314
-        $ids_query = apply_filters(
315
-            'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args',
316
-            array(
317
-                0 => array(
318
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
319
-                    'Payment.PAY_ID' => array( 'IS NULL' ),
320
-                    'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
321
-                )
322
-            ),
323
-            $time_to_leave_alone
324
-        );
325
-
326
-
327
-        /**
328
-         * This filter is for when code needs to filter the list of transaction ids that represent transactions
329
-         * about to be deleted based on some other criteria that isn't easily done via the query args filter.
330
-         */
331
-        $txn_ids = apply_filters(
332
-            'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
333
-            EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
334
-            $time_to_leave_alone
335
-        );
336
-        //now that we have the ids to delete
337
-        if (! empty($txn_ids) && is_array($txn_ids)) {
338
-            // first, make sure these TXN's are removed the "ee_locked_transactions" array
339
-            EEM_Transaction::unset_locked_transactions($txn_ids);
340
-            // let's get deletin'...
341
-            // Why no wpdb->prepare?  Because the data is trusted.
342
-            // We got the ids from the original query to get them FROM
343
-            // the db (which is sanitized) so no need to prepare them again.
344
-            $query   = '
231
+			OBJECT
232
+		);
233
+	}
234
+
235
+
236
+	/**
237
+	 * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the
238
+	 * $_REQUEST global variable. Either way, tries to find the current transaction (through
239
+	 * the registration pointed to by reg_url_link), if not returns null
240
+	 *
241
+	 * @param string $reg_url_link
242
+	 *
243
+	 * @return EE_Transaction
244
+	 */
245
+	public function get_transaction_from_reg_url_link($reg_url_link = '')
246
+	{
247
+		return $this->get_one(array(
248
+			array(
249
+				'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link',
250
+					'')
251
+			)
252
+		));
253
+	}
254
+
255
+
256
+	/**
257
+	 * Updates the provided EE_Transaction with all the applicable payments
258
+	 * (or fetch the EE_Transaction from its ID)
259
+	 *
260
+	 * @deprecated
261
+	 *
262
+	 * @param EE_Transaction|int $transaction_obj_or_id
263
+	 * @param boolean            $save_txn whether or not to save the transaction during this function call
264
+	 *
265
+	 * @return boolean
266
+	 * @throws \EE_Error
267
+	 */
268
+	public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
269
+	{
270
+		EE_Error::doing_it_wrong(
271
+			__CLASS__ . '::' . __FUNCTION__,
272
+			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
273
+				'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
274
+			'4.6.0'
275
+		);
276
+		/** @type EE_Transaction_Processor $transaction_processor */
277
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
278
+
279
+		return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
280
+			$this->ensure_is_obj($transaction_obj_or_id)
281
+		);
282
+	}
283
+
284
+	/**
285
+	 * Deletes "junk" transactions that were probably added by bots. There might be TONS
286
+	 * of these, so we are very careful to NOT select (which the models do even when deleting),
287
+	 * and so we only use wpdb directly and only do minimal joins.
288
+	 * Transactions are considered "junk" if they're failed for longer than a week.
289
+	 * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on
290
+	 * it, it's probably not junk (regardless of what status it has).
291
+	 * The downside to this approach is that is addons are listening for object deletions
292
+	 * on EEM_Base::delete() they won't be notified of this.  However, there is an action that plugins can hook into
293
+	 * to catch these types of deletions.
294
+	 *
295
+	 * @global WPDB $wpdb
296
+	 * @return mixed
297
+	 */
298
+	public function delete_junk_transactions()
299
+	{
300
+		/** @type WPDB $wpdb */
301
+		global $wpdb;
302
+		$deleted             = false;
303
+		$time_to_leave_alone = apply_filters(
304
+			'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone'
305
+			, WEEK_IN_SECONDS
306
+		);
307
+
308
+
309
+		/**
310
+		 * This allows code to filter the query arguments used for retrieving the transaction IDs to delete.
311
+		 * Useful for plugins that want to exclude transactions matching certain query parameters.
312
+		 * The query parameters should be in the format accepted by the EEM_Base model queries.
313
+		 */
314
+		$ids_query = apply_filters(
315
+			'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args',
316
+			array(
317
+				0 => array(
318
+					'STS_ID'        => EEM_Transaction::failed_status_code,
319
+					'Payment.PAY_ID' => array( 'IS NULL' ),
320
+					'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
321
+				)
322
+			),
323
+			$time_to_leave_alone
324
+		);
325
+
326
+
327
+		/**
328
+		 * This filter is for when code needs to filter the list of transaction ids that represent transactions
329
+		 * about to be deleted based on some other criteria that isn't easily done via the query args filter.
330
+		 */
331
+		$txn_ids = apply_filters(
332
+			'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
333
+			EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
334
+			$time_to_leave_alone
335
+		);
336
+		//now that we have the ids to delete
337
+		if (! empty($txn_ids) && is_array($txn_ids)) {
338
+			// first, make sure these TXN's are removed the "ee_locked_transactions" array
339
+			EEM_Transaction::unset_locked_transactions($txn_ids);
340
+			// let's get deletin'...
341
+			// Why no wpdb->prepare?  Because the data is trusted.
342
+			// We got the ids from the original query to get them FROM
343
+			// the db (which is sanitized) so no need to prepare them again.
344
+			$query   = '
345 345
 				DELETE
346 346
 				FROM ' . $this->table() . '
347 347
 				WHERE
348 348
 					TXN_ID IN ( ' . implode(",", $txn_ids) . ')';
349
-            $deleted = $wpdb->query($query);
350
-        }
351
-        if ($deleted) {
352
-            /**
353
-             * Allows code to do something after the transactions have been deleted.
354
-             */
355
-            do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
356
-        }
357
-
358
-        return $deleted;
359
-    }
360
-
361
-
362
-    /**
363
-     * @param array $transaction_IDs
364
-     *
365
-     * @return bool
366
-     */
367
-    public static function unset_locked_transactions(array $transaction_IDs)
368
-    {
369
-        $locked_transactions = get_option('ee_locked_transactions', array());
370
-        $update              = false;
371
-        foreach ($transaction_IDs as $TXN_ID) {
372
-            if (isset($locked_transactions[$TXN_ID])) {
373
-                unset($locked_transactions[$TXN_ID]);
374
-                $update = true;
375
-            }
376
-        }
377
-        if ($update) {
378
-            update_option('ee_locked_transactions', $locked_transactions);
379
-        }
380
-
381
-        return $update;
382
-    }
383
-
384
-
385
-
386
-    /**
387
-     * returns an array of EE_Transaction objects whose timestamp is less than
388
-     * the current time minus the session lifespan, which defaults to 60 minutes
389
-     *
390
-     * @return EE_Base_Class[]|EE_Transaction[]
391
-     * @throws \EE_Error
392
-     */
393
-    public function get_transactions_in_progress()
394
-    {
395
-        return $this->get_all(
396
-            array(
397
-                array(
398
-                    'TXN_timestamp' => array(
399
-                        '>',
400
-                        time() - EE_Registry::instance()->SSN->lifespan()
401
-                    ),
402
-                    'STS_ID' => array(
403
-                        '!=',
404
-                        EEM_Transaction::complete_status_code
405
-                    ),
406
-                )
407
-            )
408
-        );
409
-    }
349
+			$deleted = $wpdb->query($query);
350
+		}
351
+		if ($deleted) {
352
+			/**
353
+			 * Allows code to do something after the transactions have been deleted.
354
+			 */
355
+			do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
356
+		}
357
+
358
+		return $deleted;
359
+	}
360
+
361
+
362
+	/**
363
+	 * @param array $transaction_IDs
364
+	 *
365
+	 * @return bool
366
+	 */
367
+	public static function unset_locked_transactions(array $transaction_IDs)
368
+	{
369
+		$locked_transactions = get_option('ee_locked_transactions', array());
370
+		$update              = false;
371
+		foreach ($transaction_IDs as $TXN_ID) {
372
+			if (isset($locked_transactions[$TXN_ID])) {
373
+				unset($locked_transactions[$TXN_ID]);
374
+				$update = true;
375
+			}
376
+		}
377
+		if ($update) {
378
+			update_option('ee_locked_transactions', $locked_transactions);
379
+		}
380
+
381
+		return $update;
382
+	}
383
+
384
+
385
+
386
+	/**
387
+	 * returns an array of EE_Transaction objects whose timestamp is less than
388
+	 * the current time minus the session lifespan, which defaults to 60 minutes
389
+	 *
390
+	 * @return EE_Base_Class[]|EE_Transaction[]
391
+	 * @throws \EE_Error
392
+	 */
393
+	public function get_transactions_in_progress()
394
+	{
395
+		return $this->get_all(
396
+			array(
397
+				array(
398
+					'TXN_timestamp' => array(
399
+						'>',
400
+						time() - EE_Registry::instance()->SSN->lifespan()
401
+					),
402
+					'STS_ID' => array(
403
+						'!=',
404
+						EEM_Transaction::complete_status_code
405
+					),
406
+				)
407
+			)
408
+		);
409
+	}
410 410
 
411 411
 
412 412
 }
Please login to merge, or discard this patch.
core/EE_Request_Handler.core.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	 *    remove param
343 343
 	 *
344 344
 	 * @access    public
345
-	 * @param $key
345
+	 * @param string $key
346 346
 	 * @return    void
347 347
 	 */
348 348
 	public function un_set( $key ) {
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 	 *    add_output
383 383
 	 *
384 384
 	 * @access    public
385
-	 * @param $string
385
+	 * @param string $string
386 386
 	 * @return    void
387 387
 	 */
388 388
 	public function add_output( $string ) {
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 				if ( ! $this->get( 'post_name' ) ) {
239 239
 					// there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events
240 240
 					$post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] )
241
-                        ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ]
242
-                        : '';
241
+						? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ]
242
+						: '';
243 243
 					// if the post type matches on of our then set the endpoint
244 244
 					if ( $post_name ) {
245 245
 						$this->set( 'post_name', $post_name );
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @return    void
262 262
 	 */
263 263
 	public function set_espresso_page( $value = null ) {
264
-        $this->_params['is_espresso_page'] = ! empty($value) ? $value : $this->test_for_espresso_page();
264
+		$this->_params['is_espresso_page'] = ! empty($value) ? $value : $this->test_for_espresso_page();
265 265
 	}
266 266
 
267 267
 
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2 2
 /**
3 3
  * class EE_Request_Handler
4 4
  *
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 	 * @access public
50 50
 	 * @param  EE_Request $request
51 51
 	 */
52
-	public function __construct( EE_Request $request ) {
52
+	public function __construct(EE_Request $request) {
53 53
 		// grab request vars
54 54
 		$this->_params = $request->params();
55 55
 		// AJAX ???
56
-		$this->ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false;
57
-		$this->front_ajax = defined( 'EE_FRONT_AJAX' ) && EE_FRONT_AJAX ? true : false;
58
-		do_action( 'AHEE__EE_Request_Handler__construct__complete' );
56
+		$this->ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false;
57
+		$this->front_ajax = defined('EE_FRONT_AJAX') && EE_FRONT_AJAX ? true : false;
58
+		do_action('AHEE__EE_Request_Handler__construct__complete');
59 59
 	}
60 60
 
61 61
 
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 	 * @param WP $wp
68 68
 	 * @return void
69 69
 	 */
70
-	public function parse_request( $wp = null ) {
70
+	public function parse_request($wp = null) {
71 71
 		//if somebody forgot to provide us with WP, that's ok because its global
72
-		if ( ! $wp instanceof WP ) {
72
+		if ( ! $wp instanceof WP) {
73 73
 			global $wp;
74 74
 		}
75
-		$this->set_request_vars( $wp );
75
+		$this->set_request_vars($wp);
76 76
 	}
77 77
 
78 78
 
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 	 * @param WP $wp
85 85
 	 * @return void
86 86
 	 */
87
-	public function set_request_vars( $wp = null ) {
88
-		if ( ! is_admin() ) {
87
+	public function set_request_vars($wp = null) {
88
+		if ( ! is_admin()) {
89 89
 			// set request post_id
90
-			$this->set( 'post_id', $this->get_post_id_from_request( $wp ));
90
+			$this->set('post_id', $this->get_post_id_from_request($wp));
91 91
 			// set request post name
92
-			$this->set( 'post_name', $this->get_post_name_from_request( $wp ));
92
+			$this->set('post_name', $this->get_post_name_from_request($wp));
93 93
 			// set request post_type
94
-			$this->set( 'post_type', $this->get_post_type_from_request( $wp ));
94
+			$this->set('post_type', $this->get_post_type_from_request($wp));
95 95
 			// true or false ? is this page being used by EE ?
96 96
 			$this->set_espresso_page();
97 97
 		}
@@ -106,19 +106,19 @@  discard block
 block discarded – undo
106 106
 	 * @param WP $wp
107 107
 	 * @return int
108 108
 	 */
109
-	public function get_post_id_from_request( $wp = null ) {
110
-		if ( ! $wp instanceof WP ){
109
+	public function get_post_id_from_request($wp = null) {
110
+		if ( ! $wp instanceof WP) {
111 111
 			global $wp;
112 112
 		}
113 113
 		$post_id = null;
114
-		if ( isset( $wp->query_vars['p'] )) {
114
+		if (isset($wp->query_vars['p'])) {
115 115
 			$post_id = $wp->query_vars['p'];
116 116
 		}
117
-		if ( ! $post_id && isset( $wp->query_vars['page_id'] )) {
117
+		if ( ! $post_id && isset($wp->query_vars['page_id'])) {
118 118
 			$post_id = $wp->query_vars['page_id'];
119 119
 		}
120
-		if ( ! $post_id && isset( $wp->request ) && is_numeric( basename( $wp->request ))) {
121
-			$post_id = basename( $wp->request );
120
+		if ( ! $post_id && isset($wp->request) && is_numeric(basename($wp->request))) {
121
+			$post_id = basename($wp->request);
122 122
 		}
123 123
 		return $post_id;
124 124
 	}
@@ -132,35 +132,35 @@  discard block
 block discarded – undo
132 132
 	 * @param WP $wp
133 133
 	 * @return string
134 134
 	 */
135
-	public function get_post_name_from_request( $wp = null ) {
136
-		if ( ! $wp instanceof WP ){
135
+	public function get_post_name_from_request($wp = null) {
136
+		if ( ! $wp instanceof WP) {
137 137
 			global $wp;
138 138
 		}
139 139
 		$post_name = null;
140
-		if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) {
140
+		if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) {
141 141
 			$post_name = $wp->query_vars['name'];
142 142
 		}
143
-		if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) {
143
+		if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) {
144 144
 			$post_name = $wp->query_vars['pagename'];
145 145
 		}
146
-		if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) {
147
-			$possible_post_name = basename( $wp->request );
148
-			if ( ! is_numeric( $possible_post_name )) {
146
+		if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) {
147
+			$possible_post_name = basename($wp->request);
148
+			if ( ! is_numeric($possible_post_name)) {
149 149
 				/** @type WPDB $wpdb */
150 150
 				global $wpdb;
151 151
 				$SQL = "SELECT ID from {$wpdb->posts} WHERE post_status='publish' AND post_name=%s";
152
-				$possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name ));
153
-				if ( $possible_post_name ) {
152
+				$possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name));
153
+				if ($possible_post_name) {
154 154
 					$post_name = $possible_post_name;
155 155
 				}
156 156
 			}
157 157
 		}
158
-		if ( ! $post_name && $this->get( 'post_id' )) {
158
+		if ( ! $post_name && $this->get('post_id')) {
159 159
 			/** @type WPDB $wpdb */
160 160
 			global $wpdb;
161 161
 			$SQL = "SELECT post_name from {$wpdb->posts} WHERE post_status='publish' AND ID=%d";
162
-			$possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' )));
163
-			if( $possible_post_name ) {
162
+			$possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id')));
163
+			if ($possible_post_name) {
164 164
 				$post_name = $possible_post_name;
165 165
 			}
166 166
 		}
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
 	 * @param WP $wp
177 177
 	 * @return mixed
178 178
 	 */
179
-	public function get_post_type_from_request( $wp = null ) {
180
-		if ( ! $wp instanceof WP ){
179
+	public function get_post_type_from_request($wp = null) {
180
+		if ( ! $wp instanceof WP) {
181 181
 			global $wp;
182 182
 		}
183
-		return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null;
183
+		return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null;
184 184
 	}
185 185
 
186 186
 
@@ -190,18 +190,18 @@  discard block
 block discarded – undo
190 190
 	 * @param  WP $wp
191 191
 	 * @return string
192 192
 	 */
193
-	public function get_current_page_permalink( $wp = null ) {
194
-		$post_id = $this->get_post_id_from_request( $wp );
195
-		if ( $post_id ) {
196
-			$current_page_permalink = get_permalink( $post_id );
193
+	public function get_current_page_permalink($wp = null) {
194
+		$post_id = $this->get_post_id_from_request($wp);
195
+		if ($post_id) {
196
+			$current_page_permalink = get_permalink($post_id);
197 197
 		} else {
198
-			if ( ! $wp instanceof WP ) {
198
+			if ( ! $wp instanceof WP) {
199 199
 				global $wp;
200 200
 			}
201
-			if ( $wp->request ) {
202
-				$current_page_permalink = site_url( $wp->request );
201
+			if ($wp->request) {
202
+				$current_page_permalink = site_url($wp->request);
203 203
 			} else {
204
-				$current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) );
204
+				$current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI']));
205 205
 			}
206 206
 		}
207 207
 		return $current_page_permalink;
@@ -218,31 +218,31 @@  discard block
 block discarded – undo
218 218
 	public function test_for_espresso_page() {
219 219
 		global $wp;
220 220
 		/** @type EE_CPT_Strategy $EE_CPT_Strategy */
221
-		$EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' );
221
+		$EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy');
222 222
 		$espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies();
223
-		if ( is_array( $espresso_CPT_taxonomies ) ) {
224
-			foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) {
225
-				if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) {
223
+		if (is_array($espresso_CPT_taxonomies)) {
224
+			foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) {
225
+				if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) {
226 226
 					return true;
227 227
 				}
228 228
 			}
229 229
 		}
230 230
 		// load espresso CPT endpoints
231 231
 		$espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints();
232
-		$post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints );
233
-		$post_types = (array)$this->get( 'post_type' );
234
-		foreach ( $post_types as $post_type ) {
232
+		$post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);
233
+		$post_types = (array) $this->get('post_type');
234
+		foreach ($post_types as $post_type) {
235 235
 			// was a post name passed ?
236
-			if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) {
236
+			if (isset($post_type_CPT_endpoints[$post_type])) {
237 237
 				// kk we know this is an espresso page, but is it a specific post ?
238
-				if ( ! $this->get( 'post_name' ) ) {
238
+				if ( ! $this->get('post_name')) {
239 239
 					// there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events
240
-					$post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] )
241
-                        ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ]
240
+					$post_name = isset($post_type_CPT_endpoints[$this->get('post_type')])
241
+                        ? $post_type_CPT_endpoints[$this->get('post_type')]
242 242
                         : '';
243 243
 					// if the post type matches on of our then set the endpoint
244
-					if ( $post_name ) {
245
-						$this->set( 'post_name', $post_name );
244
+					if ($post_name) {
245
+						$this->set('post_name', $post_name);
246 246
 					}
247 247
 				}
248 248
 				return true;
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 * @param null|bool $value
261 261
 	 * @return    void
262 262
 	 */
263
-	public function set_espresso_page( $value = null ) {
263
+	public function set_espresso_page($value = null) {
264 264
         $this->_params['is_espresso_page'] = ! empty($value) ? $value : $this->test_for_espresso_page();
265 265
 	}
266 266
 
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 *  @return 	mixed
274 274
 	 */
275 275
 	public function is_espresso_page() {
276
-		return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false;
276
+		return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false;
277 277
 	}
278 278
 
279 279
 
@@ -297,14 +297,14 @@  discard block
 block discarded – undo
297 297
 	 * @param bool $override_ee
298 298
 	 * @return    void
299 299
 	 */
300
-	public function set( $key, $value, $override_ee = false ) {
300
+	public function set($key, $value, $override_ee = false) {
301 301
 		// don't allow "ee" to be overwritten unless explicitly instructed to do so
302 302
 		if (
303 303
 			$key !== 'ee' ||
304
-			( $key === 'ee' && empty( $this->_params['ee'] ))
305
-			|| ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )
304
+			($key === 'ee' && empty($this->_params['ee']))
305
+			|| ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)
306 306
 		) {
307
-			$this->_params[ $key ] = $value;
307
+			$this->_params[$key] = $value;
308 308
 		}
309 309
 	}
310 310
 
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 	 * @param null $default
319 319
 	 * @return    mixed
320 320
 	 */
321
-	public function get( $key, $default = null ) {
322
-		return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default;
321
+	public function get($key, $default = null) {
322
+		return isset($this->_params[$key]) ? $this->_params[$key] : $default;
323 323
 	}
324 324
 
325 325
 
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 	 * @param $key
332 332
 	 * @return    boolean
333 333
 	 */
334
-	public function is_set( $key ) {
335
-		return isset( $this->_params[ $key ] ) ? true : false;
334
+	public function is_set($key) {
335
+		return isset($this->_params[$key]) ? true : false;
336 336
 	}
337 337
 
338 338
 
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
 	 * @param $key
345 345
 	 * @return    void
346 346
 	 */
347
-	public function un_set( $key ) {
348
-		unset( $this->_params[ $key ] );
347
+	public function un_set($key) {
348
+		unset($this->_params[$key]);
349 349
 	}
350 350
 
351 351
 
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 * @param $value
359 359
 	 * @return    void
360 360
 	 */
361
-	public function set_notice( $key, $value ) {
362
-		$this->_notice[ $key ] = $value;
361
+	public function set_notice($key, $value) {
362
+		$this->_notice[$key] = $value;
363 363
 	}
364 364
 
365 365
 
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	 * @param $key
372 372
 	 * @return    mixed
373 373
 	 */
374
-	public function get_notice( $key ) {
375
-		return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null;
374
+	public function get_notice($key) {
375
+		return isset($this->_notice[$key]) ? $this->_notice[$key] : null;
376 376
 	}
377 377
 
378 378
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	 * @param $string
385 385
 	 * @return    void
386 386
 	 */
387
-	public function add_output( $string ) {
387
+	public function add_output($string) {
388 388
 		$this->_output .= $string;
389 389
 	}
390 390
 
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
 	 * @param $item
407 407
 	 * @param $key
408 408
 	 */
409
-	public function sanitize_text_field_for_array_walk( &$item, &$key ) {
410
-		$item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item );
409
+	public function sanitize_text_field_for_array_walk(&$item, &$key) {
410
+		$item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item);
411 411
 	}
412 412
 
413 413
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 	 * @param $b
418 418
 	 * @return bool
419 419
 	 */
420
-	public function __set($a,$b) { return false; }
420
+	public function __set($a, $b) { return false; }
421 421
 
422 422
 
423 423
 
Please login to merge, or discard this patch.
widgets/upcoming_events/EEW_Upcoming_Events.widget.php 2 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\widgets\EspressoWidget;
2 2
 
3
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5
+}
4 6
 /**
5 7
  * Event Espresso
6 8
  *
@@ -356,7 +358,7 @@  discard block
 block discarded – undo
356 358
 									$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', get_option( 'time_format' ));
357 359
 									if ( $date_range == TRUE ) {
358 360
 										echo espresso_event_date_range( $date_format, $time_format, $single_date_format, $single_time_format, $event->ID() );
359
-									}else{
361
+									} else{
360 362
 										echo espresso_list_of_event_dates( $event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit );
361 363
 									}
362 364
 								}
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public function __construct() {
33 33
 		parent::__construct(
34
-			__( 'Event Espresso Upcoming Events', 'event_espresso' ),
35
-			 array( 'description' => __( 'A widget to display your upcoming events.', 'event_espresso' ))
34
+			__('Event Espresso Upcoming Events', 'event_espresso'),
35
+			 array('description' => __('A widget to display your upcoming events.', 'event_espresso'))
36 36
 		);
37 37
 	}
38 38
 
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 * @param array $instance Previously saved values from database.
46 46
 	 * @return string|void
47 47
 	 */
48
-	public function form( $instance ) {
48
+	public function form($instance) {
49 49
 
50
-		EE_Registry::instance()->load_class( 'Question_Option', array(), FALSE, FALSE, TRUE );
50
+		EE_Registry::instance()->load_class('Question_Option', array(), FALSE, FALSE, TRUE);
51 51
 		// Set up some default widget settings.
52 52
 		$defaults = array(
53 53
 			'title' => __('Upcoming Events', 'event_espresso'),
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
 			'image_size' => 'medium'
63 63
 		);
64 64
 
65
-		$instance = wp_parse_args( (array) $instance, $defaults );
65
+		$instance = wp_parse_args((array) $instance, $defaults);
66 66
 		// don't add HTML labels for EE_Form_Fields generated inputs
67
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', '__return_empty_string' );
67
+		add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
68 68
 		$yes_no_values = array(
69
-			EE_Question_Option::new_instance( array( 'QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))),
70
-			EE_Question_Option::new_instance( array( 'QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso')))
69
+			EE_Question_Option::new_instance(array('QSO_value' => FALSE, 'QSO_desc' => __('No', 'event_espresso'))),
70
+			EE_Question_Option::new_instance(array('QSO_value' => TRUE, 'QSO_desc' => __('Yes', 'event_espresso')))
71 71
 		);
72 72
 
73 73
 	?>
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			<label for="<?php echo $this->get_field_id('title'); ?>">
79 79
 				<?php _e('Title:', 'event_espresso'); ?>
80 80
 			</label>
81
-			<input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" type="text" />
81
+			<input id="<?php echo $this->get_field_id('title'); ?>" class="widefat" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title']); ?>" type="text" />
82 82
 		</p>
83 83
 		<p>
84 84
 			<label for="<?php echo $this->get_field_id('category_name'); ?>">
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
 			<?php
88 88
 			$event_categories = array();
89 89
 			/** @type EEM_Term $EEM_Term */
90
-			$EEM_Term = EE_Registry::instance()->load_model( 'Term' );
91
-			$categories = $EEM_Term->get_all_ee_categories( TRUE );
92
-			if ( $categories ) {
93
-				foreach ( $categories as $category ) {
94
-					if ( $category instanceof EE_Term ) {
95
-						$event_categories[] = EE_Question_Option::new_instance( array( 'QSO_value' => $category->get( 'slug' ), 'QSO_desc' => $category->get( 'name' )));
90
+			$EEM_Term = EE_Registry::instance()->load_model('Term');
91
+			$categories = $EEM_Term->get_all_ee_categories(TRUE);
92
+			if ($categories) {
93
+				foreach ($categories as $category) {
94
+					if ($category instanceof EE_Term) {
95
+						$event_categories[] = EE_Question_Option::new_instance(array('QSO_value' => $category->get('slug'), 'QSO_desc' => $category->get('name')));
96 96
 					}
97 97
 				}
98 98
 			}
99
-			array_unshift( $event_categories, EE_Question_Option::new_instance( array( 'QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso'))));
99
+			array_unshift($event_categories, EE_Question_Option::new_instance(array('QSO_value' => '', 'QSO_desc' => __(' - display all - ', 'event_espresso'))));
100 100
 			echo EEH_Form_Fields::select(
101 101
 				 __('Event Category:', 'event_espresso'),
102 102
 				$instance['category_name'],
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
 			<?php
134 134
 			$image_sizes = array();
135 135
 			$sizes = get_intermediate_image_sizes();
136
-			if ( $sizes ) {
136
+			if ($sizes) {
137 137
 				// loop thru images and create option objects out of them
138
-				foreach ( $sizes as $image_size ) {
139
-					$image_size = trim( $image_size );
138
+				foreach ($sizes as $image_size) {
139
+					$image_size = trim($image_size);
140 140
 					// no big images plz
141
-					if ( ! in_array( $image_size, array( 'large', 'post-thumbnail' ))) {
142
-						$image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => $image_size, 'QSO_desc' => $image_size ));
141
+					if ( ! in_array($image_size, array('large', 'post-thumbnail'))) {
142
+						$image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => $image_size, 'QSO_desc' => $image_size));
143 143
 					}
144 144
 				}
145
-				$image_sizes[] = EE_Question_Option::new_instance( array( 'QSO_value' => 'none', 'QSO_desc' =>  __('don\'t show images', 'event_espresso') ));
145
+				$image_sizes[] = EE_Question_Option::new_instance(array('QSO_value' => 'none', 'QSO_desc' =>  __('don\'t show images', 'event_espresso')));
146 146
 			}
147 147
 			echo EEH_Form_Fields::select(
148 148
 				 __('Image Size:', 'event_espresso'),
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			<label for="<?php echo $this->get_field_id('date_limit'); ?>">
201 201
 				<?php _e('Number of Dates to Display:', 'event_espresso'); ?>
202 202
 			</label>
203
-			<input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr( $instance['date_limit'] ); ?>" size="3" type="text" />
203
+			<input id="<?php echo $this->get_field_id('date_limit'); ?>" name="<?php echo $this->get_field_name('date_limit'); ?>" value="<?php echo esc_attr($instance['date_limit']); ?>" size="3" type="text" />
204 204
 		</p>
205 205
 		<p>
206 206
 			<label for="<?php echo $this->get_field_id('date_range'); ?>">
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @return array Updated safe values to be saved.
234 234
 	 */
235
-	public function update( $new_instance, $old_instance ) {
235
+	public function update($new_instance, $old_instance) {
236 236
 		$instance = $old_instance;
237
-		$instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
237
+		$instance['title'] = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : '';
238 238
 		$instance['category_name'] = $new_instance['category_name'];
239 239
 		$instance['show_expired'] = $new_instance['show_expired'];
240 240
 		$instance['limit'] = $new_instance['limit'];
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 	 * @param array $args     Widget arguments.
258 258
 	 * @param array $instance Saved values from database.
259 259
 	 */
260
-	public function widget( $args, $instance ) {
260
+	public function widget($args, $instance) {
261 261
 
262 262
 		global $post;
263 263
 		// make sure there is some kinda post object
264
-		if ( $post instanceof WP_Post ) {
264
+		if ($post instanceof WP_Post) {
265 265
 			$before_widget = '';
266 266
 			$before_title = '';
267 267
 			$after_title = '';
268 268
 			$after_widget = '';
269 269
 			// but NOT an events archives page, cuz that would be like two event lists on the same page
270
-			$show_everywhere = isset( $instance['show_everywhere'] ) ? (bool) absint( $instance['show_everywhere'] ) : TRUE;
271
-			if ( $show_everywhere || ! ( $post->post_type == 'espresso_events' && is_archive() )) {
270
+			$show_everywhere = isset($instance['show_everywhere']) ? (bool) absint($instance['show_everywhere']) : TRUE;
271
+			if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) {
272 272
 				// let's use some of the event helper functions'
273 273
 				// make separate vars out of attributes
274 274
 
@@ -287,83 +287,83 @@  discard block
 block discarded – undo
287 287
 				// Before widget (defined by themes).
288 288
 				echo $before_widget;
289 289
 				// Display the widget title if one was input (before and after defined by themes).
290
-				if ( ! empty( $title )) {
291
-					echo $before_title . $title . $after_title;
290
+				if ( ! empty($title)) {
291
+					echo $before_title.$title.$after_title;
292 292
 				}
293 293
 				// grab widget settings
294
-				$category = isset( $instance['category_name'] ) && ! empty( $instance['category_name'] ) ? $instance['category_name'] : FALSE;
295
-				$show_expired = isset( $instance['show_expired'] ) ? (bool) absint( $instance['show_expired'] ) : FALSE;
296
-				$image_size = isset( $instance['image_size'] ) && ! empty( $instance['image_size'] ) ? $instance['image_size'] : 'medium';
297
-				$show_desc = isset( $instance['show_desc'] ) ? (bool) absint( $instance['show_desc'] ) : TRUE;
298
-				$show_dates = isset( $instance['show_dates'] ) ? (bool) absint( $instance['show_dates'] ) : TRUE;
299
-				$date_limit = isset( $instance['date_limit'] ) && ! empty( $instance['date_limit'] ) ? $instance['date_limit'] : NULL;
300
-				$date_range = isset( $instance['date_range'] ) && ! empty( $instance['date_range'] ) ? $instance['date_range'] : FALSE;
294
+				$category = isset($instance['category_name']) && ! empty($instance['category_name']) ? $instance['category_name'] : FALSE;
295
+				$show_expired = isset($instance['show_expired']) ? (bool) absint($instance['show_expired']) : FALSE;
296
+				$image_size = isset($instance['image_size']) && ! empty($instance['image_size']) ? $instance['image_size'] : 'medium';
297
+				$show_desc = isset($instance['show_desc']) ? (bool) absint($instance['show_desc']) : TRUE;
298
+				$show_dates = isset($instance['show_dates']) ? (bool) absint($instance['show_dates']) : TRUE;
299
+				$date_limit = isset($instance['date_limit']) && ! empty($instance['date_limit']) ? $instance['date_limit'] : NULL;
300
+				$date_range = isset($instance['date_range']) && ! empty($instance['date_range']) ? $instance['date_range'] : FALSE;
301 301
 				// start to build our where clause
302 302
 				$where = array(
303 303
 //					'Datetime.DTT_is_primary' => 1,
304
-					'status' => array( 'IN', array( 'publish', 'sold_out' ) )
304
+					'status' => array('IN', array('publish', 'sold_out'))
305 305
 				);
306 306
 				// add category
307
-				if ( $category ) {
307
+				if ($category) {
308 308
 					$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
309 309
 					$where['Term_Taxonomy.Term.slug'] = $category;
310 310
 				}
311 311
 				// if NOT expired then we want events that start today or in the future
312
-				if ( ! $show_expired ) {
313
-					$where['Datetime.DTT_EVT_end'] = array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
312
+				if ( ! $show_expired) {
313
+					$where['Datetime.DTT_EVT_end'] = array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
314 314
 				}
315 315
 				// allow $where to be filtered
316
-				$where = apply_filters( 'FHEE__EEW_Upcoming_Events__widget__where', $where, $category, $show_expired );
316
+				$where = apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $category, $show_expired);
317 317
 				// run the query
318
-				$events = EE_Registry::instance()->load_model( 'Event' )->get_all( array(
318
+				$events = EE_Registry::instance()->load_model('Event')->get_all(array(
319 319
 					$where,
320
-					'limit' => $instance['limit'] > 0 ? '0,' . $instance['limit'] : '0,10',
320
+					'limit' => $instance['limit'] > 0 ? '0,'.$instance['limit'] : '0,10',
321 321
 					'order_by' => 'Datetime.DTT_EVT_start',
322 322
 					'order' => 'ASC',
323 323
 					'group_by' => 'EVT_ID'
324 324
 				));
325 325
 
326
-				if ( ! empty( $events )) {
326
+				if ( ! empty($events)) {
327 327
 					echo '<ul class="ee-upcoming-events-widget-ul">';
328
-					foreach ( $events as $event ) {
329
-						if ( $event instanceof EE_Event && ( !is_single() || $post->ID != $event->ID() ) ) {
328
+					foreach ($events as $event) {
329
+						if ($event instanceof EE_Event && ( ! is_single() || $post->ID != $event->ID())) {
330 330
 							//printr( $event, '$event  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
331
-							echo '<li id="ee-upcoming-events-widget-li-' . $event->ID() . '" class="ee-upcoming-events-widget-li">';
331
+							echo '<li id="ee-upcoming-events-widget-li-'.$event->ID().'" class="ee-upcoming-events-widget-li">';
332 332
 							// how big is the event name ?
333
-							$name_length = strlen( $event->name() );
334
-							switch( $name_length ) {
333
+							$name_length = strlen($event->name());
334
+							switch ($name_length) {
335 335
 								case $name_length > 70 :
336
-									$len_class =  ' three-line';
336
+									$len_class = ' three-line';
337 337
 									break;
338 338
 								case $name_length > 35 :
339
-									$len_class =  ' two-line';
339
+									$len_class = ' two-line';
340 340
 									break;
341 341
 								default :
342
-									$len_class =  ' one-line';
342
+									$len_class = ' one-line';
343 343
 							}
344
-							$event_url = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event );
345
-							echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a' . $len_class . '" href="' . $event_url . '">' . $event->name() . '</a></h5>';
346
-							if ( post_password_required( $event->ID() ) ) {
347
-								$pswd_form = apply_filters( 'FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form( $event->ID() ), $event );
344
+							$event_url = apply_filters('FHEE_EEW_Upcoming_Events__widget__event_url', $event->get_permalink(), $event);
345
+							echo '<h5 class="ee-upcoming-events-widget-title-h5"><a class="ee-widget-event-name-a'.$len_class.'" href="'.$event_url.'">'.$event->name().'</a></h5>';
346
+							if (post_password_required($event->ID())) {
347
+								$pswd_form = apply_filters('FHEE_EEW_Upcoming_Events__widget__password_form', get_the_password_form($event->ID()), $event);
348 348
 								echo $pswd_form;
349 349
 							} else {
350
-								if ( has_post_thumbnail( $event->ID() ) && $image_size != 'none' ) {
351
-									echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="' . $event_url . '">' . get_the_post_thumbnail( $event->ID(), $image_size ) . '</a></div>';
350
+								if (has_post_thumbnail($event->ID()) && $image_size != 'none') {
351
+									echo '<div class="ee-upcoming-events-widget-img-dv"><a class="ee-upcoming-events-widget-img" href="'.$event_url.'">'.get_the_post_thumbnail($event->ID(), $image_size).'</a></div>';
352 352
 								}
353
-								$desc = $event->short_description( 25 );
354
-								if ( $show_dates ) {
355
-									$date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', get_option( 'date_format' ));
356
-									$time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', get_option( 'time_format' ));
357
-									$single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', get_option( 'date_format' ));
358
-									$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', get_option( 'time_format' ));
359
-									if ( $date_range == TRUE ) {
360
-										echo espresso_event_date_range( $date_format, $time_format, $single_date_format, $single_time_format, $event->ID() );
361
-									}else{
362
-										echo espresso_list_of_event_dates( $event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit );
353
+								$desc = $event->short_description(25);
354
+								if ($show_dates) {
355
+									$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', get_option('date_format'));
356
+									$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', get_option('time_format'));
357
+									$single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', get_option('date_format'));
358
+									$single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', get_option('time_format'));
359
+									if ($date_range == TRUE) {
360
+										echo espresso_event_date_range($date_format, $time_format, $single_date_format, $single_time_format, $event->ID());
361
+									} else {
362
+										echo espresso_list_of_event_dates($event->ID(), $date_format, $time_format, FALSE, NULL, TRUE, TRUE, $date_limit);
363 363
 									}
364 364
 								}
365
-								if ( $show_desc && $desc ) {
366
-									echo '<p style="margin-top: .5em">' . $desc . '</p>';
365
+								if ($show_desc && $desc) {
366
+									echo '<p style="margin-top: .5em">'.$desc.'</p>';
367 367
 								}
368 368
 							}
369 369
 							echo '</li>';
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * @return string
388 388
 	 */
389 389
 	public function make_the_title_a_link($title) {
390
-	    return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>';
390
+	    return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>';
391 391
 	}
392 392
 
393 393
 }
Please login to merge, or discard this patch.
widgets/EspressoWidget.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,31 +18,31 @@
 block discarded – undo
18 18
 
19 19
 
20 20
 
21
-    /**
22
-     * @param string $name
23
-     * @param array  $widget_options
24
-     * @param array  $control_options
25
-     */
26
-    public function __construct($name = '', array $widget_options = array(), array $control_options = array())
27
-    {
28
-        $id_base = EspressoWidget::getIdBase(get_class($this));
29
-        $control_options['id_base'] = $id_base;
30
-        $control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300;
31
-        $control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350;
32
-        // Register widget with WordPress
33
-        parent::__construct($id_base, $name, $widget_options, $control_options);
34
-    }
35
-
36
-
37
-
38
-    /**
39
-     * @param string $widget_class
40
-     * @return string
41
-     */
42
-    public static function getIdBase($widget_class)
43
-    {
44
-        return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget';
45
-    }
21
+	/**
22
+	 * @param string $name
23
+	 * @param array  $widget_options
24
+	 * @param array  $control_options
25
+	 */
26
+	public function __construct($name = '', array $widget_options = array(), array $control_options = array())
27
+	{
28
+		$id_base = EspressoWidget::getIdBase(get_class($this));
29
+		$control_options['id_base'] = $id_base;
30
+		$control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300;
31
+		$control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350;
32
+		// Register widget with WordPress
33
+		parent::__construct($id_base, $name, $widget_options, $control_options);
34
+	}
35
+
36
+
37
+
38
+	/**
39
+	 * @param string $widget_class
40
+	 * @return string
41
+	 */
42
+	public static function getIdBase($widget_class)
43
+	{
44
+		return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget';
45
+	}
46 46
 
47 47
 
48 48
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
      */
42 42
     public static function getIdBase($widget_class)
43 43
     {
44
-        return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget';
44
+        return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)).'-widget';
45 45
     }
46 46
 
47 47
 
Please login to merge, or discard this patch.
data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_shortcodes.dmsstage.php 2 patches
Indentation   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@
 block discarded – undo
2 2
 
3 3
 /**
4 4
  * Goes through all the posts and pages, and converts old shortcodes to new ones
5
-
6
-*/
5
+ */
7 6
 
8 7
 class EE_DMS_4_1_0_shortcodes extends EE_Data_Migration_Script_Stage{
9 8
 	function __construct() {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 */
7 7
 
8
-class EE_DMS_4_1_0_shortcodes extends EE_Data_Migration_Script_Stage{
8
+class EE_DMS_4_1_0_shortcodes extends EE_Data_Migration_Script_Stage {
9 9
 	function __construct() {
10 10
 		global $wpdb;
11 11
 		$this->_pretty_name = __("Shortcodes", "event_espresso");
@@ -15,27 +15,27 @@  discard block
 block discarded – undo
15 15
 	protected function _migrate_old_row($old_row) {
16 16
 		$new_post_content = $this->_change_event_list_shortcode($old_row['post_content']);
17 17
 		global $wpdb;
18
-		$wpdb->query($wpdb->prepare("UPDATE ".$this->_old_table." SET post_content=%s WHERE ID=%d",$new_post_content,$old_row['ID']));
18
+		$wpdb->query($wpdb->prepare("UPDATE ".$this->_old_table." SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID']));
19 19
 	}
20 20
 
21 21
 	/**
22 22
 	 * replaces [EVENT_LIST... with [ESPRESSO_EVENTS...]
23 23
 	 * @param string $old_content
24 24
 	 */
25
-	private function _change_event_list_shortcode($old_content){
26
-		return str_replace("[EVENT_LIST","[ESPRESSO_EVENTS",$old_content);
25
+	private function _change_event_list_shortcode($old_content) {
26
+		return str_replace("[EVENT_LIST", "[ESPRESSO_EVENTS", $old_content);
27 27
 	}
28 28
 
29
-	function _migration_step($num_items=50){
29
+	function _migration_step($num_items = 50) {
30 30
 		global $wpdb;
31 31
 		$start_at_record = $this->count_records_migrated();
32
-		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d",$start_at_record,$num_items),ARRAY_A);
32
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
33 33
 		$items_actually_migrated = 0;
34
-		foreach($rows as $old_row){
34
+		foreach ($rows as $old_row) {
35 35
 			$this->_migrate_old_row($old_row);
36 36
 			$items_actually_migrated++;
37 37
 		}
38
-		if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){
38
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
39 39
 			$this->set_completed();
40 40
 		}
41 41
 		return $items_actually_migrated;
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		return $count;
47 47
 	}
48 48
 
49
-	private function _sql_to_only_select_non_drafts(){
49
+	private function _sql_to_only_select_non_drafts() {
50 50
 		return " WHERE post_type NOT IN ('revision','auto-draft') ";
51 51
 	}
52 52
 
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_3_0.dms.php 1 patch
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 $stages = glob(EE_CORE . 'data_migration_scripts/4_3_0_stages/*');
15 15
 $class_to_filepath = array();
16 16
 if ( ! empty($stages)) {
17
-    foreach ($stages as $filepath) {
18
-        $matches = array();
19
-        preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-        $class_to_filepath[$matches[1]] = $filepath;
21
-    }
17
+	foreach ($stages as $filepath) {
18
+		$matches = array();
19
+		preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
+		$class_to_filepath[$matches[1]] = $filepath;
21
+	}
22 22
 }
23 23
 //give addons a chance to autoload their stages too
24 24
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_3_0__autoloaded_stages', $class_to_filepath);
@@ -31,56 +31,56 @@  discard block
 block discarded – undo
31 31
 
32 32
 
33 33
 
34
-    /**
35
-     * EE_DMS_Core_4_3_0 constructor.
36
-     *
37
-     * @param TableManager  $table_manager
38
-     * @param TableAnalysis $table_analysis
39
-     */
40
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
41
-    {
42
-        $this->_pretty_name = __("Data Update to Event Espresso 4.3.0", "event_espresso");
43
-        $this->_priority = 10;
44
-        $this->_migration_stages = array(
45
-            new EE_DMS_4_3_0_question_option_order(),
46
-            new EE_DMS_4_3_0_event_message_templates(),
47
-        );
48
-        parent::__construct($table_manager, $table_analysis);
49
-    }
34
+	/**
35
+	 * EE_DMS_Core_4_3_0 constructor.
36
+	 *
37
+	 * @param TableManager  $table_manager
38
+	 * @param TableAnalysis $table_analysis
39
+	 */
40
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
41
+	{
42
+		$this->_pretty_name = __("Data Update to Event Espresso 4.3.0", "event_espresso");
43
+		$this->_priority = 10;
44
+		$this->_migration_stages = array(
45
+			new EE_DMS_4_3_0_question_option_order(),
46
+			new EE_DMS_4_3_0_event_message_templates(),
47
+		);
48
+		parent::__construct($table_manager, $table_analysis);
49
+	}
50 50
 
51 51
 
52 52
 
53
-    public function can_migrate_from_version($version_array)
54
-    {
55
-        $version_string = $version_array['Core'];
56
-        if (version_compare($version_string, '4.3.0', '<=') && version_compare($version_string, '4.2.0', '>=')) {
53
+	public function can_migrate_from_version($version_array)
54
+	{
55
+		$version_string = $version_array['Core'];
56
+		if (version_compare($version_string, '4.3.0', '<=') && version_compare($version_string, '4.2.0', '>=')) {
57 57
 //			echo "$version_string can be migrated fro";
58
-            return true;
59
-        } elseif ( ! $version_string) {
58
+			return true;
59
+		} elseif ( ! $version_string) {
60 60
 //			echo "no version string provided: $version_string";
61
-            //no version string provided... this must be pre 4.2
62
-            return false;//changed mind. dont want people thinking they should migrate yet because they cant
63
-        } else {
61
+			//no version string provided... this must be pre 4.2
62
+			return false;//changed mind. dont want people thinking they should migrate yet because they cant
63
+		} else {
64 64
 //			echo "$version_string doesnt apply";
65
-            return false;
66
-        }
67
-    }
65
+			return false;
66
+		}
67
+	}
68 68
 
69 69
 
70 70
 
71
-    public function schema_changes_before_migration()
72
-    {
73
-        //relies on 4.1's EEH_Activation::create_table
74
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
75
-        $table_name = 'esp_answer';
76
-        $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
71
+	public function schema_changes_before_migration()
72
+	{
73
+		//relies on 4.1's EEH_Activation::create_table
74
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
75
+		$table_name = 'esp_answer';
76
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
77 77
 					REG_ID INT UNSIGNED NOT NULL,
78 78
 					QST_ID INT UNSIGNED NOT NULL,
79 79
 					ANS_value TEXT NOT NULL,
80 80
 					PRIMARY KEY  (ANS_ID)";
81
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
82
-        $table_name = 'esp_attendee_meta';
83
-        $sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
81
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
82
+		$table_name = 'esp_attendee_meta';
83
+		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
84 84
 						ATT_ID BIGINT(20) UNSIGNED NOT NULL,
85 85
 						ATT_fname VARCHAR(45) NOT NULL,
86 86
 						ATT_lname VARCHAR(45) NOT	NULL,
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 								KEY ATT_fname (ATT_fname),
97 97
 								KEY ATT_lname (ATT_lname),
98 98
 								KEY ATT_email (ATT_email)";
99
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
100
-        $table_name = 'esp_country';
101
-        $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
99
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
100
+		$table_name = 'esp_country';
101
+		$sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
102 102
 					  CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL,
103 103
 					  RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL,
104 104
 					  CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL,
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
115 115
 					  CNT_active TINYINT(1) DEFAULT '0',
116 116
 					  PRIMARY KEY  (CNT_ISO)";
117
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
118
-        $table_name = 'esp_datetime';
119
-        $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
117
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
118
+		$table_name = 'esp_datetime';
119
+		$sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
120 120
 				  EVT_ID BIGINT(20) UNSIGNED NOT NULL,
121 121
 				  DTT_name VARCHAR(255) NOT NULL DEFAULT '',
122 122
 				  DTT_description TEXT NOT NULL,
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 						PRIMARY KEY  (DTT_ID),
132 132
 						KEY EVT_ID (EVT_ID),
133 133
 						KEY DTT_is_primary (DTT_is_primary)";
134
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
-        $table_name = 'esp_event_meta';
136
-        $sql = "
134
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
+		$table_name = 'esp_event_meta';
136
+		$sql = "
137 137
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
138 138
 			EVT_ID BIGINT(20) UNSIGNED NOT NULL,
139 139
 			EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -148,31 +148,31 @@  discard block
 block discarded – undo
148 148
 			EVT_external_URL VARCHAR(200) NULL,
149 149
 			EVT_donations TINYINT(1) NULL,
150 150
 			PRIMARY KEY  (EVTM_ID)";
151
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
152
-        $table_name = 'esp_event_question_group';
153
-        $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
151
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
152
+		$table_name = 'esp_event_question_group';
153
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
154 154
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
155 155
 					QSG_ID INT UNSIGNED NOT NULL,
156 156
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
157 157
 					PRIMARY KEY  (EQG_ID)";
158
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
159
-        $table_name = 'esp_event_venue';
160
-        $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
158
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
159
+		$table_name = 'esp_event_venue';
160
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
161 161
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
162 162
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
163 163
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
164 164
 				PRIMARY KEY  (EVV_ID)";
165
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
166
-        $table_name = 'esp_extra_meta';
167
-        $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
165
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
166
+		$table_name = 'esp_extra_meta';
167
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
168 168
 				OBJ_ID INT(11) DEFAULT NULL,
169 169
 				EXM_type VARCHAR(45) DEFAULT NULL,
170 170
 				EXM_key VARCHAR(45) DEFAULT NULL,
171 171
 				EXM_value TEXT,
172 172
 				PRIMARY KEY  (EXM_ID)";
173
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
174
-        $table_name = 'esp_line_item';
175
-        $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
173
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
174
+		$table_name = 'esp_line_item';
175
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
176 176
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
177 177
 				TXN_ID INT(11) DEFAULT NULL,
178 178
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -188,19 +188,19 @@  discard block
 block discarded – undo
188 188
 				OBJ_ID INT(11) DEFAULT NULL,
189 189
 				OBJ_type VARCHAR(45)DEFAULT NULL,
190 190
 				PRIMARY KEY  (LIN_ID)";
191
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
192
-        $table_name = 'esp_message_template';
193
-        $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
191
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
192
+		$table_name = 'esp_message_template';
193
+		$sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
194 194
 					GRP_ID INT(10) UNSIGNED NOT NULL,
195 195
 					MTP_context VARCHAR(50) NOT NULL,
196 196
 					MTP_template_field VARCHAR(30) NOT NULL,
197 197
 					MTP_content TEXT NOT NULL,
198 198
 					PRIMARY KEY  (MTP_ID),
199 199
 					KEY GRP_ID (GRP_ID)";
200
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
201
-        $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
202
-        $table_name = 'esp_message_template_group';
203
-        $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
200
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
201
+		$this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
202
+		$table_name = 'esp_message_template_group';
203
+		$sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
204 204
 					MTP_user_id INT(10) NOT NULL DEFAULT '1',
205 205
 					MTP_name VARCHAR(245) NOT NULL DEFAULT '',
206 206
 					MTP_description VARCHAR(245) NOT NULL DEFAULT '',
@@ -212,17 +212,17 @@  discard block
 block discarded – undo
212 212
 					MTP_is_active TINYINT(1) NOT NULL DEFAULT '1',
213 213
 					PRIMARY KEY  (GRP_ID),
214 214
 					KEY MTP_user_id (MTP_user_id)";
215
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
216
-        $table_name = 'esp_event_message_template';
217
-        $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
215
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
216
+		$table_name = 'esp_event_message_template';
217
+		$sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
218 218
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
219 219
 					GRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0,
220 220
 					PRIMARY KEY  (EMT_ID),
221 221
 					KEY EVT_ID (EVT_ID),
222 222
 					KEY GRP_ID (GRP_ID)";
223
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
224
-        $table_name = 'esp_payment';
225
-        $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
223
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
224
+		$table_name = 'esp_payment';
225
+		$sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
226 226
 					TXN_ID INT(10) UNSIGNED DEFAULT NULL,
227 227
 					STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL,
228 228
 					PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 					PRIMARY KEY  (PAY_ID),
239 239
 					KEY TXN_ID (TXN_ID),
240 240
 					KEY PAY_timestamp (PAY_timestamp)";
241
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
242
-        $table_name = "esp_ticket";
243
-        $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
241
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
242
+		$table_name = "esp_ticket";
243
+		$sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
244 244
 					  TTM_ID INT(10) UNSIGNED NOT NULL,
245 245
 					  TKT_name VARCHAR(245) NOT NULL DEFAULT '',
246 246
 					  TKT_description TEXT NOT NULL,
@@ -260,28 +260,28 @@  discard block
 block discarded – undo
260 260
 					  TKT_parent INT(10) UNSIGNED DEFAULT '0',
261 261
 					  TKT_deleted TINYINT(1) NOT NULL DEFAULT '0',
262 262
 					  PRIMARY KEY  (TKT_ID)";
263
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
264
-        $table_name = "esp_ticket_price";
265
-        $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
263
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
264
+		$table_name = "esp_ticket_price";
265
+		$sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
266 266
 					  TKT_ID INT(10) UNSIGNED NOT NULL,
267 267
 					  PRC_ID INT(10) UNSIGNED NOT NULL,
268 268
 					  PRIMARY KEY  (TKP_ID)";
269
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
270
-        $table_name = "esp_datetime_ticket";
271
-        $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
269
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
270
+		$table_name = "esp_datetime_ticket";
271
+		$sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
272 272
 					  DTT_ID INT(10) UNSIGNED NOT NULL,
273 273
 					  TKT_ID INT(10) UNSIGNED NOT NULL,
274 274
 					  PRIMARY KEY  (DTK_ID)";
275
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
276
-        $table_name = "esp_ticket_template";
277
-        $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
275
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
276
+		$table_name = "esp_ticket_template";
277
+		$sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
278 278
 					  TTM_name VARCHAR(45) NOT NULL,
279 279
 					  TTM_description TEXT,
280 280
 					  TTM_file VARCHAR(45),
281 281
 					  PRIMARY KEY  (TTM_ID)";
282
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
283
-        $table_name = "esp_price";
284
-        $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
282
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
283
+		$table_name = "esp_price";
284
+		$sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
285 285
 					  PRT_ID TINYINT(3) UNSIGNED NOT NULL,
286 286
 					  PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00',
287 287
 					  PRC_name VARCHAR(245) NOT NULL,
@@ -292,9 +292,9 @@  discard block
 block discarded – undo
292 292
 					  PRC_order TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
293 293
 					  PRC_parent INT(10) UNSIGNED DEFAULT 0,
294 294
 					  PRIMARY KEY  (PRC_ID)";
295
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
296
-        $table_name = "esp_price_type";
297
-        $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
295
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
296
+		$table_name = "esp_price_type";
297
+		$sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
298 298
 				  PRT_name VARCHAR(45) NOT NULL,
299 299
 				  PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
300 300
 				  PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0',
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 				  PRT_deleted TINYINT(1) NOT NULL DEFAULT '0',
303 303
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
304 304
 				  PRIMARY KEY  (PRT_ID)";
305
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
306
-        $table_name = 'esp_question';
307
-        $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
305
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
306
+		$table_name = 'esp_question';
307
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
308 308
 					QST_display_text TEXT NOT NULL,
309 309
 					QST_admin_label VARCHAR(255) NOT NULL,
310 310
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 					QST_wp_user BIGINT UNSIGNED NULL,
317 317
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
318 318
 					PRIMARY KEY  (QST_ID)';
319
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
320
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
321
-        $table_name = 'esp_question_group';
322
-        $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
319
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
320
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
321
+		$table_name = 'esp_question_group';
322
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
323 323
 					QSG_name VARCHAR(255) NOT NULL,
324 324
 					QSG_identifier VARCHAR(100) NOT NULL,
325 325
 					QSG_desc TEXT NULL,
@@ -330,25 +330,25 @@  discard block
 block discarded – undo
330 330
 					QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
331 331
 					PRIMARY KEY  (QSG_ID),
332 332
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
333
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
334
-        $table_name = 'esp_question_group_question';
335
-        $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
333
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
334
+		$table_name = 'esp_question_group_question';
335
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
336 336
 					QSG_ID INT UNSIGNED NOT NULL,
337 337
 					QST_ID INT UNSIGNED NOT NULL,
338 338
 					QGQ_order INT UNSIGNED NOT NULL DEFAULT 0,
339 339
 					PRIMARY KEY  (QGQ_ID) ";
340
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
-        $table_name = 'esp_question_option';
342
-        $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
340
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
341
+		$table_name = 'esp_question_option';
342
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
343 343
 					QSO_value VARCHAR(255) NOT NULL,
344 344
 					QSO_desc TEXT NOT NULL,
345 345
 					QST_ID INT UNSIGNED NOT NULL,
346 346
 					QSO_order INT UNSIGNED NOT NULL DEFAULT 0,
347 347
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
348 348
 					PRIMARY KEY  (QSO_ID)";
349
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
350
-        $table_name = 'esp_registration';
351
-        $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
349
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
350
+		$table_name = 'esp_registration';
351
+		$sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
352 352
 					  EVT_ID BIGINT(20) UNSIGNED NOT NULL,
353 353
 					  ATT_ID BIGINT(20) UNSIGNED NOT NULL,
354 354
 					  TXN_ID INT(10) UNSIGNED NOT NULL,
@@ -371,25 +371,25 @@  discard block
 block discarded – undo
371 371
 					  KEY STS_ID (STS_ID),
372 372
 					  KEY REG_url_link (REG_url_link),
373 373
 					  KEY REG_code (REG_code)";
374
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
375
-        $table_name = 'esp_checkin';
376
-        $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
374
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
375
+		$table_name = 'esp_checkin';
376
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
377 377
 					REG_ID INT(10) UNSIGNED NOT NULL,
378 378
 					DTT_ID INT(10) UNSIGNED NOT NULL,
379 379
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
380 380
 					CHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
381 381
 					PRIMARY KEY  (CHK_ID)";
382
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
383
-        $table_name = 'esp_state';
384
-        $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT,
382
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
383
+		$table_name = 'esp_state';
384
+		$sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT,
385 385
 					  CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL,
386 386
 					  STA_abbrev VARCHAR(6) COLLATE utf8_bin NOT NULL,
387 387
 					  STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL,
388 388
 					  STA_active TINYINT(1) DEFAULT '1',
389 389
 					  PRIMARY KEY  (STA_ID)";
390
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
391
-        $table_name = 'esp_status';
392
-        $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL,
390
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
391
+		$table_name = 'esp_status';
392
+		$sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL,
393 393
 					  STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL,
394 394
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
395 395
 					  STS_can_edit TINYINT(1) NOT NULL DEFAULT 0,
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
 					  STS_open TINYINT(1) NOT NULL DEFAULT 1,
398 398
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
399 399
 					  KEY STS_type (STS_type)";
400
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
401
-        $table_name = 'esp_transaction';
402
-        $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
400
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
401
+		$table_name = 'esp_transaction';
402
+		$sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
403 403
 					  TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
404 404
 					  TXN_total DECIMAL(10,3) DEFAULT '0.00',
405 405
 					  TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00',
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
 					  PRIMARY KEY  (TXN_ID),
410 410
 					  KEY TXN_timestamp (TXN_timestamp),
411 411
 					  KEY STS_ID (STS_ID)";
412
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
413
-        $table_name = 'esp_venue_meta';
414
-        $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT,
412
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
413
+		$table_name = 'esp_venue_meta';
414
+		$sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT,
415 415
 			VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
416 416
 			VNU_address VARCHAR(255) DEFAULT NULL,
417 417
 			VNU_address2 VARCHAR(255) DEFAULT NULL,
@@ -429,79 +429,79 @@  discard block
 block discarded – undo
429 429
 			PRIMARY KEY  (VNUM_ID),
430 430
 			KEY STA_ID (STA_ID),
431 431
 			KEY CNT_ISO (CNT_ISO)";
432
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
433
-        $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
434
-        //setting up the DEFAULT stats and countries is also essential for the data migrations to run
435
-        //(because many need to convert old string states to foreign keys into the states table)
436
-        $script_with_defaults->insert_default_states();
437
-        $script_with_defaults->insert_default_countries();
438
-        //setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
439
-        $script_with_defaults->insert_default_price_types();
440
-        $script_with_defaults->insert_default_prices();
441
-        //but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's
442
-        $this->insert_default_tickets();
443
-        //setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
444
-        EE_Config::instance()->update_espresso_config(false, true);
445
-        return true;
446
-    }
447
-
448
-
449
-
450
-    /**
451
-     * @return boolean
452
-     */
453
-    public function schema_changes_after_migration()
454
-    {
455
-        return true;
456
-    }
457
-
458
-
459
-
460
-    public function migration_page_hooks()
461
-    {
462
-    }
463
-
464
-
465
-
466
-    /**
467
-     * insert DEFAULT ticket
468
-     * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field
469
-     *
470
-     * @access public
471
-     * @static
472
-     * @return void
473
-     */
474
-    public function insert_default_tickets()
475
-    {
476
-        global $wpdb;
477
-        $ticket_table = $wpdb->prefix . "esp_ticket";
478
-        if ($this->_get_table_analysis()->tableExists($ticket_table)) {
479
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
480
-            $tickets_exist = $wpdb->get_var($SQL);
481
-            if ( ! $tickets_exist) {
482
-                $SQL = "INSERT INTO $ticket_table
432
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
433
+		$script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
434
+		//setting up the DEFAULT stats and countries is also essential for the data migrations to run
435
+		//(because many need to convert old string states to foreign keys into the states table)
436
+		$script_with_defaults->insert_default_states();
437
+		$script_with_defaults->insert_default_countries();
438
+		//setting up DEFAULT prices, price types, and tickets is also essential for the price migrations
439
+		$script_with_defaults->insert_default_price_types();
440
+		$script_with_defaults->insert_default_prices();
441
+		//but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's
442
+		$this->insert_default_tickets();
443
+		//setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
444
+		EE_Config::instance()->update_espresso_config(false, true);
445
+		return true;
446
+	}
447
+
448
+
449
+
450
+	/**
451
+	 * @return boolean
452
+	 */
453
+	public function schema_changes_after_migration()
454
+	{
455
+		return true;
456
+	}
457
+
458
+
459
+
460
+	public function migration_page_hooks()
461
+	{
462
+	}
463
+
464
+
465
+
466
+	/**
467
+	 * insert DEFAULT ticket
468
+	 * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field
469
+	 *
470
+	 * @access public
471
+	 * @static
472
+	 * @return void
473
+	 */
474
+	public function insert_default_tickets()
475
+	{
476
+		global $wpdb;
477
+		$ticket_table = $wpdb->prefix . "esp_ticket";
478
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
479
+			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
480
+			$tickets_exist = $wpdb->get_var($SQL);
481
+			if ( ! $tickets_exist) {
482
+				$SQL = "INSERT INTO $ticket_table
483 483
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES
484 484
 					( 1, 0, '"
485
-                       . __("Free Ticket", "event_espresso")
486
-                       . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
487
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
488
-                $wpdb->query($SQL);
489
-            }
490
-        }
491
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
492
-        if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
493
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
494
-            $ticket_prc_exist = $wpdb->get_var($SQL);
495
-            if ( ! $ticket_prc_exist) {
496
-                $SQL = "INSERT INTO $ticket_price_table
485
+					   . __("Free Ticket", "event_espresso")
486
+					   . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
487
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
488
+				$wpdb->query($SQL);
489
+			}
490
+		}
491
+		$ticket_price_table = $wpdb->prefix . "esp_ticket_price";
492
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
493
+			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
494
+			$ticket_prc_exist = $wpdb->get_var($SQL);
495
+			if ( ! $ticket_prc_exist) {
496
+				$SQL = "INSERT INTO $ticket_price_table
497 497
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
498 498
 				( 1, 1, 1 )
499 499
 				";
500
-                $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
501
-                $wpdb->query($SQL);
502
-            }
503
-        }
504
-    }
500
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
501
+				$wpdb->query($SQL);
502
+			}
503
+		}
504
+	}
505 505
 
506 506
 }
507 507
 
Please login to merge, or discard this patch.
core/CPTs/EE_Register_CPTs.core.php 2 patches
Indentation   +614 added lines, -614 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
 
5 5
 
@@ -14,602 +14,602 @@  discard block
 block discarded – undo
14 14
 class EE_Register_CPTs
15 15
 {
16 16
 
17
-    /**
18
-     * This property is used to hold an array of EE_default_term objects assigned to a custom post type when the post
19
-     * for that post type is published with no terms set for the taxonomy.
20
-     *
21
-     * @var array of EE_Default_Term objects
22
-     */
23
-    protected $_default_terms = array();
24
-
25
-
26
-
27
-    /**
28
-     *    constructor
29
-     * instantiated at init priority 5
30
-     */
31
-    public function __construct()
32
-    {
33
-        // register taxonomies
34
-        $taxonomies = self::get_taxonomies();
35
-        foreach ($taxonomies as $taxonomy => $tax) {
36
-            $this->register_taxonomy($taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args']);
37
-        }
38
-        // register CPTs
39
-        $CPTs = self::get_CPTs();
40
-        foreach ($CPTs as $CPT_name => $CPT) {
41
-            $this->register_CPT($CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'],
42
-                $CPT['singular_slug'], $CPT['plural_slug']);
43
-        }
44
-        // setup default terms in any of our taxonomies (but only if we're in admin).
45
-        // Why not added via register_activation_hook?
46
-        // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies
47
-        // (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin.
48
-        // Keep in mind that this will READ these terms if they are deleted by the user.  Hence MUST use terms.
49
-        // if ( is_admin() ) {
50
-        // 	$this->set_must_use_event_types();
51
-        // }
52
-        //set default terms
53
-        $this->set_default_term('espresso_event_type', 'single-event', array('espresso_events'));
54
-        add_action('AHEE__EE_System__initialize_last', array(__CLASS__, 'maybe_flush_rewrite_rules'), 10);
55
-        // hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts
56
-        // IF they don't have a term for that taxonomy set.
57
-        add_action('save_post', array($this, 'save_default_term'), 100, 2);
58
-        // remove no html restrictions from core wp saving of term descriptions.
59
-        // Note. this will affect only registered EE taxonomies.
60
-        $this->_allow_html_descriptions_for_ee_taxonomies();
61
-        do_action('AHEE__EE_Register_CPTs__construct_end', $this);
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * This will flush rewrite rules on demand.  This actually gets called around wp init priority level 100.
68
-     *
69
-     * @since 4.5.0
70
-     * @return void
71
-     */
72
-    public static function maybe_flush_rewrite_rules()
73
-    {
74
-        if (get_option('ee_flush_rewrite_rules', true)) {
75
-            flush_rewrite_rules();
76
-            update_option('ee_flush_rewrite_rules', false);
77
-        }
78
-    }
79
-
80
-
81
-
82
-    /**
83
-     * By default, WordPress strips all html from term taxonomy description content.  The purpose of this method is to
84
-     * remove that restriction and ensure that we still run ee term taxonomy descriptions through some full html
85
-     * sanitization equivalent to the post content field.
86
-     *
87
-     * @since 4.7.8
88
-     */
89
-    protected function _allow_html_descriptions_for_ee_taxonomies()
90
-    {
91
-        // first remove default filter for term description but we have to do this earlier
92
-        // before wp sets their own filter
93
-        // because they just set a global filter on all term descriptions before the custom term description filter.
94
-        // Really sux.
95
-        add_filter('pre_term_description', array($this, 'ee_filter_ee_term_description_not_wp'), 1, 2);
96
-    }
97
-
98
-
99
-
100
-    /**
101
-     * Callback for pre_term_description hook.
102
-     *
103
-     * @param string $description The description content.
104
-     * @param string $taxonomy    The taxonomy name for the taxonomy being filtered.
105
-     * @return string
106
-     */
107
-    public function ee_filter_ee_term_description_not_wp($description, $taxonomy)
108
-    {
109
-        //get a list of EE taxonomies
110
-        $ee_taxonomies = array_keys(self::get_taxonomies());
111
-        //only do our own thing if the taxonomy listed is an ee taxonomy.
112
-        if (in_array($taxonomy, $ee_taxonomies, true)) {
113
-            //remove default wp filter
114
-            remove_filter('pre_term_description', 'wp_filter_kses');
115
-            //sanitize THIS content.
116
-            $description = wp_kses($description, wp_kses_allowed_html('post'));
117
-        }
118
-        return $description;
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     *    get_taxonomies
125
-     *
126
-     * @access    public
127
-     * @return    array
128
-     */
129
-    public static function get_taxonomies()
130
-    {
131
-        // define taxonomies
132
-        return apply_filters('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array(
133
-            'espresso_event_categories' => array(
134
-                'singular_name' => __("Event Category", "event_espresso"),
135
-                'plural_name'   => __("Event Categories", "event_espresso"),
136
-                'args'          => array(
137
-                    'public'            => true,
138
-                    'show_in_nav_menus' => true,
139
-                    'show_in_rest'      => true,
140
-                    'capabilities'      => array(
141
-                        'manage_terms' => 'ee_manage_event_categories',
142
-                        'edit_terms'   => 'ee_edit_event_category',
143
-                        'delete_terms' => 'ee_delete_event_category',
144
-                        'assign_terms' => 'ee_assign_event_category',
145
-                    ),
146
-                    'rewrite'           => array('slug' => __('event-category', 'event_espresso')),
147
-                ),
148
-            ),
149
-            'espresso_venue_categories' => array(
150
-                'singular_name' => __("Venue Category", "event_espresso"),
151
-                'plural_name'   => __("Venue Categories", "event_espresso"),
152
-                'args'          => array(
153
-                    'public'            => true,
154
-                    'show_in_nav_menus' => false, //by default this doesn't show for decaf
155
-                    'show_in_rest'      => true,
156
-                    'capabilities'      => array(
157
-                        'manage_terms' => 'ee_manage_venue_categories',
158
-                        'edit_terms'   => 'ee_edit_venue_category',
159
-                        'delete_terms' => 'ee_delete_venue_category',
160
-                        'assign_terms' => 'ee_assign_venue_category',
161
-                    ),
162
-                    'rewrite'           => array('slug' => __('venue-category', 'event_espresso')),
163
-                ),
164
-            ),
165
-            'espresso_event_type'       => array(
166
-                'singular_name' => __("Event Type", "event_espresso"),
167
-                'plural_name'   => __("Event Types", "event_espresso"),
168
-                'args'          => array(
169
-                    'public'       => true,
170
-                    'show_ui'      => false,
171
-                    'show_in_rest' => true,
172
-                    'capabilities' => array(
173
-                        'manage_terms' => 'ee_read_event_type',
174
-                        'edit_terms'   => 'ee_edit_event_type',
175
-                        'delete_terms' => 'ee_delete_event_type',
176
-                        'assign_terms' => 'ee_assign_event_type',
177
-                    ),
178
-                    'rewrite'      => array('slug' => __('event-type', 'event_espresso')),
179
-                    'hierarchical' => true,
180
-                ),
181
-            ),
182
-        ));
183
-    }
184
-
185
-
186
-
187
-    /**
188
-     * This returns the corresponding model name for cpts registered by EE.
189
-     *
190
-     * @since 4.6.16.rc.000
191
-     * @param string $post_type_slug              If a slug is included, then attempt to retrieve the model name for
192
-     *                                            the given cpt slug.  Otherwise if empty, then we'll return all cpt
193
-     *                                            model names for cpts registered in EE.
194
-     * @return array           Empty array if no matching model names for the given slug or an array of model
195
-     *                                            names indexed by post type slug.
196
-     */
197
-    public static function get_cpt_model_names($post_type_slug = '')
198
-    {
199
-        $cpts = self::get_CPTs();
200
-        //first if slug passed in...
201
-        if ( ! empty($post_type_slug)) {
202
-            //match?
203
-            if (
204
-                ! isset($cpts[$post_type_slug])
205
-                || (isset($cpts[$post_type_slug]) && empty($cpts[$post_type_slug]['class_name']))
206
-            ) {
207
-                return array();
208
-            }
209
-            //k let's get the model name for this cpt.
210
-            return array($post_type_slug => str_replace('EE', 'EEM', $cpts[$post_type_slug]['class_name']));
211
-        }
212
-        //if we made it here then we're returning an array of cpt model names indexed by post_type_slug.
213
-        $cpt_models = array();
214
-        foreach ($cpts as $slug => $args) {
215
-            if ( ! empty($args['class_name'])) {
216
-                $cpt_models[$slug] = str_replace('EE', 'EEM', $args['class_name']);
217
-            }
218
-        }
219
-        return $cpt_models;
220
-    }
221
-
222
-
223
-
224
-    /**
225
-     * This instantiates cpt models related to the cpts registered via EE.
226
-     *
227
-     * @since 4.6.16.rc.000
228
-     * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for
229
-     *                               the cpt matching the given slug.  Otherwise all cpt models will be
230
-     *                               instantiated (if possible).
231
-     * @return EEM_CPT_Base[]        successful instantiation will return an array of successfully instantiated
232
-     *                               EEM models indexed by post slug.
233
-     */
234
-    public static function instantiate_cpt_models($post_type_slug = '')
235
-    {
236
-        $cpt_model_names = self::get_cpt_model_names($post_type_slug);
237
-        $instantiated = array();
238
-        foreach ($cpt_model_names as $slug => $model_name) {
239
-            $instance = EE_Registry::instance()->load_model(str_replace('EEM_', '', $model_name));
240
-            if ($instance instanceof EEM_CPT_Base) {
241
-                $instantiated[$slug] = $instance;
242
-            }
243
-        }
244
-        return $instantiated;
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     *    get_CPTs
251
-     *
252
-     * @access    public
253
-     * @return    array
254
-     */
255
-    public static function get_CPTs()
256
-    {
257
-        // define CPTs
258
-        // NOTE the ['args']['page_templates'] array index is something specific to our CPTs
259
-        // and not part of the WP custom post type api.
260
-        return apply_filters('FHEE__EE_Register_CPTs__get_CPTs__cpts', array(
261
-            'espresso_events'    => array(
262
-                'singular_name' => __("Event", "event_espresso"),
263
-                'plural_name'   => __("Events", "event_espresso"),
264
-                'singular_slug' => __("event", "event_espresso"),
265
-                'plural_slug'   => EE_Registry::instance()->CFG->core->event_cpt_slug,
266
-                'class_name'    => 'EE_Event',
267
-                'args'          => array(
268
-                    'public'            => true,
269
-                    'show_in_nav_menus' => true,
270
-                    'capability_type'   => 'event',
271
-                    'capabilities'      => array(
272
-                        'edit_post'              => 'ee_edit_event',
273
-                        'read_post'              => 'ee_read_event',
274
-                        'delete_post'            => 'ee_delete_event',
275
-                        'edit_posts'             => 'ee_edit_events',
276
-                        'edit_others_posts'      => 'ee_edit_others_events',
277
-                        'publish_posts'          => 'ee_publish_events',
278
-                        'read_private_posts'     => 'ee_read_private_events',
279
-                        'delete_posts'           => 'ee_delete_events',
280
-                        'delete_private_posts'   => 'ee_delete_private_events',
281
-                        'delete_published_posts' => 'ee_delete_published_events',
282
-                        'delete_others_posts'    => 'ee_delete_others_events',
283
-                        'edit_private_posts'     => 'ee_edit_private_events',
284
-                        'edit_published_posts'   => 'ee_edit_published_events',
285
-                    ),
286
-                    'taxonomies'        => array(
287
-                        'espresso_event_categories',
288
-                        'espresso_event_type',
289
-                        'post_tag',
290
-                    ),
291
-                    'page_templates'    => true,
292
-                ),
293
-            ),
294
-            'espresso_venues'    => array(
295
-                'singular_name' => __("Venue", "event_espresso"),
296
-                'plural_name'   => __("Venues", "event_espresso"),
297
-                'singular_slug' => __("venue", "event_espresso"),
298
-                'plural_slug'   => __("venues", "event_espresso"),
299
-                'class_name'    => 'EE_Venue',
300
-                'args'          => array(
301
-                    'public'            => true,
302
-                    'show_in_nav_menus' => false, //by default this doesn't show for decaf,
303
-                    'capability_type'   => 'venue',
304
-                    'capabilities'      => array(
305
-                        'edit_post'              => 'ee_edit_venue',
306
-                        'read_post'              => 'ee_read_venue',
307
-                        'delete_post'            => 'ee_delete_venue',
308
-                        'edit_posts'             => 'ee_edit_venues',
309
-                        'edit_others_posts'      => 'ee_edit_others_venues',
310
-                        'publish_posts'          => 'ee_publish_venues',
311
-                        'read_private_posts'     => 'ee_read_private_venues',
312
-                        'delete_posts'           => 'ee_delete_venues',
313
-                        'delete_private_posts'   => 'ee_delete_private_venues',
314
-                        'delete_published_posts' => 'ee_delete_published_venues',
315
-                        'delete_others_posts'    => 'ee_edit_others_venues',
316
-                        'edit_private_posts'     => 'ee_edit_private_venues',
317
-                        'edit_published_posts'   => 'ee_edit_published_venues',
318
-                    ),
319
-                    'taxonomies'        => array(
320
-                        'espresso_venue_categories',
321
-                        'post_tag',
322
-                    ),
323
-                    'page_templates'    => true,
324
-                ),
325
-            ),
326
-            'espresso_attendees' => array(
327
-                'singular_name' => __("Contact", "event_espresso"),
328
-                'plural_name'   => __("Contacts", "event_espresso"),
329
-                'singular_slug' => __("contact", "event_espresso"),
330
-                'plural_slug'   => __("contacts", "event_espresso"),
331
-                'class_name'    => 'EE_Attendee',
332
-                'args'          => array(
333
-                    'public'             => false,
334
-                    'publicly_queryable' => false,
335
-                    'hierarchical'       => false,
336
-                    'has_archive'        => false,
337
-                    'taxonomies'         => array('post_tag'),
338
-                    'capability_type'    => 'contact',
339
-                    'capabilities'       => array(
340
-                        'edit_post'              => 'ee_edit_contact',
341
-                        'read_post'              => 'ee_read_contact',
342
-                        'delete_post'            => 'ee_delete_contact',
343
-                        'edit_posts'             => 'ee_edit_contacts',
344
-                        'edit_others_posts'      => 'ee_edit_contacts',
345
-                        'publish_posts'          => 'ee_edit_contacts',
346
-                        'read_private_posts'     => 'ee_edit_contacts',
347
-                        'delete_posts'           => 'ee_delete_contacts',
348
-                        'delete_private_posts'   => 'ee_delete_contacts',
349
-                        'delete_published_posts' => 'ee_delete_contacts',
350
-                        'delete_others_posts'    => 'ee_delete_contacts',
351
-                        'edit_private_posts'     => 'ee_edit_contacts',
352
-                        'edit_published_posts'   => 'ee_edit_contacts',
353
-                    ),
354
-                    'supports'           => array('editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'),
355
-                ),
356
-            ),
357
-        ));
358
-    }
359
-
360
-
361
-
362
-    /**
363
-     * This basically goes through the CPT array and returns only CPT's
364
-     * that have the ['args']['public'] option set as false
365
-     *
366
-     * @return array
367
-     */
368
-    public static function get_private_CPTs()
369
-    {
370
-        $CPTs = self::get_CPTs();
371
-        $private_CPTs = array();
372
-        foreach ($CPTs as $CPT => $details) {
373
-            if (empty($details['args']['public'])) {
374
-                $private_CPTs[$CPT] = $details;
375
-            }
376
-        }
377
-        return $private_CPTs;
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     * Registers a custom taxonomy. Should be called before registering custom post types,
384
-     * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'.
385
-     *
386
-     * @param string $taxonomy_name , eg 'books'
387
-     * @param string $singular_name internationalized singular name
388
-     * @param string $plural_name   internationalized plural name
389
-     * @param array  $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy
390
-     */
391
-    public function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array())
392
-    {
393
-        $args = array(
394
-            'hierarchical'      => true,
395
-            'labels'            => array(
396
-                'name'          => $plural_name,
397
-                'singular_name' => $singular_name,
398
-            ),
399
-            'show_ui'           => true,
400
-            'show_ee_ui'        => true,
401
-            'show_admin_column' => true,
402
-            'query_var'         => true,
403
-            'show_in_nav_menus' => false,
404
-            'map_meta_cap'      => true
405
-            //'rewrite'           => array( 'slug' => 'genre' ),
406
-        );
407
-        if ($override_args) {
408
-            if (isset($override_args['labels'])) {
409
-                $labels = array_merge($args['labels'], $override_args['labels']);
410
-                $args['labels'] = $labels;
411
-            }
412
-            $args = array_merge($args, $override_args);
413
-        }
414
-        register_taxonomy($taxonomy_name, null, $args);
415
-    }
416
-
417
-
418
-
419
-    /**
420
-     * Registers a new custom post type. Sets default settings given only the following params.
421
-     *
422
-     * @param string $post_type     the actual post type name
423
-     *                              (VERY IMPORTANT: this much match what the slug is for admin pages related to this
424
-     *                              cpt Also any models must use this slug as well)
425
-     * @param string $singular_name a pre-internationalized string for the singular name of the objects
426
-     * @param string $plural_name   a pre-internalized string for the plural name of the objects
427
-     * @param array  $override_args exactly like $args as described in
428
-     *                              http://codex.wordpress.org/Function_Reference/register_post_type The default values
429
-     *                              set in this function will be overridden by whatever you set in $override_args
430
-     * @param string $singular_slug
431
-     * @param string $plural_slug
432
-     * @return void , but registers the custom post type
433
-     */
434
-    public function register_CPT(
435
-        $post_type,
436
-        $singular_name,
437
-        $plural_name,
438
-        $override_args = array(),
439
-        $singular_slug = '',
440
-        $plural_slug = ''
441
-    ) {
442
-        $labels = array(
443
-            'name'               => $plural_name,
444
-            'singular_name'      => $singular_name,
445
-            'add_new'            => sprintf(__("Add %s", "event_espresso"), $singular_name),
446
-            'add_new_item'       => sprintf(__("Add New %s", "event_espresso"), $singular_name),
447
-            'edit_item'          => sprintf(__("Edit %s", "event_espresso"), $singular_name),
448
-            'new_item'           => sprintf(__("New %s", "event_espresso"), $singular_name),
449
-            'all_items'          => sprintf(__("All %s", "event_espresso"), $plural_name),
450
-            'view_item'          => sprintf(__("View %s", "event_espresso"), $singular_name),
451
-            'search_items'       => sprintf(__("Search %s", "event_espresso"), $plural_name),
452
-            'not_found'          => sprintf(__("No %s found", "event_espresso"), $plural_name),
453
-            'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"), $plural_name),
454
-            'parent_item_colon'  => '',
455
-            'menu_name'          => sprintf(__("%s", "event_espresso"), $plural_name),
456
-        );
457
-        //verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name
458
-        // $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name;
459
-        $plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name;
460
-        //note the page_templates arg in the supports index is something specific to EE.
461
-        //  WordPress doesn't actually have that in their register_post_type api.
462
-        $args = array(
463
-            'labels'             => $labels,
464
-            'public'             => true,
465
-            'publicly_queryable' => true,
466
-            'show_ui'            => false,
467
-            'show_ee_ui'         => true,
468
-            'show_in_menu'       => false,
469
-            'show_in_nav_menus'  => false,
470
-            'query_var'          => true,
471
-            'rewrite'            => apply_filters(
472
-                'FHEE__EE_Register_CPTs__register_CPT__rewrite',
473
-                array('slug' => $plural_slug),
474
-                $post_type
475
-            ),
476
-            'capability_type'    => 'post',
477
-            'map_meta_cap'       => true,
478
-            'has_archive'        => true,
479
-            'hierarchical'       => false,
480
-            'menu_position'      => null,
481
-            'supports'           => array(
482
-                'title',
483
-                'editor',
484
-                'author',
485
-                'thumbnail',
486
-                'excerpt',
487
-                'custom-fields',
488
-                'comments',
489
-            ),
490
-        );
491
-        if ($override_args) {
492
-            if (isset($override_args['labels'])) {
493
-                $labels = array_merge($args['labels'], $override_args['labels']);
494
-            }
495
-            $args = array_merge($args, $override_args);
496
-            $args['labels'] = $labels;
497
-        }
498
-        register_post_type($post_type, $args);
499
-    }
500
-
501
-
502
-
503
-    public function set_must_use_event_types()
504
-    {
505
-        $term_details = array(
506
-            //Attendee's register for the first date-time only
507
-            'single-event'    => array(
508
-                __('Single Event', 'event_espresso'),
509
-                __('A single event that spans one or more consecutive days.', 'event_espresso'),
510
-            ),
511
-            //example: a party or two-day long workshop
512
-            //Attendee's can register for any of the date-times
513
-            'multi-event'     => array(
514
-                __('Multi Event', 'event_espresso'),
515
-                __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso'),
516
-            ),
517
-            //example: a three day music festival or week long conference
518
-            //Attendee's register for the first date-time only
519
-            'event-series'    => array(
520
-                __('Event Series', 'event_espresso'),
521
-                __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso'),
522
-            ),
523
-            //example: an 8 week introduction to basket weaving course
524
-            //Attendee's can register for any of the date-times.
525
-            'recurring-event' => array(
526
-                __('Recurring Event', 'event_espresso'),
527
-                __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso'),
528
-            ),
529
-            //example: a yoga class
530
-            'ongoing' => array(
531
-                __('Ongoing Event', 'event_espresso'),
532
-                __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event',
533
-                    'event_espresso'),
534
-            )
535
-            //example: access to a museum
536
-            //'walk-in' => array( __('Walk In', 'event_espresso'), __('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ),
537
-            //'reservation' => array( __('Reservation', 'event_espresso'), __('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1
538
-            // 'multiple-session' => array( __('Multiple Session', 'event_espresso'), __('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1
539
-            //'appointment' => array( __('Appointments', 'event_espresso'), __('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') )
540
-        );
541
-        $this->set_must_use_terms('espresso_event_type', $term_details);
542
-    }
543
-
544
-
545
-
546
-    /**
547
-     * wrapper method for handling the setting up of initial terms in the db (if they don't already exist).
548
-     * Note this should ONLY be used for terms that always must be present.  Be aware that if an initial term is
549
-     * deleted then it WILL be recreated.
550
-     *
551
-     * @param string $taxonomy     The name of the taxonomy
552
-     * @param array  $term_details An array of term details indexed by slug and containing Name of term, and
553
-     *                             description as the elements in the array
554
-     * @return void
555
-     */
556
-    public function set_must_use_terms($taxonomy, $term_details)
557
-    {
558
-        $term_details = (array)$term_details;
559
-        foreach ($term_details as $slug => $details) {
560
-            if ( ! term_exists($slug, $taxonomy)) {
561
-                $insert_arr = array(
562
-                    'slug'        => $slug,
563
-                    'description' => $details[1],
564
-                );
565
-                wp_insert_term($details[0], $taxonomy, $insert_arr);
566
-            }
567
-        }
568
-    }
569
-
570
-
571
-
572
-    /**
573
-     * Allows us to set what the default will be for terms when a cpt is PUBLISHED.
574
-     *
575
-     * @param string $taxonomy  The taxonomy we're using for the default term
576
-     * @param string $term_slug The slug of the term that will be the default.
577
-     * @param array  $cpt_slugs An array of custom post types we want the default assigned to
578
-     */
579
-    public function set_default_term($taxonomy, $term_slug, $cpt_slugs = array())
580
-    {
581
-        $this->_default_terms[][$term_slug] = new EE_Default_Term($taxonomy, $term_slug, $cpt_slugs);
582
-    }
583
-
584
-
585
-
586
-    /**
587
-     * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property
588
-     *
589
-     * @param  int    $post_id ID of CPT being saved
590
-     * @param  object $post    Post object
591
-     * @return void
592
-     */
593
-    public function save_default_term($post_id, $post)
594
-    {
595
-        if (empty($this->_default_terms)) {
596
-            return;
597
-        } //no default terms set so lets just exit.
598
-        foreach ($this->_default_terms as $defaults) {
599
-            foreach ($defaults as $default_obj) {
600
-                if ($post->post_status === 'publish' && in_array($post->post_type, $default_obj->cpt_slugs, true)) {
601
-                    //note some error proofing going on here to save unnecessary db queries
602
-                    $taxonomies = get_object_taxonomies($post->post_type);
603
-                    foreach ((array)$taxonomies as $taxonomy) {
604
-                        $terms = wp_get_post_terms($post_id, $taxonomy);
605
-                        if (empty($terms) && $taxonomy === $default_obj->taxonomy) {
606
-                            wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy);
607
-                        }
608
-                    }
609
-                }
610
-            }
611
-        }
612
-    }
17
+	/**
18
+	 * This property is used to hold an array of EE_default_term objects assigned to a custom post type when the post
19
+	 * for that post type is published with no terms set for the taxonomy.
20
+	 *
21
+	 * @var array of EE_Default_Term objects
22
+	 */
23
+	protected $_default_terms = array();
24
+
25
+
26
+
27
+	/**
28
+	 *    constructor
29
+	 * instantiated at init priority 5
30
+	 */
31
+	public function __construct()
32
+	{
33
+		// register taxonomies
34
+		$taxonomies = self::get_taxonomies();
35
+		foreach ($taxonomies as $taxonomy => $tax) {
36
+			$this->register_taxonomy($taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args']);
37
+		}
38
+		// register CPTs
39
+		$CPTs = self::get_CPTs();
40
+		foreach ($CPTs as $CPT_name => $CPT) {
41
+			$this->register_CPT($CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'],
42
+				$CPT['singular_slug'], $CPT['plural_slug']);
43
+		}
44
+		// setup default terms in any of our taxonomies (but only if we're in admin).
45
+		// Why not added via register_activation_hook?
46
+		// Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies
47
+		// (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin.
48
+		// Keep in mind that this will READ these terms if they are deleted by the user.  Hence MUST use terms.
49
+		// if ( is_admin() ) {
50
+		// 	$this->set_must_use_event_types();
51
+		// }
52
+		//set default terms
53
+		$this->set_default_term('espresso_event_type', 'single-event', array('espresso_events'));
54
+		add_action('AHEE__EE_System__initialize_last', array(__CLASS__, 'maybe_flush_rewrite_rules'), 10);
55
+		// hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts
56
+		// IF they don't have a term for that taxonomy set.
57
+		add_action('save_post', array($this, 'save_default_term'), 100, 2);
58
+		// remove no html restrictions from core wp saving of term descriptions.
59
+		// Note. this will affect only registered EE taxonomies.
60
+		$this->_allow_html_descriptions_for_ee_taxonomies();
61
+		do_action('AHEE__EE_Register_CPTs__construct_end', $this);
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * This will flush rewrite rules on demand.  This actually gets called around wp init priority level 100.
68
+	 *
69
+	 * @since 4.5.0
70
+	 * @return void
71
+	 */
72
+	public static function maybe_flush_rewrite_rules()
73
+	{
74
+		if (get_option('ee_flush_rewrite_rules', true)) {
75
+			flush_rewrite_rules();
76
+			update_option('ee_flush_rewrite_rules', false);
77
+		}
78
+	}
79
+
80
+
81
+
82
+	/**
83
+	 * By default, WordPress strips all html from term taxonomy description content.  The purpose of this method is to
84
+	 * remove that restriction and ensure that we still run ee term taxonomy descriptions through some full html
85
+	 * sanitization equivalent to the post content field.
86
+	 *
87
+	 * @since 4.7.8
88
+	 */
89
+	protected function _allow_html_descriptions_for_ee_taxonomies()
90
+	{
91
+		// first remove default filter for term description but we have to do this earlier
92
+		// before wp sets their own filter
93
+		// because they just set a global filter on all term descriptions before the custom term description filter.
94
+		// Really sux.
95
+		add_filter('pre_term_description', array($this, 'ee_filter_ee_term_description_not_wp'), 1, 2);
96
+	}
97
+
98
+
99
+
100
+	/**
101
+	 * Callback for pre_term_description hook.
102
+	 *
103
+	 * @param string $description The description content.
104
+	 * @param string $taxonomy    The taxonomy name for the taxonomy being filtered.
105
+	 * @return string
106
+	 */
107
+	public function ee_filter_ee_term_description_not_wp($description, $taxonomy)
108
+	{
109
+		//get a list of EE taxonomies
110
+		$ee_taxonomies = array_keys(self::get_taxonomies());
111
+		//only do our own thing if the taxonomy listed is an ee taxonomy.
112
+		if (in_array($taxonomy, $ee_taxonomies, true)) {
113
+			//remove default wp filter
114
+			remove_filter('pre_term_description', 'wp_filter_kses');
115
+			//sanitize THIS content.
116
+			$description = wp_kses($description, wp_kses_allowed_html('post'));
117
+		}
118
+		return $description;
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 *    get_taxonomies
125
+	 *
126
+	 * @access    public
127
+	 * @return    array
128
+	 */
129
+	public static function get_taxonomies()
130
+	{
131
+		// define taxonomies
132
+		return apply_filters('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array(
133
+			'espresso_event_categories' => array(
134
+				'singular_name' => __("Event Category", "event_espresso"),
135
+				'plural_name'   => __("Event Categories", "event_espresso"),
136
+				'args'          => array(
137
+					'public'            => true,
138
+					'show_in_nav_menus' => true,
139
+					'show_in_rest'      => true,
140
+					'capabilities'      => array(
141
+						'manage_terms' => 'ee_manage_event_categories',
142
+						'edit_terms'   => 'ee_edit_event_category',
143
+						'delete_terms' => 'ee_delete_event_category',
144
+						'assign_terms' => 'ee_assign_event_category',
145
+					),
146
+					'rewrite'           => array('slug' => __('event-category', 'event_espresso')),
147
+				),
148
+			),
149
+			'espresso_venue_categories' => array(
150
+				'singular_name' => __("Venue Category", "event_espresso"),
151
+				'plural_name'   => __("Venue Categories", "event_espresso"),
152
+				'args'          => array(
153
+					'public'            => true,
154
+					'show_in_nav_menus' => false, //by default this doesn't show for decaf
155
+					'show_in_rest'      => true,
156
+					'capabilities'      => array(
157
+						'manage_terms' => 'ee_manage_venue_categories',
158
+						'edit_terms'   => 'ee_edit_venue_category',
159
+						'delete_terms' => 'ee_delete_venue_category',
160
+						'assign_terms' => 'ee_assign_venue_category',
161
+					),
162
+					'rewrite'           => array('slug' => __('venue-category', 'event_espresso')),
163
+				),
164
+			),
165
+			'espresso_event_type'       => array(
166
+				'singular_name' => __("Event Type", "event_espresso"),
167
+				'plural_name'   => __("Event Types", "event_espresso"),
168
+				'args'          => array(
169
+					'public'       => true,
170
+					'show_ui'      => false,
171
+					'show_in_rest' => true,
172
+					'capabilities' => array(
173
+						'manage_terms' => 'ee_read_event_type',
174
+						'edit_terms'   => 'ee_edit_event_type',
175
+						'delete_terms' => 'ee_delete_event_type',
176
+						'assign_terms' => 'ee_assign_event_type',
177
+					),
178
+					'rewrite'      => array('slug' => __('event-type', 'event_espresso')),
179
+					'hierarchical' => true,
180
+				),
181
+			),
182
+		));
183
+	}
184
+
185
+
186
+
187
+	/**
188
+	 * This returns the corresponding model name for cpts registered by EE.
189
+	 *
190
+	 * @since 4.6.16.rc.000
191
+	 * @param string $post_type_slug              If a slug is included, then attempt to retrieve the model name for
192
+	 *                                            the given cpt slug.  Otherwise if empty, then we'll return all cpt
193
+	 *                                            model names for cpts registered in EE.
194
+	 * @return array           Empty array if no matching model names for the given slug or an array of model
195
+	 *                                            names indexed by post type slug.
196
+	 */
197
+	public static function get_cpt_model_names($post_type_slug = '')
198
+	{
199
+		$cpts = self::get_CPTs();
200
+		//first if slug passed in...
201
+		if ( ! empty($post_type_slug)) {
202
+			//match?
203
+			if (
204
+				! isset($cpts[$post_type_slug])
205
+				|| (isset($cpts[$post_type_slug]) && empty($cpts[$post_type_slug]['class_name']))
206
+			) {
207
+				return array();
208
+			}
209
+			//k let's get the model name for this cpt.
210
+			return array($post_type_slug => str_replace('EE', 'EEM', $cpts[$post_type_slug]['class_name']));
211
+		}
212
+		//if we made it here then we're returning an array of cpt model names indexed by post_type_slug.
213
+		$cpt_models = array();
214
+		foreach ($cpts as $slug => $args) {
215
+			if ( ! empty($args['class_name'])) {
216
+				$cpt_models[$slug] = str_replace('EE', 'EEM', $args['class_name']);
217
+			}
218
+		}
219
+		return $cpt_models;
220
+	}
221
+
222
+
223
+
224
+	/**
225
+	 * This instantiates cpt models related to the cpts registered via EE.
226
+	 *
227
+	 * @since 4.6.16.rc.000
228
+	 * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for
229
+	 *                               the cpt matching the given slug.  Otherwise all cpt models will be
230
+	 *                               instantiated (if possible).
231
+	 * @return EEM_CPT_Base[]        successful instantiation will return an array of successfully instantiated
232
+	 *                               EEM models indexed by post slug.
233
+	 */
234
+	public static function instantiate_cpt_models($post_type_slug = '')
235
+	{
236
+		$cpt_model_names = self::get_cpt_model_names($post_type_slug);
237
+		$instantiated = array();
238
+		foreach ($cpt_model_names as $slug => $model_name) {
239
+			$instance = EE_Registry::instance()->load_model(str_replace('EEM_', '', $model_name));
240
+			if ($instance instanceof EEM_CPT_Base) {
241
+				$instantiated[$slug] = $instance;
242
+			}
243
+		}
244
+		return $instantiated;
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 *    get_CPTs
251
+	 *
252
+	 * @access    public
253
+	 * @return    array
254
+	 */
255
+	public static function get_CPTs()
256
+	{
257
+		// define CPTs
258
+		// NOTE the ['args']['page_templates'] array index is something specific to our CPTs
259
+		// and not part of the WP custom post type api.
260
+		return apply_filters('FHEE__EE_Register_CPTs__get_CPTs__cpts', array(
261
+			'espresso_events'    => array(
262
+				'singular_name' => __("Event", "event_espresso"),
263
+				'plural_name'   => __("Events", "event_espresso"),
264
+				'singular_slug' => __("event", "event_espresso"),
265
+				'plural_slug'   => EE_Registry::instance()->CFG->core->event_cpt_slug,
266
+				'class_name'    => 'EE_Event',
267
+				'args'          => array(
268
+					'public'            => true,
269
+					'show_in_nav_menus' => true,
270
+					'capability_type'   => 'event',
271
+					'capabilities'      => array(
272
+						'edit_post'              => 'ee_edit_event',
273
+						'read_post'              => 'ee_read_event',
274
+						'delete_post'            => 'ee_delete_event',
275
+						'edit_posts'             => 'ee_edit_events',
276
+						'edit_others_posts'      => 'ee_edit_others_events',
277
+						'publish_posts'          => 'ee_publish_events',
278
+						'read_private_posts'     => 'ee_read_private_events',
279
+						'delete_posts'           => 'ee_delete_events',
280
+						'delete_private_posts'   => 'ee_delete_private_events',
281
+						'delete_published_posts' => 'ee_delete_published_events',
282
+						'delete_others_posts'    => 'ee_delete_others_events',
283
+						'edit_private_posts'     => 'ee_edit_private_events',
284
+						'edit_published_posts'   => 'ee_edit_published_events',
285
+					),
286
+					'taxonomies'        => array(
287
+						'espresso_event_categories',
288
+						'espresso_event_type',
289
+						'post_tag',
290
+					),
291
+					'page_templates'    => true,
292
+				),
293
+			),
294
+			'espresso_venues'    => array(
295
+				'singular_name' => __("Venue", "event_espresso"),
296
+				'plural_name'   => __("Venues", "event_espresso"),
297
+				'singular_slug' => __("venue", "event_espresso"),
298
+				'plural_slug'   => __("venues", "event_espresso"),
299
+				'class_name'    => 'EE_Venue',
300
+				'args'          => array(
301
+					'public'            => true,
302
+					'show_in_nav_menus' => false, //by default this doesn't show for decaf,
303
+					'capability_type'   => 'venue',
304
+					'capabilities'      => array(
305
+						'edit_post'              => 'ee_edit_venue',
306
+						'read_post'              => 'ee_read_venue',
307
+						'delete_post'            => 'ee_delete_venue',
308
+						'edit_posts'             => 'ee_edit_venues',
309
+						'edit_others_posts'      => 'ee_edit_others_venues',
310
+						'publish_posts'          => 'ee_publish_venues',
311
+						'read_private_posts'     => 'ee_read_private_venues',
312
+						'delete_posts'           => 'ee_delete_venues',
313
+						'delete_private_posts'   => 'ee_delete_private_venues',
314
+						'delete_published_posts' => 'ee_delete_published_venues',
315
+						'delete_others_posts'    => 'ee_edit_others_venues',
316
+						'edit_private_posts'     => 'ee_edit_private_venues',
317
+						'edit_published_posts'   => 'ee_edit_published_venues',
318
+					),
319
+					'taxonomies'        => array(
320
+						'espresso_venue_categories',
321
+						'post_tag',
322
+					),
323
+					'page_templates'    => true,
324
+				),
325
+			),
326
+			'espresso_attendees' => array(
327
+				'singular_name' => __("Contact", "event_espresso"),
328
+				'plural_name'   => __("Contacts", "event_espresso"),
329
+				'singular_slug' => __("contact", "event_espresso"),
330
+				'plural_slug'   => __("contacts", "event_espresso"),
331
+				'class_name'    => 'EE_Attendee',
332
+				'args'          => array(
333
+					'public'             => false,
334
+					'publicly_queryable' => false,
335
+					'hierarchical'       => false,
336
+					'has_archive'        => false,
337
+					'taxonomies'         => array('post_tag'),
338
+					'capability_type'    => 'contact',
339
+					'capabilities'       => array(
340
+						'edit_post'              => 'ee_edit_contact',
341
+						'read_post'              => 'ee_read_contact',
342
+						'delete_post'            => 'ee_delete_contact',
343
+						'edit_posts'             => 'ee_edit_contacts',
344
+						'edit_others_posts'      => 'ee_edit_contacts',
345
+						'publish_posts'          => 'ee_edit_contacts',
346
+						'read_private_posts'     => 'ee_edit_contacts',
347
+						'delete_posts'           => 'ee_delete_contacts',
348
+						'delete_private_posts'   => 'ee_delete_contacts',
349
+						'delete_published_posts' => 'ee_delete_contacts',
350
+						'delete_others_posts'    => 'ee_delete_contacts',
351
+						'edit_private_posts'     => 'ee_edit_contacts',
352
+						'edit_published_posts'   => 'ee_edit_contacts',
353
+					),
354
+					'supports'           => array('editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'),
355
+				),
356
+			),
357
+		));
358
+	}
359
+
360
+
361
+
362
+	/**
363
+	 * This basically goes through the CPT array and returns only CPT's
364
+	 * that have the ['args']['public'] option set as false
365
+	 *
366
+	 * @return array
367
+	 */
368
+	public static function get_private_CPTs()
369
+	{
370
+		$CPTs = self::get_CPTs();
371
+		$private_CPTs = array();
372
+		foreach ($CPTs as $CPT => $details) {
373
+			if (empty($details['args']['public'])) {
374
+				$private_CPTs[$CPT] = $details;
375
+			}
376
+		}
377
+		return $private_CPTs;
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 * Registers a custom taxonomy. Should be called before registering custom post types,
384
+	 * otherwise you should link the taxonomy to the custom post type using 'register_taxonomy_for_object_type'.
385
+	 *
386
+	 * @param string $taxonomy_name , eg 'books'
387
+	 * @param string $singular_name internationalized singular name
388
+	 * @param string $plural_name   internationalized plural name
389
+	 * @param array  $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy
390
+	 */
391
+	public function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array())
392
+	{
393
+		$args = array(
394
+			'hierarchical'      => true,
395
+			'labels'            => array(
396
+				'name'          => $plural_name,
397
+				'singular_name' => $singular_name,
398
+			),
399
+			'show_ui'           => true,
400
+			'show_ee_ui'        => true,
401
+			'show_admin_column' => true,
402
+			'query_var'         => true,
403
+			'show_in_nav_menus' => false,
404
+			'map_meta_cap'      => true
405
+			//'rewrite'           => array( 'slug' => 'genre' ),
406
+		);
407
+		if ($override_args) {
408
+			if (isset($override_args['labels'])) {
409
+				$labels = array_merge($args['labels'], $override_args['labels']);
410
+				$args['labels'] = $labels;
411
+			}
412
+			$args = array_merge($args, $override_args);
413
+		}
414
+		register_taxonomy($taxonomy_name, null, $args);
415
+	}
416
+
417
+
418
+
419
+	/**
420
+	 * Registers a new custom post type. Sets default settings given only the following params.
421
+	 *
422
+	 * @param string $post_type     the actual post type name
423
+	 *                              (VERY IMPORTANT: this much match what the slug is for admin pages related to this
424
+	 *                              cpt Also any models must use this slug as well)
425
+	 * @param string $singular_name a pre-internationalized string for the singular name of the objects
426
+	 * @param string $plural_name   a pre-internalized string for the plural name of the objects
427
+	 * @param array  $override_args exactly like $args as described in
428
+	 *                              http://codex.wordpress.org/Function_Reference/register_post_type The default values
429
+	 *                              set in this function will be overridden by whatever you set in $override_args
430
+	 * @param string $singular_slug
431
+	 * @param string $plural_slug
432
+	 * @return void , but registers the custom post type
433
+	 */
434
+	public function register_CPT(
435
+		$post_type,
436
+		$singular_name,
437
+		$plural_name,
438
+		$override_args = array(),
439
+		$singular_slug = '',
440
+		$plural_slug = ''
441
+	) {
442
+		$labels = array(
443
+			'name'               => $plural_name,
444
+			'singular_name'      => $singular_name,
445
+			'add_new'            => sprintf(__("Add %s", "event_espresso"), $singular_name),
446
+			'add_new_item'       => sprintf(__("Add New %s", "event_espresso"), $singular_name),
447
+			'edit_item'          => sprintf(__("Edit %s", "event_espresso"), $singular_name),
448
+			'new_item'           => sprintf(__("New %s", "event_espresso"), $singular_name),
449
+			'all_items'          => sprintf(__("All %s", "event_espresso"), $plural_name),
450
+			'view_item'          => sprintf(__("View %s", "event_espresso"), $singular_name),
451
+			'search_items'       => sprintf(__("Search %s", "event_espresso"), $plural_name),
452
+			'not_found'          => sprintf(__("No %s found", "event_espresso"), $plural_name),
453
+			'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"), $plural_name),
454
+			'parent_item_colon'  => '',
455
+			'menu_name'          => sprintf(__("%s", "event_espresso"), $plural_name),
456
+		);
457
+		//verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name
458
+		// $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name;
459
+		$plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name;
460
+		//note the page_templates arg in the supports index is something specific to EE.
461
+		//  WordPress doesn't actually have that in their register_post_type api.
462
+		$args = array(
463
+			'labels'             => $labels,
464
+			'public'             => true,
465
+			'publicly_queryable' => true,
466
+			'show_ui'            => false,
467
+			'show_ee_ui'         => true,
468
+			'show_in_menu'       => false,
469
+			'show_in_nav_menus'  => false,
470
+			'query_var'          => true,
471
+			'rewrite'            => apply_filters(
472
+				'FHEE__EE_Register_CPTs__register_CPT__rewrite',
473
+				array('slug' => $plural_slug),
474
+				$post_type
475
+			),
476
+			'capability_type'    => 'post',
477
+			'map_meta_cap'       => true,
478
+			'has_archive'        => true,
479
+			'hierarchical'       => false,
480
+			'menu_position'      => null,
481
+			'supports'           => array(
482
+				'title',
483
+				'editor',
484
+				'author',
485
+				'thumbnail',
486
+				'excerpt',
487
+				'custom-fields',
488
+				'comments',
489
+			),
490
+		);
491
+		if ($override_args) {
492
+			if (isset($override_args['labels'])) {
493
+				$labels = array_merge($args['labels'], $override_args['labels']);
494
+			}
495
+			$args = array_merge($args, $override_args);
496
+			$args['labels'] = $labels;
497
+		}
498
+		register_post_type($post_type, $args);
499
+	}
500
+
501
+
502
+
503
+	public function set_must_use_event_types()
504
+	{
505
+		$term_details = array(
506
+			//Attendee's register for the first date-time only
507
+			'single-event'    => array(
508
+				__('Single Event', 'event_espresso'),
509
+				__('A single event that spans one or more consecutive days.', 'event_espresso'),
510
+			),
511
+			//example: a party or two-day long workshop
512
+			//Attendee's can register for any of the date-times
513
+			'multi-event'     => array(
514
+				__('Multi Event', 'event_espresso'),
515
+				__('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso'),
516
+			),
517
+			//example: a three day music festival or week long conference
518
+			//Attendee's register for the first date-time only
519
+			'event-series'    => array(
520
+				__('Event Series', 'event_espresso'),
521
+				__(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso'),
522
+			),
523
+			//example: an 8 week introduction to basket weaving course
524
+			//Attendee's can register for any of the date-times.
525
+			'recurring-event' => array(
526
+				__('Recurring Event', 'event_espresso'),
527
+				__('Multiple events that occur over multiple non-consecutive days.', 'event_espresso'),
528
+			),
529
+			//example: a yoga class
530
+			'ongoing' => array(
531
+				__('Ongoing Event', 'event_espresso'),
532
+				__('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event',
533
+					'event_espresso'),
534
+			)
535
+			//example: access to a museum
536
+			//'walk-in' => array( __('Walk In', 'event_espresso'), __('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ),
537
+			//'reservation' => array( __('Reservation', 'event_espresso'), __('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1
538
+			// 'multiple-session' => array( __('Multiple Session', 'event_espresso'), __('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1
539
+			//'appointment' => array( __('Appointments', 'event_espresso'), __('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') )
540
+		);
541
+		$this->set_must_use_terms('espresso_event_type', $term_details);
542
+	}
543
+
544
+
545
+
546
+	/**
547
+	 * wrapper method for handling the setting up of initial terms in the db (if they don't already exist).
548
+	 * Note this should ONLY be used for terms that always must be present.  Be aware that if an initial term is
549
+	 * deleted then it WILL be recreated.
550
+	 *
551
+	 * @param string $taxonomy     The name of the taxonomy
552
+	 * @param array  $term_details An array of term details indexed by slug and containing Name of term, and
553
+	 *                             description as the elements in the array
554
+	 * @return void
555
+	 */
556
+	public function set_must_use_terms($taxonomy, $term_details)
557
+	{
558
+		$term_details = (array)$term_details;
559
+		foreach ($term_details as $slug => $details) {
560
+			if ( ! term_exists($slug, $taxonomy)) {
561
+				$insert_arr = array(
562
+					'slug'        => $slug,
563
+					'description' => $details[1],
564
+				);
565
+				wp_insert_term($details[0], $taxonomy, $insert_arr);
566
+			}
567
+		}
568
+	}
569
+
570
+
571
+
572
+	/**
573
+	 * Allows us to set what the default will be for terms when a cpt is PUBLISHED.
574
+	 *
575
+	 * @param string $taxonomy  The taxonomy we're using for the default term
576
+	 * @param string $term_slug The slug of the term that will be the default.
577
+	 * @param array  $cpt_slugs An array of custom post types we want the default assigned to
578
+	 */
579
+	public function set_default_term($taxonomy, $term_slug, $cpt_slugs = array())
580
+	{
581
+		$this->_default_terms[][$term_slug] = new EE_Default_Term($taxonomy, $term_slug, $cpt_slugs);
582
+	}
583
+
584
+
585
+
586
+	/**
587
+	 * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property
588
+	 *
589
+	 * @param  int    $post_id ID of CPT being saved
590
+	 * @param  object $post    Post object
591
+	 * @return void
592
+	 */
593
+	public function save_default_term($post_id, $post)
594
+	{
595
+		if (empty($this->_default_terms)) {
596
+			return;
597
+		} //no default terms set so lets just exit.
598
+		foreach ($this->_default_terms as $defaults) {
599
+			foreach ($defaults as $default_obj) {
600
+				if ($post->post_status === 'publish' && in_array($post->post_type, $default_obj->cpt_slugs, true)) {
601
+					//note some error proofing going on here to save unnecessary db queries
602
+					$taxonomies = get_object_taxonomies($post->post_type);
603
+					foreach ((array)$taxonomies as $taxonomy) {
604
+						$terms = wp_get_post_terms($post_id, $taxonomy);
605
+						if (empty($terms) && $taxonomy === $default_obj->taxonomy) {
606
+							wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy);
607
+						}
608
+					}
609
+				}
610
+			}
611
+		}
612
+	}
613 613
 
614 614
 }
615 615
 
@@ -623,27 +623,27 @@  discard block
 block discarded – undo
623 623
 {
624 624
 
625 625
 
626
-    //props holding the items
627
-    public $taxonomy  = '';
626
+	//props holding the items
627
+	public $taxonomy  = '';
628 628
 
629
-    public $cpt_slugs = array();
629
+	public $cpt_slugs = array();
630 630
 
631
-    public $term_slug = '';
631
+	public $term_slug = '';
632 632
 
633 633
 
634 634
 
635
-    /**
636
-     * constructor
637
-     *
638
-     * @param string $taxonomy  The taxonomy the default term belongs to
639
-     * @param string $term_slug The slug of the term that will be the default.
640
-     * @param array  $cpt_slugs The custom post type the default term gets saved with
641
-     */
642
-    public function __construct($taxonomy, $term_slug, $cpt_slugs = array())
643
-    {
644
-        $this->taxonomy = $taxonomy;
645
-        $this->cpt_slugs = (array)$cpt_slugs;
646
-        $this->term_slug = $term_slug;
647
-    }
635
+	/**
636
+	 * constructor
637
+	 *
638
+	 * @param string $taxonomy  The taxonomy the default term belongs to
639
+	 * @param string $term_slug The slug of the term that will be the default.
640
+	 * @param array  $cpt_slugs The custom post type the default term gets saved with
641
+	 */
642
+	public function __construct($taxonomy, $term_slug, $cpt_slugs = array())
643
+	{
644
+		$this->taxonomy = $taxonomy;
645
+		$this->cpt_slugs = (array)$cpt_slugs;
646
+		$this->term_slug = $term_slug;
647
+	}
648 648
 
649 649
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
      */
556 556
     public function set_must_use_terms($taxonomy, $term_details)
557 557
     {
558
-        $term_details = (array)$term_details;
558
+        $term_details = (array) $term_details;
559 559
         foreach ($term_details as $slug => $details) {
560 560
             if ( ! term_exists($slug, $taxonomy)) {
561 561
                 $insert_arr = array(
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
                 if ($post->post_status === 'publish' && in_array($post->post_type, $default_obj->cpt_slugs, true)) {
601 601
                     //note some error proofing going on here to save unnecessary db queries
602 602
                     $taxonomies = get_object_taxonomies($post->post_type);
603
-                    foreach ((array)$taxonomies as $taxonomy) {
603
+                    foreach ((array) $taxonomies as $taxonomy) {
604 604
                         $terms = wp_get_post_terms($post_id, $taxonomy);
605 605
                         if (empty($terms) && $taxonomy === $default_obj->taxonomy) {
606 606
                             wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy);
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
     public function __construct($taxonomy, $term_slug, $cpt_slugs = array())
643 643
     {
644 644
         $this->taxonomy = $taxonomy;
645
-        $this->cpt_slugs = (array)$cpt_slugs;
645
+        $this->cpt_slugs = (array) $cpt_slugs;
646 646
         $this->term_slug = $term_slug;
647 647
     }
648 648
 
Please login to merge, or discard this patch.