Completed
Branch BUG/tickets-password-protected (b3a330)
by
unknown
09:09 queued 27s
created
4_3_0_stages/EE_DMS_4_3_0_event_message_templates.dmsstage.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,59 +13,59 @@
 block discarded – undo
13 13
 class EE_DMS_4_3_0_event_message_templates extends EE_Data_Migration_Script_Stage_Table
14 14
 {
15 15
 
16
-    /**
17
-     * This property will hold the table name for event_message_templates
18
-     * @var string
19
-     */
20
-    private $_emt_table;
16
+	/**
17
+	 * This property will hold the table name for event_message_templates
18
+	 * @var string
19
+	 */
20
+	private $_emt_table;
21 21
 
22 22
 
23
-    public function __construct()
24
-    {
25
-        global $wpdb;
26
-        $this->_pretty_name = __('Event Message Templates', 'event_espresso');
27
-        $this->_old_table = $wpdb->prefix."esp_message_template_group";
28
-        $this->_emt_table = $wpdb->prefix."esp_event_message_template";
29
-        parent::__construct();
30
-    }
23
+	public function __construct()
24
+	{
25
+		global $wpdb;
26
+		$this->_pretty_name = __('Event Message Templates', 'event_espresso');
27
+		$this->_old_table = $wpdb->prefix."esp_message_template_group";
28
+		$this->_emt_table = $wpdb->prefix."esp_event_message_template";
29
+		parent::__construct();
30
+	}
31 31
 
32 32
 
33 33
 
34
-    protected function _migrate_old_row($old_row)
35
-    {
36
-        // foreach row that has an evt_id ..let's create an equivalent entry in the new event_messages_template table to link the message template to the event (since EVT_ID is no longer referenced in esp_message_template_groups )
37
-        global $wpdb;
38
-        if ($old_row['EVT_ID'] > 0) {
39
-                                    // let's get the EVT for this id so we can update the custom name on the old row.
40
-                                    $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID'])));
34
+	protected function _migrate_old_row($old_row)
35
+	{
36
+		// foreach row that has an evt_id ..let's create an equivalent entry in the new event_messages_template table to link the message template to the event (since EVT_ID is no longer referenced in esp_message_template_groups )
37
+		global $wpdb;
38
+		if ($old_row['EVT_ID'] > 0) {
39
+									// let's get the EVT for this id so we can update the custom name on the old row.
40
+									$event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID'])));
41 41
 
42
-                                    // update name
43
-                                    $updated = $wpdb->update(
44
-                                        $this->_old_table,
45
-                                        array(
46
-                                            'MTP_name' =>$event_name
47
-                                            ),
48
-                                        array( 'GRP_ID' => (int) $old_row['GRP_ID'] ),
49
-                                        array( '%s' ),
50
-                                        array( '%d' )
51
-                                    );
42
+									// update name
43
+									$updated = $wpdb->update(
44
+										$this->_old_table,
45
+										array(
46
+											'MTP_name' =>$event_name
47
+											),
48
+										array( 'GRP_ID' => (int) $old_row['GRP_ID'] ),
49
+										array( '%s' ),
50
+										array( '%d' )
51
+									);
52 52
 
53
-            $inserted = $wpdb->insert(
54
-                $this->_emt_table,
55
-                array(
56
-                    'EVT_ID' => (int) $old_row['EVT_ID'],
57
-                    'GRP_ID' => (int) $old_row['GRP_ID'],
58
-                    ),
59
-                array( '%d', '%d' )
60
-            );
53
+			$inserted = $wpdb->insert(
54
+				$this->_emt_table,
55
+				array(
56
+					'EVT_ID' => (int) $old_row['EVT_ID'],
57
+					'GRP_ID' => (int) $old_row['GRP_ID'],
58
+					),
59
+				array( '%d', '%d' )
60
+			);
61 61
 
62
-            if (false === $updated) {
63
-                $this->add_error(sprintf(__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name));
64
-            }
62
+			if (false === $updated) {
63
+				$this->add_error(sprintf(__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name));
64
+			}
65 65
 
66
-            if (false === $inserted) {
67
-                $this->add_error(sprintf(__("Error in inserting a row into  setting EVT_ID = %d and GRP_ID = %d", "event_espresso"), $this->_emt_table, $old_row['EVT_ID'], $old_row['GRP_ID']));
68
-            }
69
-        }
70
-    }
66
+			if (false === $inserted) {
67
+				$this->add_error(sprintf(__("Error in inserting a row into  setting EVT_ID = %d and GRP_ID = %d", "event_espresso"), $this->_emt_table, $old_row['EVT_ID'], $old_row['GRP_ID']));
68
+			}
69
+		}
70
+	}
71 71
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         global $wpdb;
38 38
         if ($old_row['EVT_ID'] > 0) {
39 39
                                     // let's get the EVT for this id so we can update the custom name on the old row.
40
-                                    $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID'])));
40
+                                    $event_name = 'Custom Template for '.$wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID'])));
41 41
 
42 42
                                     // update name
43 43
                                     $updated = $wpdb->update(
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
                                         array(
46 46
                                             'MTP_name' =>$event_name
47 47
                                             ),
48
-                                        array( 'GRP_ID' => (int) $old_row['GRP_ID'] ),
49
-                                        array( '%s' ),
50
-                                        array( '%d' )
48
+                                        array('GRP_ID' => (int) $old_row['GRP_ID']),
49
+                                        array('%s'),
50
+                                        array('%d')
51 51
                                     );
52 52
 
53 53
             $inserted = $wpdb->insert(
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                     'EVT_ID' => (int) $old_row['EVT_ID'],
57 57
                     'GRP_ID' => (int) $old_row['GRP_ID'],
58 58
                     ),
59
-                array( '%d', '%d' )
59
+                array('%d', '%d')
60 60
             );
61 61
 
62 62
             if (false === $updated) {
Please login to merge, or discard this patch.
4_3_0_stages/EE_DMS_4_3_0_question_option_order.dmsstage.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -7,39 +7,39 @@
 block discarded – undo
7 7
 
8 8
 class EE_DMS_4_3_0_question_option_order extends EE_Data_Migration_Script_Stage_Table
9 9
 {
10
-    public function __construct()
11
-    {
12
-        global $wpdb;
13
-        $this->_pretty_name = __("Question Options", "event_espresso");
14
-        $this->_old_table = $wpdb->prefix."esp_question_option";
15
-        parent::__construct();
16
-    }
17
-    protected function _migrate_old_row($old_row)
18
-    {
19
-        // foreach question_group_question entry with this QST_ID, we want to set its
20
-        // QSG_order equal to this question's QST_order
21
-        global $wpdb;
22
-        $updated = $wpdb->update(
23
-            $this->_old_table,
24
-            array('QSO_order'=>$old_row['QSO_ID']),
25
-            array('QSO_ID'=>$old_row['QSO_ID']),
26
-            array('%d',// QSO_order
27
-                    ),
28
-            array('%d',// QSO_ID
29
-                    )
30
-        );
31
-        if (false === $updated) {
32
-            $this->add_error(
33
-                sprintf(
34
-                    __(
35
-                        "Error in updating table %s setting QSO_order = %d where QSO_ID = %d",
36
-                        'event_espresso'
37
-                    ),
38
-                    $this->_old_table,
39
-                    $old_row['QSO_ID'],
40
-                    $old_row['QSO_ID']
41
-                )
42
-            );
43
-        }
44
-    }
10
+	public function __construct()
11
+	{
12
+		global $wpdb;
13
+		$this->_pretty_name = __("Question Options", "event_espresso");
14
+		$this->_old_table = $wpdb->prefix."esp_question_option";
15
+		parent::__construct();
16
+	}
17
+	protected function _migrate_old_row($old_row)
18
+	{
19
+		// foreach question_group_question entry with this QST_ID, we want to set its
20
+		// QSG_order equal to this question's QST_order
21
+		global $wpdb;
22
+		$updated = $wpdb->update(
23
+			$this->_old_table,
24
+			array('QSO_order'=>$old_row['QSO_ID']),
25
+			array('QSO_ID'=>$old_row['QSO_ID']),
26
+			array('%d',// QSO_order
27
+					),
28
+			array('%d',// QSO_ID
29
+					)
30
+		);
31
+		if (false === $updated) {
32
+			$this->add_error(
33
+				sprintf(
34
+					__(
35
+						"Error in updating table %s setting QSO_order = %d where QSO_ID = %d",
36
+						'event_espresso'
37
+					),
38
+					$this->_old_table,
39
+					$old_row['QSO_ID'],
40
+					$old_row['QSO_ID']
41
+				)
42
+			);
43
+		}
44
+	}
45 45
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@
 block discarded – undo
23 23
             $this->_old_table,
24 24
             array('QSO_order'=>$old_row['QSO_ID']),
25 25
             array('QSO_ID'=>$old_row['QSO_ID']),
26
-            array('%d',// QSO_order
26
+            array('%d', // QSO_order
27 27
                     ),
28
-            array('%d',// QSO_ID
28
+            array('%d', // QSO_ID
29 29
                     )
30 30
         );
31 31
         if (false === $updated) {
Please login to merge, or discard this patch.
core/EE_Front_Controller.core.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
         print(
345 345
         apply_filters(
346 346
             'FHEE__EE_Front_Controller__header_meta_tag',
347
-            '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
347
+            '<meta name="generator" content="Event Espresso Version '.EVENT_ESPRESSO_VERSION."\" />\n"
348 348
         )
349 349
         );
350 350
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
             print(
361 361
             apply_filters(
362 362
                 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
363
-                '<meta name="robots" content="noindex,follow" />' . "\n"
363
+                '<meta name="robots" content="noindex,follow" />'."\n"
364 364
             )
365 365
             );
366 366
         }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
     {
414 414
         static $shown_already = false;
415 415
         do_action('AHEE__EE_Front_Controller__display_errors__begin');
416
-        if (! $shown_already
416
+        if ( ! $shown_already
417 417
             && apply_filters('FHEE__EE_Front_Controller__display_errors', true)
418 418
             && is_main_query()
419 419
             && ! is_feed()
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
         ) {
423 423
             echo EE_Error::get_notices();
424 424
             $shown_already = true;
425
-            EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
425
+            EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php');
426 426
         }
427 427
         do_action('AHEE__EE_Front_Controller__display_errors__end');
428 428
     }
Please login to merge, or discard this patch.
Indentation   +463 added lines, -463 removed lines patch added patch discarded remove patch
@@ -26,467 +26,467 @@
 block discarded – undo
26 26
 final class EE_Front_Controller
27 27
 {
28 28
 
29
-    /**
30
-     * @var string $_template_path
31
-     */
32
-    private $_template_path;
33
-
34
-    /**
35
-     * @var string $_template
36
-     */
37
-    private $_template;
38
-
39
-    /**
40
-     * @type EE_Registry $Registry
41
-     */
42
-    protected $Registry;
43
-
44
-    /**
45
-     * @type EE_Request_Handler $Request_Handler
46
-     */
47
-    protected $Request_Handler;
48
-
49
-    /**
50
-     * @type EE_Module_Request_Router $Module_Request_Router
51
-     */
52
-    protected $Module_Request_Router;
53
-
54
-
55
-    /**
56
-     *    class constructor
57
-     *    should fire after shortcode, module, addon, or other plugin's default priority init phases have run
58
-     *
59
-     * @access    public
60
-     * @param \EE_Registry              $Registry
61
-     * @param \EE_Request_Handler       $Request_Handler
62
-     * @param \EE_Module_Request_Router $Module_Request_Router
63
-     */
64
-    public function __construct(
65
-        EE_Registry $Registry,
66
-        EE_Request_Handler $Request_Handler,
67
-        EE_Module_Request_Router $Module_Request_Router
68
-    ) {
69
-        $this->Registry = $Registry;
70
-        $this->Request_Handler = $Request_Handler;
71
-        $this->Module_Request_Router = $Module_Request_Router;
72
-        // load other resources and begin to actually run shortcodes and modules
73
-        add_action('wp_loaded', array($this, 'wp_loaded'), 5);
74
-        // analyse the incoming WP request
75
-        add_action('parse_request', array($this, 'get_request'), 1, 1);
76
-        // process request with module factory
77
-        add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1);
78
-        // before headers sent
79
-        add_action('wp', array($this, 'wp'), 5);
80
-        // primarily used to process any content shortcodes
81
-        add_action('template_redirect', array($this, 'templateRedirect'), 999);
82
-        // header
83
-        add_action('wp_head', array($this, 'header_meta_tag'), 5);
84
-        add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10);
85
-        add_filter('template_include', array($this, 'template_include'), 1);
86
-        // display errors
87
-        add_action('loop_start', array($this, 'display_errors'), 2);
88
-        // the content
89
-        // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );
90
-        // exclude our private cpt comments
91
-        add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1);
92
-        // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://)
93
-        add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1);
94
-        // action hook EE
95
-        do_action('AHEE__EE_Front_Controller__construct__done', $this);
96
-    }
97
-
98
-
99
-    /**
100
-     * @return EE_Request_Handler
101
-     */
102
-    public function Request_Handler()
103
-    {
104
-        return $this->Request_Handler;
105
-    }
106
-
107
-
108
-    /**
109
-     * @return EE_Module_Request_Router
110
-     */
111
-    public function Module_Request_Router()
112
-    {
113
-        return $this->Module_Request_Router;
114
-    }
115
-
116
-
117
-    /**
118
-     * @return LegacyShortcodesManager
119
-     */
120
-    public function getLegacyShortcodesManager()
121
-    {
122
-        return EE_Config::getLegacyShortcodesManager();
123
-    }
124
-
125
-
126
-
127
-
128
-
129
-    /***********************************************        INIT ACTION HOOK         ***********************************************/
130
-    /**
131
-     * filter_wp_comments
132
-     * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment
133
-     * widgets/queries done on frontend
134
-     *
135
-     * @param  array $clauses array of comment clauses setup by WP_Comment_Query
136
-     * @return array array of comment clauses with modifications.
137
-     * @throws InvalidArgumentException
138
-     * @throws InvalidDataTypeException
139
-     * @throws InvalidInterfaceException
140
-     */
141
-    public function filter_wp_comments($clauses)
142
-    {
143
-        global $wpdb;
144
-        if (strpos($clauses['join'], $wpdb->posts) !== false) {
145
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
146
-            $custom_post_types = LoaderFactory::getLoader()->getShared(
147
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
148
-            );
149
-            $cpts = $custom_post_types->getPrivateCustomPostTypes();
150
-            foreach ($cpts as $cpt => $details) {
151
-                $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt);
152
-            }
153
-        }
154
-        return $clauses;
155
-    }
156
-
157
-
158
-    /**
159
-     * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend
160
-     *
161
-     * @param  string $url incoming url
162
-     * @return string         final assembled url
163
-     */
164
-    public function maybe_force_admin_ajax_ssl($url)
165
-    {
166
-        if (is_ssl() && preg_match('/admin-ajax.php/', $url)) {
167
-            $url = str_replace('http://', 'https://', $url);
168
-        }
169
-        return $url;
170
-    }
171
-
172
-
173
-
174
-
175
-
176
-
177
-    /***********************************************        WP_LOADED ACTION HOOK         ***********************************************/
178
-
179
-
180
-    /**
181
-     *    wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their
182
-     *    default priority init phases have run
183
-     *
184
-     * @access    public
185
-     * @return    void
186
-     */
187
-    public function wp_loaded()
188
-    {
189
-    }
190
-
191
-
192
-
193
-
194
-
195
-    /***********************************************        PARSE_REQUEST HOOK         ***********************************************/
196
-    /**
197
-     *    _get_request
198
-     *
199
-     * @access public
200
-     * @param WP $WP
201
-     * @return void
202
-     */
203
-    public function get_request(WP $WP)
204
-    {
205
-        do_action('AHEE__EE_Front_Controller__get_request__start');
206
-        $this->Request_Handler->parse_request($WP);
207
-        do_action('AHEE__EE_Front_Controller__get_request__complete');
208
-    }
209
-
210
-
211
-    /**
212
-     *    pre_get_posts - basically a module factory for instantiating modules and selecting the final view template
213
-     *
214
-     * @access    public
215
-     * @param   WP_Query $WP_Query
216
-     * @return    void
217
-     */
218
-    public function pre_get_posts($WP_Query)
219
-    {
220
-        // only load Module_Request_Router if this is the main query
221
-        if ($this->Module_Request_Router instanceof EE_Module_Request_Router
222
-            && $WP_Query->is_main_query()
223
-        ) {
224
-            // cycle thru module routes
225
-            while ($route = $this->Module_Request_Router->get_route($WP_Query)) {
226
-                // determine module and method for route
227
-                $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);
228
-                if ($module instanceof EED_Module) {
229
-                    // get registered view for route
230
-                    $this->_template_path = $this->Module_Request_Router->get_view($route);
231
-                    // grab module name
232
-                    $module_name = $module->module_name();
233
-                    // map the module to the module objects
234
-                    $this->Registry->modules->{$module_name} = $module;
235
-                }
236
-            }
237
-        }
238
-    }
239
-
240
-
241
-
242
-
243
-
244
-    /***********************************************        WP HOOK         ***********************************************/
245
-
246
-
247
-    /**
248
-     *    wp - basically last chance to do stuff before headers sent
249
-     *
250
-     * @access    public
251
-     * @return    void
252
-     */
253
-    public function wp()
254
-    {
255
-    }
256
-
257
-
258
-
259
-    /***********************     GET_HEADER && WP_HEAD HOOK     ***********************/
260
-
261
-
262
-    /**
263
-     * callback for the "template_redirect" hook point
264
-     * checks sidebars for EE widgets
265
-     * loads resources and assets accordingly
266
-     *
267
-     * @return void
268
-     */
269
-    public function templateRedirect()
270
-    {
271
-        global $wp_query;
272
-        if (empty($wp_query->posts)) {
273
-            return;
274
-        }
275
-        // if we already know this is an espresso page, then load assets
276
-        $load_assets = $this->Request_Handler->is_espresso_page();
277
-        // if we are already loading assets then just move along, otherwise check for widgets
278
-        $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars();
279
-        if ($load_assets) {
280
-            add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10);
281
-            add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10);
282
-        }
283
-    }
284
-
285
-
286
-    /**
287
-     * builds list of active widgets then scans active sidebars looking for them
288
-     * returns true is an EE widget is found in an active sidebar
289
-     * Please Note: this does NOT mean that the sidebar or widget
290
-     * is actually in use in a given template, as that is unfortunately not known
291
-     * until a sidebar and it's widgets are actually loaded
292
-     *
293
-     * @return boolean
294
-     */
295
-    private function espresso_widgets_in_active_sidebars()
296
-    {
297
-        $espresso_widgets = array();
298
-        foreach ($this->Registry->widgets as $widget_class => $widget) {
299
-            $id_base = EspressoWidget::getIdBase($widget_class);
300
-            if (is_active_widget(false, false, $id_base)) {
301
-                $espresso_widgets[] = $id_base;
302
-            }
303
-        }
304
-        $all_sidebar_widgets = wp_get_sidebars_widgets();
305
-        foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) {
306
-            if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) {
307
-                foreach ($sidebar_widgets as $sidebar_widget) {
308
-                    foreach ($espresso_widgets as $espresso_widget) {
309
-                        if (strpos($sidebar_widget, $espresso_widget) !== false) {
310
-                            return true;
311
-                        }
312
-                    }
313
-                }
314
-            }
315
-        }
316
-        return false;
317
-    }
318
-
319
-
320
-    /**
321
-     *    header_meta_tag
322
-     *
323
-     * @access    public
324
-     * @return    void
325
-     */
326
-    public function header_meta_tag()
327
-    {
328
-        print(
329
-        apply_filters(
330
-            'FHEE__EE_Front_Controller__header_meta_tag',
331
-            '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
332
-        )
333
-        );
334
-
335
-        // let's exclude all event type taxonomy term archive pages from search engine indexing
336
-        // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249
337
-        // also exclude all critical pages from indexing
338
-        if ((
339
-                is_tax('espresso_event_type')
340
-                && get_option('blog_public') !== '0'
341
-            )
342
-            || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())
343
-        ) {
344
-            print(
345
-            apply_filters(
346
-                'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
347
-                '<meta name="robots" content="noindex,follow" />' . "\n"
348
-            )
349
-            );
350
-        }
351
-    }
352
-
353
-
354
-    /**
355
-     * wp_print_scripts
356
-     *
357
-     * @return void
358
-     */
359
-    public function wp_print_scripts()
360
-    {
361
-        global $post;
362
-        if (isset($post->EE_Event)
363
-            && $post->EE_Event instanceof EE_Event
364
-            && get_post_type() === 'espresso_events'
365
-            && is_singular()
366
-        ) {
367
-            \EEH_Schema::add_json_linked_data_for_event($post->EE_Event);
368
-        }
369
-    }
370
-
371
-
372
-    public function enqueueStyle()
373
-    {
374
-        wp_enqueue_style('espresso_default');
375
-        wp_enqueue_style('espresso_custom_css');
376
-    }
377
-
378
-
379
-
380
-    /***********************************************        WP_FOOTER         ***********************************************/
381
-
382
-
383
-    public function enqueueScripts()
384
-    {
385
-        wp_enqueue_script('espresso_core');
386
-    }
387
-
388
-
389
-    /**
390
-     * display_errors
391
-     *
392
-     * @access public
393
-     * @return void
394
-     * @throws DomainException
395
-     */
396
-    public function display_errors()
397
-    {
398
-        static $shown_already = false;
399
-        do_action('AHEE__EE_Front_Controller__display_errors__begin');
400
-        if (! $shown_already
401
-            && apply_filters('FHEE__EE_Front_Controller__display_errors', true)
402
-            && is_main_query()
403
-            && ! is_feed()
404
-            && in_the_loop()
405
-            && did_action('wp_head')
406
-            && $this->Request_Handler->is_espresso_page()
407
-        ) {
408
-            echo EE_Error::get_notices();
409
-            $shown_already = true;
410
-            EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
411
-        }
412
-        do_action('AHEE__EE_Front_Controller__display_errors__end');
413
-    }
414
-
415
-
416
-
417
-
418
-
419
-    /***********************************************        UTILITIES         ***********************************************/
420
-    /**
421
-     *    template_include
422
-     *
423
-     * @access    public
424
-     * @param   string $template_include_path
425
-     * @return    string
426
-     */
427
-    public function template_include($template_include_path = null)
428
-    {
429
-        if ($this->Request_Handler->is_espresso_page()) {
430
-            $this->_template_path = ! empty($this->_template_path)
431
-                ? basename($this->_template_path)
432
-                : basename(
433
-                    $template_include_path
434
-                );
435
-            $template_path = EEH_Template::locate_template($this->_template_path, array(), false);
436
-            $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;
437
-            $this->_template = basename($this->_template_path);
438
-            return $this->_template_path;
439
-        }
440
-        return $template_include_path;
441
-    }
442
-
443
-
444
-    /**
445
-     *    get_selected_template
446
-     *
447
-     * @access    public
448
-     * @param bool $with_path
449
-     * @return    string
450
-     */
451
-    public function get_selected_template($with_path = false)
452
-    {
453
-        return $with_path ? $this->_template_path : $this->_template;
454
-    }
455
-
456
-
457
-    /**
458
-     * @deprecated 4.9.26
459
-     * @param string $shortcode_class
460
-     * @param \WP    $wp
461
-     */
462
-    public function initialize_shortcode($shortcode_class = '', WP $wp = null)
463
-    {
464
-        \EE_Error::doing_it_wrong(
465
-            __METHOD__,
466
-            __(
467
-                'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',
468
-                'event_espresso'
469
-            ),
470
-            '4.9.26'
471
-        );
472
-        $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);
473
-    }
474
-
475
-
476
-    /**
477
-     * @return void
478
-     * @deprecated 4.9.57.p
479
-     */
480
-    public function loadPersistentAdminNoticeManager()
481
-    {
482
-    }
483
-
484
-
485
-    /**
486
-     * @return void
487
-     * @deprecated 4.9.64.p
488
-     */
489
-    public function employ_CPT_Strategy()
490
-    {
491
-    }
29
+	/**
30
+	 * @var string $_template_path
31
+	 */
32
+	private $_template_path;
33
+
34
+	/**
35
+	 * @var string $_template
36
+	 */
37
+	private $_template;
38
+
39
+	/**
40
+	 * @type EE_Registry $Registry
41
+	 */
42
+	protected $Registry;
43
+
44
+	/**
45
+	 * @type EE_Request_Handler $Request_Handler
46
+	 */
47
+	protected $Request_Handler;
48
+
49
+	/**
50
+	 * @type EE_Module_Request_Router $Module_Request_Router
51
+	 */
52
+	protected $Module_Request_Router;
53
+
54
+
55
+	/**
56
+	 *    class constructor
57
+	 *    should fire after shortcode, module, addon, or other plugin's default priority init phases have run
58
+	 *
59
+	 * @access    public
60
+	 * @param \EE_Registry              $Registry
61
+	 * @param \EE_Request_Handler       $Request_Handler
62
+	 * @param \EE_Module_Request_Router $Module_Request_Router
63
+	 */
64
+	public function __construct(
65
+		EE_Registry $Registry,
66
+		EE_Request_Handler $Request_Handler,
67
+		EE_Module_Request_Router $Module_Request_Router
68
+	) {
69
+		$this->Registry = $Registry;
70
+		$this->Request_Handler = $Request_Handler;
71
+		$this->Module_Request_Router = $Module_Request_Router;
72
+		// load other resources and begin to actually run shortcodes and modules
73
+		add_action('wp_loaded', array($this, 'wp_loaded'), 5);
74
+		// analyse the incoming WP request
75
+		add_action('parse_request', array($this, 'get_request'), 1, 1);
76
+		// process request with module factory
77
+		add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1);
78
+		// before headers sent
79
+		add_action('wp', array($this, 'wp'), 5);
80
+		// primarily used to process any content shortcodes
81
+		add_action('template_redirect', array($this, 'templateRedirect'), 999);
82
+		// header
83
+		add_action('wp_head', array($this, 'header_meta_tag'), 5);
84
+		add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10);
85
+		add_filter('template_include', array($this, 'template_include'), 1);
86
+		// display errors
87
+		add_action('loop_start', array($this, 'display_errors'), 2);
88
+		// the content
89
+		// add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );
90
+		// exclude our private cpt comments
91
+		add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1);
92
+		// make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://)
93
+		add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1);
94
+		// action hook EE
95
+		do_action('AHEE__EE_Front_Controller__construct__done', $this);
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return EE_Request_Handler
101
+	 */
102
+	public function Request_Handler()
103
+	{
104
+		return $this->Request_Handler;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return EE_Module_Request_Router
110
+	 */
111
+	public function Module_Request_Router()
112
+	{
113
+		return $this->Module_Request_Router;
114
+	}
115
+
116
+
117
+	/**
118
+	 * @return LegacyShortcodesManager
119
+	 */
120
+	public function getLegacyShortcodesManager()
121
+	{
122
+		return EE_Config::getLegacyShortcodesManager();
123
+	}
124
+
125
+
126
+
127
+
128
+
129
+	/***********************************************        INIT ACTION HOOK         ***********************************************/
130
+	/**
131
+	 * filter_wp_comments
132
+	 * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment
133
+	 * widgets/queries done on frontend
134
+	 *
135
+	 * @param  array $clauses array of comment clauses setup by WP_Comment_Query
136
+	 * @return array array of comment clauses with modifications.
137
+	 * @throws InvalidArgumentException
138
+	 * @throws InvalidDataTypeException
139
+	 * @throws InvalidInterfaceException
140
+	 */
141
+	public function filter_wp_comments($clauses)
142
+	{
143
+		global $wpdb;
144
+		if (strpos($clauses['join'], $wpdb->posts) !== false) {
145
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
146
+			$custom_post_types = LoaderFactory::getLoader()->getShared(
147
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
148
+			);
149
+			$cpts = $custom_post_types->getPrivateCustomPostTypes();
150
+			foreach ($cpts as $cpt => $details) {
151
+				$clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt);
152
+			}
153
+		}
154
+		return $clauses;
155
+	}
156
+
157
+
158
+	/**
159
+	 * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend
160
+	 *
161
+	 * @param  string $url incoming url
162
+	 * @return string         final assembled url
163
+	 */
164
+	public function maybe_force_admin_ajax_ssl($url)
165
+	{
166
+		if (is_ssl() && preg_match('/admin-ajax.php/', $url)) {
167
+			$url = str_replace('http://', 'https://', $url);
168
+		}
169
+		return $url;
170
+	}
171
+
172
+
173
+
174
+
175
+
176
+
177
+	/***********************************************        WP_LOADED ACTION HOOK         ***********************************************/
178
+
179
+
180
+	/**
181
+	 *    wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their
182
+	 *    default priority init phases have run
183
+	 *
184
+	 * @access    public
185
+	 * @return    void
186
+	 */
187
+	public function wp_loaded()
188
+	{
189
+	}
190
+
191
+
192
+
193
+
194
+
195
+	/***********************************************        PARSE_REQUEST HOOK         ***********************************************/
196
+	/**
197
+	 *    _get_request
198
+	 *
199
+	 * @access public
200
+	 * @param WP $WP
201
+	 * @return void
202
+	 */
203
+	public function get_request(WP $WP)
204
+	{
205
+		do_action('AHEE__EE_Front_Controller__get_request__start');
206
+		$this->Request_Handler->parse_request($WP);
207
+		do_action('AHEE__EE_Front_Controller__get_request__complete');
208
+	}
209
+
210
+
211
+	/**
212
+	 *    pre_get_posts - basically a module factory for instantiating modules and selecting the final view template
213
+	 *
214
+	 * @access    public
215
+	 * @param   WP_Query $WP_Query
216
+	 * @return    void
217
+	 */
218
+	public function pre_get_posts($WP_Query)
219
+	{
220
+		// only load Module_Request_Router if this is the main query
221
+		if ($this->Module_Request_Router instanceof EE_Module_Request_Router
222
+			&& $WP_Query->is_main_query()
223
+		) {
224
+			// cycle thru module routes
225
+			while ($route = $this->Module_Request_Router->get_route($WP_Query)) {
226
+				// determine module and method for route
227
+				$module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);
228
+				if ($module instanceof EED_Module) {
229
+					// get registered view for route
230
+					$this->_template_path = $this->Module_Request_Router->get_view($route);
231
+					// grab module name
232
+					$module_name = $module->module_name();
233
+					// map the module to the module objects
234
+					$this->Registry->modules->{$module_name} = $module;
235
+				}
236
+			}
237
+		}
238
+	}
239
+
240
+
241
+
242
+
243
+
244
+	/***********************************************        WP HOOK         ***********************************************/
245
+
246
+
247
+	/**
248
+	 *    wp - basically last chance to do stuff before headers sent
249
+	 *
250
+	 * @access    public
251
+	 * @return    void
252
+	 */
253
+	public function wp()
254
+	{
255
+	}
256
+
257
+
258
+
259
+	/***********************     GET_HEADER && WP_HEAD HOOK     ***********************/
260
+
261
+
262
+	/**
263
+	 * callback for the "template_redirect" hook point
264
+	 * checks sidebars for EE widgets
265
+	 * loads resources and assets accordingly
266
+	 *
267
+	 * @return void
268
+	 */
269
+	public function templateRedirect()
270
+	{
271
+		global $wp_query;
272
+		if (empty($wp_query->posts)) {
273
+			return;
274
+		}
275
+		// if we already know this is an espresso page, then load assets
276
+		$load_assets = $this->Request_Handler->is_espresso_page();
277
+		// if we are already loading assets then just move along, otherwise check for widgets
278
+		$load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars();
279
+		if ($load_assets) {
280
+			add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10);
281
+			add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10);
282
+		}
283
+	}
284
+
285
+
286
+	/**
287
+	 * builds list of active widgets then scans active sidebars looking for them
288
+	 * returns true is an EE widget is found in an active sidebar
289
+	 * Please Note: this does NOT mean that the sidebar or widget
290
+	 * is actually in use in a given template, as that is unfortunately not known
291
+	 * until a sidebar and it's widgets are actually loaded
292
+	 *
293
+	 * @return boolean
294
+	 */
295
+	private function espresso_widgets_in_active_sidebars()
296
+	{
297
+		$espresso_widgets = array();
298
+		foreach ($this->Registry->widgets as $widget_class => $widget) {
299
+			$id_base = EspressoWidget::getIdBase($widget_class);
300
+			if (is_active_widget(false, false, $id_base)) {
301
+				$espresso_widgets[] = $id_base;
302
+			}
303
+		}
304
+		$all_sidebar_widgets = wp_get_sidebars_widgets();
305
+		foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) {
306
+			if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) {
307
+				foreach ($sidebar_widgets as $sidebar_widget) {
308
+					foreach ($espresso_widgets as $espresso_widget) {
309
+						if (strpos($sidebar_widget, $espresso_widget) !== false) {
310
+							return true;
311
+						}
312
+					}
313
+				}
314
+			}
315
+		}
316
+		return false;
317
+	}
318
+
319
+
320
+	/**
321
+	 *    header_meta_tag
322
+	 *
323
+	 * @access    public
324
+	 * @return    void
325
+	 */
326
+	public function header_meta_tag()
327
+	{
328
+		print(
329
+		apply_filters(
330
+			'FHEE__EE_Front_Controller__header_meta_tag',
331
+			'<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
332
+		)
333
+		);
334
+
335
+		// let's exclude all event type taxonomy term archive pages from search engine indexing
336
+		// @see https://events.codebasehq.com/projects/event-espresso/tickets/10249
337
+		// also exclude all critical pages from indexing
338
+		if ((
339
+				is_tax('espresso_event_type')
340
+				&& get_option('blog_public') !== '0'
341
+			)
342
+			|| is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())
343
+		) {
344
+			print(
345
+			apply_filters(
346
+				'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
347
+				'<meta name="robots" content="noindex,follow" />' . "\n"
348
+			)
349
+			);
350
+		}
351
+	}
352
+
353
+
354
+	/**
355
+	 * wp_print_scripts
356
+	 *
357
+	 * @return void
358
+	 */
359
+	public function wp_print_scripts()
360
+	{
361
+		global $post;
362
+		if (isset($post->EE_Event)
363
+			&& $post->EE_Event instanceof EE_Event
364
+			&& get_post_type() === 'espresso_events'
365
+			&& is_singular()
366
+		) {
367
+			\EEH_Schema::add_json_linked_data_for_event($post->EE_Event);
368
+		}
369
+	}
370
+
371
+
372
+	public function enqueueStyle()
373
+	{
374
+		wp_enqueue_style('espresso_default');
375
+		wp_enqueue_style('espresso_custom_css');
376
+	}
377
+
378
+
379
+
380
+	/***********************************************        WP_FOOTER         ***********************************************/
381
+
382
+
383
+	public function enqueueScripts()
384
+	{
385
+		wp_enqueue_script('espresso_core');
386
+	}
387
+
388
+
389
+	/**
390
+	 * display_errors
391
+	 *
392
+	 * @access public
393
+	 * @return void
394
+	 * @throws DomainException
395
+	 */
396
+	public function display_errors()
397
+	{
398
+		static $shown_already = false;
399
+		do_action('AHEE__EE_Front_Controller__display_errors__begin');
400
+		if (! $shown_already
401
+			&& apply_filters('FHEE__EE_Front_Controller__display_errors', true)
402
+			&& is_main_query()
403
+			&& ! is_feed()
404
+			&& in_the_loop()
405
+			&& did_action('wp_head')
406
+			&& $this->Request_Handler->is_espresso_page()
407
+		) {
408
+			echo EE_Error::get_notices();
409
+			$shown_already = true;
410
+			EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
411
+		}
412
+		do_action('AHEE__EE_Front_Controller__display_errors__end');
413
+	}
414
+
415
+
416
+
417
+
418
+
419
+	/***********************************************        UTILITIES         ***********************************************/
420
+	/**
421
+	 *    template_include
422
+	 *
423
+	 * @access    public
424
+	 * @param   string $template_include_path
425
+	 * @return    string
426
+	 */
427
+	public function template_include($template_include_path = null)
428
+	{
429
+		if ($this->Request_Handler->is_espresso_page()) {
430
+			$this->_template_path = ! empty($this->_template_path)
431
+				? basename($this->_template_path)
432
+				: basename(
433
+					$template_include_path
434
+				);
435
+			$template_path = EEH_Template::locate_template($this->_template_path, array(), false);
436
+			$this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;
437
+			$this->_template = basename($this->_template_path);
438
+			return $this->_template_path;
439
+		}
440
+		return $template_include_path;
441
+	}
442
+
443
+
444
+	/**
445
+	 *    get_selected_template
446
+	 *
447
+	 * @access    public
448
+	 * @param bool $with_path
449
+	 * @return    string
450
+	 */
451
+	public function get_selected_template($with_path = false)
452
+	{
453
+		return $with_path ? $this->_template_path : $this->_template;
454
+	}
455
+
456
+
457
+	/**
458
+	 * @deprecated 4.9.26
459
+	 * @param string $shortcode_class
460
+	 * @param \WP    $wp
461
+	 */
462
+	public function initialize_shortcode($shortcode_class = '', WP $wp = null)
463
+	{
464
+		\EE_Error::doing_it_wrong(
465
+			__METHOD__,
466
+			__(
467
+				'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',
468
+				'event_espresso'
469
+			),
470
+			'4.9.26'
471
+		);
472
+		$this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);
473
+	}
474
+
475
+
476
+	/**
477
+	 * @return void
478
+	 * @deprecated 4.9.57.p
479
+	 */
480
+	public function loadPersistentAdminNoticeManager()
481
+	{
482
+	}
483
+
484
+
485
+	/**
486
+	 * @return void
487
+	 * @deprecated 4.9.64.p
488
+	 */
489
+	public function employ_CPT_Strategy()
490
+	{
491
+	}
492 492
 }
Please login to merge, or discard this patch.
core/EE_Psr4AutoloaderInit.core.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -17,38 +17,38 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * @type \EventEspresso\core\Psr4Autoloader
22
-     */
23
-    protected static $psr4_loader;
24
-
25
-
26
-    /**
27
-     * @return \EventEspresso\core\Psr4Autoloader
28
-     */
29
-    public function initializeAutoloader()
30
-    {
31
-        static $initialized = false;
32
-        if (! $initialized) {
33
-            // instantiate PSR4 autoloader
34
-            espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
35
-            EE_Psr4AutoloaderInit::$psr4_loader = new Psr4Autoloader();
36
-            // register the autoloader
37
-            EE_Psr4AutoloaderInit::$psr4_loader->register();
38
-            // register the base directories for the namespace prefix
39
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspresso', EE_PLUGIN_DIR_PATH);
40
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES . 'batch');
41
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoVendor', EE_THIRD_PARTY);
42
-            $initialized = true;
43
-        }
44
-    }
45
-
46
-
47
-    /**
48
-     * @return \EventEspresso\core\Psr4Autoloader
49
-     */
50
-    public static function psr4_loader()
51
-    {
52
-        return self::$psr4_loader;
53
-    }
20
+	/**
21
+	 * @type \EventEspresso\core\Psr4Autoloader
22
+	 */
23
+	protected static $psr4_loader;
24
+
25
+
26
+	/**
27
+	 * @return \EventEspresso\core\Psr4Autoloader
28
+	 */
29
+	public function initializeAutoloader()
30
+	{
31
+		static $initialized = false;
32
+		if (! $initialized) {
33
+			// instantiate PSR4 autoloader
34
+			espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
35
+			EE_Psr4AutoloaderInit::$psr4_loader = new Psr4Autoloader();
36
+			// register the autoloader
37
+			EE_Psr4AutoloaderInit::$psr4_loader->register();
38
+			// register the base directories for the namespace prefix
39
+			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspresso', EE_PLUGIN_DIR_PATH);
40
+			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES . 'batch');
41
+			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoVendor', EE_THIRD_PARTY);
42
+			$initialized = true;
43
+		}
44
+	}
45
+
46
+
47
+	/**
48
+	 * @return \EventEspresso\core\Psr4Autoloader
49
+	 */
50
+	public static function psr4_loader()
51
+	{
52
+		return self::$psr4_loader;
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@
 block discarded – undo
29 29
     public function initializeAutoloader()
30 30
     {
31 31
         static $initialized = false;
32
-        if (! $initialized) {
32
+        if ( ! $initialized) {
33 33
             // instantiate PSR4 autoloader
34
-            espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
34
+            espresso_load_required('Psr4Autoloader', EE_CORE.'Psr4Autoloader.php');
35 35
             EE_Psr4AutoloaderInit::$psr4_loader = new Psr4Autoloader();
36 36
             // register the autoloader
37 37
             EE_Psr4AutoloaderInit::$psr4_loader->register();
38 38
             // register the base directories for the namespace prefix
39 39
             EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspresso', EE_PLUGIN_DIR_PATH);
40
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES . 'batch');
40
+            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES.'batch');
41 41
             EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoVendor', EE_THIRD_PARTY);
42 42
             $initialized = true;
43 43
         }
Please login to merge, or discard this patch.
core/EE_Object_Repository.core.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -16,98 +16,98 @@
 block discarded – undo
16 16
 abstract class EE_Object_Repository extends EE_Object_Collection implements EEI_Repository
17 17
 {
18 18
 
19
-    /**
20
-     * default persist method called on repository objects if none supplied
21
-     *
22
-     * @type string $persist_method
23
-     */
24
-    protected $persist_method;
19
+	/**
20
+	 * default persist method called on repository objects if none supplied
21
+	 *
22
+	 * @type string $persist_method
23
+	 */
24
+	protected $persist_method;
25 25
 
26 26
 
27
-    /**
28
-     * _call_user_func_array_on_current
29
-     *
30
-     * calls the supplied callback method name on the current repository object,
31
-     * an array of arguments can also be supplied that will be passed along to the callback method,
32
-     * where each element of the $arguments array corresponds to a parameter for the callback method
33
-     * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' )
34
-     * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) )
35
-     *
36
-     * @access public
37
-     * @param string $callback  name of method found on object to be called.
38
-     * @param array  $arguments arrays of arguments that will be passed to the object's callback method
39
-     * @return bool | int
40
-     */
41
-    protected function _call_user_func_array_on_current($callback = '', $arguments = array())
42
-    {
43
-        if ($callback !== '' && method_exists($this->current(), $callback)) {
44
-            return call_user_func_array(array($this->current(), $callback), $arguments);
45
-        }
46
-        return false;
47
-    }
27
+	/**
28
+	 * _call_user_func_array_on_current
29
+	 *
30
+	 * calls the supplied callback method name on the current repository object,
31
+	 * an array of arguments can also be supplied that will be passed along to the callback method,
32
+	 * where each element of the $arguments array corresponds to a parameter for the callback method
33
+	 * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' )
34
+	 * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) )
35
+	 *
36
+	 * @access public
37
+	 * @param string $callback  name of method found on object to be called.
38
+	 * @param array  $arguments arrays of arguments that will be passed to the object's callback method
39
+	 * @return bool | int
40
+	 */
41
+	protected function _call_user_func_array_on_current($callback = '', $arguments = array())
42
+	{
43
+		if ($callback !== '' && method_exists($this->current(), $callback)) {
44
+			return call_user_func_array(array($this->current(), $callback), $arguments);
45
+		}
46
+		return false;
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * _call_user_func_on_all
52
-     *
53
-     * calls the supplied callback method name on ALL repository objects,
54
-     *
55
-     * @access public
56
-     * @param string $callback name of method found on repository objects to be called
57
-     * @return bool | int
58
-     */
59
-    protected function _call_user_func_on_all($callback = '')
60
-    {
61
-        $success = true;
62
-        if ($this->valid()) {
63
-            $this->rewind();
64
-            while ($this->valid()) {
65
-                // any negative result will toggle success to false
66
-                $success = $this->_call_user_func_array_on_current($callback) ? $success : false;
67
-                $this->next();
68
-            }
69
-            $this->rewind();
70
-        }
71
-        return $success;
72
-    }
50
+	/**
51
+	 * _call_user_func_on_all
52
+	 *
53
+	 * calls the supplied callback method name on ALL repository objects,
54
+	 *
55
+	 * @access public
56
+	 * @param string $callback name of method found on repository objects to be called
57
+	 * @return bool | int
58
+	 */
59
+	protected function _call_user_func_on_all($callback = '')
60
+	{
61
+		$success = true;
62
+		if ($this->valid()) {
63
+			$this->rewind();
64
+			while ($this->valid()) {
65
+				// any negative result will toggle success to false
66
+				$success = $this->_call_user_func_array_on_current($callback) ? $success : false;
67
+				$this->next();
68
+			}
69
+			$this->rewind();
70
+		}
71
+		return $success;
72
+	}
73 73
 
74 74
 
75
-    /**
76
-     * persist
77
-     *
78
-     * primarily used for saving EE_Base_Class classes to the database,
79
-     * but can be supplied with a "persistence callback" that can be used for classes that are not instances of
80
-     * EE_Base_Class, or for providing alternate ways to persist an object such as session caching, etc... an array of
81
-     * arguments can also be supplied that will be passed along to the object's persistence method
82
-     *
83
-     * @access public
84
-     * @param string $persistence_callback                                    name of method found on object that can
85
-     *                                                                        be used for persisting the object
86
-     *                                                                        defaults to
87
-     *                                                                        EE_Object_Repository::$persist_method
88
-     * @param array  $persistence_arguments                                   arrays of arguments that will be passed
89
-     *                                                                        to the object's persistence method
90
-     * @return bool | int
91
-     */
92
-    public function persist($persistence_callback = '', $persistence_arguments = array())
93
-    {
94
-        $persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method;
95
-        return $this->_call_user_func_array_on_current($persistence_callback, $persistence_arguments);
96
-    }
75
+	/**
76
+	 * persist
77
+	 *
78
+	 * primarily used for saving EE_Base_Class classes to the database,
79
+	 * but can be supplied with a "persistence callback" that can be used for classes that are not instances of
80
+	 * EE_Base_Class, or for providing alternate ways to persist an object such as session caching, etc... an array of
81
+	 * arguments can also be supplied that will be passed along to the object's persistence method
82
+	 *
83
+	 * @access public
84
+	 * @param string $persistence_callback                                    name of method found on object that can
85
+	 *                                                                        be used for persisting the object
86
+	 *                                                                        defaults to
87
+	 *                                                                        EE_Object_Repository::$persist_method
88
+	 * @param array  $persistence_arguments                                   arrays of arguments that will be passed
89
+	 *                                                                        to the object's persistence method
90
+	 * @return bool | int
91
+	 */
92
+	public function persist($persistence_callback = '', $persistence_arguments = array())
93
+	{
94
+		$persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method;
95
+		return $this->_call_user_func_array_on_current($persistence_callback, $persistence_arguments);
96
+	}
97 97
 
98 98
 
99
-    /**
100
-     * persist_all
101
-     *
102
-     * calls \EE_Object_Repository::persist() on all objects within the repository
103
-     *
104
-     * @access public
105
-     * @param string $persistence_callback name of method found on object that can be used for persisting the object
106
-     * @return bool | int
107
-     */
108
-    public function persist_all($persistence_callback = '')
109
-    {
110
-        $persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method;
111
-        return $this->_call_user_func_on_all($persistence_callback);
112
-    }
99
+	/**
100
+	 * persist_all
101
+	 *
102
+	 * calls \EE_Object_Repository::persist() on all objects within the repository
103
+	 *
104
+	 * @access public
105
+	 * @param string $persistence_callback name of method found on object that can be used for persisting the object
106
+	 * @return bool | int
107
+	 */
108
+	public function persist_all($persistence_callback = '')
109
+	{
110
+		$persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method;
111
+		return $this->_call_user_func_on_all($persistence_callback);
112
+	}
113 113
 }
Please login to merge, or discard this patch.
core/EED_Module.module.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -12,110 +12,110 @@
 block discarded – undo
12 12
 abstract class EED_Module extends EE_Configurable implements ResettableInterface
13 13
 {
14 14
 
15
-    /**
16
-     * rendered output to be returned to WP
17
-     *
18
-     * @var    string $output
19
-     */
20
-    protected $output = '';
21
-
22
-    /**
23
-     * the current active espresso template theme
24
-     *
25
-     * @var    string $theme
26
-     */
27
-    protected $theme = '';
28
-
29
-
30
-    /**
31
-     * @return void
32
-     */
33
-    public static function reset()
34
-    {
35
-        $module_name = get_called_class();
36
-        new $module_name();
37
-    }
38
-
39
-
40
-    /**
41
-     *    set_hooks - for hooking into EE Core, other modules, etc
42
-     *
43
-     * @access    public
44
-     * @return    void
45
-     */
46
-    public static function set_hooks()
47
-    {
48
-    }
49
-
50
-
51
-    /**
52
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
53
-     *
54
-     * @access    public
55
-     * @return    void
56
-     */
57
-    public static function set_hooks_admin()
58
-    {
59
-    }
60
-
61
-
62
-    /**
63
-     *    run - initial module setup
64
-     *    this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
65
-     *
66
-     * @access    public
67
-     * @var            WP $WP
68
-     * @return    void
69
-     */
70
-    abstract public function run($WP);
71
-
72
-
73
-    /**
74
-     * EED_Module constructor.
75
-     */
76
-    final public function __construct()
77
-    {
78
-        $this->theme = EE_Config::get_current_theme();
79
-        $module_name = $this->module_name();
80
-        EE_Registry::instance()->modules->{$module_name} = $this;
81
-    }
82
-
83
-
84
-    /**
85
-     * @param $module_name
86
-     * @return EED_Module
87
-     */
88
-    protected static function get_instance($module_name = '')
89
-    {
90
-        $module_name = ! empty($module_name)
91
-            ? $module_name
92
-            : get_called_class();
93
-        if (! isset(EE_Registry::instance()->modules->{$module_name})
94
-            || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module
95
-        ) {
96
-            EE_Registry::instance()->add_module($module_name);
97
-        }
98
-        return EE_Registry::instance()->get_module($module_name);
99
-    }
100
-
101
-
102
-    /**
103
-     *    module_name
104
-     *
105
-     * @access    public
106
-     * @return    string
107
-     */
108
-    public function module_name()
109
-    {
110
-        return get_class($this);
111
-    }
112
-
113
-
114
-    /**
115
-     * @return string
116
-     */
117
-    public function theme()
118
-    {
119
-        return $this->theme;
120
-    }
15
+	/**
16
+	 * rendered output to be returned to WP
17
+	 *
18
+	 * @var    string $output
19
+	 */
20
+	protected $output = '';
21
+
22
+	/**
23
+	 * the current active espresso template theme
24
+	 *
25
+	 * @var    string $theme
26
+	 */
27
+	protected $theme = '';
28
+
29
+
30
+	/**
31
+	 * @return void
32
+	 */
33
+	public static function reset()
34
+	{
35
+		$module_name = get_called_class();
36
+		new $module_name();
37
+	}
38
+
39
+
40
+	/**
41
+	 *    set_hooks - for hooking into EE Core, other modules, etc
42
+	 *
43
+	 * @access    public
44
+	 * @return    void
45
+	 */
46
+	public static function set_hooks()
47
+	{
48
+	}
49
+
50
+
51
+	/**
52
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
53
+	 *
54
+	 * @access    public
55
+	 * @return    void
56
+	 */
57
+	public static function set_hooks_admin()
58
+	{
59
+	}
60
+
61
+
62
+	/**
63
+	 *    run - initial module setup
64
+	 *    this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
65
+	 *
66
+	 * @access    public
67
+	 * @var            WP $WP
68
+	 * @return    void
69
+	 */
70
+	abstract public function run($WP);
71
+
72
+
73
+	/**
74
+	 * EED_Module constructor.
75
+	 */
76
+	final public function __construct()
77
+	{
78
+		$this->theme = EE_Config::get_current_theme();
79
+		$module_name = $this->module_name();
80
+		EE_Registry::instance()->modules->{$module_name} = $this;
81
+	}
82
+
83
+
84
+	/**
85
+	 * @param $module_name
86
+	 * @return EED_Module
87
+	 */
88
+	protected static function get_instance($module_name = '')
89
+	{
90
+		$module_name = ! empty($module_name)
91
+			? $module_name
92
+			: get_called_class();
93
+		if (! isset(EE_Registry::instance()->modules->{$module_name})
94
+			|| ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module
95
+		) {
96
+			EE_Registry::instance()->add_module($module_name);
97
+		}
98
+		return EE_Registry::instance()->get_module($module_name);
99
+	}
100
+
101
+
102
+	/**
103
+	 *    module_name
104
+	 *
105
+	 * @access    public
106
+	 * @return    string
107
+	 */
108
+	public function module_name()
109
+	{
110
+		return get_class($this);
111
+	}
112
+
113
+
114
+	/**
115
+	 * @return string
116
+	 */
117
+	public function theme()
118
+	{
119
+		return $this->theme;
120
+	}
121 121
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
         $module_name = ! empty($module_name)
91 91
             ? $module_name
92 92
             : get_called_class();
93
-        if (! isset(EE_Registry::instance()->modules->{$module_name})
93
+        if ( ! isset(EE_Registry::instance()->modules->{$module_name})
94 94
             || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module
95 95
         ) {
96 96
             EE_Registry::instance()->add_module($module_name);
Please login to merge, or discard this patch.
core/EE_Base.core.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,42 +11,42 @@
 block discarded – undo
11 11
 class EE_Base
12 12
 {
13 13
 
14
-    /**
15
-     *        @ override magic methods
16
-     *        @ return void
17
-     */
18
-    public function __get($a)
19
-    {
20
-        return false;
21
-    }
14
+	/**
15
+	 *        @ override magic methods
16
+	 *        @ return void
17
+	 */
18
+	public function __get($a)
19
+	{
20
+		return false;
21
+	}
22 22
 
23
-    public function __set($a, $b)
24
-    {
25
-        return false;
26
-    }
23
+	public function __set($a, $b)
24
+	{
25
+		return false;
26
+	}
27 27
 
28
-    public function __isset($a)
29
-    {
30
-        return false;
31
-    }
28
+	public function __isset($a)
29
+	{
30
+		return false;
31
+	}
32 32
 
33
-    public function __unset($a)
34
-    {
35
-        return false;
36
-    }
33
+	public function __unset($a)
34
+	{
35
+		return false;
36
+	}
37 37
 
38
-    public function __clone()
39
-    {
40
-        return false;
41
-    }
38
+	public function __clone()
39
+	{
40
+		return false;
41
+	}
42 42
 
43
-    public function __wakeup()
44
-    {
45
-        return false;
46
-    }
43
+	public function __wakeup()
44
+	{
45
+		return false;
46
+	}
47 47
 
48
-    public function __destruct()
49
-    {
50
-        return false;
51
-    }
48
+	public function __destruct()
49
+	{
50
+		return false;
51
+	}
52 52
 }
Please login to merge, or discard this patch.
core/EE_Maintenance_Mode.core.php 2 patches
Indentation   +327 added lines, -327 removed lines patch added patch discarded remove patch
@@ -14,333 +14,333 @@
 block discarded – undo
14 14
 class EE_Maintenance_Mode implements ResettableInterface
15 15
 {
16 16
 
17
-    /**
18
-     * constants available to client code for interpreting the values of EE_Maintenance_Mode::level().
19
-     * level_0_not_in_maintenance means the site is NOT in maintenance mode (so everything's normal)
20
-     */
21
-    const level_0_not_in_maintenance = 0;
22
-
23
-    /**
24
-     * level_1_frontend_only_maintenance means that the site's frontend EE code should be completely disabled
25
-     * but the admin backend should be running as normal. Maybe an admin can view the frontend though
26
-     */
27
-    const level_1_frontend_only_maintenance = 1;
28
-
29
-    /**
30
-     * level_2_complete_maintenance means the frontend AND EE backend code are disabled. The only system running
31
-     * is the maintenance mode stuff, which will require users to update all addons, and then finish running all
32
-     * migration scripts before taking the site out of maintenance mode
33
-     */
34
-    const level_2_complete_maintenance = 2;
35
-
36
-    /**
37
-     * the name of the option which stores the current level of maintenance mode
38
-     */
39
-    const option_name_maintenance_mode = 'ee_maintenance_mode';
40
-
41
-
42
-    /**
43
-     * @var EE_Maintenance_Mode $_instance
44
-     */
45
-    private static $_instance;
46
-
47
-    /**
48
-     * @var EE_Registry $EE
49
-     */
50
-    protected $EE;
51
-
52
-
53
-    /**
54
-     * @singleton method used to instantiate class object
55
-     * @return EE_Maintenance_Mode
56
-     */
57
-    public static function instance()
58
-    {
59
-        // check if class object is instantiated
60
-        if (! self::$_instance instanceof EE_Maintenance_Mode) {
61
-            self::$_instance = new self();
62
-        }
63
-        return self::$_instance;
64
-    }
65
-
66
-
67
-    /**
68
-     * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode)
69
-     *
70
-     * @return EE_Maintenance_Mode
71
-     */
72
-    public static function reset()
73
-    {
74
-        self::instance()->set_maintenance_mode_if_db_old();
75
-        return self::instance();
76
-    }
77
-
78
-
79
-    /**
80
-     *private constructor to prevent direct creation
81
-     */
82
-    private function __construct()
83
-    {
84
-        // if M-Mode level 2 is engaged, we still need basic assets loaded
85
-        add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode'));
86
-        // shut 'er down down for maintenance ?
87
-        add_filter('the_content', array($this, 'the_content'), 2);
88
-        // add powered by EE msg
89
-        add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10);
90
-    }
91
-
92
-
93
-    /**
94
-     * retrieves the maintenance mode option value from the db
95
-     *
96
-     * @return int
97
-     */
98
-    public function real_level()
99
-    {
100
-        return (int) get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance);
101
-    }
102
-
103
-
104
-    /**
105
-     * Returns whether or not the models reportedly are able to run queries or not
106
-     * (ie, if the system thinks their tables are present and up-to-date).
107
-     *
108
-     * @return boolean
109
-     */
110
-    public function models_can_query()
111
-    {
112
-        return $this->real_level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
113
-    }
114
-
115
-
116
-    /**
117
-     * Determines whether or not we're in maintenance mode and what level. However, while the site
118
-     * is in level 1 maintenance, and an admin visits the frontend, this function makes it appear
119
-     * to them as if teh site isn't in maintenance mode.
120
-     * EE_Maintenance_Mode::level_0_not_in_maintenance => not in maintenance mode (in normal mode)
121
-     * EE_Maintenance_Mode::level_1_frontend_only_maintenance=> frontend-only maintenance mode
122
-     * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode
123
-     *
124
-     * @return int
125
-     */
126
-    public function level()
127
-    {
128
-        $maintenance_mode_level = $this->real_level();
129
-        // if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend
130
-        if ($maintenance_mode_level === EE_Maintenance_Mode::level_1_frontend_only_maintenance// we're in level 1
131
-            && ((defined('DOING_AJAX') && DOING_AJAX) || ! is_admin()) // on non-ajax frontend requests
132
-            && current_user_can('administrator') // when the user is an admin
133
-        ) {
134
-            $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance;
135
-        }
136
-        return $maintenance_mode_level;
137
-    }
138
-
139
-
140
-    /**
141
-     * Determines if we need to put EE in maintenance mode because the database needs updating
142
-     *
143
-     * @return boolean true if DB is old and maintenance mode was triggered; false otherwise
144
-     */
145
-    public function set_maintenance_mode_if_db_old()
146
-    {
147
-        EE_Registry::instance()->load_core('Data_Migration_Manager');
148
-        if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
149
-            update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance);
150
-            return true;
151
-        }
152
-        if ($this->level() === self::level_2_complete_maintenance) {
153
-            // we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run
154
-            // then we shouldn't be in mm2. (Maybe an addon got deactivated?)
155
-            update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance);
156
-            return false;
157
-        }
158
-        return false;
159
-    }
160
-
161
-
162
-    /**
163
-     * Updates the maintenance level on the site
164
-     *
165
-     * @param int $level
166
-     * @return void
167
-     */
168
-    public function set_maintenance_level($level)
169
-    {
170
-        do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level);
171
-        update_option(self::option_name_maintenance_mode, (int) $level);
172
-    }
173
-
174
-
175
-    /**
176
-     * returns TRUE if M-Mode is engaged and the current request is not for the admin
177
-     *
178
-     * @return    string
179
-     */
180
-    public static function disable_frontend_for_maintenance()
181
-    {
182
-        return (! is_admin() && EE_Maintenance_Mode::instance()->level());
183
-    }
184
-
185
-
186
-    /**
187
-     * @return void
188
-     */
189
-    public function load_assets_required_for_m_mode()
190
-    {
191
-        if ($this->real_level() === EE_Maintenance_Mode::level_2_complete_maintenance
192
-            && ! wp_script_is('espresso_core')
193
-        ) {
194
-            wp_register_style(
195
-                'espresso_default',
196
-                EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
197
-                array('dashicons'),
198
-                EVENT_ESPRESSO_VERSION
199
-            );
200
-            wp_enqueue_style('espresso_default');
201
-            wp_register_script(
202
-                'espresso_core',
203
-                EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
204
-                array('jquery'),
205
-                EVENT_ESPRESSO_VERSION,
206
-                true
207
-            );
208
-            wp_enqueue_script('espresso_core');
209
-        }
210
-    }
211
-
212
-
213
-    /**
214
-     * replacement EE CPT template that displays message notifying site visitors
215
-     * that EE has been temporarily placed into maintenance mode
216
-     * does NOT get called on non-EE-CPT requests
217
-     *
218
-     * @return    string
219
-     */
220
-    public static function template_include()
221
-    {
222
-        // shut 'er down down for maintenance ? then don't use any of our templates for our endpoints
223
-        return get_template_directory() . '/index.php';
224
-    }
225
-
226
-
227
-    /**
228
-     * displays message notifying site visitors that EE has been temporarily
229
-     * placed into maintenance mode when post_type != EE CPT
230
-     *
231
-     * @param string $the_content
232
-     * @return string
233
-     */
234
-    public function the_content($the_content)
235
-    {
236
-        // check if M-mode is engaged and for EE shortcode
237
-        if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) {
238
-            // this can eventually be moved to a template, or edited via admin. But for now...
239
-            $the_content = sprintf(
240
-                esc_html__(
241
-                    '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s',
242
-                    'event_espresso'
243
-                ),
244
-                '<h3>',
245
-                '</h3><p>',
246
-                '</p>'
247
-            );
248
-        }
249
-        return $the_content;
250
-    }
251
-
252
-
253
-    /**
254
-     * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode
255
-     */
256
-    public function display_maintenance_mode_notice()
257
-    {
258
-        // check if M-mode is engaged and for EE shortcode
259
-        if (! (defined('DOING_AJAX') && DOING_AJAX)
260
-            && $this->real_level()
261
-            && ! is_admin()
262
-            && current_user_can('administrator')
263
-            && EE_Registry::instance()->REQ->is_espresso_page()
264
-        ) {
265
-            printf(
266
-                esc_html__(
267
-                    '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s',
268
-                    'event_espresso'
269
-                ),
270
-                '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="',
271
-                '"><span class="dashicons dashicons-no"></span></a><p>',
272
-                ' &raquo; <a href="' . add_query_arg(
273
-                    array('page' => 'espresso_maintenance_settings'),
274
-                    admin_url('admin.php')
275
-                ) . '">',
276
-                '</a></p></div>'
277
-            );
278
-        }
279
-    }
280
-    // espresso-notices important-notice ee-attention
281
-
282
-
283
-    /**
284
-     * override magic methods
285
-     */
286
-    final public function __destruct()
287
-    {
288
-    }
289
-
290
-
291
-    final public function __call($a, $b)
292
-    {
293
-    }
294
-
295
-
296
-    final public function __get($a)
297
-    {
298
-    }
299
-
300
-
301
-    final public function __set($a, $b)
302
-    {
303
-    }
304
-
305
-
306
-    final public function __isset($a)
307
-    {
308
-    }
309
-
310
-
311
-    final public function __unset($a)
312
-    {
313
-    }
314
-
315
-
316
-    final public function __sleep()
317
-    {
318
-        return array();
319
-    }
320
-
321
-
322
-    final public function __wakeup()
323
-    {
324
-    }
325
-
326
-
327
-    final public function __invoke()
328
-    {
329
-    }
330
-
331
-
332
-    final public static function __set_state($a = null)
333
-    {
334
-        return EE_Maintenance_Mode::instance();
335
-    }
336
-
337
-
338
-    final public function __clone()
339
-    {
340
-    }
17
+	/**
18
+	 * constants available to client code for interpreting the values of EE_Maintenance_Mode::level().
19
+	 * level_0_not_in_maintenance means the site is NOT in maintenance mode (so everything's normal)
20
+	 */
21
+	const level_0_not_in_maintenance = 0;
22
+
23
+	/**
24
+	 * level_1_frontend_only_maintenance means that the site's frontend EE code should be completely disabled
25
+	 * but the admin backend should be running as normal. Maybe an admin can view the frontend though
26
+	 */
27
+	const level_1_frontend_only_maintenance = 1;
28
+
29
+	/**
30
+	 * level_2_complete_maintenance means the frontend AND EE backend code are disabled. The only system running
31
+	 * is the maintenance mode stuff, which will require users to update all addons, and then finish running all
32
+	 * migration scripts before taking the site out of maintenance mode
33
+	 */
34
+	const level_2_complete_maintenance = 2;
35
+
36
+	/**
37
+	 * the name of the option which stores the current level of maintenance mode
38
+	 */
39
+	const option_name_maintenance_mode = 'ee_maintenance_mode';
40
+
41
+
42
+	/**
43
+	 * @var EE_Maintenance_Mode $_instance
44
+	 */
45
+	private static $_instance;
46
+
47
+	/**
48
+	 * @var EE_Registry $EE
49
+	 */
50
+	protected $EE;
51
+
52
+
53
+	/**
54
+	 * @singleton method used to instantiate class object
55
+	 * @return EE_Maintenance_Mode
56
+	 */
57
+	public static function instance()
58
+	{
59
+		// check if class object is instantiated
60
+		if (! self::$_instance instanceof EE_Maintenance_Mode) {
61
+			self::$_instance = new self();
62
+		}
63
+		return self::$_instance;
64
+	}
65
+
66
+
67
+	/**
68
+	 * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode)
69
+	 *
70
+	 * @return EE_Maintenance_Mode
71
+	 */
72
+	public static function reset()
73
+	{
74
+		self::instance()->set_maintenance_mode_if_db_old();
75
+		return self::instance();
76
+	}
77
+
78
+
79
+	/**
80
+	 *private constructor to prevent direct creation
81
+	 */
82
+	private function __construct()
83
+	{
84
+		// if M-Mode level 2 is engaged, we still need basic assets loaded
85
+		add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode'));
86
+		// shut 'er down down for maintenance ?
87
+		add_filter('the_content', array($this, 'the_content'), 2);
88
+		// add powered by EE msg
89
+		add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10);
90
+	}
91
+
92
+
93
+	/**
94
+	 * retrieves the maintenance mode option value from the db
95
+	 *
96
+	 * @return int
97
+	 */
98
+	public function real_level()
99
+	{
100
+		return (int) get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance);
101
+	}
102
+
103
+
104
+	/**
105
+	 * Returns whether or not the models reportedly are able to run queries or not
106
+	 * (ie, if the system thinks their tables are present and up-to-date).
107
+	 *
108
+	 * @return boolean
109
+	 */
110
+	public function models_can_query()
111
+	{
112
+		return $this->real_level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
113
+	}
114
+
115
+
116
+	/**
117
+	 * Determines whether or not we're in maintenance mode and what level. However, while the site
118
+	 * is in level 1 maintenance, and an admin visits the frontend, this function makes it appear
119
+	 * to them as if teh site isn't in maintenance mode.
120
+	 * EE_Maintenance_Mode::level_0_not_in_maintenance => not in maintenance mode (in normal mode)
121
+	 * EE_Maintenance_Mode::level_1_frontend_only_maintenance=> frontend-only maintenance mode
122
+	 * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode
123
+	 *
124
+	 * @return int
125
+	 */
126
+	public function level()
127
+	{
128
+		$maintenance_mode_level = $this->real_level();
129
+		// if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend
130
+		if ($maintenance_mode_level === EE_Maintenance_Mode::level_1_frontend_only_maintenance// we're in level 1
131
+			&& ((defined('DOING_AJAX') && DOING_AJAX) || ! is_admin()) // on non-ajax frontend requests
132
+			&& current_user_can('administrator') // when the user is an admin
133
+		) {
134
+			$maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance;
135
+		}
136
+		return $maintenance_mode_level;
137
+	}
138
+
139
+
140
+	/**
141
+	 * Determines if we need to put EE in maintenance mode because the database needs updating
142
+	 *
143
+	 * @return boolean true if DB is old and maintenance mode was triggered; false otherwise
144
+	 */
145
+	public function set_maintenance_mode_if_db_old()
146
+	{
147
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
148
+		if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
149
+			update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance);
150
+			return true;
151
+		}
152
+		if ($this->level() === self::level_2_complete_maintenance) {
153
+			// we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run
154
+			// then we shouldn't be in mm2. (Maybe an addon got deactivated?)
155
+			update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance);
156
+			return false;
157
+		}
158
+		return false;
159
+	}
160
+
161
+
162
+	/**
163
+	 * Updates the maintenance level on the site
164
+	 *
165
+	 * @param int $level
166
+	 * @return void
167
+	 */
168
+	public function set_maintenance_level($level)
169
+	{
170
+		do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level);
171
+		update_option(self::option_name_maintenance_mode, (int) $level);
172
+	}
173
+
174
+
175
+	/**
176
+	 * returns TRUE if M-Mode is engaged and the current request is not for the admin
177
+	 *
178
+	 * @return    string
179
+	 */
180
+	public static function disable_frontend_for_maintenance()
181
+	{
182
+		return (! is_admin() && EE_Maintenance_Mode::instance()->level());
183
+	}
184
+
185
+
186
+	/**
187
+	 * @return void
188
+	 */
189
+	public function load_assets_required_for_m_mode()
190
+	{
191
+		if ($this->real_level() === EE_Maintenance_Mode::level_2_complete_maintenance
192
+			&& ! wp_script_is('espresso_core')
193
+		) {
194
+			wp_register_style(
195
+				'espresso_default',
196
+				EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
197
+				array('dashicons'),
198
+				EVENT_ESPRESSO_VERSION
199
+			);
200
+			wp_enqueue_style('espresso_default');
201
+			wp_register_script(
202
+				'espresso_core',
203
+				EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
204
+				array('jquery'),
205
+				EVENT_ESPRESSO_VERSION,
206
+				true
207
+			);
208
+			wp_enqueue_script('espresso_core');
209
+		}
210
+	}
211
+
212
+
213
+	/**
214
+	 * replacement EE CPT template that displays message notifying site visitors
215
+	 * that EE has been temporarily placed into maintenance mode
216
+	 * does NOT get called on non-EE-CPT requests
217
+	 *
218
+	 * @return    string
219
+	 */
220
+	public static function template_include()
221
+	{
222
+		// shut 'er down down for maintenance ? then don't use any of our templates for our endpoints
223
+		return get_template_directory() . '/index.php';
224
+	}
225
+
226
+
227
+	/**
228
+	 * displays message notifying site visitors that EE has been temporarily
229
+	 * placed into maintenance mode when post_type != EE CPT
230
+	 *
231
+	 * @param string $the_content
232
+	 * @return string
233
+	 */
234
+	public function the_content($the_content)
235
+	{
236
+		// check if M-mode is engaged and for EE shortcode
237
+		if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) {
238
+			// this can eventually be moved to a template, or edited via admin. But for now...
239
+			$the_content = sprintf(
240
+				esc_html__(
241
+					'%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s',
242
+					'event_espresso'
243
+				),
244
+				'<h3>',
245
+				'</h3><p>',
246
+				'</p>'
247
+			);
248
+		}
249
+		return $the_content;
250
+	}
251
+
252
+
253
+	/**
254
+	 * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode
255
+	 */
256
+	public function display_maintenance_mode_notice()
257
+	{
258
+		// check if M-mode is engaged and for EE shortcode
259
+		if (! (defined('DOING_AJAX') && DOING_AJAX)
260
+			&& $this->real_level()
261
+			&& ! is_admin()
262
+			&& current_user_can('administrator')
263
+			&& EE_Registry::instance()->REQ->is_espresso_page()
264
+		) {
265
+			printf(
266
+				esc_html__(
267
+					'%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s',
268
+					'event_espresso'
269
+				),
270
+				'<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="',
271
+				'"><span class="dashicons dashicons-no"></span></a><p>',
272
+				' &raquo; <a href="' . add_query_arg(
273
+					array('page' => 'espresso_maintenance_settings'),
274
+					admin_url('admin.php')
275
+				) . '">',
276
+				'</a></p></div>'
277
+			);
278
+		}
279
+	}
280
+	// espresso-notices important-notice ee-attention
281
+
282
+
283
+	/**
284
+	 * override magic methods
285
+	 */
286
+	final public function __destruct()
287
+	{
288
+	}
289
+
290
+
291
+	final public function __call($a, $b)
292
+	{
293
+	}
294
+
295
+
296
+	final public function __get($a)
297
+	{
298
+	}
299
+
300
+
301
+	final public function __set($a, $b)
302
+	{
303
+	}
304
+
305
+
306
+	final public function __isset($a)
307
+	{
308
+	}
309
+
310
+
311
+	final public function __unset($a)
312
+	{
313
+	}
314
+
315
+
316
+	final public function __sleep()
317
+	{
318
+		return array();
319
+	}
320
+
321
+
322
+	final public function __wakeup()
323
+	{
324
+	}
325
+
326
+
327
+	final public function __invoke()
328
+	{
329
+	}
330
+
331
+
332
+	final public static function __set_state($a = null)
333
+	{
334
+		return EE_Maintenance_Mode::instance();
335
+	}
336
+
337
+
338
+	final public function __clone()
339
+	{
340
+	}
341 341
 
342 342
 
343
-    final public static function __callStatic($a, $b)
344
-    {
345
-    }
343
+	final public static function __callStatic($a, $b)
344
+	{
345
+	}
346 346
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     public static function instance()
58 58
     {
59 59
         // check if class object is instantiated
60
-        if (! self::$_instance instanceof EE_Maintenance_Mode) {
60
+        if ( ! self::$_instance instanceof EE_Maintenance_Mode) {
61 61
             self::$_instance = new self();
62 62
         }
63 63
         return self::$_instance;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public static function disable_frontend_for_maintenance()
181 181
     {
182
-        return (! is_admin() && EE_Maintenance_Mode::instance()->level());
182
+        return ( ! is_admin() && EE_Maintenance_Mode::instance()->level());
183 183
     }
184 184
 
185 185
 
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
         ) {
194 194
             wp_register_style(
195 195
                 'espresso_default',
196
-                EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
196
+                EE_GLOBAL_ASSETS_URL.'css/espresso_default.css',
197 197
                 array('dashicons'),
198 198
                 EVENT_ESPRESSO_VERSION
199 199
             );
200 200
             wp_enqueue_style('espresso_default');
201 201
             wp_register_script(
202 202
                 'espresso_core',
203
-                EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
203
+                EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
204 204
                 array('jquery'),
205 205
                 EVENT_ESPRESSO_VERSION,
206 206
                 true
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     public static function template_include()
221 221
     {
222 222
         // shut 'er down down for maintenance ? then don't use any of our templates for our endpoints
223
-        return get_template_directory() . '/index.php';
223
+        return get_template_directory().'/index.php';
224 224
     }
225 225
 
226 226
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
     public function display_maintenance_mode_notice()
257 257
     {
258 258
         // check if M-mode is engaged and for EE shortcode
259
-        if (! (defined('DOING_AJAX') && DOING_AJAX)
259
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)
260 260
             && $this->real_level()
261 261
             && ! is_admin()
262 262
             && current_user_can('administrator')
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
                 ),
270 270
                 '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="',
271 271
                 '"><span class="dashicons dashicons-no"></span></a><p>',
272
-                ' &raquo; <a href="' . add_query_arg(
272
+                ' &raquo; <a href="'.add_query_arg(
273 273
                     array('page' => 'espresso_maintenance_settings'),
274 274
                     admin_url('admin.php')
275
-                ) . '">',
275
+                ).'">',
276 276
                 '</a></p></div>'
277 277
             );
278 278
         }
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 2 patches
Indentation   +834 added lines, -834 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (! class_exists('WP_List_Table')) {
4
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
4
+	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
5 5
 }
6 6
 
7 7
 
@@ -20,847 +20,847 @@  discard block
 block discarded – undo
20 20
 abstract class EE_Admin_List_Table extends WP_List_Table
21 21
 {
22 22
 
23
-    /**
24
-     * holds the data that will be processed for the table
25
-     *
26
-     * @var array $_data
27
-     */
28
-    protected $_data;
29
-
30
-
31
-    /**
32
-     * This holds the value of all the data available for the given view (for all pages).
33
-     *
34
-     * @var int $_all_data_count
35
-     */
36
-    protected $_all_data_count;
37
-
38
-
39
-    /**
40
-     * Will contain the count of trashed items for the view label.
41
-     *
42
-     * @var int $_trashed_count
43
-     */
44
-    protected $_trashed_count;
45
-
46
-
47
-    /**
48
-     * This is what will be referenced as the slug for the current screen
49
-     *
50
-     * @var string $_screen
51
-     */
52
-    protected $_screen;
53
-
54
-
55
-    /**
56
-     * this is the EE_Admin_Page object
57
-     *
58
-     * @var EE_Admin_Page $_admin_page
59
-     */
60
-    protected $_admin_page;
61
-
62
-
63
-    /**
64
-     * The current view
65
-     *
66
-     * @var string $_view
67
-     */
68
-    protected $_view;
69
-
70
-
71
-    /**
72
-     * array of possible views for this table
73
-     *
74
-     * @var array $_views
75
-     */
76
-    protected $_views;
77
-
78
-
79
-    /**
80
-     * An array of key => value pairs containing information about the current table
81
-     * array(
82
-     *        'plural' => 'plural label',
83
-     *        'singular' => 'singular label',
84
-     *        'ajax' => false, //whether to use ajax or not
85
-     *        'screen' => null, //string used to reference what screen this is
86
-     *        (WP_List_table converts to screen object)
87
-     * )
88
-     *
89
-     * @var array $_wp_list_args
90
-     */
91
-    protected $_wp_list_args;
92
-
93
-    /**
94
-     * an array of column names
95
-     * array(
96
-     *    'internal-name' => 'Title'
97
-     * )
98
-     *
99
-     * @var array $_columns
100
-     */
101
-    protected $_columns;
102
-
103
-    /**
104
-     * An array of sortable columns
105
-     * array(
106
-     *    'internal-name' => 'orderby' //or
107
-     *    'internal-name' => array( 'orderby', true )
108
-     * )
109
-     *
110
-     * @var array $_sortable_columns
111
-     */
112
-    protected $_sortable_columns;
113
-
114
-    /**
115
-     * callback method used to perform AJAX row reordering
116
-     *
117
-     * @var string $_ajax_sorting_callback
118
-     */
119
-    protected $_ajax_sorting_callback;
120
-
121
-    /**
122
-     * An array of hidden columns (if needed)
123
-     * array('internal-name', 'internal-name')
124
-     *
125
-     * @var array $_hidden_columns
126
-     */
127
-    protected $_hidden_columns;
128
-
129
-    /**
130
-     * holds the per_page value
131
-     *
132
-     * @var int $_per_page
133
-     */
134
-    protected $_per_page;
135
-
136
-    /**
137
-     * holds what page number is currently being viewed
138
-     *
139
-     * @var int $_current_page
140
-     */
141
-    protected $_current_page;
142
-
143
-    /**
144
-     * the reference string for the nonce_action
145
-     *
146
-     * @var string $_nonce_action_ref
147
-     */
148
-    protected $_nonce_action_ref;
149
-
150
-    /**
151
-     * property to hold incoming request data (as set by the admin_page_core)
152
-     *
153
-     * @var array $_req_data
154
-     */
155
-    protected $_req_data;
156
-
157
-
158
-    /**
159
-     * yes / no array for admin form fields
160
-     *
161
-     * @var array $_yes_no
162
-     */
163
-    protected $_yes_no = array();
164
-
165
-    /**
166
-     * Array describing buttons that should appear at the bottom of the page
167
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
168
-     * and the values are another array with the following keys
169
-     * array(
170
-     *    'route' => 'page_route',
171
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
172
-     * )
173
-     *
174
-     * @var array $_bottom_buttons
175
-     */
176
-    protected $_bottom_buttons = array();
177
-
178
-
179
-    /**
180
-     * Used to indicate what should be the primary column for the list table.
181
-     * If not present then falls back to what WP calculates
182
-     * as the primary column.
183
-     *
184
-     * @type string $_primary_column
185
-     */
186
-    protected $_primary_column = '';
187
-
188
-
189
-    /**
190
-     * Used to indicate whether the table has a checkbox column or not.
191
-     *
192
-     * @type bool $_has_checkbox_column
193
-     */
194
-    protected $_has_checkbox_column = false;
195
-
196
-
197
-    /**
198
-     * @param \EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
199
-     */
200
-    public function __construct(EE_Admin_Page $admin_page)
201
-    {
202
-        $this->_admin_page = $admin_page;
203
-        $this->_req_data = $this->_admin_page->get_request_data();
204
-        $this->_view = $this->_admin_page->get_view();
205
-        $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
206
-        $this->_current_page = $this->get_pagenum();
207
-        $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
208
-        $this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso'));
209
-
210
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10);
211
-
212
-        $this->_setup_data();
213
-        $this->_add_view_counts();
214
-
215
-        $this->_nonce_action_ref = $this->_view;
216
-
217
-        $this->_set_properties();
218
-
219
-        // set primary column
220
-        add_filter('list_table_primary_column', array($this, 'set_primary_column'));
221
-
222
-        // set parent defaults
223
-        parent::__construct($this->_wp_list_args);
224
-
225
-        $this->prepare_items();
226
-    }
227
-
228
-
229
-    /**
230
-     * _setup_data
231
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
232
-     *
233
-     * @uses $this->_admin_page
234
-     * @return void
235
-     */
236
-    abstract protected function _setup_data();
237
-
238
-
239
-    /**
240
-     * set the properties that this class needs to be able to execute wp_list_table properly
241
-     * properties set:
242
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
243
-     * _columns = set the columns in an array.
244
-     * _sortable_columns = columns that are sortable (array).
245
-     * _hidden_columns = columns that are hidden (array)
246
-     * _default_orderby = the default orderby for sorting.
247
-     *
248
-     * @abstract
249
-     * @access protected
250
-     * @return void
251
-     */
252
-    abstract protected function _set_properties();
253
-
254
-
255
-    /**
256
-     * _get_table_filters
257
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
258
-     * get's shown in the table.
259
-     *
260
-     * @abstract
261
-     * @access protected
262
-     * @return string
263
-     */
264
-    abstract protected function _get_table_filters();
265
-
266
-
267
-    /**
268
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
269
-     * counts of the views is accurate.
270
-     *
271
-     * @abstract
272
-     * @access protected
273
-     * @return void
274
-     */
275
-    abstract protected function _add_view_counts();
276
-
277
-
278
-    /**
279
-     * _get_hidden_fields
280
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
281
-     *
282
-     * @return string
283
-     */
284
-    protected function _get_hidden_fields()
285
-    {
286
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
287
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
288
-        // if action is STILL empty, then we set it to default
289
-        $action = empty($action) ? 'default' : $action;
290
-        $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
291
-        $field .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
292
-        $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
293
-
294
-        $bulk_actions = $this->_get_bulk_actions();
295
-        foreach ($bulk_actions as $bulk_action => $label) {
296
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
297
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
298
-        }
299
-
300
-        return $field;
301
-    }
302
-
303
-
304
-    /**
305
-     * _set_column_info
306
-     * we're using this to set the column headers property.
307
-     *
308
-     * @access protected
309
-     * @return void
310
-     */
311
-    protected function _set_column_info()
312
-    {
313
-        $columns = $this->get_columns();
314
-        $hidden = $this->get_hidden_columns();
315
-        $_sortable = $this->get_sortable_columns();
316
-
317
-        /**
318
-         * Dynamic hook allowing for adding sortable columns in this list table.
319
-         * Note that $this->screen->id is in the format
320
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
321
-         * table it is: event-espresso_page_espresso_messages.
322
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
323
-         * hook prefix ("event-espresso") will be different.
324
-         *
325
-         * @var array
326
-         */
327
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
328
-
329
-        $sortable = array();
330
-        foreach ($_sortable as $id => $data) {
331
-            if (empty($data)) {
332
-                continue;
333
-            }
334
-            // fix for offset errors with WP_List_Table default get_columninfo()
335
-            if (is_array($data)) {
336
-                $_data[0] = key($data);
337
-                $_data[1] = isset($data[1]) ? $data[1] : false;
338
-            } else {
339
-                $_data[0] = $data;
340
-            }
341
-
342
-            $data = (array) $data;
343
-
344
-            if (! isset($data[1])) {
345
-                $_data[1] = false;
346
-            }
347
-
348
-            $sortable[ $id ] = $_data;
349
-        }
350
-        $primary = $this->get_primary_column_name();
351
-        $this->_column_headers = array($columns, $hidden, $sortable, $primary);
352
-    }
353
-
354
-
355
-    /**
356
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
357
-     *
358
-     * @return string
359
-     */
360
-    protected function get_primary_column_name()
361
-    {
362
-        foreach (class_parents($this) as $parent) {
363
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
364
-                return parent::get_primary_column_name();
365
-            }
366
-        }
367
-        return $this->_primary_column;
368
-    }
369
-
370
-
371
-    /**
372
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
373
-     *
374
-     * @param EE_Base_Class $item
375
-     * @param string        $column_name
376
-     * @param string        $primary
377
-     * @return string
378
-     */
379
-    protected function handle_row_actions($item, $column_name, $primary)
380
-    {
381
-        foreach (class_parents($this) as $parent) {
382
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
383
-                return parent::handle_row_actions($item, $column_name, $primary);
384
-            }
385
-        }
386
-        return '';
387
-    }
388
-
389
-
390
-    /**
391
-     * _get_bulk_actions
392
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
393
-     *
394
-     * @access protected
395
-     * @return array bulk_actions
396
-     */
397
-    protected function _get_bulk_actions()
398
-    {
399
-        $actions = array();
400
-        // the _views property should have the bulk_actions, so let's go through and extract them into a properly
401
-        // formatted array for the wp_list_table();
402
-        foreach ($this->_views as $view => $args) {
403
-            if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
404
-                // each bulk action will correspond with a admin page route, so we can check whatever the capability is
405
-                // for that page route and skip adding the bulk action if no access for the current logged in user.
406
-                foreach ($args['bulk_action'] as $route => $label) {
407
-                    if ($this->_admin_page->check_user_access($route, true)) {
408
-                        $actions[ $route ] = $label;
409
-                    }
410
-                }
411
-            }
412
-        }
413
-        return $actions;
414
-    }
415
-
416
-
417
-    /**
418
-     * Generate the table navigation above or below the table.
419
-     * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
420
-     *
421
-     * @since 4.9.44.rc.001
422
-     */
423
-    public function display_tablenav($which)
424
-    {
425
-        if ('top' === $which) {
426
-            wp_nonce_field('bulk-' . $this->_args['plural']);
427
-        }
428
-        ?>
23
+	/**
24
+	 * holds the data that will be processed for the table
25
+	 *
26
+	 * @var array $_data
27
+	 */
28
+	protected $_data;
29
+
30
+
31
+	/**
32
+	 * This holds the value of all the data available for the given view (for all pages).
33
+	 *
34
+	 * @var int $_all_data_count
35
+	 */
36
+	protected $_all_data_count;
37
+
38
+
39
+	/**
40
+	 * Will contain the count of trashed items for the view label.
41
+	 *
42
+	 * @var int $_trashed_count
43
+	 */
44
+	protected $_trashed_count;
45
+
46
+
47
+	/**
48
+	 * This is what will be referenced as the slug for the current screen
49
+	 *
50
+	 * @var string $_screen
51
+	 */
52
+	protected $_screen;
53
+
54
+
55
+	/**
56
+	 * this is the EE_Admin_Page object
57
+	 *
58
+	 * @var EE_Admin_Page $_admin_page
59
+	 */
60
+	protected $_admin_page;
61
+
62
+
63
+	/**
64
+	 * The current view
65
+	 *
66
+	 * @var string $_view
67
+	 */
68
+	protected $_view;
69
+
70
+
71
+	/**
72
+	 * array of possible views for this table
73
+	 *
74
+	 * @var array $_views
75
+	 */
76
+	protected $_views;
77
+
78
+
79
+	/**
80
+	 * An array of key => value pairs containing information about the current table
81
+	 * array(
82
+	 *        'plural' => 'plural label',
83
+	 *        'singular' => 'singular label',
84
+	 *        'ajax' => false, //whether to use ajax or not
85
+	 *        'screen' => null, //string used to reference what screen this is
86
+	 *        (WP_List_table converts to screen object)
87
+	 * )
88
+	 *
89
+	 * @var array $_wp_list_args
90
+	 */
91
+	protected $_wp_list_args;
92
+
93
+	/**
94
+	 * an array of column names
95
+	 * array(
96
+	 *    'internal-name' => 'Title'
97
+	 * )
98
+	 *
99
+	 * @var array $_columns
100
+	 */
101
+	protected $_columns;
102
+
103
+	/**
104
+	 * An array of sortable columns
105
+	 * array(
106
+	 *    'internal-name' => 'orderby' //or
107
+	 *    'internal-name' => array( 'orderby', true )
108
+	 * )
109
+	 *
110
+	 * @var array $_sortable_columns
111
+	 */
112
+	protected $_sortable_columns;
113
+
114
+	/**
115
+	 * callback method used to perform AJAX row reordering
116
+	 *
117
+	 * @var string $_ajax_sorting_callback
118
+	 */
119
+	protected $_ajax_sorting_callback;
120
+
121
+	/**
122
+	 * An array of hidden columns (if needed)
123
+	 * array('internal-name', 'internal-name')
124
+	 *
125
+	 * @var array $_hidden_columns
126
+	 */
127
+	protected $_hidden_columns;
128
+
129
+	/**
130
+	 * holds the per_page value
131
+	 *
132
+	 * @var int $_per_page
133
+	 */
134
+	protected $_per_page;
135
+
136
+	/**
137
+	 * holds what page number is currently being viewed
138
+	 *
139
+	 * @var int $_current_page
140
+	 */
141
+	protected $_current_page;
142
+
143
+	/**
144
+	 * the reference string for the nonce_action
145
+	 *
146
+	 * @var string $_nonce_action_ref
147
+	 */
148
+	protected $_nonce_action_ref;
149
+
150
+	/**
151
+	 * property to hold incoming request data (as set by the admin_page_core)
152
+	 *
153
+	 * @var array $_req_data
154
+	 */
155
+	protected $_req_data;
156
+
157
+
158
+	/**
159
+	 * yes / no array for admin form fields
160
+	 *
161
+	 * @var array $_yes_no
162
+	 */
163
+	protected $_yes_no = array();
164
+
165
+	/**
166
+	 * Array describing buttons that should appear at the bottom of the page
167
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
168
+	 * and the values are another array with the following keys
169
+	 * array(
170
+	 *    'route' => 'page_route',
171
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
172
+	 * )
173
+	 *
174
+	 * @var array $_bottom_buttons
175
+	 */
176
+	protected $_bottom_buttons = array();
177
+
178
+
179
+	/**
180
+	 * Used to indicate what should be the primary column for the list table.
181
+	 * If not present then falls back to what WP calculates
182
+	 * as the primary column.
183
+	 *
184
+	 * @type string $_primary_column
185
+	 */
186
+	protected $_primary_column = '';
187
+
188
+
189
+	/**
190
+	 * Used to indicate whether the table has a checkbox column or not.
191
+	 *
192
+	 * @type bool $_has_checkbox_column
193
+	 */
194
+	protected $_has_checkbox_column = false;
195
+
196
+
197
+	/**
198
+	 * @param \EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
199
+	 */
200
+	public function __construct(EE_Admin_Page $admin_page)
201
+	{
202
+		$this->_admin_page = $admin_page;
203
+		$this->_req_data = $this->_admin_page->get_request_data();
204
+		$this->_view = $this->_admin_page->get_view();
205
+		$this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
206
+		$this->_current_page = $this->get_pagenum();
207
+		$this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
208
+		$this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso'));
209
+
210
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10);
211
+
212
+		$this->_setup_data();
213
+		$this->_add_view_counts();
214
+
215
+		$this->_nonce_action_ref = $this->_view;
216
+
217
+		$this->_set_properties();
218
+
219
+		// set primary column
220
+		add_filter('list_table_primary_column', array($this, 'set_primary_column'));
221
+
222
+		// set parent defaults
223
+		parent::__construct($this->_wp_list_args);
224
+
225
+		$this->prepare_items();
226
+	}
227
+
228
+
229
+	/**
230
+	 * _setup_data
231
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
232
+	 *
233
+	 * @uses $this->_admin_page
234
+	 * @return void
235
+	 */
236
+	abstract protected function _setup_data();
237
+
238
+
239
+	/**
240
+	 * set the properties that this class needs to be able to execute wp_list_table properly
241
+	 * properties set:
242
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
243
+	 * _columns = set the columns in an array.
244
+	 * _sortable_columns = columns that are sortable (array).
245
+	 * _hidden_columns = columns that are hidden (array)
246
+	 * _default_orderby = the default orderby for sorting.
247
+	 *
248
+	 * @abstract
249
+	 * @access protected
250
+	 * @return void
251
+	 */
252
+	abstract protected function _set_properties();
253
+
254
+
255
+	/**
256
+	 * _get_table_filters
257
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
258
+	 * get's shown in the table.
259
+	 *
260
+	 * @abstract
261
+	 * @access protected
262
+	 * @return string
263
+	 */
264
+	abstract protected function _get_table_filters();
265
+
266
+
267
+	/**
268
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
269
+	 * counts of the views is accurate.
270
+	 *
271
+	 * @abstract
272
+	 * @access protected
273
+	 * @return void
274
+	 */
275
+	abstract protected function _add_view_counts();
276
+
277
+
278
+	/**
279
+	 * _get_hidden_fields
280
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
281
+	 *
282
+	 * @return string
283
+	 */
284
+	protected function _get_hidden_fields()
285
+	{
286
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
287
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
288
+		// if action is STILL empty, then we set it to default
289
+		$action = empty($action) ? 'default' : $action;
290
+		$field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
291
+		$field .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
292
+		$field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
293
+
294
+		$bulk_actions = $this->_get_bulk_actions();
295
+		foreach ($bulk_actions as $bulk_action => $label) {
296
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
297
+					  . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
298
+		}
299
+
300
+		return $field;
301
+	}
302
+
303
+
304
+	/**
305
+	 * _set_column_info
306
+	 * we're using this to set the column headers property.
307
+	 *
308
+	 * @access protected
309
+	 * @return void
310
+	 */
311
+	protected function _set_column_info()
312
+	{
313
+		$columns = $this->get_columns();
314
+		$hidden = $this->get_hidden_columns();
315
+		$_sortable = $this->get_sortable_columns();
316
+
317
+		/**
318
+		 * Dynamic hook allowing for adding sortable columns in this list table.
319
+		 * Note that $this->screen->id is in the format
320
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
321
+		 * table it is: event-espresso_page_espresso_messages.
322
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
323
+		 * hook prefix ("event-espresso") will be different.
324
+		 *
325
+		 * @var array
326
+		 */
327
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
328
+
329
+		$sortable = array();
330
+		foreach ($_sortable as $id => $data) {
331
+			if (empty($data)) {
332
+				continue;
333
+			}
334
+			// fix for offset errors with WP_List_Table default get_columninfo()
335
+			if (is_array($data)) {
336
+				$_data[0] = key($data);
337
+				$_data[1] = isset($data[1]) ? $data[1] : false;
338
+			} else {
339
+				$_data[0] = $data;
340
+			}
341
+
342
+			$data = (array) $data;
343
+
344
+			if (! isset($data[1])) {
345
+				$_data[1] = false;
346
+			}
347
+
348
+			$sortable[ $id ] = $_data;
349
+		}
350
+		$primary = $this->get_primary_column_name();
351
+		$this->_column_headers = array($columns, $hidden, $sortable, $primary);
352
+	}
353
+
354
+
355
+	/**
356
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
357
+	 *
358
+	 * @return string
359
+	 */
360
+	protected function get_primary_column_name()
361
+	{
362
+		foreach (class_parents($this) as $parent) {
363
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
364
+				return parent::get_primary_column_name();
365
+			}
366
+		}
367
+		return $this->_primary_column;
368
+	}
369
+
370
+
371
+	/**
372
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
373
+	 *
374
+	 * @param EE_Base_Class $item
375
+	 * @param string        $column_name
376
+	 * @param string        $primary
377
+	 * @return string
378
+	 */
379
+	protected function handle_row_actions($item, $column_name, $primary)
380
+	{
381
+		foreach (class_parents($this) as $parent) {
382
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
383
+				return parent::handle_row_actions($item, $column_name, $primary);
384
+			}
385
+		}
386
+		return '';
387
+	}
388
+
389
+
390
+	/**
391
+	 * _get_bulk_actions
392
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
393
+	 *
394
+	 * @access protected
395
+	 * @return array bulk_actions
396
+	 */
397
+	protected function _get_bulk_actions()
398
+	{
399
+		$actions = array();
400
+		// the _views property should have the bulk_actions, so let's go through and extract them into a properly
401
+		// formatted array for the wp_list_table();
402
+		foreach ($this->_views as $view => $args) {
403
+			if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
404
+				// each bulk action will correspond with a admin page route, so we can check whatever the capability is
405
+				// for that page route and skip adding the bulk action if no access for the current logged in user.
406
+				foreach ($args['bulk_action'] as $route => $label) {
407
+					if ($this->_admin_page->check_user_access($route, true)) {
408
+						$actions[ $route ] = $label;
409
+					}
410
+				}
411
+			}
412
+		}
413
+		return $actions;
414
+	}
415
+
416
+
417
+	/**
418
+	 * Generate the table navigation above or below the table.
419
+	 * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
420
+	 *
421
+	 * @since 4.9.44.rc.001
422
+	 */
423
+	public function display_tablenav($which)
424
+	{
425
+		if ('top' === $which) {
426
+			wp_nonce_field('bulk-' . $this->_args['plural']);
427
+		}
428
+		?>
429 429
         <div class="tablenav <?php echo esc_attr($which); ?>">
430 430
             <?php if ($this->_get_bulk_actions()) { ?>
431 431
                 <div class="alignleft actions bulkactions">
432 432
                     <?php $this->bulk_actions(); ?>
433 433
                 </div>
434 434
             <?php }
435
-            $this->extra_tablenav($which);
436
-            $this->pagination($which);
437
-            ?>
435
+			$this->extra_tablenav($which);
436
+			$this->pagination($which);
437
+			?>
438 438
 
439 439
             <br class="clear"/>
440 440
         </div>
441 441
         <?php
442
-    }
443
-
444
-
445
-    /**
446
-     * _filters
447
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
448
-     * button.
449
-     *
450
-     * @access private
451
-     * @return string html showing filters
452
-     */
453
-    private function _filters()
454
-    {
455
-        $classname = get_class($this);
456
-        $filters = apply_filters(
457
-            "FHEE__{$classname}__filters",
458
-            (array) $this->_get_table_filters(),
459
-            $this,
460
-            $this->_screen
461
-        );
462
-
463
-        if (empty($filters)) {
464
-            return;
465
-        }
466
-        foreach ($filters as $filter) {
467
-            echo $filter;
468
-        }
469
-        // add filter button at end
470
-        echo '<input type="submit" class="button-secondary" value="'
471
-             . esc_html__('Filter', 'event_espresso')
472
-             . '" id="post-query-submit" />';
473
-        // add reset filters button at end
474
-        echo '<a class="button button-secondary"  href="'
475
-             . $this->_admin_page->get_current_page_view_url()
476
-             . '" style="display:inline-block">'
477
-             . esc_html__('Reset Filters', 'event_espresso')
478
-             . '</a>';
479
-    }
480
-
481
-
482
-    /**
483
-     * Callback for 'list_table_primary_column' WordPress filter
484
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
485
-     * column when class is instantiated.
486
-     *
487
-     * @see WP_List_Table::get_primary_column_name
488
-     * @param string $column_name
489
-     * @return string
490
-     */
491
-    public function set_primary_column($column_name)
492
-    {
493
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
494
-    }
495
-
496
-
497
-    /**
498
-     *
499
-     */
500
-    public function prepare_items()
501
-    {
502
-
503
-        $this->_set_column_info();
504
-        // $this->_column_headers = $this->get_column_info();
505
-        $total_items = $this->_all_data_count;
506
-        $this->process_bulk_action();
507
-
508
-        $this->items = $this->_data;
509
-        $this->set_pagination_args(
510
-            array(
511
-                'total_items' => $total_items,
512
-                'per_page'    => $this->_per_page,
513
-                'total_pages' => ceil($total_items / $this->_per_page),
514
-            )
515
-        );
516
-    }
517
-
518
-
519
-    /**
520
-     * This column is the default for when there is no defined column method for a registered column.
521
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
522
-     *
523
-     * @param EE_Base_Class $item
524
-     * @param string        $column_name The column being called.
525
-     * @return string html content for the column
526
-     */
527
-    public function column_default($item, $column_name)
528
-    {
529
-        /**
530
-         * Dynamic hook allowing for adding additional column content in this list table.
531
-         * Note that $this->screen->id is in the format
532
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
533
-         * table it is: event-espresso_page_espresso_messages.
534
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
535
-         * hook prefix ("event-espresso") will be different.
536
-         */
537
-        do_action(
538
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
539
-            $item,
540
-            $this->_screen
541
-        );
542
-    }
543
-
544
-
545
-    /**
546
-     * Get a list of columns. The format is:
547
-     * 'internal-name' => 'Title'
548
-     *
549
-     * @since  3.1.0
550
-     * @access public
551
-     * @abstract
552
-     * @return array
553
-     */
554
-    public function get_columns()
555
-    {
556
-        /**
557
-         * Dynamic hook allowing for adding additional columns in this list table.
558
-         * Note that $this->screen->id is in the format
559
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
560
-         * table it is: event-espresso_page_espresso_messages.
561
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
562
-         * hook prefix ("event-espresso") will be different.
563
-         *
564
-         * @var array
565
-         */
566
-        $columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
567
-        return $columns;
568
-    }
569
-
570
-
571
-    /**
572
-     * Get an associative array ( id => link ) with the list
573
-     * of views available on this table.
574
-     *
575
-     * @since  3.1.0
576
-     * @access protected
577
-     * @return array
578
-     */
579
-    public function get_views()
580
-    {
581
-        return $this->_views;
582
-    }
583
-
584
-
585
-    /**
586
-     * Generate the views html.
587
-     */
588
-    public function display_views()
589
-    {
590
-        $views = $this->get_views();
591
-        $assembled_views = array();
592
-
593
-        if (empty($views)) {
594
-            return;
595
-        }
596
-        echo "<ul class='subsubsub'>\n";
597
-        foreach ($views as $view) {
598
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
599
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
600
-                $assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>"
601
-                                                    . '<a href="' . $view['url'] . '">' . $view['label'] . '</a>'
602
-                                                    . ' <span class="count">(' . $count . ')</span>';
603
-            }
604
-        }
605
-
606
-        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
607
-        echo "</ul>";
608
-    }
609
-
610
-
611
-    /**
612
-     * Generates content for a single row of the table
613
-     *
614
-     * @since  4.1
615
-     * @access public
616
-     * @param EE_Base_Class $item The current item
617
-     */
618
-    public function single_row($item)
619
-    {
620
-        $row_class = $this->_get_row_class($item);
621
-        echo '<tr class="' . esc_attr($row_class) . '">';
622
-        $this->single_row_columns($item);
623
-        echo '</tr>';
624
-    }
625
-
626
-
627
-    /**
628
-     * This simply sets up the row class for the table rows.
629
-     * Allows for easier overriding of child methods for setting up sorting.
630
-     *
631
-     * @param  EE_Base_Class $item the current item
632
-     * @return string
633
-     */
634
-    protected function _get_row_class($item)
635
-    {
636
-        static $row_class = '';
637
-        $row_class = ($row_class === '' ? 'alternate' : '');
638
-
639
-        $new_row_class = $row_class;
640
-
641
-        if (! empty($this->_ajax_sorting_callback)) {
642
-            $new_row_class .= ' rowsortable';
643
-        }
644
-
645
-        return $new_row_class;
646
-    }
647
-
648
-
649
-    /**
650
-     * @return array
651
-     */
652
-    public function get_sortable_columns()
653
-    {
654
-        return (array) $this->_sortable_columns;
655
-    }
656
-
657
-
658
-    /**
659
-     * @return string
660
-     */
661
-    public function get_ajax_sorting_callback()
662
-    {
663
-        return $this->_ajax_sorting_callback;
664
-    }
665
-
666
-
667
-    /**
668
-     * @return array
669
-     */
670
-    public function get_hidden_columns()
671
-    {
672
-        $user_id = get_current_user_id();
673
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
674
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
675
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
676
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
677
-        }
678
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
679
-        return (array) get_user_option($ref, $user_id);
680
-    }
681
-
682
-
683
-    /**
684
-     * Generates the columns for a single row of the table.
685
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
686
-     * column.
687
-     *
688
-     * @since 3.1.0
689
-     * @param EE_Base_Class $item The current item
690
-     */
691
-    public function single_row_columns($item)
692
-    {
693
-        list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
694
-
695
-        global $wp_version;
696
-        $use_hidden_class = version_compare($wp_version, '4.3-RC', '>=');
697
-
698
-        foreach ($columns as $column_name => $column_display_name) {
699
-
700
-            /**
701
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
702
-             * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
703
-             */
704
-            $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
705
-            $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
706
-
707
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
708
-            if ($primary === $column_name) {
709
-                $classes .= ' has-row-actions column-primary';
710
-            }
711
-
712
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
713
-
714
-            $class = "class='$classes'";
715
-
716
-            $attributes = "$class$style$data";
717
-
718
-            if ($column_name === 'cb') {
719
-                echo '<th scope="row" class="check-column">';
720
-                echo apply_filters(
721
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
722
-                    $this->column_cb($item),
723
-                    $item,
724
-                    $this
725
-                );
726
-                echo '</th>';
727
-            } elseif (method_exists($this, 'column_' . $column_name)) {
728
-                echo "<td $attributes>";
729
-                echo apply_filters(
730
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
731
-                    call_user_func(array($this, 'column_' . $column_name), $item),
732
-                    $item,
733
-                    $this
734
-                );
735
-                echo $this->handle_row_actions($item, $column_name, $primary);
736
-                echo "</td>";
737
-            } else {
738
-                echo "<td $attributes>";
739
-                echo apply_filters(
740
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
741
-                    $this->column_default($item, $column_name),
742
-                    $item,
743
-                    $column_name,
744
-                    $this
745
-                );
746
-                echo $this->handle_row_actions($item, $column_name, $primary);
747
-                echo "</td>";
748
-            }
749
-        }
750
-    }
751
-
752
-
753
-    /**
754
-     * Extra controls to be displayed between bulk actions and pagination
755
-     *
756
-     * @access public
757
-     * @param string $which
758
-     * @throws \EE_Error
759
-     */
760
-    public function extra_tablenav($which)
761
-    {
762
-        if ($which === 'top') {
763
-            $this->_filters();
764
-            echo $this->_get_hidden_fields();
765
-        } else {
766
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
767
-            foreach ($this->_bottom_buttons as $type => $action) {
768
-                $route = isset($action['route']) ? $action['route'] : '';
769
-                $extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
770
-                echo $this->_admin_page->get_action_link_or_button(
771
-                    $route,
772
-                    $type,
773
-                    $extra_request,
774
-                    'button button-secondary',
775
-                    '',
776
-                    false
777
-                );
778
-            }
779
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
780
-            echo '</div>';
781
-        }
782
-        // echo $this->_entries_per_page_dropdown;
783
-    }
784
-
785
-
786
-    /**
787
-     * Get an associative array ( option_name => option_title ) with the list
788
-     * of bulk actions available on this table.
789
-     *
790
-     * @since  3.1.0
791
-     * @access protected
792
-     * @return array
793
-     */
794
-    public function get_bulk_actions()
795
-    {
796
-        return (array) $this->_get_bulk_actions();
797
-    }
798
-
799
-    /**
800
-     * Processing bulk actions.
801
-     */
802
-    public function process_bulk_action()
803
-    {
804
-        // this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
805
-        // reference in case there is a case where it gets used.
806
-    }
807
-
808
-
809
-    /**
810
-     * returns the EE admin page this list table is associated with
811
-     *
812
-     * @return EE_Admin_Page
813
-     */
814
-    public function get_admin_page()
815
-    {
816
-        return $this->_admin_page;
817
-    }
818
-
819
-
820
-    /**
821
-     * A "helper" function for all children to provide an html string of
822
-     * actions to output in their content.  It is preferable for child classes
823
-     * to use this method for generating their actions content so that it's
824
-     * filterable by plugins
825
-     *
826
-     * @param string        $action_container           what are the html container
827
-     *                                                  elements for this actions string?
828
-     * @param string        $action_class               What class is for the container
829
-     *                                                  element.
830
-     * @param string        $action_items               The contents for the action items
831
-     *                                                  container.  This is filtered before
832
-     *                                                  returned.
833
-     * @param string        $action_id                  What id (optional) is used for the
834
-     *                                                  container element.
835
-     * @param EE_Base_Class $item                       The object for the column displaying
836
-     *                                                  the actions.
837
-     * @return string The assembled action elements container.
838
-     */
839
-    protected function _action_string(
840
-        $action_items,
841
-        $item,
842
-        $action_container = 'ul',
843
-        $action_class = '',
844
-        $action_id = ''
845
-    ) {
846
-        $content = '';
847
-        $action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
848
-        $action_id = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
849
-        $content .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
850
-        try {
851
-            $content .= apply_filters(
852
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
853
-                $action_items,
854
-                $item,
855
-                $this
856
-            );
857
-        } catch (\Exception $e) {
858
-            if (WP_DEBUG) {
859
-                \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
860
-            }
861
-            $content .= $action_items;
862
-        }
863
-        $content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
864
-        return $content;
865
-    }
442
+	}
443
+
444
+
445
+	/**
446
+	 * _filters
447
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
448
+	 * button.
449
+	 *
450
+	 * @access private
451
+	 * @return string html showing filters
452
+	 */
453
+	private function _filters()
454
+	{
455
+		$classname = get_class($this);
456
+		$filters = apply_filters(
457
+			"FHEE__{$classname}__filters",
458
+			(array) $this->_get_table_filters(),
459
+			$this,
460
+			$this->_screen
461
+		);
462
+
463
+		if (empty($filters)) {
464
+			return;
465
+		}
466
+		foreach ($filters as $filter) {
467
+			echo $filter;
468
+		}
469
+		// add filter button at end
470
+		echo '<input type="submit" class="button-secondary" value="'
471
+			 . esc_html__('Filter', 'event_espresso')
472
+			 . '" id="post-query-submit" />';
473
+		// add reset filters button at end
474
+		echo '<a class="button button-secondary"  href="'
475
+			 . $this->_admin_page->get_current_page_view_url()
476
+			 . '" style="display:inline-block">'
477
+			 . esc_html__('Reset Filters', 'event_espresso')
478
+			 . '</a>';
479
+	}
480
+
481
+
482
+	/**
483
+	 * Callback for 'list_table_primary_column' WordPress filter
484
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
485
+	 * column when class is instantiated.
486
+	 *
487
+	 * @see WP_List_Table::get_primary_column_name
488
+	 * @param string $column_name
489
+	 * @return string
490
+	 */
491
+	public function set_primary_column($column_name)
492
+	{
493
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
494
+	}
495
+
496
+
497
+	/**
498
+	 *
499
+	 */
500
+	public function prepare_items()
501
+	{
502
+
503
+		$this->_set_column_info();
504
+		// $this->_column_headers = $this->get_column_info();
505
+		$total_items = $this->_all_data_count;
506
+		$this->process_bulk_action();
507
+
508
+		$this->items = $this->_data;
509
+		$this->set_pagination_args(
510
+			array(
511
+				'total_items' => $total_items,
512
+				'per_page'    => $this->_per_page,
513
+				'total_pages' => ceil($total_items / $this->_per_page),
514
+			)
515
+		);
516
+	}
517
+
518
+
519
+	/**
520
+	 * This column is the default for when there is no defined column method for a registered column.
521
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
522
+	 *
523
+	 * @param EE_Base_Class $item
524
+	 * @param string        $column_name The column being called.
525
+	 * @return string html content for the column
526
+	 */
527
+	public function column_default($item, $column_name)
528
+	{
529
+		/**
530
+		 * Dynamic hook allowing for adding additional column content in this list table.
531
+		 * Note that $this->screen->id is in the format
532
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
533
+		 * table it is: event-espresso_page_espresso_messages.
534
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
535
+		 * hook prefix ("event-espresso") will be different.
536
+		 */
537
+		do_action(
538
+			'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
539
+			$item,
540
+			$this->_screen
541
+		);
542
+	}
543
+
544
+
545
+	/**
546
+	 * Get a list of columns. The format is:
547
+	 * 'internal-name' => 'Title'
548
+	 *
549
+	 * @since  3.1.0
550
+	 * @access public
551
+	 * @abstract
552
+	 * @return array
553
+	 */
554
+	public function get_columns()
555
+	{
556
+		/**
557
+		 * Dynamic hook allowing for adding additional columns in this list table.
558
+		 * Note that $this->screen->id is in the format
559
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
560
+		 * table it is: event-espresso_page_espresso_messages.
561
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
562
+		 * hook prefix ("event-espresso") will be different.
563
+		 *
564
+		 * @var array
565
+		 */
566
+		$columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
567
+		return $columns;
568
+	}
569
+
570
+
571
+	/**
572
+	 * Get an associative array ( id => link ) with the list
573
+	 * of views available on this table.
574
+	 *
575
+	 * @since  3.1.0
576
+	 * @access protected
577
+	 * @return array
578
+	 */
579
+	public function get_views()
580
+	{
581
+		return $this->_views;
582
+	}
583
+
584
+
585
+	/**
586
+	 * Generate the views html.
587
+	 */
588
+	public function display_views()
589
+	{
590
+		$views = $this->get_views();
591
+		$assembled_views = array();
592
+
593
+		if (empty($views)) {
594
+			return;
595
+		}
596
+		echo "<ul class='subsubsub'>\n";
597
+		foreach ($views as $view) {
598
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
599
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
600
+				$assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>"
601
+													. '<a href="' . $view['url'] . '">' . $view['label'] . '</a>'
602
+													. ' <span class="count">(' . $count . ')</span>';
603
+			}
604
+		}
605
+
606
+		echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
607
+		echo "</ul>";
608
+	}
609
+
610
+
611
+	/**
612
+	 * Generates content for a single row of the table
613
+	 *
614
+	 * @since  4.1
615
+	 * @access public
616
+	 * @param EE_Base_Class $item The current item
617
+	 */
618
+	public function single_row($item)
619
+	{
620
+		$row_class = $this->_get_row_class($item);
621
+		echo '<tr class="' . esc_attr($row_class) . '">';
622
+		$this->single_row_columns($item);
623
+		echo '</tr>';
624
+	}
625
+
626
+
627
+	/**
628
+	 * This simply sets up the row class for the table rows.
629
+	 * Allows for easier overriding of child methods for setting up sorting.
630
+	 *
631
+	 * @param  EE_Base_Class $item the current item
632
+	 * @return string
633
+	 */
634
+	protected function _get_row_class($item)
635
+	{
636
+		static $row_class = '';
637
+		$row_class = ($row_class === '' ? 'alternate' : '');
638
+
639
+		$new_row_class = $row_class;
640
+
641
+		if (! empty($this->_ajax_sorting_callback)) {
642
+			$new_row_class .= ' rowsortable';
643
+		}
644
+
645
+		return $new_row_class;
646
+	}
647
+
648
+
649
+	/**
650
+	 * @return array
651
+	 */
652
+	public function get_sortable_columns()
653
+	{
654
+		return (array) $this->_sortable_columns;
655
+	}
656
+
657
+
658
+	/**
659
+	 * @return string
660
+	 */
661
+	public function get_ajax_sorting_callback()
662
+	{
663
+		return $this->_ajax_sorting_callback;
664
+	}
665
+
666
+
667
+	/**
668
+	 * @return array
669
+	 */
670
+	public function get_hidden_columns()
671
+	{
672
+		$user_id = get_current_user_id();
673
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
674
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
675
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
676
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
677
+		}
678
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
679
+		return (array) get_user_option($ref, $user_id);
680
+	}
681
+
682
+
683
+	/**
684
+	 * Generates the columns for a single row of the table.
685
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
686
+	 * column.
687
+	 *
688
+	 * @since 3.1.0
689
+	 * @param EE_Base_Class $item The current item
690
+	 */
691
+	public function single_row_columns($item)
692
+	{
693
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
694
+
695
+		global $wp_version;
696
+		$use_hidden_class = version_compare($wp_version, '4.3-RC', '>=');
697
+
698
+		foreach ($columns as $column_name => $column_display_name) {
699
+
700
+			/**
701
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
702
+			 * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
703
+			 */
704
+			$hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
705
+			$style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
706
+
707
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
708
+			if ($primary === $column_name) {
709
+				$classes .= ' has-row-actions column-primary';
710
+			}
711
+
712
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
713
+
714
+			$class = "class='$classes'";
715
+
716
+			$attributes = "$class$style$data";
717
+
718
+			if ($column_name === 'cb') {
719
+				echo '<th scope="row" class="check-column">';
720
+				echo apply_filters(
721
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
722
+					$this->column_cb($item),
723
+					$item,
724
+					$this
725
+				);
726
+				echo '</th>';
727
+			} elseif (method_exists($this, 'column_' . $column_name)) {
728
+				echo "<td $attributes>";
729
+				echo apply_filters(
730
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
731
+					call_user_func(array($this, 'column_' . $column_name), $item),
732
+					$item,
733
+					$this
734
+				);
735
+				echo $this->handle_row_actions($item, $column_name, $primary);
736
+				echo "</td>";
737
+			} else {
738
+				echo "<td $attributes>";
739
+				echo apply_filters(
740
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
741
+					$this->column_default($item, $column_name),
742
+					$item,
743
+					$column_name,
744
+					$this
745
+				);
746
+				echo $this->handle_row_actions($item, $column_name, $primary);
747
+				echo "</td>";
748
+			}
749
+		}
750
+	}
751
+
752
+
753
+	/**
754
+	 * Extra controls to be displayed between bulk actions and pagination
755
+	 *
756
+	 * @access public
757
+	 * @param string $which
758
+	 * @throws \EE_Error
759
+	 */
760
+	public function extra_tablenav($which)
761
+	{
762
+		if ($which === 'top') {
763
+			$this->_filters();
764
+			echo $this->_get_hidden_fields();
765
+		} else {
766
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
767
+			foreach ($this->_bottom_buttons as $type => $action) {
768
+				$route = isset($action['route']) ? $action['route'] : '';
769
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
770
+				echo $this->_admin_page->get_action_link_or_button(
771
+					$route,
772
+					$type,
773
+					$extra_request,
774
+					'button button-secondary',
775
+					'',
776
+					false
777
+				);
778
+			}
779
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
780
+			echo '</div>';
781
+		}
782
+		// echo $this->_entries_per_page_dropdown;
783
+	}
784
+
785
+
786
+	/**
787
+	 * Get an associative array ( option_name => option_title ) with the list
788
+	 * of bulk actions available on this table.
789
+	 *
790
+	 * @since  3.1.0
791
+	 * @access protected
792
+	 * @return array
793
+	 */
794
+	public function get_bulk_actions()
795
+	{
796
+		return (array) $this->_get_bulk_actions();
797
+	}
798
+
799
+	/**
800
+	 * Processing bulk actions.
801
+	 */
802
+	public function process_bulk_action()
803
+	{
804
+		// this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
805
+		// reference in case there is a case where it gets used.
806
+	}
807
+
808
+
809
+	/**
810
+	 * returns the EE admin page this list table is associated with
811
+	 *
812
+	 * @return EE_Admin_Page
813
+	 */
814
+	public function get_admin_page()
815
+	{
816
+		return $this->_admin_page;
817
+	}
818
+
819
+
820
+	/**
821
+	 * A "helper" function for all children to provide an html string of
822
+	 * actions to output in their content.  It is preferable for child classes
823
+	 * to use this method for generating their actions content so that it's
824
+	 * filterable by plugins
825
+	 *
826
+	 * @param string        $action_container           what are the html container
827
+	 *                                                  elements for this actions string?
828
+	 * @param string        $action_class               What class is for the container
829
+	 *                                                  element.
830
+	 * @param string        $action_items               The contents for the action items
831
+	 *                                                  container.  This is filtered before
832
+	 *                                                  returned.
833
+	 * @param string        $action_id                  What id (optional) is used for the
834
+	 *                                                  container element.
835
+	 * @param EE_Base_Class $item                       The object for the column displaying
836
+	 *                                                  the actions.
837
+	 * @return string The assembled action elements container.
838
+	 */
839
+	protected function _action_string(
840
+		$action_items,
841
+		$item,
842
+		$action_container = 'ul',
843
+		$action_class = '',
844
+		$action_id = ''
845
+	) {
846
+		$content = '';
847
+		$action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
848
+		$action_id = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
849
+		$content .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
850
+		try {
851
+			$content .= apply_filters(
852
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
853
+				$action_items,
854
+				$item,
855
+				$this
856
+			);
857
+		} catch (\Exception $e) {
858
+			if (WP_DEBUG) {
859
+				\EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
860
+			}
861
+			$content .= $action_items;
862
+		}
863
+		$content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
864
+		return $content;
865
+	}
866 866
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! class_exists('WP_List_Table')) {
4
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
3
+if ( ! class_exists('WP_List_Table')) {
4
+    require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
5 5
 }
6 6
 
7 7
 
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
         $this->_view = $this->_admin_page->get_view();
205 205
         $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
206 206
         $this->_current_page = $this->get_pagenum();
207
-        $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
207
+        $this->_screen = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view();
208 208
         $this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso'));
209 209
 
210
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10);
210
+        $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 10);
211 211
 
212 212
         $this->_setup_data();
213 213
         $this->_add_view_counts();
@@ -287,14 +287,14 @@  discard block
 block discarded – undo
287 287
         $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
288 288
         // if action is STILL empty, then we set it to default
289 289
         $action = empty($action) ? 'default' : $action;
290
-        $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
291
-        $field .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
292
-        $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
290
+        $field = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n";
291
+        $field .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/
292
+        $field .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n";
293 293
 
294 294
         $bulk_actions = $this->_get_bulk_actions();
295 295
         foreach ($bulk_actions as $bulk_action => $label) {
296
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
297
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
296
+            $field .= '<input type="hidden" name="'.$bulk_action.'_nonce"'
297
+                      . ' value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n";
298 298
         }
299 299
 
300 300
         return $field;
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
 
342 342
             $data = (array) $data;
343 343
 
344
-            if (! isset($data[1])) {
344
+            if ( ! isset($data[1])) {
345 345
                 $_data[1] = false;
346 346
             }
347 347
 
348
-            $sortable[ $id ] = $_data;
348
+            $sortable[$id] = $_data;
349 349
         }
350 350
         $primary = $this->get_primary_column_name();
351 351
         $this->_column_headers = array($columns, $hidden, $sortable, $primary);
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
                 // for that page route and skip adding the bulk action if no access for the current logged in user.
406 406
                 foreach ($args['bulk_action'] as $route => $label) {
407 407
                     if ($this->_admin_page->check_user_access($route, true)) {
408
-                        $actions[ $route ] = $label;
408
+                        $actions[$route] = $label;
409 409
                     }
410 410
                 }
411 411
             }
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
     public function display_tablenav($which)
424 424
     {
425 425
         if ('top' === $which) {
426
-            wp_nonce_field('bulk-' . $this->_args['plural']);
426
+            wp_nonce_field('bulk-'.$this->_args['plural']);
427 427
         }
428 428
         ?>
429 429
         <div class="tablenav <?php echo esc_attr($which); ?>">
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
          * hook prefix ("event-espresso") will be different.
536 536
          */
537 537
         do_action(
538
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
538
+            'AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id,
539 539
             $item,
540 540
             $this->_screen
541 541
         );
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
          *
564 564
          * @var array
565 565
          */
566
-        $columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
566
+        $columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen);
567 567
         return $columns;
568 568
     }
569 569
 
@@ -597,13 +597,13 @@  discard block
 block discarded – undo
597 597
         foreach ($views as $view) {
598 598
             $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
599 599
             if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
600
-                $assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>"
601
-                                                    . '<a href="' . $view['url'] . '">' . $view['label'] . '</a>'
602
-                                                    . ' <span class="count">(' . $count . ')</span>';
600
+                $assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>"
601
+                                                    . '<a href="'.$view['url'].'">'.$view['label'].'</a>'
602
+                                                    . ' <span class="count">('.$count.')</span>';
603 603
             }
604 604
         }
605 605
 
606
-        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
606
+        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : '';
607 607
         echo "</ul>";
608 608
     }
609 609
 
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
     public function single_row($item)
619 619
     {
620 620
         $row_class = $this->_get_row_class($item);
621
-        echo '<tr class="' . esc_attr($row_class) . '">';
621
+        echo '<tr class="'.esc_attr($row_class).'">';
622 622
         $this->single_row_columns($item);
623 623
         echo '</tr>';
624 624
     }
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 
639 639
         $new_row_class = $row_class;
640 640
 
641
-        if (! empty($this->_ajax_sorting_callback)) {
641
+        if ( ! empty($this->_ajax_sorting_callback)) {
642 642
             $new_row_class .= ' rowsortable';
643 643
         }
644 644
 
@@ -670,12 +670,12 @@  discard block
 block discarded – undo
670 670
     public function get_hidden_columns()
671 671
     {
672 672
         $user_id = get_current_user_id();
673
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
673
+        $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id);
674 674
         if (empty($has_default) && ! empty($this->_hidden_columns)) {
675
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
676
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
675
+            update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', true);
676
+            update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, true);
677 677
         }
678
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
678
+        $ref = 'manage'.$this->screen->id.'columnshidden';
679 679
         return (array) get_user_option($ref, $user_id);
680 680
     }
681 681
 
@@ -704,12 +704,12 @@  discard block
 block discarded – undo
704 704
             $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
705 705
             $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
706 706
 
707
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
707
+            $classes = $column_name.' column-'.$column_name.$hidden_class;
708 708
             if ($primary === $column_name) {
709 709
                 $classes .= ' has-row-actions column-primary';
710 710
             }
711 711
 
712
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
712
+            $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"';
713 713
 
714 714
             $class = "class='$classes'";
715 715
 
@@ -724,11 +724,11 @@  discard block
 block discarded – undo
724 724
                     $this
725 725
                 );
726 726
                 echo '</th>';
727
-            } elseif (method_exists($this, 'column_' . $column_name)) {
727
+            } elseif (method_exists($this, 'column_'.$column_name)) {
728 728
                 echo "<td $attributes>";
729 729
                 echo apply_filters(
730
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
731
-                    call_user_func(array($this, 'column_' . $column_name), $item),
730
+                    'FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content',
731
+                    call_user_func(array($this, 'column_'.$column_name), $item),
732 732
                     $item,
733 733
                     $this
734 734
                 );
@@ -844,9 +844,9 @@  discard block
 block discarded – undo
844 844
         $action_id = ''
845 845
     ) {
846 846
         $content = '';
847
-        $action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
848
-        $action_id = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
849
-        $content .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
847
+        $action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : '';
848
+        $action_id = ! empty($action_id) ? ' id="'.$action_id.'"' : '';
849
+        $content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : '';
850 850
         try {
851 851
             $content .= apply_filters(
852 852
                 'FHEE__EE_Admin_List_Table___action_string__action_items',
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
             }
861 861
             $content .= $action_items;
862 862
         }
863
-        $content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
863
+        $content .= ! empty($action_container) ? '</'.$action_container.'>' : '';
864 864
         return $content;
865 865
     }
866 866
 }
Please login to merge, or discard this patch.