Completed
Branch FET-10785-ee-system-loader (19068c)
by
unknown
129:11 queued 116:44
created
core/libraries/messages/messenger/EE_Pdf_messenger.class.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Event Espresso
7 7
  * @subpackage messages
8 8
  */
9
-if (!defined('EVENT_ESPRESSO_VERSION') )
9
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
10 10
 	exit('NO direct script access allowed');
11 11
 
12 12
 /**
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @subpackage		messages
21 21
  * @author			Darren Ethier
22 22
  */
23
-class EE_Pdf_messenger extends EE_messenger  {
23
+class EE_Pdf_messenger extends EE_messenger {
24 24
 
25 25
 
26 26
 	/**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @see abstract declaration in EE_messenger for details.
94 94
 	 */
95 95
 	protected function _set_admin_pages() {
96
-		$this->admin_registered_pages = array( 'events_edit' => false );
96
+		$this->admin_registered_pages = array('events_edit' => false);
97 97
 	}
98 98
 
99 99
 
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
 	protected function _set_validator_config() {
114 114
 		$this->_validator_config = array(
115 115
 			'subject' => array(
116
-				'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email','event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
116
+				'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
117 117
 				),
118 118
 			'content' => array(
119
-				'shortcodes' => array( 'recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email','event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
119
+				'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
120 120
 				),
121 121
 			'attendee_list' => array(
122 122
 				'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 				'required' => array('[EVENT_LIST]')
128 128
 				),
129 129
 			'ticket_list' => array(
130
-				'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list','primary_registration_details', 'recipient_details'),
130
+				'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'),
131 131
 				'required' => array('[TICKET_LIST]')
132 132
 				),
133 133
 			'datetime_list' => array(
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public  function enqueue_scripts_styles() {
149 149
 		parent::enqueue_scripts_styles();
150
-		do_action( 'AHEE__EE_Pdf_messenger__enqueue_scripts_styles');
150
+		do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles');
151 151
 	}
152 152
 
153 153
 
@@ -273,18 +273,18 @@  discard block
 block discarded – undo
273 273
 	 */
274 274
 	protected function _send_message() {
275 275
 		$this->_template_args = array(
276
-			'page_title' => html_entity_decode( stripslashes( $this->_subject ), ENT_QUOTES, "UTF-8"),
277
-			'base_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'base', $this->_variation ),
278
-			'print_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'print', $this->_variation ),
279
-			'main_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'main', $this->_variation ),
280
-			'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css',
281
-			'main_body' => apply_filters( 'FHEE__EE_Pdf_messenger___send_message__main_body', wpautop(stripslashes_deep( html_entity_decode($this->_content,  ENT_QUOTES,"UTF-8" ) )), $this->_content )
276
+			'page_title' => html_entity_decode(stripslashes($this->_subject), ENT_QUOTES, "UTF-8"),
277
+			'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'base', $this->_variation),
278
+			'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'print', $this->_variation),
279
+			'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'main', $this->_variation),
280
+			'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css',
281
+			'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop(stripslashes_deep(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))), $this->_content)
282 282
 			);
283 283
 		$this->_deregister_wp_hooks();
284
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) );
284
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
285 285
 		$content = $this->_get_main_template();
286 286
 //		die( $content );
287
-		$this->_do_pdf( $content );
287
+		$this->_do_pdf($content);
288 288
 		exit(0);
289 289
 	}
290 290
 
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 
309 309
 		//just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
310 310
 		add_action('wp_head', 'wp_enqueue_scripts');
311
-		add_action( 'wp_footer', 'wp_print_footer_scripts' );
312
-		add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' );
311
+		add_action('wp_footer', 'wp_print_footer_scripts');
312
+		add_action('wp_print_footer_scripts', '_wp_footer_scripts');
313 313
 	}
314 314
 
315 315
 
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
 	 * @param bool $preview
323 323
 	 * @return string
324 324
 	 */
325
-	protected function _get_main_template( $preview = FALSE ) {
326
-		$wrapper_template = $this->_tmp_pack->get_wrapper( 'html', 'main' );
325
+	protected function _get_main_template($preview = FALSE) {
326
+		$wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main');
327 327
 		//add message type to template_args
328 328
 		$this->_template_args['message_type'] = $this->_incoming_message_type;
329
-		return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE );
329
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE);
330 330
 	}
331 331
 
332 332
 
@@ -339,15 +339,15 @@  discard block
 block discarded – undo
339 339
 	 *
340 340
 	 * @return void
341 341
 	 */
342
-	protected function _do_pdf( $content = '' ) {
343
-		$invoice_name = html_entity_decode( $this->_subject, ENT_QUOTES, "UTF-8");
342
+	protected function _do_pdf($content = '') {
343
+		$invoice_name = html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8");
344 344
 
345 345
 		//only load dompdf if nobody else has yet...
346
-		if( ! defined('DOMPDF_DIR')){
346
+		if ( ! defined('DOMPDF_DIR')) {
347 347
 			define('DOMPDF_ENABLE_REMOTE', TRUE);
348 348
 			define('DOMPDF_ENABLE_JAVASCRIPT', FALSE);
349 349
 			define('DOMPDF_ENABLE_CSS_FLOAT', TRUE);
350
-			require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php');
350
+			require_once(EE_THIRD_PARTY.'dompdf/dompdf_config.inc.php');
351 351
 		}
352 352
 		$dompdf = new DOMPDF();
353 353
 		if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) {
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 		$dompdf->load_html($content);
357 357
 		$dompdf->render();
358 358
 		//forcing the browser to open a download dialog.
359
-		$dompdf->stream($invoice_name . ".pdf", array( 'Attachment' => TRUE ));
359
+		$dompdf->stream($invoice_name.".pdf", array('Attachment' => TRUE));
360 360
 	}
361 361
 
362 362
 
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_Payment_Method_Manager.lib.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     /**
21 21
      * prefix added to all payment method capabilities names
22 22
      */
23
-    const   CAPABILITIES_PREFIX= 'ee_payment_method_';
23
+    const   CAPABILITIES_PREFIX = 'ee_payment_method_';
24 24
 
25 25
     /**
26 26
      * @var EE_Payment_Method_Manager $_instance
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     public static function instance()
77 77
     {
78 78
         // check if class object is instantiated, and instantiated properly
79
-        if (! self::$_instance instanceof EE_Payment_Method_Manager) {
79
+        if ( ! self::$_instance instanceof EE_Payment_Method_Manager) {
80 80
             EE_Registry::instance()->load_lib('PMT_Base');
81 81
             self::$_instance = new self();
82 82
         }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function maybe_register_payment_methods($force_recheck = false)
111 111
     {
112
-        if (! $this->_payment_method_types || $force_recheck) {
112
+        if ( ! $this->_payment_method_types || $force_recheck) {
113 113
             $this->_register_payment_methods();
114 114
         }
115 115
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     protected function _register_payment_methods()
125 125
     {
126 126
         // grab list of installed modules
127
-        $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
127
+        $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR);
128 128
         // filter list of modules to register
129 129
         $pm_to_register = apply_filters(
130 130
             'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
@@ -165,31 +165,31 @@  discard block
 block discarded – undo
165 165
         // create class name from module directory name
166 166
         $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir);
167 167
         // add class prefix
168
-        $module_class = 'EE_PMT_' . $module;
168
+        $module_class = 'EE_PMT_'.$module;
169 169
         // does the module exist ?
170
-        if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
170
+        if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) {
171 171
             $msg = sprintf(
172 172
                 esc_html__(
173 173
                     'The requested %s payment method file could not be found or is not readable due to file permissions.',
174 174
                     'event_espresso'
175 175
                 ), $module
176 176
             );
177
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
177
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
178 178
             return false;
179 179
         }
180 180
         // load the module class file
181
-        require_once($payment_method_path . DS . $module_class . $module_ext);
181
+        require_once($payment_method_path.DS.$module_class.$module_ext);
182 182
         // verify that class exists
183
-        if (! class_exists($module_class)) {
183
+        if ( ! class_exists($module_class)) {
184 184
             $msg = sprintf(
185 185
                 esc_html__('The requested %s module class does not exist.', 'event_espresso'),
186 186
                 $module_class
187 187
             );
188
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
188
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
189 189
             return false;
190 190
         }
191 191
         // add to array of registered modules
192
-        $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
192
+        $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext;
193 193
         return true;
194 194
     }
195 195
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         if ($force_recheck || empty($this->payment_method_objects)) {
257 257
             $this->maybe_register_payment_methods($force_recheck);
258 258
             foreach ($this->payment_method_type_names(true) as $classname) {
259
-                if (! isset($this->payment_method_objects[$classname])) {
259
+                if ( ! isset($this->payment_method_objects[$classname])) {
260 260
                     $this->payment_method_objects[$classname] = new $classname;
261 261
                 }
262 262
             }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
      */
289 289
     public function payment_method_class_from_type($type)
290 290
     {
291
-        return 'EE_PMT_' . $type;
291
+        return 'EE_PMT_'.$type;
292 292
     }
293 293
 
294 294
 
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
     {
305 305
         $this->maybe_register_payment_methods();
306 306
         $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
307
-        if (! $payment_method instanceof EE_Payment_Method) {
307
+        if ( ! $payment_method instanceof EE_Payment_Method) {
308 308
             $pm_type_class = $this->payment_method_class_from_type($payment_method_type);
309 309
             if (class_exists($pm_type_class)) {
310 310
                 /** @var $pm_type_obj EE_PMT_Base */
311 311
                 $pm_type_obj = new $pm_type_class;
312 312
                 $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
313
-                if (! $payment_method) {
313
+                if ( ! $payment_method) {
314 314
                     $payment_method = $this->create_payment_method_of_type($pm_type_obj);
315 315
                 }
316 316
                 $payment_method->set_type($payment_method_type);
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
                         'The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
342 342
                         'event_espresso'
343 343
                     ),
344
-                    '<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
344
+                    '<a href="'.admin_url('admin.php?page=espresso_messages').'">',
345 345
                     '</a>'
346 346
                 ),
347 347
                 true
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                 'PMD_type'       => $pm_type_obj->system_name(),
369 369
                 'PMD_name'       => $pm_type_obj->pretty_name(),
370 370
                 'PMD_admin_name' => $pm_type_obj->pretty_name(),
371
-                'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
371
+                'PMD_slug'       => $pm_type_obj->system_name(), //automatically converted to slug
372 372
                 'PMD_wp_user'    => $current_user->ID,
373 373
                 'PMD_order'      => EEM_Payment_Method::instance()->count(
374 374
                         array(array('PMD_type' => array('!=', 'Admin_Only')))
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
     {
392 392
         $pm_type_obj = $payment_method->type_obj();
393 393
         $payment_method->set_description($pm_type_obj->default_description());
394
-        if (! $payment_method->button_url()) {
394
+        if ( ! $payment_method->button_url()) {
395 395
             $payment_method->set_button_url($pm_type_obj->default_button_url());
396 396
         }
397 397
         //now add setup its default extra meta properties
398 398
         $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
399
-        if (! empty($extra_metas)) {
399
+        if ( ! empty($extra_metas)) {
400 400
             //verify the payment method has an ID before adding extra meta
401
-            if (! $payment_method->ID()) {
401
+            if ( ! $payment_method->ID()) {
402 402
                 $payment_method->save();
403 403
             }
404 404
             foreach ($extra_metas as $meta_name => $input) {
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
     {
507 507
         $caps = array();
508 508
         foreach ($this->payment_method_type_names() as $payment_method_name) {
509
-            $caps = $this->addPaymentMethodCap($payment_method_name,$caps);
509
+            $caps = $this->addPaymentMethodCap($payment_method_name, $caps);
510 510
         }
511 511
         return $caps;
512 512
     }
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
                 )
542 542
             );
543 543
         }
544
-        if(! isset($payment_method_caps[$role])) {
544
+        if ( ! isset($payment_method_caps[$role])) {
545 545
             $payment_method_caps[$role] = array();
546 546
         }
547 547
         $payment_method_caps[$role][] = EE_Payment_Method_Manager::CAPABILITIES_PREFIX
Please login to merge, or discard this patch.
Indentation   +564 added lines, -564 removed lines patch added patch discarded remove patch
@@ -19,570 +19,570 @@
 block discarded – undo
19 19
 class EE_Payment_Method_Manager implements ResettableInterface
20 20
 {
21 21
 
22
-    /**
23
-     * prefix added to all payment method capabilities names
24
-     */
25
-    const   CAPABILITIES_PREFIX= 'ee_payment_method_';
26
-
27
-    /**
28
-     * @var EE_Payment_Method_Manager $_instance
29
-     */
30
-    private static $_instance;
31
-
32
-    /**
33
-     * @var boolean
34
-     */
35
-    protected $payment_method_caps_initialized = false;
36
-
37
-    /**
38
-     * @var array keys are class names without 'EE_PMT_', values are their filepaths
39
-     */
40
-    protected $_payment_method_types = array();
41
-
42
-    /**
43
-     * @var EE_PMT_Base[]
44
-     */
45
-    protected $payment_method_objects = array();
46
-
47
-
48
-
49
-    /**
50
-     * EE_Payment_Method_Manager constructor.
51
-     *
52
-     * @throws EE_Error
53
-     * @throws DomainException
54
-     */
55
-    public function __construct()
56
-    {
57
-        // if in admin lets ensure caps are set.
58
-        if (is_admin()) {
59
-            $this->_register_payment_methods();
60
-            // set them immediately
61
-            $this->initializePaymentMethodCaps();
62
-            // plus any time they get reset
63
-            add_filter(
64
-                'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
65
-                array($this, 'addPaymentMethodCapsDuringReset')
66
-            );
67
-        }
68
-    }
69
-
70
-
71
-
72
-    /**
73
-     * @singleton method used to instantiate class object
74
-     * @return EE_Payment_Method_Manager instance
75
-     * @throws DomainException
76
-     * @throws EE_Error
77
-     */
78
-    public static function instance()
79
-    {
80
-        // check if class object is instantiated, and instantiated properly
81
-        if (! self::$_instance instanceof EE_Payment_Method_Manager) {
82
-            EE_Registry::instance()->load_lib('PMT_Base');
83
-            self::$_instance = new self();
84
-        }
85
-        return self::$_instance;
86
-    }
87
-
88
-
89
-
90
-    /**
91
-     * Resets the instance and returns a new one
92
-     *
93
-     * @return EE_Payment_Method_Manager
94
-     * @throws DomainException
95
-     * @throws EE_Error
96
-     */
97
-    public static function reset()
98
-    {
99
-        self::$_instance = null;
100
-        return self::instance();
101
-    }
102
-
103
-
104
-
105
-    /**
106
-     * If necessary, re-register payment methods
107
-     *
108
-     * @param boolean $force_recheck whether to recheck for payment method types,
109
-     *                               or just re-use the PMTs we found last time we checked during this request (if
110
-     *                               we have not yet checked during this request, then we need to check anyways)
111
-     */
112
-    public function maybe_register_payment_methods($force_recheck = false)
113
-    {
114
-        if (! $this->_payment_method_types || $force_recheck) {
115
-            $this->_register_payment_methods();
116
-        }
117
-    }
118
-
119
-
120
-
121
-    /**
122
-     * register_payment_methods
123
-     *
124
-     * @return array
125
-     */
126
-    protected function _register_payment_methods()
127
-    {
128
-        // grab list of installed modules
129
-        $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
130
-        // filter list of modules to register
131
-        $pm_to_register = apply_filters(
132
-            'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
133
-            $pm_to_register
134
-        );
135
-        // remove any duplicates if that should happen for some reason
136
-        $pm_to_register = array_unique($pm_to_register);
137
-        // loop through folders
138
-        foreach ($pm_to_register as $pm_path) {
139
-            $this->register_payment_method($pm_path);
140
-        }
141
-        do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
142
-        // filter list of installed modules
143
-        //keep them organized alphabetically by the payment method type's name
144
-        ksort($this->_payment_method_types);
145
-        return apply_filters(
146
-            'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
147
-            $this->_payment_method_types
148
-        );
149
-    }
150
-
151
-
152
-
153
-    /**
154
-     * register_payment_method- makes core aware of this payment method
155
-     *
156
-     * @param string $payment_method_path - full path up to and including payment method folder
157
-     * @return boolean
158
-     */
159
-    public function register_payment_method($payment_method_path = '')
160
-    {
161
-        do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
162
-        $module_ext = '.pm.php';
163
-        // make all separators match
164
-        $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
165
-        // grab and sanitize module name
166
-        $module_dir = basename($payment_method_path);
167
-        // create class name from module directory name
168
-        $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir);
169
-        // add class prefix
170
-        $module_class = 'EE_PMT_' . $module;
171
-        // does the module exist ?
172
-        if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
173
-            $msg = sprintf(
174
-                esc_html__(
175
-                    'The requested %s payment method file could not be found or is not readable due to file permissions.',
176
-                    'event_espresso'
177
-                ), $module
178
-            );
179
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
180
-            return false;
181
-        }
182
-        // load the module class file
183
-        require_once($payment_method_path . DS . $module_class . $module_ext);
184
-        // verify that class exists
185
-        if (! class_exists($module_class)) {
186
-            $msg = sprintf(
187
-                esc_html__('The requested %s module class does not exist.', 'event_espresso'),
188
-                $module_class
189
-            );
190
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
191
-            return false;
192
-        }
193
-        // add to array of registered modules
194
-        $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
195
-        return true;
196
-    }
197
-
198
-
199
-
200
-    /**
201
-     * Checks if a payment method has been registered, and if so includes it
202
-     *
203
-     * @param string  $payment_method_name like 'PayPal_Pro', (ie class name without the prefix 'EEPM_')
204
-     * @param boolean $force_recheck       whether to force re-checking for new payment method types
205
-     * @return boolean
206
-     */
207
-    public function payment_method_type_exists($payment_method_name, $force_recheck = false)
208
-    {
209
-        if (
210
-            $force_recheck
211
-            || ! is_array($this->_payment_method_types)
212
-            || ! isset($this->_payment_method_types[$payment_method_name])
213
-        ) {
214
-            $this->maybe_register_payment_methods($force_recheck);
215
-        }
216
-        if (isset($this->_payment_method_types[$payment_method_name])) {
217
-            require_once($this->_payment_method_types[$payment_method_name]);
218
-            return true;
219
-        }
220
-        return false;
221
-    }
222
-
223
-
224
-
225
-    /**
226
-     * Returns all the class names of the various payment method types
227
-     *
228
-     * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names'
229
-     *                               (what you'd find in wp_esp_payment_method.PMD_type)
230
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
231
-     * @return array
232
-     */
233
-    public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
234
-    {
235
-        $this->maybe_register_payment_methods($force_recheck);
236
-        if ($with_prefixes) {
237
-            $classnames = array_keys($this->_payment_method_types);
238
-            $payment_methods = array();
239
-            foreach ($classnames as $classname) {
240
-                $payment_methods[] = $this->payment_method_class_from_type($classname);
241
-            }
242
-            return $payment_methods;
243
-        }
244
-        return array_keys($this->_payment_method_types);
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     * Gets an object of each payment method type, none of which are bound to a
251
-     * payment method instance
252
-     *
253
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
254
-     * @return EE_PMT_Base[]
255
-     */
256
-    public function payment_method_types($force_recheck = false)
257
-    {
258
-        if ($force_recheck || empty($this->payment_method_objects)) {
259
-            $this->maybe_register_payment_methods($force_recheck);
260
-            foreach ($this->payment_method_type_names(true) as $classname) {
261
-                if (! isset($this->payment_method_objects[$classname])) {
262
-                    $this->payment_method_objects[$classname] = new $classname;
263
-                }
264
-            }
265
-        }
266
-        return $this->payment_method_objects;
267
-    }
268
-
269
-
270
-
271
-    /**
272
-     * Changes the payment method's class name into the payment method type's name
273
-     * (as used on the payment method's table's PMD_type field)
274
-     *
275
-     * @param string $classname
276
-     * @return string
277
-     */
278
-    public function payment_method_type_sans_class_prefix($classname)
279
-    {
280
-        return str_replace('EE_PMT_', '', $classname);
281
-    }
282
-
283
-
284
-
285
-    /**
286
-     * Does the opposite of payment-method_type_sans_prefix
287
-     *
288
-     * @param string $type
289
-     * @return string
290
-     */
291
-    public function payment_method_class_from_type($type)
292
-    {
293
-        return 'EE_PMT_' . $type;
294
-    }
295
-
296
-
297
-
298
-    /**
299
-     * Activates a payment method of the given type.
300
-     *
301
-     * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
302
-     * @return EE_Payment_Method
303
-     * @throws EE_Error
304
-     */
305
-    public function activate_a_payment_method_of_type($payment_method_type)
306
-    {
307
-        $this->maybe_register_payment_methods();
308
-        $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
309
-        if (! $payment_method instanceof EE_Payment_Method) {
310
-            $pm_type_class = $this->payment_method_class_from_type($payment_method_type);
311
-            if (class_exists($pm_type_class)) {
312
-                /** @var $pm_type_obj EE_PMT_Base */
313
-                $pm_type_obj = new $pm_type_class;
314
-                $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
315
-                if (! $payment_method) {
316
-                    $payment_method = $this->create_payment_method_of_type($pm_type_obj);
317
-                }
318
-                $payment_method->set_type($payment_method_type);
319
-                $this->initialize_payment_method($payment_method);
320
-            } else {
321
-                throw new EE_Error(
322
-                    sprintf(
323
-                        esc_html__(
324
-                            'There is no payment method of type %1$s, so it could not be activated',
325
-                            'event_espresso'
326
-                        ),
327
-                        $pm_type_class
328
-                    )
329
-                );
330
-            }
331
-        }
332
-        $payment_method->set_active();
333
-        $payment_method->save();
334
-        if ($payment_method->type() === 'Invoice') {
335
-            /** @type EE_Message_Resource_Manager $message_resource_manager */
336
-            $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
337
-            $message_resource_manager->ensure_message_type_is_active('invoice', 'html');
338
-            $message_resource_manager->ensure_messenger_is_active('pdf');
339
-            EE_Error::add_persistent_admin_notice(
340
-                'invoice_pm_requirements_notice',
341
-                sprintf(
342
-                    esc_html__(
343
-                        'The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
344
-                        'event_espresso'
345
-                    ),
346
-                    '<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
347
-                    '</a>'
348
-                ),
349
-                true
350
-            );
351
-        }
352
-        return $payment_method;
353
-    }
354
-
355
-
356
-
357
-    /**
358
-     * Creates a payment method of the specified type. Does not save it.
359
-     *
360
-     * @global WP_User    $current_user
361
-     * @param EE_PMT_Base $pm_type_obj
362
-     * @return EE_Payment_Method
363
-     * @throws EE_Error
364
-     */
365
-    public function create_payment_method_of_type($pm_type_obj)
366
-    {
367
-        global $current_user;
368
-        $payment_method = EE_Payment_Method::new_instance(
369
-            array(
370
-                'PMD_type'       => $pm_type_obj->system_name(),
371
-                'PMD_name'       => $pm_type_obj->pretty_name(),
372
-                'PMD_admin_name' => $pm_type_obj->pretty_name(),
373
-                'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
374
-                'PMD_wp_user'    => $current_user->ID,
375
-                'PMD_order'      => EEM_Payment_Method::instance()->count(
376
-                        array(array('PMD_type' => array('!=', 'Admin_Only')))
377
-                    ) * 10,
378
-            )
379
-        );
380
-        return $payment_method;
381
-    }
382
-
383
-
384
-
385
-    /**
386
-     * Sets the initial payment method properties (including extra meta)
387
-     *
388
-     * @param EE_Payment_Method $payment_method
389
-     * @return EE_Payment_Method
390
-     * @throws EE_Error
391
-     */
392
-    public function initialize_payment_method($payment_method)
393
-    {
394
-        $pm_type_obj = $payment_method->type_obj();
395
-        $payment_method->set_description($pm_type_obj->default_description());
396
-        if (! $payment_method->button_url()) {
397
-            $payment_method->set_button_url($pm_type_obj->default_button_url());
398
-        }
399
-        //now add setup its default extra meta properties
400
-        $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
401
-        if (! empty($extra_metas)) {
402
-            //verify the payment method has an ID before adding extra meta
403
-            if (! $payment_method->ID()) {
404
-                $payment_method->save();
405
-            }
406
-            foreach ($extra_metas as $meta_name => $input) {
407
-                $payment_method->update_extra_meta($meta_name, $input->raw_value());
408
-            }
409
-        }
410
-        return $payment_method;
411
-    }
412
-
413
-
414
-
415
-    /**
416
-     * Makes sure the payment method is related to the specified payment method
417
-     *
418
-     * @deprecated in 4.9.40 because the currency payment method table is being deprecated
419
-     * @param EE_Payment_Method $payment_method
420
-     * @return EE_Payment_Method
421
-     * @throws EE_Error
422
-     */
423
-    public function set_usable_currencies_on_payment_method($payment_method)
424
-    {
425
-        EE_Error::doing_it_wrong(
426
-            'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method',
427
-            esc_html__(
428
-                'We no longer define what currencies are usable by payment methods. Its not used nor efficient.',
429
-                'event_espresso'
430
-            ),
431
-            '4.9.40'
432
-        );
433
-        return $payment_method;
434
-    }
435
-
436
-
437
-
438
-    /**
439
-     * Deactivates a payment method of the given payment method slug.
440
-     *
441
-     * @param string $payment_method_slug The slug for the payment method to deactivate.
442
-     * @return int count of rows updated.
443
-     * @throws EE_Error
444
-     */
445
-    public function deactivate_payment_method($payment_method_slug)
446
-    {
447
-        EE_Log::instance()->log(
448
-            __FILE__,
449
-            __FUNCTION__,
450
-            sprintf(
451
-                esc_html__(
452
-                    'Payment method with slug %1$s is being deactivated by site admin',
453
-                    'event_espresso'
454
-                ),
455
-                $payment_method_slug
456
-            ),
457
-            'payment_method_change'
458
-        );
459
-        $count_updated = EEM_Payment_Method::instance()->update(
460
-            array('PMD_scope' => array()),
461
-            array(array('PMD_slug' => $payment_method_slug))
462
-        );
463
-        return $count_updated;
464
-    }
465
-
466
-
467
-
468
-    /**
469
-     * initializes payment method access caps via EE_Capabilities::init_role_caps()
470
-     * upon EE_Payment_Method_Manager construction
471
-     *
472
-     * @throws EE_Error
473
-     * @throws DomainException
474
-     */
475
-    protected function initializePaymentMethodCaps()
476
-    {
477
-        // don't do this twice
478
-        if ($this->payment_method_caps_initialized) {
479
-            return;
480
-        }
481
-        EE_Capabilities::instance()->addCaps(
482
-            $this->getPaymentMethodCaps()
483
-        );
484
-        $this->payment_method_caps_initialized = true;
485
-    }
486
-
487
-
488
-
489
-    /**
490
-     * array  of dynamic payment method access caps.
491
-     * at the time of writing, october 20 2014, these are the caps added:
492
-     *  ee_payment_method_admin_only
493
-     *  ee_payment_method_aim
494
-     *  ee_payment_method_bank
495
-     *  ee_payment_method_check
496
-     *  ee_payment_method_invoice
497
-     *  ee_payment_method_mijireh
498
-     *  ee_payment_method_paypal_pro
499
-     *  ee_payment_method_paypal_standard
500
-     * Any other payment methods added to core or via addons will also get
501
-     * their related capability automatically added too, so long as they are
502
-     * registered properly using EE_Register_Payment_Method::register()
503
-     *
504
-     * @return array
505
-     * @throws DomainException
506
-     */
507
-    protected function getPaymentMethodCaps()
508
-    {
509
-        $caps = array();
510
-        foreach ($this->payment_method_type_names() as $payment_method_name) {
511
-            $caps = $this->addPaymentMethodCap($payment_method_name,$caps);
512
-        }
513
-        return $caps;
514
-    }
515
-
516
-
517
-
518
-    /**
519
-     * @param string $payment_method_name
520
-     * @param array  $payment_method_caps
521
-     * @param string $role
522
-     * @return array
523
-     * @throws DomainException
524
-     */
525
-    public function addPaymentMethodCap($payment_method_name, array $payment_method_caps, $role = 'administrator')
526
-    {
527
-        if (empty($payment_method_name)) {
528
-            throw new DomainException(
529
-                esc_html__(
530
-                    'The name of a payment method must be specified to add capabilities.',
531
-                    'event_espresso'
532
-                )
533
-            );
534
-        }
535
-        if (empty($role)) {
536
-            throw new DomainException(
537
-                sprintf(
538
-                    esc_html__(
539
-                        'No role was supplied while trying to add capabilities for the %1$s payment method.',
540
-                        'event_espresso'
541
-                    ),
542
-                    $payment_method_name
543
-                )
544
-            );
545
-        }
546
-        if(! isset($payment_method_caps[$role])) {
547
-            $payment_method_caps[$role] = array();
548
-        }
549
-        $payment_method_caps[$role][] = EE_Payment_Method_Manager::CAPABILITIES_PREFIX
550
-                                                  . strtolower($payment_method_name);
551
-        return $payment_method_caps;
552
-    }
553
-
554
-
555
-
556
-    /**
557
-     * callback for FHEE__EE_Capabilities__init_role_caps__caps_map filter
558
-     * to add dynamic payment method access caps when capabilities are reset
559
-     * (or if that filter is called and PM caps are not already set)
560
-     *
561
-     * @param array $caps capabilities being filtered
562
-     * @param bool  $reset
563
-     * @return array
564
-     * @throws DomainException
565
-     */
566
-    public function addPaymentMethodCapsDuringReset(array $caps, $reset = false)
567
-    {
568
-        if ($reset || ! $this->payment_method_caps_initialized) {
569
-            $this->payment_method_caps_initialized = true;
570
-            $caps = array_merge_recursive($caps, $this->getPaymentMethodCaps());
571
-        }
572
-        return $caps;
573
-    }
574
-
575
-
576
-
577
-    /**
578
-     * @deprecated 4.9.42
579
-     * @param $caps
580
-     * @return mixed
581
-     */
582
-    public function add_payment_method_caps($caps)
583
-    {
584
-        return $caps;
585
-    }
22
+	/**
23
+	 * prefix added to all payment method capabilities names
24
+	 */
25
+	const   CAPABILITIES_PREFIX= 'ee_payment_method_';
26
+
27
+	/**
28
+	 * @var EE_Payment_Method_Manager $_instance
29
+	 */
30
+	private static $_instance;
31
+
32
+	/**
33
+	 * @var boolean
34
+	 */
35
+	protected $payment_method_caps_initialized = false;
36
+
37
+	/**
38
+	 * @var array keys are class names without 'EE_PMT_', values are their filepaths
39
+	 */
40
+	protected $_payment_method_types = array();
41
+
42
+	/**
43
+	 * @var EE_PMT_Base[]
44
+	 */
45
+	protected $payment_method_objects = array();
46
+
47
+
48
+
49
+	/**
50
+	 * EE_Payment_Method_Manager constructor.
51
+	 *
52
+	 * @throws EE_Error
53
+	 * @throws DomainException
54
+	 */
55
+	public function __construct()
56
+	{
57
+		// if in admin lets ensure caps are set.
58
+		if (is_admin()) {
59
+			$this->_register_payment_methods();
60
+			// set them immediately
61
+			$this->initializePaymentMethodCaps();
62
+			// plus any time they get reset
63
+			add_filter(
64
+				'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
65
+				array($this, 'addPaymentMethodCapsDuringReset')
66
+			);
67
+		}
68
+	}
69
+
70
+
71
+
72
+	/**
73
+	 * @singleton method used to instantiate class object
74
+	 * @return EE_Payment_Method_Manager instance
75
+	 * @throws DomainException
76
+	 * @throws EE_Error
77
+	 */
78
+	public static function instance()
79
+	{
80
+		// check if class object is instantiated, and instantiated properly
81
+		if (! self::$_instance instanceof EE_Payment_Method_Manager) {
82
+			EE_Registry::instance()->load_lib('PMT_Base');
83
+			self::$_instance = new self();
84
+		}
85
+		return self::$_instance;
86
+	}
87
+
88
+
89
+
90
+	/**
91
+	 * Resets the instance and returns a new one
92
+	 *
93
+	 * @return EE_Payment_Method_Manager
94
+	 * @throws DomainException
95
+	 * @throws EE_Error
96
+	 */
97
+	public static function reset()
98
+	{
99
+		self::$_instance = null;
100
+		return self::instance();
101
+	}
102
+
103
+
104
+
105
+	/**
106
+	 * If necessary, re-register payment methods
107
+	 *
108
+	 * @param boolean $force_recheck whether to recheck for payment method types,
109
+	 *                               or just re-use the PMTs we found last time we checked during this request (if
110
+	 *                               we have not yet checked during this request, then we need to check anyways)
111
+	 */
112
+	public function maybe_register_payment_methods($force_recheck = false)
113
+	{
114
+		if (! $this->_payment_method_types || $force_recheck) {
115
+			$this->_register_payment_methods();
116
+		}
117
+	}
118
+
119
+
120
+
121
+	/**
122
+	 * register_payment_methods
123
+	 *
124
+	 * @return array
125
+	 */
126
+	protected function _register_payment_methods()
127
+	{
128
+		// grab list of installed modules
129
+		$pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
130
+		// filter list of modules to register
131
+		$pm_to_register = apply_filters(
132
+			'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
133
+			$pm_to_register
134
+		);
135
+		// remove any duplicates if that should happen for some reason
136
+		$pm_to_register = array_unique($pm_to_register);
137
+		// loop through folders
138
+		foreach ($pm_to_register as $pm_path) {
139
+			$this->register_payment_method($pm_path);
140
+		}
141
+		do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
142
+		// filter list of installed modules
143
+		//keep them organized alphabetically by the payment method type's name
144
+		ksort($this->_payment_method_types);
145
+		return apply_filters(
146
+			'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
147
+			$this->_payment_method_types
148
+		);
149
+	}
150
+
151
+
152
+
153
+	/**
154
+	 * register_payment_method- makes core aware of this payment method
155
+	 *
156
+	 * @param string $payment_method_path - full path up to and including payment method folder
157
+	 * @return boolean
158
+	 */
159
+	public function register_payment_method($payment_method_path = '')
160
+	{
161
+		do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
162
+		$module_ext = '.pm.php';
163
+		// make all separators match
164
+		$payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
165
+		// grab and sanitize module name
166
+		$module_dir = basename($payment_method_path);
167
+		// create class name from module directory name
168
+		$module = str_replace(array('_', ' '), array(' ', '_'), $module_dir);
169
+		// add class prefix
170
+		$module_class = 'EE_PMT_' . $module;
171
+		// does the module exist ?
172
+		if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
173
+			$msg = sprintf(
174
+				esc_html__(
175
+					'The requested %s payment method file could not be found or is not readable due to file permissions.',
176
+					'event_espresso'
177
+				), $module
178
+			);
179
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
180
+			return false;
181
+		}
182
+		// load the module class file
183
+		require_once($payment_method_path . DS . $module_class . $module_ext);
184
+		// verify that class exists
185
+		if (! class_exists($module_class)) {
186
+			$msg = sprintf(
187
+				esc_html__('The requested %s module class does not exist.', 'event_espresso'),
188
+				$module_class
189
+			);
190
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
191
+			return false;
192
+		}
193
+		// add to array of registered modules
194
+		$this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
195
+		return true;
196
+	}
197
+
198
+
199
+
200
+	/**
201
+	 * Checks if a payment method has been registered, and if so includes it
202
+	 *
203
+	 * @param string  $payment_method_name like 'PayPal_Pro', (ie class name without the prefix 'EEPM_')
204
+	 * @param boolean $force_recheck       whether to force re-checking for new payment method types
205
+	 * @return boolean
206
+	 */
207
+	public function payment_method_type_exists($payment_method_name, $force_recheck = false)
208
+	{
209
+		if (
210
+			$force_recheck
211
+			|| ! is_array($this->_payment_method_types)
212
+			|| ! isset($this->_payment_method_types[$payment_method_name])
213
+		) {
214
+			$this->maybe_register_payment_methods($force_recheck);
215
+		}
216
+		if (isset($this->_payment_method_types[$payment_method_name])) {
217
+			require_once($this->_payment_method_types[$payment_method_name]);
218
+			return true;
219
+		}
220
+		return false;
221
+	}
222
+
223
+
224
+
225
+	/**
226
+	 * Returns all the class names of the various payment method types
227
+	 *
228
+	 * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names'
229
+	 *                               (what you'd find in wp_esp_payment_method.PMD_type)
230
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
231
+	 * @return array
232
+	 */
233
+	public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
234
+	{
235
+		$this->maybe_register_payment_methods($force_recheck);
236
+		if ($with_prefixes) {
237
+			$classnames = array_keys($this->_payment_method_types);
238
+			$payment_methods = array();
239
+			foreach ($classnames as $classname) {
240
+				$payment_methods[] = $this->payment_method_class_from_type($classname);
241
+			}
242
+			return $payment_methods;
243
+		}
244
+		return array_keys($this->_payment_method_types);
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 * Gets an object of each payment method type, none of which are bound to a
251
+	 * payment method instance
252
+	 *
253
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
254
+	 * @return EE_PMT_Base[]
255
+	 */
256
+	public function payment_method_types($force_recheck = false)
257
+	{
258
+		if ($force_recheck || empty($this->payment_method_objects)) {
259
+			$this->maybe_register_payment_methods($force_recheck);
260
+			foreach ($this->payment_method_type_names(true) as $classname) {
261
+				if (! isset($this->payment_method_objects[$classname])) {
262
+					$this->payment_method_objects[$classname] = new $classname;
263
+				}
264
+			}
265
+		}
266
+		return $this->payment_method_objects;
267
+	}
268
+
269
+
270
+
271
+	/**
272
+	 * Changes the payment method's class name into the payment method type's name
273
+	 * (as used on the payment method's table's PMD_type field)
274
+	 *
275
+	 * @param string $classname
276
+	 * @return string
277
+	 */
278
+	public function payment_method_type_sans_class_prefix($classname)
279
+	{
280
+		return str_replace('EE_PMT_', '', $classname);
281
+	}
282
+
283
+
284
+
285
+	/**
286
+	 * Does the opposite of payment-method_type_sans_prefix
287
+	 *
288
+	 * @param string $type
289
+	 * @return string
290
+	 */
291
+	public function payment_method_class_from_type($type)
292
+	{
293
+		return 'EE_PMT_' . $type;
294
+	}
295
+
296
+
297
+
298
+	/**
299
+	 * Activates a payment method of the given type.
300
+	 *
301
+	 * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
302
+	 * @return EE_Payment_Method
303
+	 * @throws EE_Error
304
+	 */
305
+	public function activate_a_payment_method_of_type($payment_method_type)
306
+	{
307
+		$this->maybe_register_payment_methods();
308
+		$payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
309
+		if (! $payment_method instanceof EE_Payment_Method) {
310
+			$pm_type_class = $this->payment_method_class_from_type($payment_method_type);
311
+			if (class_exists($pm_type_class)) {
312
+				/** @var $pm_type_obj EE_PMT_Base */
313
+				$pm_type_obj = new $pm_type_class;
314
+				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
315
+				if (! $payment_method) {
316
+					$payment_method = $this->create_payment_method_of_type($pm_type_obj);
317
+				}
318
+				$payment_method->set_type($payment_method_type);
319
+				$this->initialize_payment_method($payment_method);
320
+			} else {
321
+				throw new EE_Error(
322
+					sprintf(
323
+						esc_html__(
324
+							'There is no payment method of type %1$s, so it could not be activated',
325
+							'event_espresso'
326
+						),
327
+						$pm_type_class
328
+					)
329
+				);
330
+			}
331
+		}
332
+		$payment_method->set_active();
333
+		$payment_method->save();
334
+		if ($payment_method->type() === 'Invoice') {
335
+			/** @type EE_Message_Resource_Manager $message_resource_manager */
336
+			$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
337
+			$message_resource_manager->ensure_message_type_is_active('invoice', 'html');
338
+			$message_resource_manager->ensure_messenger_is_active('pdf');
339
+			EE_Error::add_persistent_admin_notice(
340
+				'invoice_pm_requirements_notice',
341
+				sprintf(
342
+					esc_html__(
343
+						'The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
344
+						'event_espresso'
345
+					),
346
+					'<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
347
+					'</a>'
348
+				),
349
+				true
350
+			);
351
+		}
352
+		return $payment_method;
353
+	}
354
+
355
+
356
+
357
+	/**
358
+	 * Creates a payment method of the specified type. Does not save it.
359
+	 *
360
+	 * @global WP_User    $current_user
361
+	 * @param EE_PMT_Base $pm_type_obj
362
+	 * @return EE_Payment_Method
363
+	 * @throws EE_Error
364
+	 */
365
+	public function create_payment_method_of_type($pm_type_obj)
366
+	{
367
+		global $current_user;
368
+		$payment_method = EE_Payment_Method::new_instance(
369
+			array(
370
+				'PMD_type'       => $pm_type_obj->system_name(),
371
+				'PMD_name'       => $pm_type_obj->pretty_name(),
372
+				'PMD_admin_name' => $pm_type_obj->pretty_name(),
373
+				'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
374
+				'PMD_wp_user'    => $current_user->ID,
375
+				'PMD_order'      => EEM_Payment_Method::instance()->count(
376
+						array(array('PMD_type' => array('!=', 'Admin_Only')))
377
+					) * 10,
378
+			)
379
+		);
380
+		return $payment_method;
381
+	}
382
+
383
+
384
+
385
+	/**
386
+	 * Sets the initial payment method properties (including extra meta)
387
+	 *
388
+	 * @param EE_Payment_Method $payment_method
389
+	 * @return EE_Payment_Method
390
+	 * @throws EE_Error
391
+	 */
392
+	public function initialize_payment_method($payment_method)
393
+	{
394
+		$pm_type_obj = $payment_method->type_obj();
395
+		$payment_method->set_description($pm_type_obj->default_description());
396
+		if (! $payment_method->button_url()) {
397
+			$payment_method->set_button_url($pm_type_obj->default_button_url());
398
+		}
399
+		//now add setup its default extra meta properties
400
+		$extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
401
+		if (! empty($extra_metas)) {
402
+			//verify the payment method has an ID before adding extra meta
403
+			if (! $payment_method->ID()) {
404
+				$payment_method->save();
405
+			}
406
+			foreach ($extra_metas as $meta_name => $input) {
407
+				$payment_method->update_extra_meta($meta_name, $input->raw_value());
408
+			}
409
+		}
410
+		return $payment_method;
411
+	}
412
+
413
+
414
+
415
+	/**
416
+	 * Makes sure the payment method is related to the specified payment method
417
+	 *
418
+	 * @deprecated in 4.9.40 because the currency payment method table is being deprecated
419
+	 * @param EE_Payment_Method $payment_method
420
+	 * @return EE_Payment_Method
421
+	 * @throws EE_Error
422
+	 */
423
+	public function set_usable_currencies_on_payment_method($payment_method)
424
+	{
425
+		EE_Error::doing_it_wrong(
426
+			'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method',
427
+			esc_html__(
428
+				'We no longer define what currencies are usable by payment methods. Its not used nor efficient.',
429
+				'event_espresso'
430
+			),
431
+			'4.9.40'
432
+		);
433
+		return $payment_method;
434
+	}
435
+
436
+
437
+
438
+	/**
439
+	 * Deactivates a payment method of the given payment method slug.
440
+	 *
441
+	 * @param string $payment_method_slug The slug for the payment method to deactivate.
442
+	 * @return int count of rows updated.
443
+	 * @throws EE_Error
444
+	 */
445
+	public function deactivate_payment_method($payment_method_slug)
446
+	{
447
+		EE_Log::instance()->log(
448
+			__FILE__,
449
+			__FUNCTION__,
450
+			sprintf(
451
+				esc_html__(
452
+					'Payment method with slug %1$s is being deactivated by site admin',
453
+					'event_espresso'
454
+				),
455
+				$payment_method_slug
456
+			),
457
+			'payment_method_change'
458
+		);
459
+		$count_updated = EEM_Payment_Method::instance()->update(
460
+			array('PMD_scope' => array()),
461
+			array(array('PMD_slug' => $payment_method_slug))
462
+		);
463
+		return $count_updated;
464
+	}
465
+
466
+
467
+
468
+	/**
469
+	 * initializes payment method access caps via EE_Capabilities::init_role_caps()
470
+	 * upon EE_Payment_Method_Manager construction
471
+	 *
472
+	 * @throws EE_Error
473
+	 * @throws DomainException
474
+	 */
475
+	protected function initializePaymentMethodCaps()
476
+	{
477
+		// don't do this twice
478
+		if ($this->payment_method_caps_initialized) {
479
+			return;
480
+		}
481
+		EE_Capabilities::instance()->addCaps(
482
+			$this->getPaymentMethodCaps()
483
+		);
484
+		$this->payment_method_caps_initialized = true;
485
+	}
486
+
487
+
488
+
489
+	/**
490
+	 * array  of dynamic payment method access caps.
491
+	 * at the time of writing, october 20 2014, these are the caps added:
492
+	 *  ee_payment_method_admin_only
493
+	 *  ee_payment_method_aim
494
+	 *  ee_payment_method_bank
495
+	 *  ee_payment_method_check
496
+	 *  ee_payment_method_invoice
497
+	 *  ee_payment_method_mijireh
498
+	 *  ee_payment_method_paypal_pro
499
+	 *  ee_payment_method_paypal_standard
500
+	 * Any other payment methods added to core or via addons will also get
501
+	 * their related capability automatically added too, so long as they are
502
+	 * registered properly using EE_Register_Payment_Method::register()
503
+	 *
504
+	 * @return array
505
+	 * @throws DomainException
506
+	 */
507
+	protected function getPaymentMethodCaps()
508
+	{
509
+		$caps = array();
510
+		foreach ($this->payment_method_type_names() as $payment_method_name) {
511
+			$caps = $this->addPaymentMethodCap($payment_method_name,$caps);
512
+		}
513
+		return $caps;
514
+	}
515
+
516
+
517
+
518
+	/**
519
+	 * @param string $payment_method_name
520
+	 * @param array  $payment_method_caps
521
+	 * @param string $role
522
+	 * @return array
523
+	 * @throws DomainException
524
+	 */
525
+	public function addPaymentMethodCap($payment_method_name, array $payment_method_caps, $role = 'administrator')
526
+	{
527
+		if (empty($payment_method_name)) {
528
+			throw new DomainException(
529
+				esc_html__(
530
+					'The name of a payment method must be specified to add capabilities.',
531
+					'event_espresso'
532
+				)
533
+			);
534
+		}
535
+		if (empty($role)) {
536
+			throw new DomainException(
537
+				sprintf(
538
+					esc_html__(
539
+						'No role was supplied while trying to add capabilities for the %1$s payment method.',
540
+						'event_espresso'
541
+					),
542
+					$payment_method_name
543
+				)
544
+			);
545
+		}
546
+		if(! isset($payment_method_caps[$role])) {
547
+			$payment_method_caps[$role] = array();
548
+		}
549
+		$payment_method_caps[$role][] = EE_Payment_Method_Manager::CAPABILITIES_PREFIX
550
+												  . strtolower($payment_method_name);
551
+		return $payment_method_caps;
552
+	}
553
+
554
+
555
+
556
+	/**
557
+	 * callback for FHEE__EE_Capabilities__init_role_caps__caps_map filter
558
+	 * to add dynamic payment method access caps when capabilities are reset
559
+	 * (or if that filter is called and PM caps are not already set)
560
+	 *
561
+	 * @param array $caps capabilities being filtered
562
+	 * @param bool  $reset
563
+	 * @return array
564
+	 * @throws DomainException
565
+	 */
566
+	public function addPaymentMethodCapsDuringReset(array $caps, $reset = false)
567
+	{
568
+		if ($reset || ! $this->payment_method_caps_initialized) {
569
+			$this->payment_method_caps_initialized = true;
570
+			$caps = array_merge_recursive($caps, $this->getPaymentMethodCaps());
571
+		}
572
+		return $caps;
573
+	}
574
+
575
+
576
+
577
+	/**
578
+	 * @deprecated 4.9.42
579
+	 * @param $caps
580
+	 * @return mixed
581
+	 */
582
+	public function add_payment_method_caps($caps)
583
+	{
584
+		return $caps;
585
+	}
586 586
 
587 587
 
588 588
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Payment_Method.lib.php 1 patch
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -18,149 +18,149 @@
 block discarded – undo
18 18
 class EE_Register_Payment_Method implements EEI_Plugin_API
19 19
 {
20 20
 
21
-    /**
22
-     * Holds values for registered payment methods
23
-     *
24
-     * @var array
25
-     */
26
-    protected static $_settings = array();
27
-
28
-
29
-
30
-    /**
31
-     * Method for registering new EE_PMT_Base children
32
-     *
33
-     * @since    4.5.0
34
-     * @param string  $payment_method_id    a unique identifier for this set of modules Required.
35
-     * @param  array  $setup_args           an array of arguments provided for registering modules Required.{
36
-     * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class
37
-     *                                      (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains
38
-     *                                      the files EE_PMT_Payomatic.pm.php)
39
-     *                                      }
40
-     * @throws EE_Error
41
-     * @type array payment_method_paths    an array of full server paths to folders containing any EE_PMT_Base
42
-     *                                      children, or to the EED_Module files themselves
43
-     * @return void
44
-     * @throws DomainException
45
-     */
46
-    public static function register($payment_method_id = null, $setup_args = array())
47
-    {
48
-        //required fields MUST be present, so let's make sure they are.
49
-        if (empty($payment_method_id) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) {
50
-            throw new EE_Error(
51
-                esc_html__(
52
-                    'In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)',
53
-                    'event_espresso'
54
-                )
55
-            );
56
-        }
57
-        //make sure we don't register twice
58
-        if (isset(self::$_settings[$payment_method_id])) {
59
-            return;
60
-        }
61
-        //make sure this was called in the right place!
62
-        if (
63
-            ! did_action('AHEE__EE_System__load_espresso_addons')
64
-            || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
65
-        ) {
66
-            EE_Error::doing_it_wrong(
67
-                __METHOD__,
68
-                esc_html__(
69
-                    'An attempt to register modules has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.',
70
-                    'event_espresso'
71
-                ),
72
-                '4.3.0'
73
-            );
74
-        }
75
-        //setup $_settings array from incoming values.
76
-        self::$_settings[$payment_method_id] = array(
77
-            // array of full server paths to any EE_PMT_Base children used
78
-            'payment_method_paths' => isset($setup_args['payment_method_paths'])
79
-                ? (array)$setup_args['payment_method_paths']
80
-                : array(),
81
-        );
82
-        // add to list of modules to be registered
83
-        add_filter(
84
-            'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
85
-            array('EE_Register_Payment_Method', 'add_payment_methods')
86
-        );
87
-        // If EE_Payment_Method_Manager::register_payment_methods has already been called,
88
-        // then we need to add our caps for this payment method manually
89
-        if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) {
90
-            // register payment methods directly
91
-            foreach (self::$_settings[$payment_method_id]['payment_method_paths'] as $payment_method_path) {
92
-                EE_Payment_Method_Manager::instance()->register_payment_method($payment_method_path);
93
-            }
94
-            EE_Capabilities::instance()->addCaps(
95
-                self::getPaymentMethodCapabilities(self::$_settings[$payment_method_id])
96
-            );
97
-        }
98
-    }
99
-
100
-
101
-
102
-    /**
103
-     * Filters the list of payment methods to add ours.
104
-     * and they're just full filepaths to FOLDERS containing a payment method class file. Eg.
105
-     *
106
-     * @param array $payment_method_folders array of paths to all payment methods that require registering
107
-     * @return array
108
-     */
109
-    public static function add_payment_methods($payment_method_folders)
110
-    {
111
-        foreach (self::$_settings as $settings) {
112
-            foreach ($settings['payment_method_paths'] as $payment_method_path) {
113
-                $payment_method_folders[] = $payment_method_path;
114
-            }
115
-        }
116
-        return $payment_method_folders;
117
-    }
118
-
119
-
120
-
121
-    /**
122
-     * This deregisters a module that was previously registered with a specific $module_id.
123
-     *
124
-     * @since    4.3.0
125
-     *
126
-     * @param string $module_id the name for the module that was previously registered
127
-     * @return void
128
-     * @throws DomainException
129
-     * @throws EE_Error
130
-     */
131
-    public static function deregister($module_id = null)
132
-    {
133
-        if (isset(self::$_settings[$module_id])) {
134
-            EE_Capabilities::instance()->removeCaps(
135
-                self::getPaymentMethodCapabilities(self::$_settings[$module_id])
136
-            );
137
-            unset(self::$_settings[$module_id]);
138
-        }
139
-    }
140
-
141
-
142
-
143
-    /**
144
-     * returns an array of the caps that get added when a Payment Method is registered
145
-     *
146
-     * @param array $settings
147
-     * @return array
148
-     * @throws DomainException
149
-     * @throws EE_Error
150
-     */
151
-    private static function getPaymentMethodCapabilities(array $settings)
152
-    {
153
-        $payment_method_caps = array('administrator' => array());
154
-        if (isset($settings['payment_method_paths'])) {
155
-            foreach ($settings['payment_method_paths'] as $payment_method_path) {
156
-                $payment_method_caps = EE_Payment_Method_Manager::instance()->addPaymentMethodCap(
157
-                    strtolower(basename($payment_method_path)),
158
-                    $payment_method_caps
159
-                );
160
-            }
161
-        }
162
-        return $payment_method_caps;
163
-    }
21
+	/**
22
+	 * Holds values for registered payment methods
23
+	 *
24
+	 * @var array
25
+	 */
26
+	protected static $_settings = array();
27
+
28
+
29
+
30
+	/**
31
+	 * Method for registering new EE_PMT_Base children
32
+	 *
33
+	 * @since    4.5.0
34
+	 * @param string  $payment_method_id    a unique identifier for this set of modules Required.
35
+	 * @param  array  $setup_args           an array of arguments provided for registering modules Required.{
36
+	 * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class
37
+	 *                                      (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains
38
+	 *                                      the files EE_PMT_Payomatic.pm.php)
39
+	 *                                      }
40
+	 * @throws EE_Error
41
+	 * @type array payment_method_paths    an array of full server paths to folders containing any EE_PMT_Base
42
+	 *                                      children, or to the EED_Module files themselves
43
+	 * @return void
44
+	 * @throws DomainException
45
+	 */
46
+	public static function register($payment_method_id = null, $setup_args = array())
47
+	{
48
+		//required fields MUST be present, so let's make sure they are.
49
+		if (empty($payment_method_id) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) {
50
+			throw new EE_Error(
51
+				esc_html__(
52
+					'In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)',
53
+					'event_espresso'
54
+				)
55
+			);
56
+		}
57
+		//make sure we don't register twice
58
+		if (isset(self::$_settings[$payment_method_id])) {
59
+			return;
60
+		}
61
+		//make sure this was called in the right place!
62
+		if (
63
+			! did_action('AHEE__EE_System__load_espresso_addons')
64
+			|| did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
65
+		) {
66
+			EE_Error::doing_it_wrong(
67
+				__METHOD__,
68
+				esc_html__(
69
+					'An attempt to register modules has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.',
70
+					'event_espresso'
71
+				),
72
+				'4.3.0'
73
+			);
74
+		}
75
+		//setup $_settings array from incoming values.
76
+		self::$_settings[$payment_method_id] = array(
77
+			// array of full server paths to any EE_PMT_Base children used
78
+			'payment_method_paths' => isset($setup_args['payment_method_paths'])
79
+				? (array)$setup_args['payment_method_paths']
80
+				: array(),
81
+		);
82
+		// add to list of modules to be registered
83
+		add_filter(
84
+			'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
85
+			array('EE_Register_Payment_Method', 'add_payment_methods')
86
+		);
87
+		// If EE_Payment_Method_Manager::register_payment_methods has already been called,
88
+		// then we need to add our caps for this payment method manually
89
+		if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) {
90
+			// register payment methods directly
91
+			foreach (self::$_settings[$payment_method_id]['payment_method_paths'] as $payment_method_path) {
92
+				EE_Payment_Method_Manager::instance()->register_payment_method($payment_method_path);
93
+			}
94
+			EE_Capabilities::instance()->addCaps(
95
+				self::getPaymentMethodCapabilities(self::$_settings[$payment_method_id])
96
+			);
97
+		}
98
+	}
99
+
100
+
101
+
102
+	/**
103
+	 * Filters the list of payment methods to add ours.
104
+	 * and they're just full filepaths to FOLDERS containing a payment method class file. Eg.
105
+	 *
106
+	 * @param array $payment_method_folders array of paths to all payment methods that require registering
107
+	 * @return array
108
+	 */
109
+	public static function add_payment_methods($payment_method_folders)
110
+	{
111
+		foreach (self::$_settings as $settings) {
112
+			foreach ($settings['payment_method_paths'] as $payment_method_path) {
113
+				$payment_method_folders[] = $payment_method_path;
114
+			}
115
+		}
116
+		return $payment_method_folders;
117
+	}
118
+
119
+
120
+
121
+	/**
122
+	 * This deregisters a module that was previously registered with a specific $module_id.
123
+	 *
124
+	 * @since    4.3.0
125
+	 *
126
+	 * @param string $module_id the name for the module that was previously registered
127
+	 * @return void
128
+	 * @throws DomainException
129
+	 * @throws EE_Error
130
+	 */
131
+	public static function deregister($module_id = null)
132
+	{
133
+		if (isset(self::$_settings[$module_id])) {
134
+			EE_Capabilities::instance()->removeCaps(
135
+				self::getPaymentMethodCapabilities(self::$_settings[$module_id])
136
+			);
137
+			unset(self::$_settings[$module_id]);
138
+		}
139
+	}
140
+
141
+
142
+
143
+	/**
144
+	 * returns an array of the caps that get added when a Payment Method is registered
145
+	 *
146
+	 * @param array $settings
147
+	 * @return array
148
+	 * @throws DomainException
149
+	 * @throws EE_Error
150
+	 */
151
+	private static function getPaymentMethodCapabilities(array $settings)
152
+	{
153
+		$payment_method_caps = array('administrator' => array());
154
+		if (isset($settings['payment_method_paths'])) {
155
+			foreach ($settings['payment_method_paths'] as $payment_method_path) {
156
+				$payment_method_caps = EE_Payment_Method_Manager::instance()->addPaymentMethodCap(
157
+					strtolower(basename($payment_method_path)),
158
+					$payment_method_caps
159
+				);
160
+			}
161
+		}
162
+		return $payment_method_caps;
163
+	}
164 164
 
165 165
 }
166 166
 // End of file EE_Register_Payment_Method.lib.php
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
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 defined('EVENT_ESPRESSO_VERSION') || exit('No direct access allowed.');
4 4
 
5 5
 if (! class_exists('WP_List_Table')) {
6
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
+	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
7 7
 }
8 8
 
9 9
 
@@ -22,847 +22,847 @@  discard block
 block discarded – undo
22 22
 abstract class EE_Admin_List_Table extends WP_List_Table
23 23
 {
24 24
 
25
-    /**
26
-     * holds the data that will be processed for the table
27
-     *
28
-     * @var array $_data
29
-     */
30
-    protected $_data;
31
-
32
-
33
-    /**
34
-     * This holds the value of all the data available for the given view (for all pages).
35
-     *
36
-     * @var int $_all_data_count
37
-     */
38
-    protected $_all_data_count;
39
-
40
-
41
-    /**
42
-     * Will contain the count of trashed items for the view label.
43
-     *
44
-     * @var int $_trashed_count
45
-     */
46
-    protected $_trashed_count;
47
-
48
-
49
-    /**
50
-     * This is what will be referenced as the slug for the current screen
51
-     *
52
-     * @var string $_screen
53
-     */
54
-    protected $_screen;
55
-
56
-
57
-    /**
58
-     * this is the EE_Admin_Page object
59
-     *
60
-     * @var EE_Admin_Page $_admin_page
61
-     */
62
-    protected $_admin_page;
63
-
64
-
65
-    /**
66
-     * The current view
67
-     *
68
-     * @var string $_view
69
-     */
70
-    protected $_view;
71
-
72
-
73
-    /**
74
-     * array of possible views for this table
75
-     *
76
-     * @var array $_views
77
-     */
78
-    protected $_views;
79
-
80
-
81
-    /**
82
-     * An array of key => value pairs containing information about the current table
83
-     * array(
84
-     *        'plural' => 'plural label',
85
-     *        'singular' => 'singular label',
86
-     *        'ajax' => false, //whether to use ajax or not
87
-     *        'screen' => null, //string used to reference what screen this is
88
-     *        (WP_List_table converts to screen object)
89
-     * )
90
-     *
91
-     * @var array $_wp_list_args
92
-     */
93
-    protected $_wp_list_args;
94
-
95
-    /**
96
-     * an array of column names
97
-     * array(
98
-     *    'internal-name' => 'Title'
99
-     * )
100
-     *
101
-     * @var array $_columns
102
-     */
103
-    protected $_columns;
104
-
105
-    /**
106
-     * An array of sortable columns
107
-     * array(
108
-     *    'internal-name' => 'orderby' //or
109
-     *    'internal-name' => array( 'orderby', true )
110
-     * )
111
-     *
112
-     * @var array $_sortable_columns
113
-     */
114
-    protected $_sortable_columns;
115
-
116
-    /**
117
-     * callback method used to perform AJAX row reordering
118
-     *
119
-     * @var string $_ajax_sorting_callback
120
-     */
121
-    protected $_ajax_sorting_callback;
122
-
123
-    /**
124
-     * An array of hidden columns (if needed)
125
-     * array('internal-name', 'internal-name')
126
-     *
127
-     * @var array $_hidden_columns
128
-     */
129
-    protected $_hidden_columns;
130
-
131
-    /**
132
-     * holds the per_page value
133
-     *
134
-     * @var int $_per_page
135
-     */
136
-    protected $_per_page;
137
-
138
-    /**
139
-     * holds what page number is currently being viewed
140
-     *
141
-     * @var int $_current_page
142
-     */
143
-    protected $_current_page;
144
-
145
-    /**
146
-     * the reference string for the nonce_action
147
-     *
148
-     * @var string $_nonce_action_ref
149
-     */
150
-    protected $_nonce_action_ref;
151
-
152
-    /**
153
-     * property to hold incoming request data (as set by the admin_page_core)
154
-     *
155
-     * @var array $_req_data
156
-     */
157
-    protected $_req_data;
158
-
159
-
160
-    /**
161
-     * yes / no array for admin form fields
162
-     *
163
-     * @var array $_yes_no
164
-     */
165
-    protected $_yes_no = array();
166
-
167
-    /**
168
-     * Array describing buttons that should appear at the bottom of the page
169
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
170
-     * and the values are another array with the following keys
171
-     * array(
172
-     *    'route' => 'page_route',
173
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
174
-     * )
175
-     *
176
-     * @var array $_bottom_buttons
177
-     */
178
-    protected $_bottom_buttons = array();
179
-
180
-
181
-    /**
182
-     * Used to indicate what should be the primary column for the list table.
183
-     * If not present then falls back to what WP calculates
184
-     * as the primary column.
185
-     *
186
-     * @type string $_primary_column
187
-     */
188
-    protected $_primary_column = '';
189
-
190
-
191
-    /**
192
-     * Used to indicate whether the table has a checkbox column or not.
193
-     *
194
-     * @type bool $_has_checkbox_column
195
-     */
196
-    protected $_has_checkbox_column = false;
197
-
198
-
199
-    /**
200
-     * @param \EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
201
-     */
202
-    public function __construct(EE_Admin_Page $admin_page)
203
-    {
204
-        $this->_admin_page   = $admin_page;
205
-        $this->_req_data     = $this->_admin_page->get_request_data();
206
-        $this->_view         = $this->_admin_page->get_view();
207
-        $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
208
-        $this->_current_page = $this->get_pagenum();
209
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
210
-        $this->_yes_no       = array(__('No', 'event_espresso'), __('Yes', 'event_espresso'));
211
-
212
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10);
213
-
214
-        $this->_setup_data();
215
-        $this->_add_view_counts();
216
-
217
-        $this->_nonce_action_ref = $this->_view;
218
-
219
-        $this->_set_properties();
220
-
221
-        //set primary column
222
-        add_filter('list_table_primary_column', array($this, 'set_primary_column'));
223
-
224
-        //set parent defaults
225
-        parent::__construct($this->_wp_list_args);
226
-
227
-        $this->prepare_items();
228
-    }
229
-
230
-
231
-    /**
232
-     * _setup_data
233
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
234
-     *
235
-     * @uses $this->_admin_page
236
-     * @return void
237
-     */
238
-    abstract protected function _setup_data();
239
-
240
-
241
-    /**
242
-     * set the properties that this class needs to be able to execute wp_list_table properly
243
-     * properties set:
244
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
245
-     * _columns = set the columns in an array.
246
-     * _sortable_columns = columns that are sortable (array).
247
-     * _hidden_columns = columns that are hidden (array)
248
-     * _default_orderby = the default orderby for sorting.
249
-     *
250
-     * @abstract
251
-     * @access protected
252
-     * @return void
253
-     */
254
-    abstract protected function _set_properties();
255
-
256
-
257
-    /**
258
-     * _get_table_filters
259
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
260
-     * get's shown in the table.
261
-     *
262
-     * @abstract
263
-     * @access protected
264
-     * @return string
265
-     */
266
-    abstract protected function _get_table_filters();
267
-
268
-
269
-    /**
270
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
271
-     * counts of the views is accurate.
272
-     *
273
-     * @abstract
274
-     * @access protected
275
-     * @return void
276
-     */
277
-    abstract protected function _add_view_counts();
278
-
279
-
280
-    /**
281
-     * _get_hidden_fields
282
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
283
-     *
284
-     * @return string
285
-     */
286
-    protected function _get_hidden_fields()
287
-    {
288
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
289
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
290
-        //if action is STILL empty, then we set it to default
291
-        $action = empty($action) ? 'default' : $action;
292
-        $field  = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
293
-        $field  .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
294
-        $field  .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
295
-
296
-        $bulk_actions = $this->_get_bulk_actions();
297
-        foreach ($bulk_actions as $bulk_action => $label) {
298
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
299
-                . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
300
-        }
301
-
302
-        return $field;
303
-    }
304
-
305
-
306
-    /**
307
-     * _set_column_info
308
-     * we're using this to set the column headers property.
309
-     *
310
-     * @access protected
311
-     * @return void
312
-     */
313
-    protected function _set_column_info()
314
-    {
315
-        $columns   = $this->get_columns();
316
-        $hidden    = $this->get_hidden_columns();
317
-        $_sortable = $this->get_sortable_columns();
318
-
319
-        /**
320
-         * Dynamic hook allowing for adding sortable columns in this list table.
321
-         * Note that $this->screen->id is in the format
322
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
323
-         * table it is: event-espresso_page_espresso_messages.
324
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
325
-         * hook prefix ("event-espresso") will be different.
326
-         *
327
-         * @var array
328
-         */
329
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
330
-
331
-        $sortable = array();
332
-        foreach ($_sortable as $id => $data) {
333
-            if (empty($data)) {
334
-                continue;
335
-            }
336
-            //fix for offset errors with WP_List_Table default get_columninfo()
337
-            if (is_array($data)) {
338
-                $_data[0] = key($data);
339
-                $_data[1] = isset($data[1]) ? $data[1] : false;
340
-            } else {
341
-                $_data[0] = $data;
342
-            }
343
-
344
-            $data = (array)$data;
345
-
346
-            if (! isset($data[1])) {
347
-                $_data[1] = false;
348
-            }
349
-
350
-            $sortable[$id] = $_data;
351
-        }
352
-        $primary               = $this->get_primary_column_name();
353
-        $this->_column_headers = array($columns, $hidden, $sortable, $primary);
354
-    }
355
-
356
-
357
-    /**
358
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
359
-     *
360
-     * @return string
361
-     */
362
-    protected function get_primary_column_name()
363
-    {
364
-        foreach (class_parents($this) as $parent) {
365
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
366
-                return parent::get_primary_column_name();
367
-            }
368
-        }
369
-        return $this->_primary_column;
370
-    }
371
-
372
-
373
-    /**
374
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
375
-     *
376
-     * @param EE_Base_Class $item
377
-     * @param string        $column_name
378
-     * @param string        $primary
379
-     * @return string
380
-     */
381
-    protected function handle_row_actions($item, $column_name, $primary)
382
-    {
383
-        foreach (class_parents($this) as $parent) {
384
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
385
-                return parent::handle_row_actions($item, $column_name, $primary);
386
-            }
387
-        }
388
-        return '';
389
-    }
390
-
391
-
392
-    /**
393
-     * _get_bulk_actions
394
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
395
-     *
396
-     * @access protected
397
-     * @return array bulk_actions
398
-     */
399
-    protected function _get_bulk_actions()
400
-    {
401
-        $actions = array();
402
-        //the _views property should have the bulk_actions, so let's go through and extract them into a properly
403
-        // formatted array for the wp_list_table();
404
-        foreach ($this->_views as $view => $args) {
405
-            if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
406
-                //each bulk action will correspond with a admin page route, so we can check whatever the capability is
407
-                // for that page route and skip adding the bulk action if no access for the current logged in user.
408
-                foreach ($args['bulk_action'] as $route => $label) {
409
-                    if ($this->_admin_page->check_user_access($route, true)) {
410
-                        $actions[$route] = $label;
411
-                    }
412
-                }
413
-            }
414
-        }
415
-        return $actions;
416
-    }
417
-
418
-
419
-    /**
420
-     * Generate the table navigation above or below the table.
421
-     * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
422
-     *
423
-     * @since 4.9.44.rc.001
424
-     */
425
-    public function display_tablenav($which)
426
-    {
427
-        if ('top' === $which) {
428
-            wp_nonce_field('bulk-' . $this->_args['plural']);
429
-        }
430
-        ?>
25
+	/**
26
+	 * holds the data that will be processed for the table
27
+	 *
28
+	 * @var array $_data
29
+	 */
30
+	protected $_data;
31
+
32
+
33
+	/**
34
+	 * This holds the value of all the data available for the given view (for all pages).
35
+	 *
36
+	 * @var int $_all_data_count
37
+	 */
38
+	protected $_all_data_count;
39
+
40
+
41
+	/**
42
+	 * Will contain the count of trashed items for the view label.
43
+	 *
44
+	 * @var int $_trashed_count
45
+	 */
46
+	protected $_trashed_count;
47
+
48
+
49
+	/**
50
+	 * This is what will be referenced as the slug for the current screen
51
+	 *
52
+	 * @var string $_screen
53
+	 */
54
+	protected $_screen;
55
+
56
+
57
+	/**
58
+	 * this is the EE_Admin_Page object
59
+	 *
60
+	 * @var EE_Admin_Page $_admin_page
61
+	 */
62
+	protected $_admin_page;
63
+
64
+
65
+	/**
66
+	 * The current view
67
+	 *
68
+	 * @var string $_view
69
+	 */
70
+	protected $_view;
71
+
72
+
73
+	/**
74
+	 * array of possible views for this table
75
+	 *
76
+	 * @var array $_views
77
+	 */
78
+	protected $_views;
79
+
80
+
81
+	/**
82
+	 * An array of key => value pairs containing information about the current table
83
+	 * array(
84
+	 *        'plural' => 'plural label',
85
+	 *        'singular' => 'singular label',
86
+	 *        'ajax' => false, //whether to use ajax or not
87
+	 *        'screen' => null, //string used to reference what screen this is
88
+	 *        (WP_List_table converts to screen object)
89
+	 * )
90
+	 *
91
+	 * @var array $_wp_list_args
92
+	 */
93
+	protected $_wp_list_args;
94
+
95
+	/**
96
+	 * an array of column names
97
+	 * array(
98
+	 *    'internal-name' => 'Title'
99
+	 * )
100
+	 *
101
+	 * @var array $_columns
102
+	 */
103
+	protected $_columns;
104
+
105
+	/**
106
+	 * An array of sortable columns
107
+	 * array(
108
+	 *    'internal-name' => 'orderby' //or
109
+	 *    'internal-name' => array( 'orderby', true )
110
+	 * )
111
+	 *
112
+	 * @var array $_sortable_columns
113
+	 */
114
+	protected $_sortable_columns;
115
+
116
+	/**
117
+	 * callback method used to perform AJAX row reordering
118
+	 *
119
+	 * @var string $_ajax_sorting_callback
120
+	 */
121
+	protected $_ajax_sorting_callback;
122
+
123
+	/**
124
+	 * An array of hidden columns (if needed)
125
+	 * array('internal-name', 'internal-name')
126
+	 *
127
+	 * @var array $_hidden_columns
128
+	 */
129
+	protected $_hidden_columns;
130
+
131
+	/**
132
+	 * holds the per_page value
133
+	 *
134
+	 * @var int $_per_page
135
+	 */
136
+	protected $_per_page;
137
+
138
+	/**
139
+	 * holds what page number is currently being viewed
140
+	 *
141
+	 * @var int $_current_page
142
+	 */
143
+	protected $_current_page;
144
+
145
+	/**
146
+	 * the reference string for the nonce_action
147
+	 *
148
+	 * @var string $_nonce_action_ref
149
+	 */
150
+	protected $_nonce_action_ref;
151
+
152
+	/**
153
+	 * property to hold incoming request data (as set by the admin_page_core)
154
+	 *
155
+	 * @var array $_req_data
156
+	 */
157
+	protected $_req_data;
158
+
159
+
160
+	/**
161
+	 * yes / no array for admin form fields
162
+	 *
163
+	 * @var array $_yes_no
164
+	 */
165
+	protected $_yes_no = array();
166
+
167
+	/**
168
+	 * Array describing buttons that should appear at the bottom of the page
169
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
170
+	 * and the values are another array with the following keys
171
+	 * array(
172
+	 *    'route' => 'page_route',
173
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
174
+	 * )
175
+	 *
176
+	 * @var array $_bottom_buttons
177
+	 */
178
+	protected $_bottom_buttons = array();
179
+
180
+
181
+	/**
182
+	 * Used to indicate what should be the primary column for the list table.
183
+	 * If not present then falls back to what WP calculates
184
+	 * as the primary column.
185
+	 *
186
+	 * @type string $_primary_column
187
+	 */
188
+	protected $_primary_column = '';
189
+
190
+
191
+	/**
192
+	 * Used to indicate whether the table has a checkbox column or not.
193
+	 *
194
+	 * @type bool $_has_checkbox_column
195
+	 */
196
+	protected $_has_checkbox_column = false;
197
+
198
+
199
+	/**
200
+	 * @param \EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
201
+	 */
202
+	public function __construct(EE_Admin_Page $admin_page)
203
+	{
204
+		$this->_admin_page   = $admin_page;
205
+		$this->_req_data     = $this->_admin_page->get_request_data();
206
+		$this->_view         = $this->_admin_page->get_view();
207
+		$this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
208
+		$this->_current_page = $this->get_pagenum();
209
+		$this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
210
+		$this->_yes_no       = array(__('No', 'event_espresso'), __('Yes', 'event_espresso'));
211
+
212
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10);
213
+
214
+		$this->_setup_data();
215
+		$this->_add_view_counts();
216
+
217
+		$this->_nonce_action_ref = $this->_view;
218
+
219
+		$this->_set_properties();
220
+
221
+		//set primary column
222
+		add_filter('list_table_primary_column', array($this, 'set_primary_column'));
223
+
224
+		//set parent defaults
225
+		parent::__construct($this->_wp_list_args);
226
+
227
+		$this->prepare_items();
228
+	}
229
+
230
+
231
+	/**
232
+	 * _setup_data
233
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
234
+	 *
235
+	 * @uses $this->_admin_page
236
+	 * @return void
237
+	 */
238
+	abstract protected function _setup_data();
239
+
240
+
241
+	/**
242
+	 * set the properties that this class needs to be able to execute wp_list_table properly
243
+	 * properties set:
244
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
245
+	 * _columns = set the columns in an array.
246
+	 * _sortable_columns = columns that are sortable (array).
247
+	 * _hidden_columns = columns that are hidden (array)
248
+	 * _default_orderby = the default orderby for sorting.
249
+	 *
250
+	 * @abstract
251
+	 * @access protected
252
+	 * @return void
253
+	 */
254
+	abstract protected function _set_properties();
255
+
256
+
257
+	/**
258
+	 * _get_table_filters
259
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
260
+	 * get's shown in the table.
261
+	 *
262
+	 * @abstract
263
+	 * @access protected
264
+	 * @return string
265
+	 */
266
+	abstract protected function _get_table_filters();
267
+
268
+
269
+	/**
270
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
271
+	 * counts of the views is accurate.
272
+	 *
273
+	 * @abstract
274
+	 * @access protected
275
+	 * @return void
276
+	 */
277
+	abstract protected function _add_view_counts();
278
+
279
+
280
+	/**
281
+	 * _get_hidden_fields
282
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
283
+	 *
284
+	 * @return string
285
+	 */
286
+	protected function _get_hidden_fields()
287
+	{
288
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
289
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
290
+		//if action is STILL empty, then we set it to default
291
+		$action = empty($action) ? 'default' : $action;
292
+		$field  = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
293
+		$field  .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
294
+		$field  .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
295
+
296
+		$bulk_actions = $this->_get_bulk_actions();
297
+		foreach ($bulk_actions as $bulk_action => $label) {
298
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
299
+				. ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
300
+		}
301
+
302
+		return $field;
303
+	}
304
+
305
+
306
+	/**
307
+	 * _set_column_info
308
+	 * we're using this to set the column headers property.
309
+	 *
310
+	 * @access protected
311
+	 * @return void
312
+	 */
313
+	protected function _set_column_info()
314
+	{
315
+		$columns   = $this->get_columns();
316
+		$hidden    = $this->get_hidden_columns();
317
+		$_sortable = $this->get_sortable_columns();
318
+
319
+		/**
320
+		 * Dynamic hook allowing for adding sortable columns in this list table.
321
+		 * Note that $this->screen->id is in the format
322
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
323
+		 * table it is: event-espresso_page_espresso_messages.
324
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
325
+		 * hook prefix ("event-espresso") will be different.
326
+		 *
327
+		 * @var array
328
+		 */
329
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
330
+
331
+		$sortable = array();
332
+		foreach ($_sortable as $id => $data) {
333
+			if (empty($data)) {
334
+				continue;
335
+			}
336
+			//fix for offset errors with WP_List_Table default get_columninfo()
337
+			if (is_array($data)) {
338
+				$_data[0] = key($data);
339
+				$_data[1] = isset($data[1]) ? $data[1] : false;
340
+			} else {
341
+				$_data[0] = $data;
342
+			}
343
+
344
+			$data = (array)$data;
345
+
346
+			if (! isset($data[1])) {
347
+				$_data[1] = false;
348
+			}
349
+
350
+			$sortable[$id] = $_data;
351
+		}
352
+		$primary               = $this->get_primary_column_name();
353
+		$this->_column_headers = array($columns, $hidden, $sortable, $primary);
354
+	}
355
+
356
+
357
+	/**
358
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
359
+	 *
360
+	 * @return string
361
+	 */
362
+	protected function get_primary_column_name()
363
+	{
364
+		foreach (class_parents($this) as $parent) {
365
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
366
+				return parent::get_primary_column_name();
367
+			}
368
+		}
369
+		return $this->_primary_column;
370
+	}
371
+
372
+
373
+	/**
374
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
375
+	 *
376
+	 * @param EE_Base_Class $item
377
+	 * @param string        $column_name
378
+	 * @param string        $primary
379
+	 * @return string
380
+	 */
381
+	protected function handle_row_actions($item, $column_name, $primary)
382
+	{
383
+		foreach (class_parents($this) as $parent) {
384
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
385
+				return parent::handle_row_actions($item, $column_name, $primary);
386
+			}
387
+		}
388
+		return '';
389
+	}
390
+
391
+
392
+	/**
393
+	 * _get_bulk_actions
394
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
395
+	 *
396
+	 * @access protected
397
+	 * @return array bulk_actions
398
+	 */
399
+	protected function _get_bulk_actions()
400
+	{
401
+		$actions = array();
402
+		//the _views property should have the bulk_actions, so let's go through and extract them into a properly
403
+		// formatted array for the wp_list_table();
404
+		foreach ($this->_views as $view => $args) {
405
+			if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
406
+				//each bulk action will correspond with a admin page route, so we can check whatever the capability is
407
+				// for that page route and skip adding the bulk action if no access for the current logged in user.
408
+				foreach ($args['bulk_action'] as $route => $label) {
409
+					if ($this->_admin_page->check_user_access($route, true)) {
410
+						$actions[$route] = $label;
411
+					}
412
+				}
413
+			}
414
+		}
415
+		return $actions;
416
+	}
417
+
418
+
419
+	/**
420
+	 * Generate the table navigation above or below the table.
421
+	 * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
422
+	 *
423
+	 * @since 4.9.44.rc.001
424
+	 */
425
+	public function display_tablenav($which)
426
+	{
427
+		if ('top' === $which) {
428
+			wp_nonce_field('bulk-' . $this->_args['plural']);
429
+		}
430
+		?>
431 431
         <div class="tablenav <?php echo esc_attr($which); ?>">
432 432
             <?php if ($this->_get_bulk_actions()) { ?>
433 433
                 <div class="alignleft actions bulkactions">
434 434
                     <?php $this->bulk_actions(); ?>
435 435
                 </div>
436 436
             <?php }
437
-            $this->extra_tablenav($which);
438
-            $this->pagination($which);
439
-            ?>
437
+			$this->extra_tablenav($which);
438
+			$this->pagination($which);
439
+			?>
440 440
 
441 441
             <br class="clear"/>
442 442
         </div>
443 443
         <?php
444
-    }
445
-
446
-
447
-    /**
448
-     * _filters
449
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
450
-     * button.
451
-     *
452
-     * @access private
453
-     * @return string html showing filters
454
-     */
455
-    private function _filters()
456
-    {
457
-        $classname = get_class($this);
458
-        $filters   = apply_filters(
459
-            "FHEE__{$classname}__filters",
460
-            (array) $this->_get_table_filters(),
461
-            $this,
462
-            $this->_screen
463
-        );
464
-
465
-        if (empty($filters)) {
466
-            return;
467
-        }
468
-        foreach ($filters as $filter) {
469
-            echo $filter;
470
-        }
471
-        //add filter button at end
472
-        echo '<input type="submit" class="button-secondary" value="'
473
-             . esc_html__('Filter', 'event_espresso')
474
-             . '" id="post-query-submit" />';
475
-        //add reset filters button at end
476
-        echo '<a class="button button-secondary"  href="'
477
-             . $this->_admin_page->get_current_page_view_url()
478
-             . '" style="display:inline-block">'
479
-             . esc_html__('Reset Filters', 'event_espresso')
480
-             . '</a>';
481
-    }
482
-
483
-
484
-    /**
485
-     * Callback for 'list_table_primary_column' WordPress filter
486
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
487
-     * column when class is instantiated.
488
-     *
489
-     * @see WP_List_Table::get_primary_column_name
490
-     * @param string $column_name
491
-     * @return string
492
-     */
493
-    public function set_primary_column($column_name)
494
-    {
495
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
496
-    }
497
-
498
-
499
-    /**
500
-     *
501
-     */
502
-    public function prepare_items()
503
-    {
504
-
505
-        $this->_set_column_info();
506
-        //$this->_column_headers = $this->get_column_info();
507
-        $total_items = $this->_all_data_count;
508
-        $this->process_bulk_action();
509
-
510
-        $this->items = $this->_data;
511
-        $this->set_pagination_args(
512
-            array(
513
-                'total_items' => $total_items,
514
-                'per_page'    => $this->_per_page,
515
-                'total_pages' => ceil($total_items / $this->_per_page),
516
-            )
517
-        );
518
-    }
519
-
520
-
521
-    /**
522
-     * This column is the default for when there is no defined column method for a registered column.
523
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
524
-     *
525
-     * @param EE_Base_Class $item
526
-     * @param string        $column_name The column being called.
527
-     * @return string html content for the column
528
-     */
529
-    public function column_default($item, $column_name)
530
-    {
531
-        /**
532
-         * Dynamic hook allowing for adding additional column content in this list table.
533
-         * Note that $this->screen->id is in the format
534
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
535
-         * table it is: event-espresso_page_espresso_messages.
536
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
537
-         * hook prefix ("event-espresso") will be different.
538
-         */
539
-        do_action(
540
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
541
-            $item,
542
-            $this->_screen
543
-        );
544
-    }
545
-
546
-
547
-    /**
548
-     * Get a list of columns. The format is:
549
-     * 'internal-name' => 'Title'
550
-     *
551
-     * @since  3.1.0
552
-     * @access public
553
-     * @abstract
554
-     * @return array
555
-     */
556
-    public function get_columns()
557
-    {
558
-        /**
559
-         * Dynamic hook allowing for adding additional columns in this list table.
560
-         * Note that $this->screen->id is in the format
561
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
562
-         * table it is: event-espresso_page_espresso_messages.
563
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
564
-         * hook prefix ("event-espresso") will be different.
565
-         *
566
-         * @var array
567
-         */
568
-        $columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
569
-        return $columns;
570
-    }
571
-
572
-
573
-    /**
574
-     * Get an associative array ( id => link ) with the list
575
-     * of views available on this table.
576
-     *
577
-     * @since  3.1.0
578
-     * @access protected
579
-     * @return array
580
-     */
581
-    public function get_views()
582
-    {
583
-        return $this->_views;
584
-    }
585
-
586
-
587
-    /**
588
-     * Generate the views html.
589
-     */
590
-    public function display_views()
591
-    {
592
-        $views           = $this->get_views();
593
-        $assembled_views = array();
594
-
595
-        if (empty($views)) {
596
-            return;
597
-        }
598
-        echo "<ul class='subsubsub'>\n";
599
-        foreach ($views as $view) {
600
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
601
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
602
-                $assembled_views[$view['slug']] = "\t<li class='" . $view['class'] . "'>"
603
-                                                  . '<a href="' . $view['url'] . '">' . $view['label'] . '</a>'
604
-                                                  . ' <span class="count">(' . $count . ')</span>';
605
-            }
606
-        }
607
-
608
-        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
609
-        echo "</ul>";
610
-    }
611
-
612
-
613
-    /**
614
-     * Generates content for a single row of the table
615
-     *
616
-     * @since  4.1
617
-     * @access public
618
-     * @param EE_Base_Class $item The current item
619
-     */
620
-    public function single_row($item)
621
-    {
622
-        $row_class = $this->_get_row_class($item);
623
-        echo '<tr class="' . esc_attr($row_class) . '">';
624
-        $this->single_row_columns($item);
625
-        echo '</tr>';
626
-    }
627
-
628
-
629
-    /**
630
-     * This simply sets up the row class for the table rows.
631
-     * Allows for easier overriding of child methods for setting up sorting.
632
-     *
633
-     * @param  EE_Base_Class $item the current item
634
-     * @return string
635
-     */
636
-    protected function _get_row_class($item)
637
-    {
638
-        static $row_class = '';
639
-        $row_class = ($row_class === '' ? 'alternate' : '');
640
-
641
-        $new_row_class = $row_class;
642
-
643
-        if (! empty($this->_ajax_sorting_callback)) {
644
-            $new_row_class .= ' rowsortable';
645
-        }
646
-
647
-        return $new_row_class;
648
-    }
649
-
650
-
651
-    /**
652
-     * @return array
653
-     */
654
-    public function get_sortable_columns()
655
-    {
656
-        return (array)$this->_sortable_columns;
657
-    }
658
-
659
-
660
-    /**
661
-     * @return string
662
-     */
663
-    public function get_ajax_sorting_callback()
664
-    {
665
-        return $this->_ajax_sorting_callback;
666
-    }
667
-
668
-
669
-    /**
670
-     * @return array
671
-     */
672
-    public function get_hidden_columns()
673
-    {
674
-        $user_id     = get_current_user_id();
675
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
676
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
677
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
678
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
679
-        }
680
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
681
-        return (array) get_user_option($ref, $user_id);
682
-    }
683
-
684
-
685
-    /**
686
-     * Generates the columns for a single row of the table.
687
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
688
-     * column.
689
-     *
690
-     * @since 3.1.0
691
-     * @param EE_Base_Class $item The current item
692
-     */
693
-    public function single_row_columns($item)
694
-    {
695
-        list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
696
-
697
-        global $wp_version;
698
-        $use_hidden_class = version_compare($wp_version, '4.3-RC', '>=');
699
-
700
-        foreach ($columns as $column_name => $column_display_name) {
701
-
702
-            /**
703
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
704
-             * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
705
-             */
706
-            $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
707
-            $style        = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
708
-
709
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
710
-            if ($primary === $column_name) {
711
-                $classes .= ' has-row-actions column-primary';
712
-            }
713
-
714
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
715
-
716
-            $class = "class='$classes'";
717
-
718
-            $attributes = "$class$style$data";
719
-
720
-            if ($column_name === 'cb') {
721
-                echo '<th scope="row" class="check-column">';
722
-                echo apply_filters(
723
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
724
-                    $this->column_cb($item),
725
-                    $item,
726
-                    $this
727
-                );
728
-                echo '</th>';
729
-            } elseif (method_exists($this, 'column_' . $column_name)) {
730
-                echo "<td $attributes>";
731
-                echo apply_filters(
732
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
733
-                    call_user_func(array($this, 'column_' . $column_name), $item),
734
-                    $item,
735
-                    $this
736
-                );
737
-                echo $this->handle_row_actions($item, $column_name, $primary);
738
-                echo "</td>";
739
-            } else {
740
-                echo "<td $attributes>";
741
-                echo apply_filters(
742
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
743
-                    $this->column_default($item, $column_name),
744
-                    $item,
745
-                    $column_name,
746
-                    $this
747
-                );
748
-                echo $this->handle_row_actions($item, $column_name, $primary);
749
-                echo "</td>";
750
-            }
751
-        }
752
-    }
753
-
754
-
755
-    /**
756
-     * Extra controls to be displayed between bulk actions and pagination
757
-     *
758
-     * @access public
759
-     * @param string $which
760
-     * @throws \EE_Error
761
-     */
762
-    public function extra_tablenav($which)
763
-    {
764
-        if ($which === 'top') {
765
-            $this->_filters();
766
-            echo $this->_get_hidden_fields();
767
-        } else {
768
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
769
-            foreach ($this->_bottom_buttons as $type => $action) {
770
-                $route         = isset($action['route']) ? $action['route'] : '';
771
-                $extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
772
-                echo $this->_admin_page->get_action_link_or_button(
773
-                    $route,
774
-                    $type,
775
-                    $extra_request,
776
-                    'button button-secondary',
777
-                    '',
778
-                    false
779
-                );
780
-            }
781
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
782
-            echo '</div>';
783
-        }
784
-        //echo $this->_entries_per_page_dropdown;
785
-    }
786
-
787
-
788
-    /**
789
-     * Get an associative array ( option_name => option_title ) with the list
790
-     * of bulk actions available on this table.
791
-     *
792
-     * @since  3.1.0
793
-     * @access protected
794
-     * @return array
795
-     */
796
-    public function get_bulk_actions()
797
-    {
798
-        return (array) $this->_get_bulk_actions();
799
-    }
800
-
801
-    /**
802
-     * Processing bulk actions.
803
-     */
804
-    public function process_bulk_action()
805
-    {
806
-        //this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
807
-        //reference in case there is a case where it gets used.
808
-    }
809
-
810
-
811
-    /**
812
-     * returns the EE admin page this list table is associated with
813
-     *
814
-     * @return EE_Admin_Page
815
-     */
816
-    public function get_admin_page()
817
-    {
818
-        return $this->_admin_page;
819
-    }
820
-
821
-
822
-    /**
823
-     * A "helper" function for all children to provide an html string of
824
-     * actions to output in their content.  It is preferable for child classes
825
-     * to use this method for generating their actions content so that it's
826
-     * filterable by plugins
827
-     *
828
-     * @param string        $action_container           what are the html container
829
-     *                                                  elements for this actions string?
830
-     * @param string        $action_class               What class is for the container
831
-     *                                                  element.
832
-     * @param string        $action_items               The contents for the action items
833
-     *                                                  container.  This is filtered before
834
-     *                                                  returned.
835
-     * @param string        $action_id                  What id (optional) is used for the
836
-     *                                                  container element.
837
-     * @param EE_Base_Class $item                       The object for the column displaying
838
-     *                                                  the actions.
839
-     * @return string The assembled action elements container.
840
-     */
841
-    protected function _action_string(
842
-        $action_items,
843
-        $item,
844
-        $action_container = 'ul',
845
-        $action_class = '',
846
-        $action_id = ''
847
-    ) {
848
-        $content      = '';
849
-        $action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
850
-        $action_id    = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
851
-        $content      .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
852
-        try {
853
-            $content .= apply_filters(
854
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
855
-                $action_items,
856
-                $item,
857
-                $this
858
-            );
859
-        } catch (\Exception $e) {
860
-            if (WP_DEBUG) {
861
-                \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
862
-            }
863
-            $content .= $action_items;
864
-        }
865
-        $content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
866
-        return $content;
867
-    }
444
+	}
445
+
446
+
447
+	/**
448
+	 * _filters
449
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
450
+	 * button.
451
+	 *
452
+	 * @access private
453
+	 * @return string html showing filters
454
+	 */
455
+	private function _filters()
456
+	{
457
+		$classname = get_class($this);
458
+		$filters   = apply_filters(
459
+			"FHEE__{$classname}__filters",
460
+			(array) $this->_get_table_filters(),
461
+			$this,
462
+			$this->_screen
463
+		);
464
+
465
+		if (empty($filters)) {
466
+			return;
467
+		}
468
+		foreach ($filters as $filter) {
469
+			echo $filter;
470
+		}
471
+		//add filter button at end
472
+		echo '<input type="submit" class="button-secondary" value="'
473
+			 . esc_html__('Filter', 'event_espresso')
474
+			 . '" id="post-query-submit" />';
475
+		//add reset filters button at end
476
+		echo '<a class="button button-secondary"  href="'
477
+			 . $this->_admin_page->get_current_page_view_url()
478
+			 . '" style="display:inline-block">'
479
+			 . esc_html__('Reset Filters', 'event_espresso')
480
+			 . '</a>';
481
+	}
482
+
483
+
484
+	/**
485
+	 * Callback for 'list_table_primary_column' WordPress filter
486
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
487
+	 * column when class is instantiated.
488
+	 *
489
+	 * @see WP_List_Table::get_primary_column_name
490
+	 * @param string $column_name
491
+	 * @return string
492
+	 */
493
+	public function set_primary_column($column_name)
494
+	{
495
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
496
+	}
497
+
498
+
499
+	/**
500
+	 *
501
+	 */
502
+	public function prepare_items()
503
+	{
504
+
505
+		$this->_set_column_info();
506
+		//$this->_column_headers = $this->get_column_info();
507
+		$total_items = $this->_all_data_count;
508
+		$this->process_bulk_action();
509
+
510
+		$this->items = $this->_data;
511
+		$this->set_pagination_args(
512
+			array(
513
+				'total_items' => $total_items,
514
+				'per_page'    => $this->_per_page,
515
+				'total_pages' => ceil($total_items / $this->_per_page),
516
+			)
517
+		);
518
+	}
519
+
520
+
521
+	/**
522
+	 * This column is the default for when there is no defined column method for a registered column.
523
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
524
+	 *
525
+	 * @param EE_Base_Class $item
526
+	 * @param string        $column_name The column being called.
527
+	 * @return string html content for the column
528
+	 */
529
+	public function column_default($item, $column_name)
530
+	{
531
+		/**
532
+		 * Dynamic hook allowing for adding additional column content in this list table.
533
+		 * Note that $this->screen->id is in the format
534
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
535
+		 * table it is: event-espresso_page_espresso_messages.
536
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
537
+		 * hook prefix ("event-espresso") will be different.
538
+		 */
539
+		do_action(
540
+			'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
541
+			$item,
542
+			$this->_screen
543
+		);
544
+	}
545
+
546
+
547
+	/**
548
+	 * Get a list of columns. The format is:
549
+	 * 'internal-name' => 'Title'
550
+	 *
551
+	 * @since  3.1.0
552
+	 * @access public
553
+	 * @abstract
554
+	 * @return array
555
+	 */
556
+	public function get_columns()
557
+	{
558
+		/**
559
+		 * Dynamic hook allowing for adding additional columns in this list table.
560
+		 * Note that $this->screen->id is in the format
561
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
562
+		 * table it is: event-espresso_page_espresso_messages.
563
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
564
+		 * hook prefix ("event-espresso") will be different.
565
+		 *
566
+		 * @var array
567
+		 */
568
+		$columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
569
+		return $columns;
570
+	}
571
+
572
+
573
+	/**
574
+	 * Get an associative array ( id => link ) with the list
575
+	 * of views available on this table.
576
+	 *
577
+	 * @since  3.1.0
578
+	 * @access protected
579
+	 * @return array
580
+	 */
581
+	public function get_views()
582
+	{
583
+		return $this->_views;
584
+	}
585
+
586
+
587
+	/**
588
+	 * Generate the views html.
589
+	 */
590
+	public function display_views()
591
+	{
592
+		$views           = $this->get_views();
593
+		$assembled_views = array();
594
+
595
+		if (empty($views)) {
596
+			return;
597
+		}
598
+		echo "<ul class='subsubsub'>\n";
599
+		foreach ($views as $view) {
600
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
601
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
602
+				$assembled_views[$view['slug']] = "\t<li class='" . $view['class'] . "'>"
603
+												  . '<a href="' . $view['url'] . '">' . $view['label'] . '</a>'
604
+												  . ' <span class="count">(' . $count . ')</span>';
605
+			}
606
+		}
607
+
608
+		echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
609
+		echo "</ul>";
610
+	}
611
+
612
+
613
+	/**
614
+	 * Generates content for a single row of the table
615
+	 *
616
+	 * @since  4.1
617
+	 * @access public
618
+	 * @param EE_Base_Class $item The current item
619
+	 */
620
+	public function single_row($item)
621
+	{
622
+		$row_class = $this->_get_row_class($item);
623
+		echo '<tr class="' . esc_attr($row_class) . '">';
624
+		$this->single_row_columns($item);
625
+		echo '</tr>';
626
+	}
627
+
628
+
629
+	/**
630
+	 * This simply sets up the row class for the table rows.
631
+	 * Allows for easier overriding of child methods for setting up sorting.
632
+	 *
633
+	 * @param  EE_Base_Class $item the current item
634
+	 * @return string
635
+	 */
636
+	protected function _get_row_class($item)
637
+	{
638
+		static $row_class = '';
639
+		$row_class = ($row_class === '' ? 'alternate' : '');
640
+
641
+		$new_row_class = $row_class;
642
+
643
+		if (! empty($this->_ajax_sorting_callback)) {
644
+			$new_row_class .= ' rowsortable';
645
+		}
646
+
647
+		return $new_row_class;
648
+	}
649
+
650
+
651
+	/**
652
+	 * @return array
653
+	 */
654
+	public function get_sortable_columns()
655
+	{
656
+		return (array)$this->_sortable_columns;
657
+	}
658
+
659
+
660
+	/**
661
+	 * @return string
662
+	 */
663
+	public function get_ajax_sorting_callback()
664
+	{
665
+		return $this->_ajax_sorting_callback;
666
+	}
667
+
668
+
669
+	/**
670
+	 * @return array
671
+	 */
672
+	public function get_hidden_columns()
673
+	{
674
+		$user_id     = get_current_user_id();
675
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
676
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
677
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
678
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
679
+		}
680
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
681
+		return (array) get_user_option($ref, $user_id);
682
+	}
683
+
684
+
685
+	/**
686
+	 * Generates the columns for a single row of the table.
687
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
688
+	 * column.
689
+	 *
690
+	 * @since 3.1.0
691
+	 * @param EE_Base_Class $item The current item
692
+	 */
693
+	public function single_row_columns($item)
694
+	{
695
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
696
+
697
+		global $wp_version;
698
+		$use_hidden_class = version_compare($wp_version, '4.3-RC', '>=');
699
+
700
+		foreach ($columns as $column_name => $column_display_name) {
701
+
702
+			/**
703
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
704
+			 * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
705
+			 */
706
+			$hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
707
+			$style        = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
708
+
709
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
710
+			if ($primary === $column_name) {
711
+				$classes .= ' has-row-actions column-primary';
712
+			}
713
+
714
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
715
+
716
+			$class = "class='$classes'";
717
+
718
+			$attributes = "$class$style$data";
719
+
720
+			if ($column_name === 'cb') {
721
+				echo '<th scope="row" class="check-column">';
722
+				echo apply_filters(
723
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
724
+					$this->column_cb($item),
725
+					$item,
726
+					$this
727
+				);
728
+				echo '</th>';
729
+			} elseif (method_exists($this, 'column_' . $column_name)) {
730
+				echo "<td $attributes>";
731
+				echo apply_filters(
732
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
733
+					call_user_func(array($this, 'column_' . $column_name), $item),
734
+					$item,
735
+					$this
736
+				);
737
+				echo $this->handle_row_actions($item, $column_name, $primary);
738
+				echo "</td>";
739
+			} else {
740
+				echo "<td $attributes>";
741
+				echo apply_filters(
742
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
743
+					$this->column_default($item, $column_name),
744
+					$item,
745
+					$column_name,
746
+					$this
747
+				);
748
+				echo $this->handle_row_actions($item, $column_name, $primary);
749
+				echo "</td>";
750
+			}
751
+		}
752
+	}
753
+
754
+
755
+	/**
756
+	 * Extra controls to be displayed between bulk actions and pagination
757
+	 *
758
+	 * @access public
759
+	 * @param string $which
760
+	 * @throws \EE_Error
761
+	 */
762
+	public function extra_tablenav($which)
763
+	{
764
+		if ($which === 'top') {
765
+			$this->_filters();
766
+			echo $this->_get_hidden_fields();
767
+		} else {
768
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
769
+			foreach ($this->_bottom_buttons as $type => $action) {
770
+				$route         = isset($action['route']) ? $action['route'] : '';
771
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
772
+				echo $this->_admin_page->get_action_link_or_button(
773
+					$route,
774
+					$type,
775
+					$extra_request,
776
+					'button button-secondary',
777
+					'',
778
+					false
779
+				);
780
+			}
781
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
782
+			echo '</div>';
783
+		}
784
+		//echo $this->_entries_per_page_dropdown;
785
+	}
786
+
787
+
788
+	/**
789
+	 * Get an associative array ( option_name => option_title ) with the list
790
+	 * of bulk actions available on this table.
791
+	 *
792
+	 * @since  3.1.0
793
+	 * @access protected
794
+	 * @return array
795
+	 */
796
+	public function get_bulk_actions()
797
+	{
798
+		return (array) $this->_get_bulk_actions();
799
+	}
800
+
801
+	/**
802
+	 * Processing bulk actions.
803
+	 */
804
+	public function process_bulk_action()
805
+	{
806
+		//this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
807
+		//reference in case there is a case where it gets used.
808
+	}
809
+
810
+
811
+	/**
812
+	 * returns the EE admin page this list table is associated with
813
+	 *
814
+	 * @return EE_Admin_Page
815
+	 */
816
+	public function get_admin_page()
817
+	{
818
+		return $this->_admin_page;
819
+	}
820
+
821
+
822
+	/**
823
+	 * A "helper" function for all children to provide an html string of
824
+	 * actions to output in their content.  It is preferable for child classes
825
+	 * to use this method for generating their actions content so that it's
826
+	 * filterable by plugins
827
+	 *
828
+	 * @param string        $action_container           what are the html container
829
+	 *                                                  elements for this actions string?
830
+	 * @param string        $action_class               What class is for the container
831
+	 *                                                  element.
832
+	 * @param string        $action_items               The contents for the action items
833
+	 *                                                  container.  This is filtered before
834
+	 *                                                  returned.
835
+	 * @param string        $action_id                  What id (optional) is used for the
836
+	 *                                                  container element.
837
+	 * @param EE_Base_Class $item                       The object for the column displaying
838
+	 *                                                  the actions.
839
+	 * @return string The assembled action elements container.
840
+	 */
841
+	protected function _action_string(
842
+		$action_items,
843
+		$item,
844
+		$action_container = 'ul',
845
+		$action_class = '',
846
+		$action_id = ''
847
+	) {
848
+		$content      = '';
849
+		$action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
850
+		$action_id    = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
851
+		$content      .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
852
+		try {
853
+			$content .= apply_filters(
854
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
855
+				$action_items,
856
+				$item,
857
+				$this
858
+			);
859
+		} catch (\Exception $e) {
860
+			if (WP_DEBUG) {
861
+				\EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
862
+			}
863
+			$content .= $action_items;
864
+		}
865
+		$content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
866
+		return $content;
867
+	}
868 868
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 defined('EVENT_ESPRESSO_VERSION') || exit('No direct access allowed.');
4 4
 
5
-if (! class_exists('WP_List_Table')) {
6
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
5
+if ( ! class_exists('WP_List_Table')) {
6
+    require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
7 7
 }
8 8
 
9 9
 
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
         $this->_view         = $this->_admin_page->get_view();
207 207
         $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
208 208
         $this->_current_page = $this->get_pagenum();
209
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
209
+        $this->_screen       = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view();
210 210
         $this->_yes_no       = array(__('No', 'event_espresso'), __('Yes', 'event_espresso'));
211 211
 
212
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10);
212
+        $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 10);
213 213
 
214 214
         $this->_setup_data();
215 215
         $this->_add_view_counts();
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
         $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
290 290
         //if action is STILL empty, then we set it to default
291 291
         $action = empty($action) ? 'default' : $action;
292
-        $field  = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
293
-        $field  .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
294
-        $field  .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
292
+        $field  = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n";
293
+        $field  .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/
294
+        $field  .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n";
295 295
 
296 296
         $bulk_actions = $this->_get_bulk_actions();
297 297
         foreach ($bulk_actions as $bulk_action => $label) {
298
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
299
-                . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
298
+            $field .= '<input type="hidden" name="'.$bulk_action.'_nonce"'
299
+                . ' value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n";
300 300
         }
301 301
 
302 302
         return $field;
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
                 $_data[0] = $data;
342 342
             }
343 343
 
344
-            $data = (array)$data;
344
+            $data = (array) $data;
345 345
 
346
-            if (! isset($data[1])) {
346
+            if ( ! isset($data[1])) {
347 347
                 $_data[1] = false;
348 348
             }
349 349
 
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
     public function display_tablenav($which)
426 426
     {
427 427
         if ('top' === $which) {
428
-            wp_nonce_field('bulk-' . $this->_args['plural']);
428
+            wp_nonce_field('bulk-'.$this->_args['plural']);
429 429
         }
430 430
         ?>
431 431
         <div class="tablenav <?php echo esc_attr($which); ?>">
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
          * hook prefix ("event-espresso") will be different.
538 538
          */
539 539
         do_action(
540
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
540
+            'AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id,
541 541
             $item,
542 542
             $this->_screen
543 543
         );
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
          *
566 566
          * @var array
567 567
          */
568
-        $columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
568
+        $columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen);
569 569
         return $columns;
570 570
     }
571 571
 
@@ -599,13 +599,13 @@  discard block
 block discarded – undo
599 599
         foreach ($views as $view) {
600 600
             $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
601 601
             if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
602
-                $assembled_views[$view['slug']] = "\t<li class='" . $view['class'] . "'>"
603
-                                                  . '<a href="' . $view['url'] . '">' . $view['label'] . '</a>'
604
-                                                  . ' <span class="count">(' . $count . ')</span>';
602
+                $assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>"
603
+                                                  . '<a href="'.$view['url'].'">'.$view['label'].'</a>'
604
+                                                  . ' <span class="count">('.$count.')</span>';
605 605
             }
606 606
         }
607 607
 
608
-        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
608
+        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : '';
609 609
         echo "</ul>";
610 610
     }
611 611
 
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
     public function single_row($item)
621 621
     {
622 622
         $row_class = $this->_get_row_class($item);
623
-        echo '<tr class="' . esc_attr($row_class) . '">';
623
+        echo '<tr class="'.esc_attr($row_class).'">';
624 624
         $this->single_row_columns($item);
625 625
         echo '</tr>';
626 626
     }
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 
641 641
         $new_row_class = $row_class;
642 642
 
643
-        if (! empty($this->_ajax_sorting_callback)) {
643
+        if ( ! empty($this->_ajax_sorting_callback)) {
644 644
             $new_row_class .= ' rowsortable';
645 645
         }
646 646
 
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
      */
654 654
     public function get_sortable_columns()
655 655
     {
656
-        return (array)$this->_sortable_columns;
656
+        return (array) $this->_sortable_columns;
657 657
     }
658 658
 
659 659
 
@@ -672,12 +672,12 @@  discard block
 block discarded – undo
672 672
     public function get_hidden_columns()
673 673
     {
674 674
         $user_id     = get_current_user_id();
675
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
675
+        $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id);
676 676
         if (empty($has_default) && ! empty($this->_hidden_columns)) {
677
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
678
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
677
+            update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', true);
678
+            update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, true);
679 679
         }
680
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
680
+        $ref = 'manage'.$this->screen->id.'columnshidden';
681 681
         return (array) get_user_option($ref, $user_id);
682 682
     }
683 683
 
@@ -706,12 +706,12 @@  discard block
 block discarded – undo
706 706
             $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
707 707
             $style        = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
708 708
 
709
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
709
+            $classes = $column_name.' column-'.$column_name.$hidden_class;
710 710
             if ($primary === $column_name) {
711 711
                 $classes .= ' has-row-actions column-primary';
712 712
             }
713 713
 
714
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
714
+            $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"';
715 715
 
716 716
             $class = "class='$classes'";
717 717
 
@@ -726,11 +726,11 @@  discard block
 block discarded – undo
726 726
                     $this
727 727
                 );
728 728
                 echo '</th>';
729
-            } elseif (method_exists($this, 'column_' . $column_name)) {
729
+            } elseif (method_exists($this, 'column_'.$column_name)) {
730 730
                 echo "<td $attributes>";
731 731
                 echo apply_filters(
732
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
733
-                    call_user_func(array($this, 'column_' . $column_name), $item),
732
+                    'FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content',
733
+                    call_user_func(array($this, 'column_'.$column_name), $item),
734 734
                     $item,
735 735
                     $this
736 736
                 );
@@ -846,9 +846,9 @@  discard block
 block discarded – undo
846 846
         $action_id = ''
847 847
     ) {
848 848
         $content      = '';
849
-        $action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
850
-        $action_id    = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
851
-        $content      .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
849
+        $action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : '';
850
+        $action_id    = ! empty($action_id) ? ' id="'.$action_id.'"' : '';
851
+        $content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : '';
852 852
         try {
853 853
             $content .= apply_filters(
854 854
                 'FHEE__EE_Admin_List_Table___action_string__action_items',
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
             }
863 863
             $content .= $action_items;
864 864
         }
865
-        $content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
865
+        $content .= ! empty($action_container) ? '</'.$action_container.'>' : '';
866 866
         return $content;
867 867
     }
868 868
 }
Please login to merge, or discard this patch.
core/services/shortcodes/LegacyShortcodesManager.php 1 patch
Indentation   +423 added lines, -423 removed lines patch added patch discarded remove patch
@@ -25,429 +25,429 @@
 block discarded – undo
25 25
 class LegacyShortcodesManager
26 26
 {
27 27
 
28
-    /**
29
-     * @var EE_Registry $registry
30
-     */
31
-    private $registry;
32
-
33
-
34
-
35
-
36
-    /**
37
-     * LegacyShortcodesManager constructor.
38
-     *
39
-     * @param \EE_Registry $registry
40
-     */
41
-    public function __construct(EE_Registry $registry)
42
-    {
43
-        $this->registry = $registry;
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * @return EE_Registry
50
-     */
51
-    public function registry()
52
-    {
53
-        return $this->registry;
54
-    }
55
-
56
-
57
-
58
-    /**
59
-     * registerShortcodes
60
-     *
61
-     * @return void
62
-     */
63
-    public function registerShortcodes()
64
-    {
65
-        $this->registry->shortcodes = $this->getShortcodes();
66
-    }
67
-
68
-
69
-
70
-    /**
71
-     * getShortcodes
72
-     *
73
-     * @return array
74
-     */
75
-    public function getShortcodes()
76
-    {
77
-        // previously this method would glob the shortcodes directory
78
-        // then filter that list of shortcodes to register,
79
-        // but now we are going to just supply an empty array.
80
-        // this allows any shortcodes that have not yet been converted to the new system
81
-        // to still get loaded and processed, albeit using the same legacy logic as before
82
-        $shortcodes_to_register = apply_filters(
83
-            'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
84
-            array()
85
-        );
86
-        if ( ! empty($shortcodes_to_register)) {
87
-            // cycle thru shortcode folders
88
-            foreach ($shortcodes_to_register as $shortcode_path) {
89
-                // add to list of installed shortcode modules
90
-                $this->registerShortcode($shortcode_path);
91
-            }
92
-        }
93
-        // filter list of installed modules
94
-        return apply_filters(
95
-            'FHEE__EE_Config___register_shortcodes__installed_shortcodes',
96
-            ! empty($this->registry->shortcodes)
97
-                ? $this->registry->shortcodes
98
-                : array()
99
-        );
100
-    }
101
-
102
-
103
-
104
-    /**
105
-     *    register_shortcode - makes core aware of this shortcode
106
-     *
107
-     * @access    public
108
-     * @param    string $shortcode_path - full path up to and including shortcode folder
109
-     * @return    bool
110
-     */
111
-    public function registerShortcode($shortcode_path = null)
112
-    {
113
-        do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
114
-        $shortcode_ext = '.shortcode.php';
115
-        // make all separators match
116
-        $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path);
117
-        // does the file path INCLUDE the actual file name as part of the path ?
118
-        if (strpos($shortcode_path, $shortcode_ext) !== false) {
119
-            // grab shortcode file name from directory name and break apart at dots
120
-            $shortcode_file = explode('.', basename($shortcode_path));
121
-            // take first segment from file name pieces and remove class prefix if it exists
122
-            $shortcode = strpos($shortcode_file[0], 'EES_') === 0
123
-                ? substr($shortcode_file[0], 4)
124
-                : $shortcode_file[0];
125
-            // sanitize shortcode directory name
126
-            $shortcode = sanitize_key($shortcode);
127
-            // now we need to rebuild the shortcode path
128
-            $shortcode_path = explode(DS, $shortcode_path);
129
-            // remove last segment
130
-            array_pop($shortcode_path);
131
-            // glue it back together
132
-            $shortcode_path = implode(DS, $shortcode_path) . DS;
133
-        } else {
134
-            // we need to generate the filename based off of the folder name
135
-            // grab and sanitize shortcode directory name
136
-            $shortcode = sanitize_key(basename($shortcode_path));
137
-            $shortcode_path = rtrim($shortcode_path, DS) . DS;
138
-        }
139
-        // create classname from shortcode directory or file name
140
-        $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
141
-        // add class prefix
142
-        $shortcode_class = 'EES_' . $shortcode;
143
-        // does the shortcode exist ?
144
-        if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) {
145
-            $msg = sprintf(
146
-                esc_html__(
147
-                    'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s',
148
-                    'event_espresso'
149
-                ),
150
-                $shortcode_class,
151
-                $shortcode_path . DS . $shortcode_class . $shortcode_ext
152
-            );
153
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
154
-            return false;
155
-        }
156
-        // load the shortcode class file
157
-        require_once($shortcode_path . $shortcode_class . $shortcode_ext);
158
-        // verify that class exists
159
-        if ( ! class_exists($shortcode_class)) {
160
-            $msg = sprintf(
161
-                esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'),
162
-                $shortcode_class
163
-            );
164
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
165
-            return false;
166
-        }
167
-        $shortcode = strtoupper($shortcode);
168
-        // add to array of registered shortcodes
169
-        $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
170
-        return true;
171
-    }
172
-
173
-
174
-
175
-    /**
176
-     *    _initialize_shortcodes
177
-     *    allow shortcodes to set hooks for the rest of the system
178
-     *
179
-     * @access private
180
-     * @return void
181
-     */
182
-    public function addShortcodes()
183
-    {
184
-        // cycle thru shortcode folders
185
-        foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) {
186
-            // add class prefix
187
-            $shortcode_class = 'EES_' . $shortcode;
188
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
189
-            // which set hooks ?
190
-            if (is_admin()) {
191
-                // fire immediately
192
-                call_user_func(array($shortcode_class, 'set_hooks_admin'));
193
-            } else {
194
-                // delay until other systems are online
195
-                add_action(
196
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
197
-                    array($shortcode_class, 'set_hooks')
198
-                );
199
-                // convert classname to UPPERCASE and create WP shortcode.
200
-                $shortcode_tag = strtoupper($shortcode);
201
-                // but first check if the shortcode has already
202
-                // been added before assigning 'fallback_shortcode_processor'
203
-                if ( ! shortcode_exists($shortcode_tag)) {
204
-                    // NOTE: this shortcode declaration will get overridden if the shortcode
205
-                    // is successfully detected in the post content in initializeShortcode()
206
-                    add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
207
-                }
208
-            }
209
-        }
210
-    }
211
-
212
-
213
-
214
-    /**
215
-     * callback for the WP "get_header" hook point
216
-     * checks posts for EE shortcodes, and initializes them,
217
-     * then toggles filter switch that loads core default assets
218
-     *
219
-     * @param \WP_Query $wp_query
220
-     * @return void
221
-     */
222
-    public function initializeShortcodes(WP_Query $wp_query)
223
-    {
224
-        if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) {
225
-            return;
226
-        }
227
-        global $wp;
228
-        /** @var EE_Front_controller $Front_Controller */
229
-        $Front_Controller = $this->registry->load_core('Front_Controller', array(), false);
230
-        do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller);
231
-        $Front_Controller->Request_Handler()->set_request_vars();
232
-        // grab post_name from request
233
-        $current_post = apply_filters(
234
-            'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name',
235
-            $Front_Controller->Request_Handler()->get('post_name')
236
-        );
237
-        $show_on_front = get_option('show_on_front');
238
-        // if it's not set, then check if frontpage is blog
239
-        if (empty($current_post)) {
240
-            // yup.. this is the posts page, prepare to load all shortcode modules
241
-            $current_post = 'posts';
242
-            // unless..
243
-            if ($show_on_front === 'page') {
244
-                // some other page is set as the homepage
245
-                $page_on_front = get_option('page_on_front');
246
-                if ($page_on_front) {
247
-                    // k now we need to find the post_name for this page
248
-                    global $wpdb;
249
-                    $page_on_front = $wpdb->get_var(
250
-                        $wpdb->prepare(
251
-                            "SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d",
252
-                            $page_on_front
253
-                        )
254
-                    );
255
-                    // set the current post slug to what it actually is
256
-                    $current_post = $page_on_front ? $page_on_front : $current_post;
257
-                }
258
-            }
259
-        }
260
-        // in case $current_post is hierarchical like: /parent-page/current-page
261
-        $current_post = basename($current_post);
262
-        if (
263
-            // is current page/post the "blog" page ?
264
-            $current_post === EE_Config::get_page_for_posts()
265
-            // or are we on a category page?
266
-            || (
267
-                is_array(term_exists($current_post, 'category'))
268
-                || array_key_exists('category_name', $wp->query_vars)
269
-            )
270
-        ) {
271
-            // initialize all legacy shortcodes
272
-            $load_assets = $this->parseContentForShortcodes('', true);
273
-        } else {
274
-            global $wpdb;
275
-            $post_content = $wpdb->get_var(
276
-                $wpdb->prepare(
277
-                    "SELECT post_content from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s",
278
-                    $current_post
279
-                )
280
-            );
281
-            $load_assets = $this->parseContentForShortcodes($post_content);
282
-        }
283
-        if ($load_assets) {
284
-            $this->registry->REQ->set_espresso_page(true);
285
-            add_filter('FHEE_load_css', '__return_true');
286
-            add_filter('FHEE_load_js', '__return_true');
287
-        }
288
-        do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller);
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * checks supplied content against list of legacy shortcodes,
295
-     * then initializes any found shortcodes, and returns true.
296
-     * returns false if no shortcodes found.
297
-     *
298
-     * @param string $content
299
-     * @param bool   $load_all if true, then ALL active legacy shortcodes will be initialized
300
-     * @return bool
301
-     */
302
-    public function parseContentForShortcodes($content = '', $load_all = false)
303
-    {
304
-        $has_shortcode = false;
305
-        foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) {
306
-            if ($load_all || has_shortcode($content, $shortcode_class) ) {
307
-                // load up the shortcode
308
-                $this->initializeShortcode($shortcode_class);
309
-                $has_shortcode = true;
310
-            }
311
-        }
312
-        return $has_shortcode;
313
-    }
314
-
315
-
316
-
317
-    /**
318
-     * given a shortcode name, will instantiate the shortcode and call it's run() method
319
-     *
320
-     * @param string $shortcode_class
321
-     * @param WP     $wp
322
-     */
323
-    public function initializeShortcode($shortcode_class = '', WP $wp = null)
324
-    {
325
-        // don't do anything if shortcode is already initialized
326
-        if (
327
-            empty($this->registry->shortcodes->{$shortcode_class})
328
-            || ! is_string($this->registry->shortcodes->{$shortcode_class})
329
-        ) {
330
-            return;
331
-        }
332
-        // let's pause to reflect on this...
333
-        $sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class));
334
-        // ensure that class is actually a shortcode
335
-        if (
336
-            defined('WP_DEBUG')
337
-            && WP_DEBUG === true
338
-            && ! $sc_reflector->isSubclassOf('EES_Shortcode')
339
-        ) {
340
-            EE_Error::add_error(
341
-                sprintf(
342
-                    esc_html__(
343
-                        'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.',
344
-                        'event_espresso'
345
-                    ),
346
-                    $shortcode_class
347
-                ),
348
-                __FILE__,
349
-                __FUNCTION__,
350
-                __LINE__
351
-            );
352
-            add_filter('FHEE_run_EE_the_content', '__return_true');
353
-            return;
354
-        }
355
-        global $wp;
356
-        // and pass the request object to the run method
357
-        $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance();
358
-        // fire the shortcode class's run method, so that it can activate resources
359
-        $this->registry->shortcodes->{$shortcode_class}->run($wp);
360
-    }
361
-
362
-
363
-
364
-    /**
365
-     * get classname, remove EES_prefix, and convert to UPPERCASE
366
-     *
367
-     * @param string $class_name
368
-     * @return string
369
-     */
370
-    public static function generateShortcodeTagFromClassName($class_name)
371
-    {
372
-        return strtoupper(str_replace('EES_', '', $class_name));
373
-    }
374
-
375
-
376
-
377
-    /**
378
-     * add EES_prefix and Capitalize words
379
-     *
380
-     * @param string $tag
381
-     * @return string
382
-     */
383
-    public static function generateShortcodeClassNameFromTag($tag)
384
-    {
385
-        // order of operation runs from inside to out
386
-        // 5) maybe add prefix
387
-        return LegacyShortcodesManager::addShortcodeClassPrefix(
388
-        // 4) find spaces, replace with underscores
389
-            str_replace(
390
-                ' ',
391
-                '_',
392
-                // 3) capitalize first letter of each word
393
-                ucwords(
394
-                // 2) also change to lowercase so ucwords() will work
395
-                    strtolower(
396
-                    // 1) find underscores, replace with spaces so ucwords() will work
397
-                        str_replace(
398
-                            '_',
399
-                            ' ',
400
-                            $tag
401
-                        )
402
-                    )
403
-                )
404
-            )
405
-        );
406
-    }
407
-
408
-
409
-
410
-    /**
411
-     * maybe add EES_prefix
412
-     *
413
-     * @param string $class_name
414
-     * @return string
415
-     */
416
-    public static function addShortcodeClassPrefix($class_name)
417
-    {
418
-        return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name;
419
-    }
420
-
421
-
422
-
423
-    /**
424
-     * @return array
425
-     */
426
-    public function getEspressoShortcodeTags()
427
-    {
428
-        static $shortcode_tags = array();
429
-        if (empty($shortcode_tags)) {
430
-            $shortcode_tags = array_keys((array)$this->registry->shortcodes);
431
-        }
432
-        return $shortcode_tags;
433
-    }
434
-
435
-
436
-
437
-    /**
438
-     * @param string $content
439
-     * @return string
440
-     */
441
-    public function doShortcode($content)
442
-    {
443
-        foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) {
444
-            if (strpos($content, $shortcode_tag) !== false) {
445
-                $shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag);
446
-                $this->initializeShortcode($shortcode_class);
447
-            }
448
-        }
449
-        return do_shortcode($content);
450
-    }
28
+	/**
29
+	 * @var EE_Registry $registry
30
+	 */
31
+	private $registry;
32
+
33
+
34
+
35
+
36
+	/**
37
+	 * LegacyShortcodesManager constructor.
38
+	 *
39
+	 * @param \EE_Registry $registry
40
+	 */
41
+	public function __construct(EE_Registry $registry)
42
+	{
43
+		$this->registry = $registry;
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * @return EE_Registry
50
+	 */
51
+	public function registry()
52
+	{
53
+		return $this->registry;
54
+	}
55
+
56
+
57
+
58
+	/**
59
+	 * registerShortcodes
60
+	 *
61
+	 * @return void
62
+	 */
63
+	public function registerShortcodes()
64
+	{
65
+		$this->registry->shortcodes = $this->getShortcodes();
66
+	}
67
+
68
+
69
+
70
+	/**
71
+	 * getShortcodes
72
+	 *
73
+	 * @return array
74
+	 */
75
+	public function getShortcodes()
76
+	{
77
+		// previously this method would glob the shortcodes directory
78
+		// then filter that list of shortcodes to register,
79
+		// but now we are going to just supply an empty array.
80
+		// this allows any shortcodes that have not yet been converted to the new system
81
+		// to still get loaded and processed, albeit using the same legacy logic as before
82
+		$shortcodes_to_register = apply_filters(
83
+			'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
84
+			array()
85
+		);
86
+		if ( ! empty($shortcodes_to_register)) {
87
+			// cycle thru shortcode folders
88
+			foreach ($shortcodes_to_register as $shortcode_path) {
89
+				// add to list of installed shortcode modules
90
+				$this->registerShortcode($shortcode_path);
91
+			}
92
+		}
93
+		// filter list of installed modules
94
+		return apply_filters(
95
+			'FHEE__EE_Config___register_shortcodes__installed_shortcodes',
96
+			! empty($this->registry->shortcodes)
97
+				? $this->registry->shortcodes
98
+				: array()
99
+		);
100
+	}
101
+
102
+
103
+
104
+	/**
105
+	 *    register_shortcode - makes core aware of this shortcode
106
+	 *
107
+	 * @access    public
108
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
109
+	 * @return    bool
110
+	 */
111
+	public function registerShortcode($shortcode_path = null)
112
+	{
113
+		do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
114
+		$shortcode_ext = '.shortcode.php';
115
+		// make all separators match
116
+		$shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path);
117
+		// does the file path INCLUDE the actual file name as part of the path ?
118
+		if (strpos($shortcode_path, $shortcode_ext) !== false) {
119
+			// grab shortcode file name from directory name and break apart at dots
120
+			$shortcode_file = explode('.', basename($shortcode_path));
121
+			// take first segment from file name pieces and remove class prefix if it exists
122
+			$shortcode = strpos($shortcode_file[0], 'EES_') === 0
123
+				? substr($shortcode_file[0], 4)
124
+				: $shortcode_file[0];
125
+			// sanitize shortcode directory name
126
+			$shortcode = sanitize_key($shortcode);
127
+			// now we need to rebuild the shortcode path
128
+			$shortcode_path = explode(DS, $shortcode_path);
129
+			// remove last segment
130
+			array_pop($shortcode_path);
131
+			// glue it back together
132
+			$shortcode_path = implode(DS, $shortcode_path) . DS;
133
+		} else {
134
+			// we need to generate the filename based off of the folder name
135
+			// grab and sanitize shortcode directory name
136
+			$shortcode = sanitize_key(basename($shortcode_path));
137
+			$shortcode_path = rtrim($shortcode_path, DS) . DS;
138
+		}
139
+		// create classname from shortcode directory or file name
140
+		$shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
141
+		// add class prefix
142
+		$shortcode_class = 'EES_' . $shortcode;
143
+		// does the shortcode exist ?
144
+		if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) {
145
+			$msg = sprintf(
146
+				esc_html__(
147
+					'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s',
148
+					'event_espresso'
149
+				),
150
+				$shortcode_class,
151
+				$shortcode_path . DS . $shortcode_class . $shortcode_ext
152
+			);
153
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
154
+			return false;
155
+		}
156
+		// load the shortcode class file
157
+		require_once($shortcode_path . $shortcode_class . $shortcode_ext);
158
+		// verify that class exists
159
+		if ( ! class_exists($shortcode_class)) {
160
+			$msg = sprintf(
161
+				esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'),
162
+				$shortcode_class
163
+			);
164
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
165
+			return false;
166
+		}
167
+		$shortcode = strtoupper($shortcode);
168
+		// add to array of registered shortcodes
169
+		$this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
170
+		return true;
171
+	}
172
+
173
+
174
+
175
+	/**
176
+	 *    _initialize_shortcodes
177
+	 *    allow shortcodes to set hooks for the rest of the system
178
+	 *
179
+	 * @access private
180
+	 * @return void
181
+	 */
182
+	public function addShortcodes()
183
+	{
184
+		// cycle thru shortcode folders
185
+		foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) {
186
+			// add class prefix
187
+			$shortcode_class = 'EES_' . $shortcode;
188
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
189
+			// which set hooks ?
190
+			if (is_admin()) {
191
+				// fire immediately
192
+				call_user_func(array($shortcode_class, 'set_hooks_admin'));
193
+			} else {
194
+				// delay until other systems are online
195
+				add_action(
196
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
197
+					array($shortcode_class, 'set_hooks')
198
+				);
199
+				// convert classname to UPPERCASE and create WP shortcode.
200
+				$shortcode_tag = strtoupper($shortcode);
201
+				// but first check if the shortcode has already
202
+				// been added before assigning 'fallback_shortcode_processor'
203
+				if ( ! shortcode_exists($shortcode_tag)) {
204
+					// NOTE: this shortcode declaration will get overridden if the shortcode
205
+					// is successfully detected in the post content in initializeShortcode()
206
+					add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
207
+				}
208
+			}
209
+		}
210
+	}
211
+
212
+
213
+
214
+	/**
215
+	 * callback for the WP "get_header" hook point
216
+	 * checks posts for EE shortcodes, and initializes them,
217
+	 * then toggles filter switch that loads core default assets
218
+	 *
219
+	 * @param \WP_Query $wp_query
220
+	 * @return void
221
+	 */
222
+	public function initializeShortcodes(WP_Query $wp_query)
223
+	{
224
+		if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) {
225
+			return;
226
+		}
227
+		global $wp;
228
+		/** @var EE_Front_controller $Front_Controller */
229
+		$Front_Controller = $this->registry->load_core('Front_Controller', array(), false);
230
+		do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller);
231
+		$Front_Controller->Request_Handler()->set_request_vars();
232
+		// grab post_name from request
233
+		$current_post = apply_filters(
234
+			'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name',
235
+			$Front_Controller->Request_Handler()->get('post_name')
236
+		);
237
+		$show_on_front = get_option('show_on_front');
238
+		// if it's not set, then check if frontpage is blog
239
+		if (empty($current_post)) {
240
+			// yup.. this is the posts page, prepare to load all shortcode modules
241
+			$current_post = 'posts';
242
+			// unless..
243
+			if ($show_on_front === 'page') {
244
+				// some other page is set as the homepage
245
+				$page_on_front = get_option('page_on_front');
246
+				if ($page_on_front) {
247
+					// k now we need to find the post_name for this page
248
+					global $wpdb;
249
+					$page_on_front = $wpdb->get_var(
250
+						$wpdb->prepare(
251
+							"SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d",
252
+							$page_on_front
253
+						)
254
+					);
255
+					// set the current post slug to what it actually is
256
+					$current_post = $page_on_front ? $page_on_front : $current_post;
257
+				}
258
+			}
259
+		}
260
+		// in case $current_post is hierarchical like: /parent-page/current-page
261
+		$current_post = basename($current_post);
262
+		if (
263
+			// is current page/post the "blog" page ?
264
+			$current_post === EE_Config::get_page_for_posts()
265
+			// or are we on a category page?
266
+			|| (
267
+				is_array(term_exists($current_post, 'category'))
268
+				|| array_key_exists('category_name', $wp->query_vars)
269
+			)
270
+		) {
271
+			// initialize all legacy shortcodes
272
+			$load_assets = $this->parseContentForShortcodes('', true);
273
+		} else {
274
+			global $wpdb;
275
+			$post_content = $wpdb->get_var(
276
+				$wpdb->prepare(
277
+					"SELECT post_content from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s",
278
+					$current_post
279
+				)
280
+			);
281
+			$load_assets = $this->parseContentForShortcodes($post_content);
282
+		}
283
+		if ($load_assets) {
284
+			$this->registry->REQ->set_espresso_page(true);
285
+			add_filter('FHEE_load_css', '__return_true');
286
+			add_filter('FHEE_load_js', '__return_true');
287
+		}
288
+		do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller);
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * checks supplied content against list of legacy shortcodes,
295
+	 * then initializes any found shortcodes, and returns true.
296
+	 * returns false if no shortcodes found.
297
+	 *
298
+	 * @param string $content
299
+	 * @param bool   $load_all if true, then ALL active legacy shortcodes will be initialized
300
+	 * @return bool
301
+	 */
302
+	public function parseContentForShortcodes($content = '', $load_all = false)
303
+	{
304
+		$has_shortcode = false;
305
+		foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) {
306
+			if ($load_all || has_shortcode($content, $shortcode_class) ) {
307
+				// load up the shortcode
308
+				$this->initializeShortcode($shortcode_class);
309
+				$has_shortcode = true;
310
+			}
311
+		}
312
+		return $has_shortcode;
313
+	}
314
+
315
+
316
+
317
+	/**
318
+	 * given a shortcode name, will instantiate the shortcode and call it's run() method
319
+	 *
320
+	 * @param string $shortcode_class
321
+	 * @param WP     $wp
322
+	 */
323
+	public function initializeShortcode($shortcode_class = '', WP $wp = null)
324
+	{
325
+		// don't do anything if shortcode is already initialized
326
+		if (
327
+			empty($this->registry->shortcodes->{$shortcode_class})
328
+			|| ! is_string($this->registry->shortcodes->{$shortcode_class})
329
+		) {
330
+			return;
331
+		}
332
+		// let's pause to reflect on this...
333
+		$sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class));
334
+		// ensure that class is actually a shortcode
335
+		if (
336
+			defined('WP_DEBUG')
337
+			&& WP_DEBUG === true
338
+			&& ! $sc_reflector->isSubclassOf('EES_Shortcode')
339
+		) {
340
+			EE_Error::add_error(
341
+				sprintf(
342
+					esc_html__(
343
+						'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.',
344
+						'event_espresso'
345
+					),
346
+					$shortcode_class
347
+				),
348
+				__FILE__,
349
+				__FUNCTION__,
350
+				__LINE__
351
+			);
352
+			add_filter('FHEE_run_EE_the_content', '__return_true');
353
+			return;
354
+		}
355
+		global $wp;
356
+		// and pass the request object to the run method
357
+		$this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance();
358
+		// fire the shortcode class's run method, so that it can activate resources
359
+		$this->registry->shortcodes->{$shortcode_class}->run($wp);
360
+	}
361
+
362
+
363
+
364
+	/**
365
+	 * get classname, remove EES_prefix, and convert to UPPERCASE
366
+	 *
367
+	 * @param string $class_name
368
+	 * @return string
369
+	 */
370
+	public static function generateShortcodeTagFromClassName($class_name)
371
+	{
372
+		return strtoupper(str_replace('EES_', '', $class_name));
373
+	}
374
+
375
+
376
+
377
+	/**
378
+	 * add EES_prefix and Capitalize words
379
+	 *
380
+	 * @param string $tag
381
+	 * @return string
382
+	 */
383
+	public static function generateShortcodeClassNameFromTag($tag)
384
+	{
385
+		// order of operation runs from inside to out
386
+		// 5) maybe add prefix
387
+		return LegacyShortcodesManager::addShortcodeClassPrefix(
388
+		// 4) find spaces, replace with underscores
389
+			str_replace(
390
+				' ',
391
+				'_',
392
+				// 3) capitalize first letter of each word
393
+				ucwords(
394
+				// 2) also change to lowercase so ucwords() will work
395
+					strtolower(
396
+					// 1) find underscores, replace with spaces so ucwords() will work
397
+						str_replace(
398
+							'_',
399
+							' ',
400
+							$tag
401
+						)
402
+					)
403
+				)
404
+			)
405
+		);
406
+	}
407
+
408
+
409
+
410
+	/**
411
+	 * maybe add EES_prefix
412
+	 *
413
+	 * @param string $class_name
414
+	 * @return string
415
+	 */
416
+	public static function addShortcodeClassPrefix($class_name)
417
+	{
418
+		return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name;
419
+	}
420
+
421
+
422
+
423
+	/**
424
+	 * @return array
425
+	 */
426
+	public function getEspressoShortcodeTags()
427
+	{
428
+		static $shortcode_tags = array();
429
+		if (empty($shortcode_tags)) {
430
+			$shortcode_tags = array_keys((array)$this->registry->shortcodes);
431
+		}
432
+		return $shortcode_tags;
433
+	}
434
+
435
+
436
+
437
+	/**
438
+	 * @param string $content
439
+	 * @return string
440
+	 */
441
+	public function doShortcode($content)
442
+	{
443
+		foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) {
444
+			if (strpos($content, $shortcode_tag) !== false) {
445
+				$shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag);
446
+				$this->initializeShortcode($shortcode_class);
447
+			}
448
+		}
449
+		return do_shortcode($content);
450
+	}
451 451
 
452 452
 
453 453
 
Please login to merge, or discard this patch.
admin/extend/messages/espresso_events_Messages_Hooks_Extend.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@
 block discarded – undo
98 98
      *
99 99
      * @param  EE_Event $event EE event object
100 100
      * @param  array    $data  The request data from the form
101
-     * @return bool success or fail
101
+     * @return integer success or fail
102 102
      * @throws EE_Error
103 103
      */
104 104
     public function attach_evt_message_templates($event, $data)
Please login to merge, or discard this patch.
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -14,276 +14,276 @@
 block discarded – undo
14 14
  */
15 15
 class espresso_events_Messages_Hooks_Extend extends espresso_events_Messages_Hooks
16 16
 {
17
-    /**
18
-     * espresso_events_Messages_Hooks_Extend constructor.
19
-     *
20
-     * @param \EE_Admin_Page $admin_page
21
-     */
22
-    public function __construct(EE_Admin_Page $admin_page)
23
-    {
24
-        /**
25
-         * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages
26
-         */
27
-        if (! EE_Registry::instance()->CAP->current_user_can(
28
-            'ee_edit_messages',
29
-            'messages_events_editor_metabox'
30
-        )) {
31
-            return;
32
-        }
33
-        add_filter(
34
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
35
-            array($this, 'caf_updates'),
36
-            10
37
-        );
38
-        add_action(
39
-            'AHEE__Extend_Events_Admin_Page___duplicate_event__after',
40
-            array($this, 'duplicate_custom_message_settings'),
41
-            10,
42
-            2
43
-        );
44
-        parent::__construct($admin_page);
45
-    }
46
-
47
-
48
-    /**
49
-     * extending the properties set in espresso_events_Messages_Hooks
50
-     *
51
-     * @access protected
52
-     * @return void
53
-     */
54
-    protected function _extend_properties()
55
-    {
56
-        define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/');
57
-        $this->_ajax_func = array(
58
-            'ee_msgs_create_new_custom' => 'create_new_custom',
59
-        );
60
-        $this->_metaboxes = array(
61
-            0 => array(
62
-                'page_route' => array('edit', 'create_new'),
63
-                'func'       => 'messages_metabox',
64
-                'label'      => esc_html__('Notifications', 'event_espresso'),
65
-                'priority'   => 'high',
66
-            ),
67
-        );
68
-
69
-        //see explanation for layout in EE_Admin_Hooks
70
-        $this->_scripts_styles = array(
71
-            'registers' => array(
72
-                'events_msg_admin'     => array(
73
-                    'url'     => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js',
74
-                    'depends' => array('ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'),
75
-                ),
76
-                'events_msg_admin_css' => array(
77
-                    'url'  => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css',
78
-                    'type' => 'css',
79
-                ),
80
-            ),
81
-            'enqueues'  => array(
82
-                'events_msg_admin'     => array('edit', 'create_new'),
83
-                'events_msg_admin_css' => array('edit', 'create_new'),
84
-            ),
85
-        );
86
-    }
87
-
88
-
89
-    public function caf_updates($update_callbacks)
90
-    {
91
-        $update_callbacks[] = array($this, 'attach_evt_message_templates');
92
-        return $update_callbacks;
93
-    }
94
-
95
-
96
-    /**
97
-     * Handles attaching Message Templates to the Event on save.
98
-     *
99
-     * @param  EE_Event $event EE event object
100
-     * @param  array    $data  The request data from the form
101
-     * @return bool success or fail
102
-     * @throws EE_Error
103
-     */
104
-    public function attach_evt_message_templates($event, $data)
105
-    {
106
-        //first we remove all existing relations on the Event for message types.
107
-        $event->_remove_relations('Message_Template_Group');
108
-        //now let's just loop through the selected templates and add relations!
109
-        if (isset($data['event_message_templates_relation'])) {
110
-            foreach ($data['event_message_templates_relation'] as $grp_ID) {
111
-                $event->_add_relation_to($grp_ID, 'Message_Template_Group');
112
-            }
113
-        }
114
-        //now save
115
-        return $event->save();
116
-    }
117
-
118
-
119
-    /**
120
-     * @param $event
121
-     * @param $callback_args
122
-     * @return string
123
-     * @throws \EE_Error
124
-     */
125
-    public function messages_metabox($event, $callback_args)
126
-    {
127
-        //let's get the active messengers (b/c messenger objects have the active message templates)
128
-        //convert 'evt_id' to 'EVT_ID'
129
-        $this->_req_data['EVT_ID'] = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null;
130
-        $this->_req_data['EVT_ID'] = isset($this->_req_data['post']) && empty($this->_req_data['EVT_ID'])
131
-            ? $this->_req_data['post']
132
-            : $this->_req_data['EVT_ID'];
133
-
134
-        $this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID']) && isset($this->_req_data['evt_id'])
135
-            ? $this->_req_data['evt_id']
136
-            : $this->_req_data['EVT_ID'];
137
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
138
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
139
-        $active_messengers        = $message_resource_manager->active_messengers();
140
-        $tabs                     = array();
141
-
142
-        //empty messengers?
143
-        //Note message types will always have at least one available because every messenger has a default message type
144
-        // associated with it (payment) if no other message types are selected.
145
-        if (empty($active_messengers)) {
146
-            $msg_activate_url = EE_Admin_Page::add_query_args_and_nonce(
147
-                array('action' => 'settings'),
148
-                EE_MSG_ADMIN_URL
149
-            );
150
-            $error_msg        = sprintf(
151
-                esc_html__(
152
-                    'There are no active messengers. So no notifications will go out for %1$sany%2$s events.  You will want to %3$sActivate a Messenger%4$s.',
153
-                    'event_espresso'
154
-                ),
155
-                '<strong>',
156
-                '</strong>',
157
-                '<a href="' . $msg_activate_url . '">',
158
-                '</a>'
159
-            );
160
-            $error_content    = '<div class="error"><p>' . $error_msg . '</p></div>';
161
-            $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>';
162
-
163
-            echo $error_content;
164
-            echo $internal_content;
165
-            return '';
166
-        }
167
-
168
-        $event_id = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null;
169
-        //get content for active messengers
170
-        foreach ($active_messengers as $name => $messenger) {
171
-            //first check if there are any active message types for this messenger.
172
-            $active_mts = $message_resource_manager->get_active_message_types_for_messenger($name);
173
-            if (empty($active_mts)) {
174
-                continue;
175
-            }
176
-
177
-            $tab_content = $messenger->get_messenger_admin_page_content(
178
-                'events',
179
-                'edit',
180
-                array('event' => $event_id)
181
-            );
182
-
183
-            if (! empty($tab_content)) {
184
-                $tabs[$name] = $tab_content;
185
-            }
186
-        }
187
-
188
-
189
-        //we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper.
190
-        $tabbed_content = EEH_Tabbed_Content::display($tabs);
191
-        if ($tabbed_content instanceof WP_Error) {
192
-            $tabbed_content = $tabbed_content->get_error_message();
193
-        }
194
-
195
-        $notices = '
17
+	/**
18
+	 * espresso_events_Messages_Hooks_Extend constructor.
19
+	 *
20
+	 * @param \EE_Admin_Page $admin_page
21
+	 */
22
+	public function __construct(EE_Admin_Page $admin_page)
23
+	{
24
+		/**
25
+		 * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages
26
+		 */
27
+		if (! EE_Registry::instance()->CAP->current_user_can(
28
+			'ee_edit_messages',
29
+			'messages_events_editor_metabox'
30
+		)) {
31
+			return;
32
+		}
33
+		add_filter(
34
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
35
+			array($this, 'caf_updates'),
36
+			10
37
+		);
38
+		add_action(
39
+			'AHEE__Extend_Events_Admin_Page___duplicate_event__after',
40
+			array($this, 'duplicate_custom_message_settings'),
41
+			10,
42
+			2
43
+		);
44
+		parent::__construct($admin_page);
45
+	}
46
+
47
+
48
+	/**
49
+	 * extending the properties set in espresso_events_Messages_Hooks
50
+	 *
51
+	 * @access protected
52
+	 * @return void
53
+	 */
54
+	protected function _extend_properties()
55
+	{
56
+		define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/');
57
+		$this->_ajax_func = array(
58
+			'ee_msgs_create_new_custom' => 'create_new_custom',
59
+		);
60
+		$this->_metaboxes = array(
61
+			0 => array(
62
+				'page_route' => array('edit', 'create_new'),
63
+				'func'       => 'messages_metabox',
64
+				'label'      => esc_html__('Notifications', 'event_espresso'),
65
+				'priority'   => 'high',
66
+			),
67
+		);
68
+
69
+		//see explanation for layout in EE_Admin_Hooks
70
+		$this->_scripts_styles = array(
71
+			'registers' => array(
72
+				'events_msg_admin'     => array(
73
+					'url'     => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js',
74
+					'depends' => array('ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'),
75
+				),
76
+				'events_msg_admin_css' => array(
77
+					'url'  => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css',
78
+					'type' => 'css',
79
+				),
80
+			),
81
+			'enqueues'  => array(
82
+				'events_msg_admin'     => array('edit', 'create_new'),
83
+				'events_msg_admin_css' => array('edit', 'create_new'),
84
+			),
85
+		);
86
+	}
87
+
88
+
89
+	public function caf_updates($update_callbacks)
90
+	{
91
+		$update_callbacks[] = array($this, 'attach_evt_message_templates');
92
+		return $update_callbacks;
93
+	}
94
+
95
+
96
+	/**
97
+	 * Handles attaching Message Templates to the Event on save.
98
+	 *
99
+	 * @param  EE_Event $event EE event object
100
+	 * @param  array    $data  The request data from the form
101
+	 * @return bool success or fail
102
+	 * @throws EE_Error
103
+	 */
104
+	public function attach_evt_message_templates($event, $data)
105
+	{
106
+		//first we remove all existing relations on the Event for message types.
107
+		$event->_remove_relations('Message_Template_Group');
108
+		//now let's just loop through the selected templates and add relations!
109
+		if (isset($data['event_message_templates_relation'])) {
110
+			foreach ($data['event_message_templates_relation'] as $grp_ID) {
111
+				$event->_add_relation_to($grp_ID, 'Message_Template_Group');
112
+			}
113
+		}
114
+		//now save
115
+		return $event->save();
116
+	}
117
+
118
+
119
+	/**
120
+	 * @param $event
121
+	 * @param $callback_args
122
+	 * @return string
123
+	 * @throws \EE_Error
124
+	 */
125
+	public function messages_metabox($event, $callback_args)
126
+	{
127
+		//let's get the active messengers (b/c messenger objects have the active message templates)
128
+		//convert 'evt_id' to 'EVT_ID'
129
+		$this->_req_data['EVT_ID'] = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null;
130
+		$this->_req_data['EVT_ID'] = isset($this->_req_data['post']) && empty($this->_req_data['EVT_ID'])
131
+			? $this->_req_data['post']
132
+			: $this->_req_data['EVT_ID'];
133
+
134
+		$this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID']) && isset($this->_req_data['evt_id'])
135
+			? $this->_req_data['evt_id']
136
+			: $this->_req_data['EVT_ID'];
137
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
138
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
139
+		$active_messengers        = $message_resource_manager->active_messengers();
140
+		$tabs                     = array();
141
+
142
+		//empty messengers?
143
+		//Note message types will always have at least one available because every messenger has a default message type
144
+		// associated with it (payment) if no other message types are selected.
145
+		if (empty($active_messengers)) {
146
+			$msg_activate_url = EE_Admin_Page::add_query_args_and_nonce(
147
+				array('action' => 'settings'),
148
+				EE_MSG_ADMIN_URL
149
+			);
150
+			$error_msg        = sprintf(
151
+				esc_html__(
152
+					'There are no active messengers. So no notifications will go out for %1$sany%2$s events.  You will want to %3$sActivate a Messenger%4$s.',
153
+					'event_espresso'
154
+				),
155
+				'<strong>',
156
+				'</strong>',
157
+				'<a href="' . $msg_activate_url . '">',
158
+				'</a>'
159
+			);
160
+			$error_content    = '<div class="error"><p>' . $error_msg . '</p></div>';
161
+			$internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>';
162
+
163
+			echo $error_content;
164
+			echo $internal_content;
165
+			return '';
166
+		}
167
+
168
+		$event_id = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null;
169
+		//get content for active messengers
170
+		foreach ($active_messengers as $name => $messenger) {
171
+			//first check if there are any active message types for this messenger.
172
+			$active_mts = $message_resource_manager->get_active_message_types_for_messenger($name);
173
+			if (empty($active_mts)) {
174
+				continue;
175
+			}
176
+
177
+			$tab_content = $messenger->get_messenger_admin_page_content(
178
+				'events',
179
+				'edit',
180
+				array('event' => $event_id)
181
+			);
182
+
183
+			if (! empty($tab_content)) {
184
+				$tabs[$name] = $tab_content;
185
+			}
186
+		}
187
+
188
+
189
+		//we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper.
190
+		$tabbed_content = EEH_Tabbed_Content::display($tabs);
191
+		if ($tabbed_content instanceof WP_Error) {
192
+			$tabbed_content = $tabbed_content->get_error_message();
193
+		}
194
+
195
+		$notices = '
196 196
 	<div id="espresso-ajax-loading" class="ajax-loader-grey">
197 197
 		<span class="ee-spinner ee-spin"></span><span class="hidden">'
198
-        . esc_html__('loading...', 'event_espresso')
199
-        . '</span>
198
+		. esc_html__('loading...', 'event_espresso')
199
+		. '</span>
200 200
 	</div>
201 201
 	<div class="ee-notices"></div>';
202 202
 
203
-        if (defined('DOING_AJAX')) {
204
-            return $tabbed_content;
205
-        }
206
-
207
-        do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content');
208
-        echo $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>';
209
-        do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content');
210
-    }
211
-
212
-
213
-    /**
214
-     * Ajax callback for ee_msgs_create_new_custom ajax request.
215
-     * Takes incoming GRP_ID and name and description values from ajax request
216
-     * to create a new custom template based off of the incoming GRP_ID.
217
-     *
218
-     * @access public
219
-     * @return string either an html string will be returned or a success message
220
-     * @throws EE_Error
221
-     */
222
-    public function create_new_custom()
223
-    {
224
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) {
225
-            wp_die(__('You don\'t have privileges to do this action', 'event_espresso'));
226
-        }
227
-
228
-        //let's clean up the _POST global a bit for downstream usage of name and description.
229
-        $_POST['templateName']        = ! empty($this->_req_data['custom_template_args']['MTP_name'])
230
-            ? $this->_req_data['custom_template_args']['MTP_name']
231
-            : '';
232
-        $_POST['templateDescription'] = ! empty($this->_req_data['custom_template_args']['MTP_description'])
233
-            ? $this->_req_data['custom_template_args']['MTP_description']
234
-            : '';
235
-
236
-
237
-        // set EE_Admin_Page object (see method details in EE_Admin_Hooks parent
238
-        $this->_set_page_object();
239
-
240
-        // is this a template switch if so EE_Admin_Page child needs this object
241
-        $this->_page_object->set_hook_object($this);
242
-
243
-        $this->_page_object->add_message_template(
244
-            $this->_req_data['messageType'],
245
-            $this->_req_data['messenger'],
246
-            $this->_req_data['group_ID']
247
-        );
248
-    }
249
-
250
-
251
-    public function create_new_admin_footer()
252
-    {
253
-        $this->edit_admin_footer();
254
-    }
255
-
256
-
257
-    /**
258
-     * This is the dynamic method for this class
259
-     * that will end up hooking into the 'admin_footer' hook on the 'edit_event' route in the events page.
260
-     *
261
-     * @return string
262
-     * @throws DomainException
263
-     */
264
-    public function edit_admin_footer()
265
-    {
266
-        EEH_Template::display_template(
267
-            EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php'
268
-        );
269
-    }
270
-
271
-
272
-    /**
273
-     * Callback for AHEE__Extend_Events_Admin_Page___duplicate_event__after hook used to ensure new events duplicate
274
-     * the assigned custom message templates.
275
-     *
276
-     * @param EE_Event $new_event
277
-     * @param EE_Event $original_event
278
-     * @throws EE_Error
279
-     */
280
-    public function duplicate_custom_message_settings(EE_Event $new_event, EE_Event $original_event)
281
-    {
282
-        $message_template_groups = $original_event->get_many_related('Message_Template_Group');
283
-        foreach ($message_template_groups as $message_template_group) {
284
-            $new_event->_add_relation_to($message_template_group, 'Message_Template_Group');
285
-        }
286
-        //save new event
287
-        $new_event->save();
288
-    }
203
+		if (defined('DOING_AJAX')) {
204
+			return $tabbed_content;
205
+		}
206
+
207
+		do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content');
208
+		echo $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>';
209
+		do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content');
210
+	}
211
+
212
+
213
+	/**
214
+	 * Ajax callback for ee_msgs_create_new_custom ajax request.
215
+	 * Takes incoming GRP_ID and name and description values from ajax request
216
+	 * to create a new custom template based off of the incoming GRP_ID.
217
+	 *
218
+	 * @access public
219
+	 * @return string either an html string will be returned or a success message
220
+	 * @throws EE_Error
221
+	 */
222
+	public function create_new_custom()
223
+	{
224
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) {
225
+			wp_die(__('You don\'t have privileges to do this action', 'event_espresso'));
226
+		}
227
+
228
+		//let's clean up the _POST global a bit for downstream usage of name and description.
229
+		$_POST['templateName']        = ! empty($this->_req_data['custom_template_args']['MTP_name'])
230
+			? $this->_req_data['custom_template_args']['MTP_name']
231
+			: '';
232
+		$_POST['templateDescription'] = ! empty($this->_req_data['custom_template_args']['MTP_description'])
233
+			? $this->_req_data['custom_template_args']['MTP_description']
234
+			: '';
235
+
236
+
237
+		// set EE_Admin_Page object (see method details in EE_Admin_Hooks parent
238
+		$this->_set_page_object();
239
+
240
+		// is this a template switch if so EE_Admin_Page child needs this object
241
+		$this->_page_object->set_hook_object($this);
242
+
243
+		$this->_page_object->add_message_template(
244
+			$this->_req_data['messageType'],
245
+			$this->_req_data['messenger'],
246
+			$this->_req_data['group_ID']
247
+		);
248
+	}
249
+
250
+
251
+	public function create_new_admin_footer()
252
+	{
253
+		$this->edit_admin_footer();
254
+	}
255
+
256
+
257
+	/**
258
+	 * This is the dynamic method for this class
259
+	 * that will end up hooking into the 'admin_footer' hook on the 'edit_event' route in the events page.
260
+	 *
261
+	 * @return string
262
+	 * @throws DomainException
263
+	 */
264
+	public function edit_admin_footer()
265
+	{
266
+		EEH_Template::display_template(
267
+			EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php'
268
+		);
269
+	}
270
+
271
+
272
+	/**
273
+	 * Callback for AHEE__Extend_Events_Admin_Page___duplicate_event__after hook used to ensure new events duplicate
274
+	 * the assigned custom message templates.
275
+	 *
276
+	 * @param EE_Event $new_event
277
+	 * @param EE_Event $original_event
278
+	 * @throws EE_Error
279
+	 */
280
+	public function duplicate_custom_message_settings(EE_Event $new_event, EE_Event $original_event)
281
+	{
282
+		$message_template_groups = $original_event->get_many_related('Message_Template_Group');
283
+		foreach ($message_template_groups as $message_template_group) {
284
+			$new_event->_add_relation_to($message_template_group, 'Message_Template_Group');
285
+		}
286
+		//save new event
287
+		$new_event->save();
288
+	}
289 289
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         /**
25 25
          * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages
26 26
          */
27
-        if (! EE_Registry::instance()->CAP->current_user_can(
27
+        if ( ! EE_Registry::instance()->CAP->current_user_can(
28 28
             'ee_edit_messages',
29 29
             'messages_events_editor_metabox'
30 30
         )) {
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     protected function _extend_properties()
55 55
     {
56
-        define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/');
56
+        define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'messages/assets/');
57 57
         $this->_ajax_func = array(
58 58
             'ee_msgs_create_new_custom' => 'create_new_custom',
59 59
         );
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
         $this->_scripts_styles = array(
71 71
             'registers' => array(
72 72
                 'events_msg_admin'     => array(
73
-                    'url'     => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js',
73
+                    'url'     => EE_MSGS_EXTEND_ASSETS_URL.'events_messages_admin.js',
74 74
                     'depends' => array('ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array'),
75 75
                 ),
76 76
                 'events_msg_admin_css' => array(
77
-                    'url'  => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css',
77
+                    'url'  => EE_MSGS_EXTEND_ASSETS_URL.'ee_msg_events_admin.css',
78 78
                     'type' => 'css',
79 79
                 ),
80 80
             ),
@@ -147,18 +147,18 @@  discard block
 block discarded – undo
147 147
                 array('action' => 'settings'),
148 148
                 EE_MSG_ADMIN_URL
149 149
             );
150
-            $error_msg        = sprintf(
150
+            $error_msg = sprintf(
151 151
                 esc_html__(
152 152
                     'There are no active messengers. So no notifications will go out for %1$sany%2$s events.  You will want to %3$sActivate a Messenger%4$s.',
153 153
                     'event_espresso'
154 154
                 ),
155 155
                 '<strong>',
156 156
                 '</strong>',
157
-                '<a href="' . $msg_activate_url . '">',
157
+                '<a href="'.$msg_activate_url.'">',
158 158
                 '</a>'
159 159
             );
160
-            $error_content    = '<div class="error"><p>' . $error_msg . '</p></div>';
161
-            $internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>';
160
+            $error_content    = '<div class="error"><p>'.$error_msg.'</p></div>';
161
+            $internal_content = '<div id="messages-error"><p>'.$error_msg.'</p></div>';
162 162
 
163 163
             echo $error_content;
164 164
             echo $internal_content;
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
                 array('event' => $event_id)
181 181
             );
182 182
 
183
-            if (! empty($tab_content)) {
183
+            if ( ! empty($tab_content)) {
184 184
                 $tabs[$name] = $tab_content;
185 185
             }
186 186
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         }
206 206
 
207 207
         do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content');
208
-        echo $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>';
208
+        echo $notices.'<div class="messages-tabs-content">'.$tabbed_content.'</div>';
209 209
         do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content');
210 210
     }
211 211
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function create_new_custom()
223 223
     {
224
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) {
224
+        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) {
225 225
             wp_die(__('You don\'t have privileges to do this action', 'event_espresso'));
226 226
         }
227 227
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     public function edit_admin_footer()
265 265
     {
266 266
         EEH_Template::display_template(
267
-            EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php'
267
+            EE_CORE_CAF_ADMIN_EXTEND.'messages/templates/create_custom_template_form.template.php'
268 268
         );
269 269
     }
270 270
 
Please login to merge, or discard this patch.
core/helpers/EEH_Event_View.helper.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -32,51 +32,51 @@  discard block
 block discarded – undo
32 32
 
33 33
 
34 34
 
35
-    /**
36
-     * get_event
37
-     * attempts to retrieve an EE_Event object any way it can
38
-     *
39
-     * @param int|WP_Post $EVT_ID
40
-     * @return EE_Event|null
41
-     * @throws \EE_Error
42
-     */
43
-    public static function get_event($EVT_ID = 0)
44
-    {
45
-        // international newspaper?
46
-        global $post;
47
-        $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events'
48
-            ? $EVT_ID->ID
49
-            : absint($EVT_ID);
50
-        // do we already have the Event  you are looking for?
51
-        if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
52
-            return EEH_Event_View::$_event;
53
-        }
54
-        //reset property so that the new event is cached.
55
-        EEH_Event_View::$_event = null;
56
-        if (! $EVT_ID && $post instanceof EE_Event) {
57
-            EEH_Event_View::$_event = $post;
58
-            return EEH_Event_View::$_event;
59
-        }
60
-        //if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID
61
-        //then let's just use that cached event on the $post object.
62
-        if (
63
-            $post instanceof WP_Post
64
-            && $post->post_type === 'espresso_events'
65
-            && isset($post->EE_Event)
66
-            && (
67
-                $EVT_ID === 0
68
-                || $EVT_ID === $post->ID
69
-            )
70
-        ) {
71
-            EEH_Event_View::$_event = $post->EE_Event;
72
-            return EEH_Event_View::$_event;
73
-        }
74
-        //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
75
-        if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
76
-            EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
77
-        }
78
-        return EEH_Event_View::$_event;
79
-    }
35
+	/**
36
+	 * get_event
37
+	 * attempts to retrieve an EE_Event object any way it can
38
+	 *
39
+	 * @param int|WP_Post $EVT_ID
40
+	 * @return EE_Event|null
41
+	 * @throws \EE_Error
42
+	 */
43
+	public static function get_event($EVT_ID = 0)
44
+	{
45
+		// international newspaper?
46
+		global $post;
47
+		$EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events'
48
+			? $EVT_ID->ID
49
+			: absint($EVT_ID);
50
+		// do we already have the Event  you are looking for?
51
+		if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
52
+			return EEH_Event_View::$_event;
53
+		}
54
+		//reset property so that the new event is cached.
55
+		EEH_Event_View::$_event = null;
56
+		if (! $EVT_ID && $post instanceof EE_Event) {
57
+			EEH_Event_View::$_event = $post;
58
+			return EEH_Event_View::$_event;
59
+		}
60
+		//if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID
61
+		//then let's just use that cached event on the $post object.
62
+		if (
63
+			$post instanceof WP_Post
64
+			&& $post->post_type === 'espresso_events'
65
+			&& isset($post->EE_Event)
66
+			&& (
67
+				$EVT_ID === 0
68
+				|| $EVT_ID === $post->ID
69
+			)
70
+		) {
71
+			EEH_Event_View::$_event = $post->EE_Event;
72
+			return EEH_Event_View::$_event;
73
+		}
74
+		//If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
75
+		if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
76
+			EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
77
+		}
78
+		return EEH_Event_View::$_event;
79
+	}
80 80
 
81 81
 
82 82
 
@@ -152,58 +152,58 @@  discard block
 block discarded – undo
152 152
 	 * @return    string
153 153
 	 */
154 154
 	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
155
-        global $post;
155
+		global $post;
156 156
 		ob_start();
157 157
 		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
158 158
 			// admin has chosen "full description"
159
-            // for the "Event Espresso - Events > Templates > Display Description" option
159
+			// for the "Event Espresso - Events > Templates > Display Description" option
160 160
 			the_content();
161 161
 		} else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) {
162
-            if ( has_excerpt( $post->ID )) {
163
-                // admin has chosen "excerpt (short desc)"
164
-                // for the "Event Espresso - Events > Templates > Display Description" option
165
-                // AND an excerpt actually exists
166
-                the_excerpt();
167
-            } else {
168
-                // admin has chosen "excerpt (short desc)"
169
-                // for the "Event Espresso - Events > Templates > Display Description" option
170
-                // but NO excerpt actually exists, so we need to create one
171
-                if ( ! empty( $num_words )) {
172
-                    if ( empty( $more )) {
173
-                        $more_link_text = __( '(more&hellip;)' );
174
-                        $more = ' <a href="' . get_permalink() . '"';
175
-                        $more .= ' class="more-link"';
176
-                        $more .= \EED_Events_Archive::link_target();
177
-                        $more .= '>' . $more_link_text . '</a>';
178
-                        $more = apply_filters( 'the_content_more_link', $more, $more_link_text );
179
-                    }
180
-                    $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
181
-
182
-                    $content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
183
-                } else {
184
-                    $content =  get_the_content();
185
-                }
186
-                global $allowedtags;
187
-                // make sure links are allowed
188
-                $allowedtags['a'] = isset($allowedtags['a'])
189
-                    ? $allowedtags['a']
190
-                    : array();
191
-                // as well as target attribute
192
-                $allowedtags['a']['target'] = isset($allowedtags['a']['target'])
193
-                    ? $allowedtags['a']['target']
194
-                    : false;
195
-                // but get previous value so we can reset it
196
-                $prev_value = $allowedtags['a']['target'];
197
-                $allowedtags['a']['target'] = true;
198
-                $content = wp_kses( $content, $allowedtags );
199
-                $content = strip_shortcodes( $content );
200
-                echo apply_filters( 'the_content', $content );
201
-                $allowedtags['a']['target'] = $prev_value;
202
-            }
203
-        } else {
204
-            // admin has chosen "none"
205
-            // for the "Event Espresso - Events > Templates > Display Description" option
206
-            echo apply_filters( 'the_content', '' );
162
+			if ( has_excerpt( $post->ID )) {
163
+				// admin has chosen "excerpt (short desc)"
164
+				// for the "Event Espresso - Events > Templates > Display Description" option
165
+				// AND an excerpt actually exists
166
+				the_excerpt();
167
+			} else {
168
+				// admin has chosen "excerpt (short desc)"
169
+				// for the "Event Espresso - Events > Templates > Display Description" option
170
+				// but NO excerpt actually exists, so we need to create one
171
+				if ( ! empty( $num_words )) {
172
+					if ( empty( $more )) {
173
+						$more_link_text = __( '(more&hellip;)' );
174
+						$more = ' <a href="' . get_permalink() . '"';
175
+						$more .= ' class="more-link"';
176
+						$more .= \EED_Events_Archive::link_target();
177
+						$more .= '>' . $more_link_text . '</a>';
178
+						$more = apply_filters( 'the_content_more_link', $more, $more_link_text );
179
+					}
180
+					$content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
181
+
182
+					$content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
183
+				} else {
184
+					$content =  get_the_content();
185
+				}
186
+				global $allowedtags;
187
+				// make sure links are allowed
188
+				$allowedtags['a'] = isset($allowedtags['a'])
189
+					? $allowedtags['a']
190
+					: array();
191
+				// as well as target attribute
192
+				$allowedtags['a']['target'] = isset($allowedtags['a']['target'])
193
+					? $allowedtags['a']['target']
194
+					: false;
195
+				// but get previous value so we can reset it
196
+				$prev_value = $allowedtags['a']['target'];
197
+				$allowedtags['a']['target'] = true;
198
+				$content = wp_kses( $content, $allowedtags );
199
+				$content = strip_shortcodes( $content );
200
+				echo apply_filters( 'the_content', $content );
201
+				$allowedtags['a']['target'] = $prev_value;
202
+			}
203
+		} else {
204
+			// admin has chosen "none"
205
+			// for the "Event Espresso - Events > Templates > Display Description" option
206
+			echo apply_filters( 'the_content', '' );
207 207
 		}
208 208
 		return ob_get_clean();
209 209
 	}
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 					$url = get_term_link( $term, 'espresso_venue_categories' );
251 251
 					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
252 252
 						$category_links[] = '<a href="' . esc_url( $url )
253
-                                            . '" rel="tag"'
254
-                                            . \EED_Events_Archive::link_target()
255
-                                            .'>'
256
-                                            . $term->name
257
-                                            . '</a>';
253
+											. '" rel="tag"'
254
+											. \EED_Events_Archive::link_target()
255
+											.'>'
256
+											. $term->name
257
+											. '</a>';
258 258
 					}
259 259
 				}
260 260
 			}
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         }
54 54
         //reset property so that the new event is cached.
55 55
         EEH_Event_View::$_event = null;
56
-        if (! $EVT_ID && $post instanceof EE_Event) {
56
+        if ( ! $EVT_ID && $post instanceof EE_Event) {
57 57
             EEH_Event_View::$_event = $post;
58 58
             return EEH_Event_View::$_event;
59 59
         }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             return EEH_Event_View::$_event;
73 73
         }
74 74
         //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
75
-        if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
75
+        if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
76 76
             EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
77 77
         }
78 78
         return EEH_Event_View::$_event;
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 * @param    int $EVT_ID
88 88
 	 * @return    boolean
89 89
 	 */
90
-	public static function display_ticket_selector( $EVT_ID = 0 ) {
91
-		$event = EEH_Event_View::get_event( $EVT_ID );
90
+	public static function display_ticket_selector($EVT_ID = 0) {
91
+		$event = EEH_Event_View::get_event($EVT_ID);
92 92
 		return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE;
93 93
 	}
94 94
 
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	 * @param    int $EVT_ID
102 102
 	 * @return    string
103 103
 	 */
104
-	public static function event_status( $EVT_ID = 0 ) {
105
-		$event = EEH_Event_View::get_event( $EVT_ID );
106
-		return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : '';
104
+	public static function event_status($EVT_ID = 0) {
105
+		$event = EEH_Event_View::get_event($EVT_ID);
106
+		return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : '';
107 107
 	}
108 108
 
109 109
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * @param    int $EVT_ID
116 116
 	 *  @return 	string
117 117
 	 */
118
-	public static function event_active_status( $EVT_ID = 0 ) {
119
-		$event = EEH_Event_View::get_event( $EVT_ID );
118
+	public static function event_active_status($EVT_ID = 0) {
119
+		$event = EEH_Event_View::get_event($EVT_ID);
120 120
 		return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive';
121 121
 	}
122 122
 
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 * @param    int $EVT_ID
130 130
 	 *  @return 	string
131 131
 	 */
132
-	public static function event_has_content_or_excerpt( $EVT_ID = 0 ) {
133
-		$event = EEH_Event_View::get_event( $EVT_ID );
132
+	public static function event_has_content_or_excerpt($EVT_ID = 0) {
133
+		$event = EEH_Event_View::get_event($EVT_ID);
134 134
 		$has_content_or_excerpt = FALSE;
135
-		if ( $event instanceof EE_Event ) {
136
-			$has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE;
135
+		if ($event instanceof EE_Event) {
136
+			$has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE;
137 137
 		}
138
-		if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) {
138
+		if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) {
139 139
 			$has_content_or_excerpt = FALSE;
140 140
 		}
141 141
 		return $has_content_or_excerpt;
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 	 * @param null $more
152 152
 	 * @return    string
153 153
 	 */
154
-	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
154
+	public static function event_content_or_excerpt($num_words = NULL, $more = NULL) {
155 155
         global $post;
156 156
 		ob_start();
157
-		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
157
+		if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) {
158 158
 			// admin has chosen "full description"
159 159
             // for the "Event Espresso - Events > Templates > Display Description" option
160 160
 			the_content();
161
-		} else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) {
162
-            if ( has_excerpt( $post->ID )) {
161
+		} else if ((is_archive() && espresso_display_excerpt_in_event_list())) {
162
+            if (has_excerpt($post->ID)) {
163 163
                 // admin has chosen "excerpt (short desc)"
164 164
                 // for the "Event Espresso - Events > Templates > Display Description" option
165 165
                 // AND an excerpt actually exists
@@ -168,20 +168,20 @@  discard block
 block discarded – undo
168 168
                 // admin has chosen "excerpt (short desc)"
169 169
                 // for the "Event Espresso - Events > Templates > Display Description" option
170 170
                 // but NO excerpt actually exists, so we need to create one
171
-                if ( ! empty( $num_words )) {
172
-                    if ( empty( $more )) {
173
-                        $more_link_text = __( '(more&hellip;)' );
174
-                        $more = ' <a href="' . get_permalink() . '"';
171
+                if ( ! empty($num_words)) {
172
+                    if (empty($more)) {
173
+                        $more_link_text = __('(more&hellip;)');
174
+                        $more = ' <a href="'.get_permalink().'"';
175 175
                         $more .= ' class="more-link"';
176 176
                         $more .= \EED_Events_Archive::link_target();
177
-                        $more .= '>' . $more_link_text . '</a>';
178
-                        $more = apply_filters( 'the_content_more_link', $more, $more_link_text );
177
+                        $more .= '>'.$more_link_text.'</a>';
178
+                        $more = apply_filters('the_content_more_link', $more, $more_link_text);
179 179
                     }
180
-                    $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
180
+                    $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK'));
181 181
 
182
-                    $content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
182
+                    $content = wp_trim_words($content, $num_words, ' ').$more;
183 183
                 } else {
184
-                    $content =  get_the_content();
184
+                    $content = get_the_content();
185 185
                 }
186 186
                 global $allowedtags;
187 187
                 // make sure links are allowed
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
                 // but get previous value so we can reset it
196 196
                 $prev_value = $allowedtags['a']['target'];
197 197
                 $allowedtags['a']['target'] = true;
198
-                $content = wp_kses( $content, $allowedtags );
199
-                $content = strip_shortcodes( $content );
200
-                echo apply_filters( 'the_content', $content );
198
+                $content = wp_kses($content, $allowedtags);
199
+                $content = strip_shortcodes($content);
200
+                echo apply_filters('the_content', $content);
201 201
                 $allowedtags['a']['target'] = $prev_value;
202 202
             }
203 203
         } else {
204 204
             // admin has chosen "none"
205 205
             // for the "Event Espresso - Events > Templates > Display Description" option
206
-            echo apply_filters( 'the_content', '' );
206
+            echo apply_filters('the_content', '');
207 207
 		}
208 208
 		return ob_get_clean();
209 209
 	}
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 	 * @param    int $EVT_ID
218 218
 	 *  @return 	EE_Ticket[]
219 219
 	 */
220
-	public static function event_tickets_available( $EVT_ID = 0 ) {
221
-		$event = EEH_Event_View::get_event( $EVT_ID );
220
+	public static function event_tickets_available($EVT_ID = 0) {
221
+		$event = EEH_Event_View::get_event($EVT_ID);
222 222
 		$tickets_available_for_purchase = array();
223
-		if( $event instanceof EE_Event ) {
224
-			$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE );
225
-			foreach( $datetimes as $datetime ) {
226
-				$tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() );
223
+		if ($event instanceof EE_Event) {
224
+			$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE);
225
+			foreach ($datetimes as $datetime) {
226
+				$tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase());
227 227
 			}
228 228
 		}
229 229
 		return $tickets_available_for_purchase;
@@ -239,17 +239,17 @@  discard block
 block discarded – undo
239 239
 	 * @param 	  bool   $hide_uncategorized
240 240
 	 * @return    string
241 241
 	 */
242
-	public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) {
242
+	public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) {
243 243
 		$category_links = array();
244
-		$event = EEH_Event_View::get_event( $EVT_ID );
245
-		if ( $event instanceof EE_Event ) {
246
-			$event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' );
247
-			if ( $event_categories ) {
244
+		$event = EEH_Event_View::get_event($EVT_ID);
245
+		if ($event instanceof EE_Event) {
246
+			$event_categories = get_the_terms($event->ID(), 'espresso_event_categories');
247
+			if ($event_categories) {
248 248
 				// loop thru terms and create links
249
-				foreach ( $event_categories as $term ) {
250
-					$url = get_term_link( $term, 'espresso_venue_categories' );
251
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
252
-						$category_links[] = '<a href="' . esc_url( $url )
249
+				foreach ($event_categories as $term) {
250
+					$url = get_term_link($term, 'espresso_venue_categories');
251
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
252
+						$category_links[] = '<a href="'.esc_url($url)
253 253
                                             . '" rel="tag"'
254 254
                                             . \EED_Events_Archive::link_target()
255 255
                                             .'>'
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 				}
260 260
 			}
261 261
 		}
262
-		return implode( ', ', $category_links );
262
+		return implode(', ', $category_links);
263 263
 	}
264 264
 
265 265
 
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 	 * @param int    $EVT_ID
274 274
 	 * @return    string
275 275
 	 */
276
-	public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
277
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
278
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
279
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) :  '';
276
+	public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
277
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
278
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
279
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
280 280
 	}
281 281
 
282 282
 
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 * @param int    $EVT_ID
291 291
 	 * @return    string
292 292
 	 */
293
-	public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
294
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
295
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
296
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
293
+	public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
294
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
295
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
296
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
297 297
 	}
298 298
 
299 299
 
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	 * @param int    $EVT_ID
308 308
 	 * @return    string
309 309
 	 */
310
-	public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
311
-		$datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID );
312
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
313
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : '';
310
+	public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
311
+		$datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
312
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
313
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
314 314
 	}
315 315
 
316 316
 
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	 * @param int    $EVT_ID
325 325
 	 * @return    string
326 326
 	 */
327
-	public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
328
-		$datetime = EEH_Event_View::get_latest_date_obj( $EVT_ID );
329
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
330
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
327
+	public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
328
+		$datetime = EEH_Event_View::get_latest_date_obj($EVT_ID);
329
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
330
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
331 331
 	}
332 332
 
333 333
 
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
 	 * @param int $EVT_ID
340 340
 	 * @return    string
341 341
 	 */
342
-	public static function event_date_as_calendar_page( $EVT_ID = 0 ) {
343
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
344
-		if ( $datetime instanceof EE_Datetime ) {
342
+	public static function event_date_as_calendar_page($EVT_ID = 0) {
343
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
344
+		if ($datetime instanceof EE_Datetime) {
345 345
 	?>
346 346
 		<div class="event-date-calendar-page-dv">
347
-			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div>
348
-			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div>
347
+			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div>
348
+			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div>
349 349
 		</div>
350 350
 	<?php
351 351
 		}
@@ -360,17 +360,17 @@  discard block
 block discarded – undo
360 360
 	 * @param int $EVT_ID
361 361
 	 * @return    string
362 362
 	 */
363
-	public static function get_primary_date_obj( $EVT_ID = 0 ) {
364
-		$event = EEH_Event_View::get_event( $EVT_ID );
365
-		if ( $event instanceof EE_Event ) {
363
+	public static function get_primary_date_obj($EVT_ID = 0) {
364
+		$event = EEH_Event_View::get_event($EVT_ID);
365
+		if ($event instanceof EE_Event) {
366 366
 			$datetimes = $event->get_many_related(
367 367
 				'Datetime',
368 368
 				array(
369 369
 					'limit' => 1,
370
-					'order_by' => array( 'DTT_order' => 'ASC' )
370
+					'order_by' => array('DTT_order' => 'ASC')
371 371
 				)
372 372
 			);
373
-			return reset( $datetimes );
373
+			return reset($datetimes);
374 374
 		} else {
375 375
 			 return FALSE;
376 376
 		}
@@ -385,17 +385,17 @@  discard block
 block discarded – undo
385 385
 	 * @param int $EVT_ID
386 386
 	 * @return    string
387 387
 	 */
388
-	public static function get_last_date_obj( $EVT_ID = 0 ) {
389
-		$event = EEH_Event_View::get_event( $EVT_ID );
390
-		if ( $event instanceof EE_Event ) {
388
+	public static function get_last_date_obj($EVT_ID = 0) {
389
+		$event = EEH_Event_View::get_event($EVT_ID);
390
+		if ($event instanceof EE_Event) {
391 391
 			$datetimes = $event->get_many_related(
392 392
 				'Datetime',
393 393
 				array(
394 394
 					'limit' => 1,
395
-					'order_by' => array( 'DTT_order' => 'DESC' )
395
+					'order_by' => array('DTT_order' => 'DESC')
396 396
 				)
397 397
 			);
398
-			return end( $datetimes );
398
+			return end($datetimes);
399 399
 		} else {
400 400
 			return FALSE;
401 401
 		}
@@ -410,17 +410,17 @@  discard block
 block discarded – undo
410 410
 	 * @param int $EVT_ID
411 411
 	 * @return    string
412 412
 	 */
413
-	public static function get_earliest_date_obj( $EVT_ID = 0 ) {
414
-		$event = EEH_Event_View::get_event( $EVT_ID );
415
-		if ( $event instanceof EE_Event ) {
413
+	public static function get_earliest_date_obj($EVT_ID = 0) {
414
+		$event = EEH_Event_View::get_event($EVT_ID);
415
+		if ($event instanceof EE_Event) {
416 416
 			$datetimes = $event->get_many_related(
417 417
 				'Datetime',
418 418
 				array(
419 419
 					'limit' => 1,
420
-					'order_by' => array( 'DTT_EVT_start' => 'ASC' )
420
+					'order_by' => array('DTT_EVT_start' => 'ASC')
421 421
 				)
422 422
 			);
423
-			return reset( $datetimes );
423
+			return reset($datetimes);
424 424
 		} else {
425 425
 			 return FALSE;
426 426
 		}
@@ -435,17 +435,17 @@  discard block
 block discarded – undo
435 435
 	 * @param int $EVT_ID
436 436
 	 * @return    string
437 437
 	 */
438
-	public static function get_latest_date_obj( $EVT_ID = 0 ) {
439
-		$event = EEH_Event_View::get_event( $EVT_ID );
440
-		if ( $event instanceof EE_Event ) {
438
+	public static function get_latest_date_obj($EVT_ID = 0) {
439
+		$event = EEH_Event_View::get_event($EVT_ID);
440
+		if ($event instanceof EE_Event) {
441 441
 			$datetimes = $event->get_many_related(
442 442
 				'Datetime',
443 443
 				array(
444 444
 					'limit' => 1,
445
-					'order_by' => array( 'DTT_EVT_start' => 'DESC' )
445
+					'order_by' => array('DTT_EVT_start' => 'DESC')
446 446
 				)
447 447
 			);
448
-			return end( $datetimes );
448
+			return end($datetimes);
449 449
 		} else {
450 450
 			return FALSE;
451 451
 		}
@@ -463,17 +463,17 @@  discard block
 block discarded – undo
463 463
 	 * @param null $limit
464 464
 	 * @return EE_Datetime[]
465 465
 	 */
466
-	public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) {
467
-		$event = EEH_Event_View::get_event( $EVT_ID );
468
-		if($include_expired === null){
469
-			if($event instanceof EE_Event && $event->is_expired()){
466
+	public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) {
467
+		$event = EEH_Event_View::get_event($EVT_ID);
468
+		if ($include_expired === null) {
469
+			if ($event instanceof EE_Event && $event->is_expired()) {
470 470
 				$include_expired = true;
471
-			}else{
471
+			} else {
472 472
 				$include_expired = false;
473 473
 			}
474 474
 		}
475 475
 
476
-		if ( $event instanceof EE_Event ) {
476
+		if ($event instanceof EE_Event) {
477 477
 			return $event->datetimes_ordered($include_expired, $include_deleted, $limit);
478 478
 		} else {
479 479
 			 return array();
@@ -489,11 +489,11 @@  discard block
 block discarded – undo
489 489
 	 * @param int $EVT_ID
490 490
 	 * @return    string
491 491
 	 */
492
-	public static function event_link_url( $EVT_ID = 0 ) {
493
-		$event = EEH_Event_View::get_event( $EVT_ID );
494
-		if ( $event instanceof EE_Event ) {
495
-			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() );
496
-			return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url;
492
+	public static function event_link_url($EVT_ID = 0) {
493
+		$event = EEH_Event_View::get_event($EVT_ID);
494
+		if ($event instanceof EE_Event) {
495
+			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID());
496
+			return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url;
497 497
 		}
498 498
 		return NULL;
499 499
 	}
@@ -507,10 +507,10 @@  discard block
 block discarded – undo
507 507
 	 * @param int $EVT_ID
508 508
 	 * @return    string
509 509
 	 */
510
-	public static function event_phone( $EVT_ID = 0 ) {
511
-		$event = EEH_Event_View::get_event( $EVT_ID );
512
-		if ( $event instanceof EE_Event ) {
513
-			return EEH_Schema::telephone( $event->phone() );
510
+	public static function event_phone($EVT_ID = 0) {
511
+		$event = EEH_Event_View::get_event($EVT_ID);
512
+		if ($event instanceof EE_Event) {
513
+			return EEH_Schema::telephone($event->phone());
514 514
 		}
515 515
 		return NULL;
516 516
 	}
@@ -527,26 +527,26 @@  discard block
 block discarded – undo
527 527
 	 * @param string $after
528 528
 	 * @return    string
529 529
 	 */
530
-	public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) {
531
-		$event = EEH_Event_View::get_event( $EVT_ID );
532
-		if ( $event instanceof EE_Event ) {
530
+	public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') {
531
+		$event = EEH_Event_View::get_event($EVT_ID);
532
+		if ($event instanceof EE_Event) {
533 533
 			// can the user edit this post ?
534
-			if ( current_user_can( 'edit_post', $event->ID() )) {
534
+			if (current_user_can('edit_post', $event->ID())) {
535 535
 				// set link text
536
-				$link_text = ! empty( $link ) ? $link : __('edit this event');
536
+				$link_text = ! empty($link) ? $link : __('edit this event');
537 537
 				// generate nonce
538
-				$nonce = wp_create_nonce( 'edit_nonce' );
538
+				$nonce = wp_create_nonce('edit_nonce');
539 539
 				// generate url to event editor for this event
540
-				$url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() );
540
+				$url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url());
541 541
 				// get edit CPT text
542
-				$post_type_obj = get_post_type_object( 'espresso_events' );
542
+				$post_type_obj = get_post_type_object('espresso_events');
543 543
 				// build final link html
544
-				$link = '<a class="post-edit-link" href="' . $url . '" ';
545
-				$link .= ' title="' . esc_attr( $post_type_obj->labels->edit_item ) . '"';
544
+				$link = '<a class="post-edit-link" href="'.$url.'" ';
545
+				$link .= ' title="'.esc_attr($post_type_obj->labels->edit_item).'"';
546 546
 				$link .= \EED_Events_Archive::link_target();
547
-				$link .='>' . $link_text . '</a>';
547
+				$link .= '>'.$link_text.'</a>';
548 548
 				// put it all together
549
-				return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after;
549
+				return $before.apply_filters('edit_post_link', $link, $event->ID()).$after;
550 550
 			}
551 551
 		}
552 552
 		return '';
Please login to merge, or discard this patch.
public/template_tags.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@
 block discarded – undo
206 206
 	function espresso_ticket_selector( $event = NULL ) {
207 207
 		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
208 208
 			espresso_load_ticket_selector();
209
-            \EED_Ticket_Selector::set_definitions();
209
+			\EED_Ticket_Selector::set_definitions();
210 210
 			echo EED_Ticket_Selector::display_ticket_selector( $event );
211 211
 		}
212 212
 	}
Please login to merge, or discard this patch.
Spacing   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
  * @param int | \EE_Event $event
15 15
  * @return bool
16 16
  */
17
-function is_espresso_event( $event = NULL ) {
18
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
17
+function is_espresso_event($event = NULL) {
18
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
19 19
 		// extract EE_Event object from passed param regardless of what it is (within reason of course)
20
-		$event = EEH_Event_View::get_event( $event );
20
+		$event = EEH_Event_View::get_event($event);
21 21
 		// do we have a valid event ?
22
-		return $event instanceof EE_Event  ? TRUE : FALSE;
22
+		return $event instanceof EE_Event ? TRUE : FALSE;
23 23
 	}
24 24
 	return FALSE;
25 25
 }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return bool
32 32
  */
33 33
 function is_espresso_event_single() {
34
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
34
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
35 35
 		global $wp_query;
36 36
 		// return conditionals set by CPTs
37 37
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE;
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  * @return bool
47 47
  */
48 48
 function is_espresso_event_archive() {
49
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
49
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
50 50
 		global $wp_query;
51 51
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE;
52 52
 	}
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  * @return bool
61 61
  */
62 62
 function is_espresso_event_taxonomy() {
63
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
63
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
64 64
 		global $wp_query;
65 65
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE;
66 66
 	}
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
  * @param int | \EE_Venue $venue
75 75
  * @return bool
76 76
  */
77
-function is_espresso_venue( $venue = NULL ) {
78
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
77
+function is_espresso_venue($venue = NULL) {
78
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
79 79
 		// extract EE_Venue object from passed param regardless of what it is (within reason of course)
80
-		$venue = EEH_Venue_View::get_venue( $venue, FALSE );
80
+		$venue = EEH_Venue_View::get_venue($venue, FALSE);
81 81
 		// do we have a valid event ?
82 82
 		return $venue instanceof EE_Venue ? TRUE : FALSE;
83 83
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
  * @return bool
92 92
  */
93 93
 function is_espresso_venue_single() {
94
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
94
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
95 95
 		global $wp_query;
96 96
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE;
97 97
 	}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
  * @return bool
106 106
  */
107 107
 function is_espresso_venue_archive() {
108
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
108
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
109 109
 		global $wp_query;
110 110
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE;
111 111
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
  * @return bool
120 120
  */
121 121
 function is_espresso_venue_taxonomy() {
122
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
122
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
123 123
 		global $wp_query;
124 124
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE;
125 125
 	}
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
  * @param $conditional_tag
134 134
  * @return bool
135 135
  */
136
-function can_use_espresso_conditionals( $conditional_tag ) {
137
-	if ( ! did_action( 'AHEE__EE_System__initialize' )) {
136
+function can_use_espresso_conditionals($conditional_tag) {
137
+	if ( ! did_action('AHEE__EE_System__initialize')) {
138 138
 		EE_Error::doing_it_wrong(
139 139
 			__FUNCTION__,
140 140
 			sprintf(
141
-				__( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'),
141
+				__('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'),
142 142
 				$conditional_tag
143 143
 			),
144 144
 			'4.4.0'
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
 
154 154
 /*************************** Event Queries ***************************/
155 155
 
156
-if ( ! function_exists( 'espresso_get_events' )) {
156
+if ( ! function_exists('espresso_get_events')) {
157 157
 	/**
158 158
 	 * 	espresso_get_events
159 159
 	 * @param array $params
160 160
 	 * @return array
161 161
 	 */
162
-	function espresso_get_events( $params = array() ) {
162
+	function espresso_get_events($params = array()) {
163 163
 		//set default params
164 164
 		$default_espresso_events_params = array(
165 165
 			'limit' => 10,
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 			'sort' => 'ASC'
171 171
 		);
172 172
 		// allow the defaults to be filtered
173
-		$default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params );
173
+		$default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params);
174 174
 		// grab params and merge with defaults, then extract
175
-		$params = array_merge( $default_espresso_events_params, $params );
175
+		$params = array_merge($default_espresso_events_params, $params);
176 176
 		// run the query
177
-		$events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery( $params );
177
+		$events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params);
178 178
 		// assign results to a variable so we can return it
179 179
 		$events = $events_query->have_posts() ? $events_query->posts : array();
180 180
 		// but first reset the query and postdata
181 181
 		wp_reset_query();
182 182
 		wp_reset_postdata();
183 183
 		EED_Events_Archive::remove_all_events_archive_filters();
184
-		unset( $events_query );
184
+		unset($events_query);
185 185
 		return $events;
186 186
 	}
187 187
 }
@@ -195,33 +195,33 @@  discard block
 block discarded – undo
195 195
  * espresso_load_ticket_selector
196 196
  */
197 197
 function espresso_load_ticket_selector() {
198
-	EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' );
198
+	EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module');
199 199
 }
200 200
 
201
-if ( ! function_exists( 'espresso_ticket_selector' )) {
201
+if ( ! function_exists('espresso_ticket_selector')) {
202 202
 	/**
203 203
 	 * espresso_ticket_selector
204 204
 	 * @param null $event
205 205
 	 */
206
-	function espresso_ticket_selector( $event = NULL ) {
207
-		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
206
+	function espresso_ticket_selector($event = NULL) {
207
+		if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) {
208 208
 			espresso_load_ticket_selector();
209 209
             \EED_Ticket_Selector::set_definitions();
210
-			echo EED_Ticket_Selector::display_ticket_selector( $event );
210
+			echo EED_Ticket_Selector::display_ticket_selector($event);
211 211
 		}
212 212
 	}
213 213
 }
214 214
 
215 215
 
216
-	if ( ! function_exists( 'espresso_view_details_btn' )) {
216
+	if ( ! function_exists('espresso_view_details_btn')) {
217 217
 	/**
218 218
 	 * espresso_view_details_btn
219 219
 	 * @param null $event
220 220
 	 */
221
-	function espresso_view_details_btn( $event = NULL ) {
222
-		if (  ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) {
221
+	function espresso_view_details_btn($event = NULL) {
222
+		if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) {
223 223
 			espresso_load_ticket_selector();
224
-			echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE );
224
+			echo EED_Ticket_Selector::display_ticket_selector($event, TRUE);
225 225
 		}
226 226
 	}
227 227
 }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 /*************************** EEH_Event_View ***************************/
233 233
 
234
-if ( ! function_exists( 'espresso_load_event_list_assets' )) {
234
+if ( ! function_exists('espresso_load_event_list_assets')) {
235 235
 	/**
236 236
 	 * espresso_load_event_list_assets
237 237
 	 * ensures that event list styles and scripts are loaded
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	function espresso_load_event_list_assets() {
242 242
 		$event_list = EED_Events_Archive::instance();
243
-		add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 );
244
-		add_filter( 'FHEE_enable_default_espresso_css', '__return_true' );
243
+		add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10);
244
+		add_filter('FHEE_enable_default_espresso_css', '__return_true');
245 245
 	}
246 246
 }
247 247
 
248 248
 
249
-if ( ! function_exists( 'espresso_event_reg_button' )) {
249
+if ( ! function_exists('espresso_event_reg_button')) {
250 250
 	/**
251 251
 	 * espresso_event_reg_button
252 252
 	 * returns the "Register Now" button if event is active,
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
 	 * @param bool $EVT_ID
259 259
 	 * @return string
260 260
 	 */
261
-	function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) {
262
-		$event_status = EEH_Event_View::event_active_status( $EVT_ID );
263
-		switch ( $event_status ) {
261
+	function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) {
262
+		$event_status = EEH_Event_View::event_active_status($EVT_ID);
263
+		switch ($event_status) {
264 264
 			case EE_Datetime::sold_out :
265 265
 				$btn_text = __('Sold Out', 'event_espresso');
266 266
 				$class = 'ee-pink';
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 			case EE_Datetime::upcoming :
277 277
 			case EE_Datetime::active :
278 278
 			default :
279
-				$btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' );
279
+				$btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso');
280 280
 				$class = 'ee-green';
281 281
 		}
282
-		if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) {
282
+		if ($event_status < 1 && ! empty($btn_text_if_inactive)) {
283 283
 			$btn_text = $btn_text_if_inactive;
284 284
 			$class = 'ee-grey';
285 285
 		}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
 
295 295
 
296
-if ( ! function_exists( 'espresso_display_ticket_selector' )) {
296
+if ( ! function_exists('espresso_display_ticket_selector')) {
297 297
 	/**
298 298
 	 * espresso_display_ticket_selector
299 299
 	 * whether or not to display the Ticket Selector for an event
@@ -301,14 +301,14 @@  discard block
 block discarded – undo
301 301
 	 * @param bool $EVT_ID
302 302
 	 * @return boolean
303 303
 	 */
304
-	function espresso_display_ticket_selector( $EVT_ID = FALSE ) {
305
-		return EEH_Event_View::display_ticket_selector( $EVT_ID );
304
+	function espresso_display_ticket_selector($EVT_ID = FALSE) {
305
+		return EEH_Event_View::display_ticket_selector($EVT_ID);
306 306
 	}
307 307
 }
308 308
 
309 309
 
310 310
 
311
-if ( ! function_exists( 'espresso_event_status_banner' )) {
311
+if ( ! function_exists('espresso_event_status_banner')) {
312 312
 	/**
313 313
 	 * espresso_event_status
314 314
 	 * returns a banner showing the event status if it is sold out, expired, or inactive
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 * @param bool $EVT_ID
317 317
 	 * @return string
318 318
 	 */
319
-	function espresso_event_status_banner( $EVT_ID = FALSE ) {
320
-		return EEH_Event_View::event_status( $EVT_ID );
319
+	function espresso_event_status_banner($EVT_ID = FALSE) {
320
+		return EEH_Event_View::event_status($EVT_ID);
321 321
 	}
322 322
 }
323 323
 
324 324
 
325
-if ( ! function_exists( 'espresso_event_status' )) {
325
+if ( ! function_exists('espresso_event_status')) {
326 326
 	/**
327 327
 	 * espresso_event_status
328 328
 	 * returns the event status if it is sold out, expired, or inactive
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
 	 * @param bool $echo
332 332
 	 * @return string
333 333
 	 */
334
-	function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) {
335
-		if ( $echo ) {
336
-			echo EEH_Event_View::event_active_status( $EVT_ID );
334
+	function espresso_event_status($EVT_ID = 0, $echo = TRUE) {
335
+		if ($echo) {
336
+			echo EEH_Event_View::event_active_status($EVT_ID);
337 337
 			return '';
338 338
 		}
339
-		return EEH_Event_View::event_active_status( $EVT_ID );
339
+		return EEH_Event_View::event_active_status($EVT_ID);
340 340
 	}
341 341
 }
342 342
 
343 343
 
344
-if ( ! function_exists( 'espresso_event_categories' )) {
344
+if ( ! function_exists('espresso_event_categories')) {
345 345
 	/**
346 346
 	 * espresso_event_categories
347 347
 	 * returns the terms associated with an event
@@ -351,17 +351,17 @@  discard block
 block discarded – undo
351 351
 	 * @param bool $echo
352 352
 	 * @return string
353 353
 	 */
354
-	function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) {
355
-		if ( $echo ) {
356
-			echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
354
+	function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
355
+		if ($echo) {
356
+			echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
357 357
 			return '';
358 358
 		}
359
-		return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
359
+		return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
360 360
 	}
361 361
 }
362 362
 
363 363
 
364
-if ( ! function_exists( 'espresso_event_tickets_available' )) {
364
+if ( ! function_exists('espresso_event_tickets_available')) {
365 365
 	/**
366 366
 	 * espresso_event_tickets_available
367 367
 	 * returns the ticket types available for purchase for an event
@@ -371,26 +371,26 @@  discard block
 block discarded – undo
371 371
 	 * @param bool $format
372 372
 	 * @return string
373 373
 	 */
374
-	function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) {
375
-		$tickets = EEH_Event_View::event_tickets_available( $EVT_ID );
376
-		if ( is_array( $tickets ) && ! empty( $tickets )) {
374
+	function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) {
375
+		$tickets = EEH_Event_View::event_tickets_available($EVT_ID);
376
+		if (is_array($tickets) && ! empty($tickets)) {
377 377
 			// if formatting then $html will be a string, else it will be an array of ticket objects
378
-			$html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array();
379
-			foreach ( $tickets as $ticket ) {
380
-				if ( $ticket instanceof EE_Ticket ) {
381
-					if ( $format ) {
382
-						$html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">';
383
-						$html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() );
378
+			$html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array();
379
+			foreach ($tickets as $ticket) {
380
+				if ($ticket instanceof EE_Ticket) {
381
+					if ($format) {
382
+						$html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">';
383
+						$html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes());
384 384
 						$html .= '</li>';
385 385
 					} else {
386 386
 						$html[] = $ticket;
387 387
 					}
388 388
 				}
389 389
 			}
390
-			if ( $format ) {
390
+			if ($format) {
391 391
 				$html .= '</ul>';
392 392
 			}
393
-			if ( $echo && ! $format ) {
393
+			if ($echo && ! $format) {
394 394
 				echo $html;
395 395
 				return '';
396 396
 			}
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	}
401 401
 }
402 402
 
403
-if ( ! function_exists( 'espresso_event_date_obj' )) {
403
+if ( ! function_exists('espresso_event_date_obj')) {
404 404
 	/**
405 405
 	 * espresso_event_date_obj
406 406
 	 * returns the primary date object for an event
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
 	 * @param bool $EVT_ID
409 409
 	 * @return object
410 410
 	 */
411
-	function espresso_event_date_obj( $EVT_ID = FALSE ) {
412
-		return EEH_Event_View::get_primary_date_obj( $EVT_ID );
411
+	function espresso_event_date_obj($EVT_ID = FALSE) {
412
+		return EEH_Event_View::get_primary_date_obj($EVT_ID);
413 413
 	}
414 414
 }
415 415
 
416 416
 
417
-if ( ! function_exists( 'espresso_event_date' )) {
417
+if ( ! function_exists('espresso_event_date')) {
418 418
 	/**
419 419
 	 * espresso_event_date
420 420
 	 * returns the primary date for an event
@@ -425,22 +425,22 @@  discard block
 block discarded – undo
425 425
 	 * @param bool $echo
426 426
 	 * @return string
427 427
 	 */
428
-	function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
429
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
430
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
431
-		$date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format );
432
-		$time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format );
433
-		if($echo){
434
-			echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
428
+	function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
429
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
430
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
431
+		$date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format);
432
+		$time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format);
433
+		if ($echo) {
434
+			echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
435 435
 			return '';
436 436
 		}
437
-		return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
437
+		return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
438 438
 
439 439
 	}
440 440
 }
441 441
 
442 442
 
443
-if ( ! function_exists( 'espresso_list_of_event_dates' )) {
443
+if ( ! function_exists('espresso_list_of_event_dates')) {
444 444
 	/**
445 445
 	 * espresso_list_of_event_dates
446 446
 	 * returns a unordered list of dates for an event
@@ -455,40 +455,40 @@  discard block
 block discarded – undo
455 455
 	 * @param null   $limit
456 456
 	 * @return string
457 457
 	 */
458
-	function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) {
459
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
460
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
461
-		$date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format );
462
-		$time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format );
463
-		$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
464
-		if ( ! $format ) {
465
-			return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes );
458
+	function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) {
459
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
460
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
461
+		$date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format);
462
+		$time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format);
463
+		$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit);
464
+		if ( ! $format) {
465
+			return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes);
466 466
 		}
467 467
 		//d( $datetimes );
468
-		if ( is_array( $datetimes ) && ! empty( $datetimes )) {
468
+		if (is_array($datetimes) && ! empty($datetimes)) {
469 469
 			global $post;
470
-			$html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : '';
471
-			foreach ( $datetimes as $datetime ) {
472
-				if ( $datetime instanceof EE_Datetime ) {
473
-					$html .= '<li id="ee-event-datetimes-li-' . $datetime->ID();
474
-					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">';
470
+			$html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : '';
471
+			foreach ($datetimes as $datetime) {
472
+				if ($datetime instanceof EE_Datetime) {
473
+					$html .= '<li id="ee-event-datetimes-li-'.$datetime->ID();
474
+					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">';
475 475
 					$datetime_name = $datetime->name();
476
-					$html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : '';
477
-					$html .= ! empty( $datetime_name )  && $add_breaks ? '<br />' : '';
478
-					$html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">' . $datetime->date_range( $date_format ) . '</span><br/>';
479
-					$html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">' . $datetime->time_range( $time_format ) . '</span>';
476
+					$html .= ! empty($datetime_name) ? '<strong>'.$datetime_name.'</strong>' : '';
477
+					$html .= ! empty($datetime_name) && $add_breaks ? '<br />' : '';
478
+					$html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">'.$datetime->date_range($date_format).'</span><br/>';
479
+					$html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">'.$datetime->time_range($time_format).'</span>';
480 480
 					$datetime_description = $datetime->description();
481
-					$html .= ! empty( $datetime_description )  && $add_breaks ? '<br />' : '';
482
-					$html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : '';
483
-					$html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
481
+					$html .= ! empty($datetime_description) && $add_breaks ? '<br />' : '';
482
+					$html .= ! empty($datetime_description) ? ' - '.$datetime_description : '';
483
+					$html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime);
484 484
 					$html .= '</li>';
485 485
 				}
486 486
 			}
487 487
 			$html .= $format ? '</ul>' : '';
488 488
 		} else {
489
-			$html = $format ?  '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
489
+			$html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : '';
490 490
 		}
491
-		if ( $echo ) {
491
+		if ($echo) {
492 492
 			echo $html;
493 493
 			return '';
494 494
 		}
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 }
498 498
 
499 499
 
500
-if ( ! function_exists( 'espresso_event_end_date' )) {
500
+if ( ! function_exists('espresso_event_end_date')) {
501 501
 	/**
502 502
 	 * espresso_event_end_date
503 503
 	 * returns the last date for an event
@@ -508,20 +508,20 @@  discard block
 block discarded – undo
508 508
 	 * @param bool   $echo
509 509
 	 * @return string
510 510
 	 */
511
-	function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
512
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
513
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
514
-		$date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format );
515
-		$time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format );
516
-		if($echo){
517
-			echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
511
+	function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
512
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
513
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
514
+		$date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format);
515
+		$time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format);
516
+		if ($echo) {
517
+			echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
518 518
 			return '';
519 519
 		}
520
-		return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
520
+		return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
521 521
 	}
522 522
 }
523 523
 
524
-if ( ! function_exists( 'espresso_event_date_range' )) {
524
+if ( ! function_exists('espresso_event_date_range')) {
525 525
 	/**
526 526
 	 * espresso_event_date_range
527 527
 	 * returns the first and last chronologically ordered dates for an event (if different)
@@ -534,31 +534,31 @@  discard block
 block discarded – undo
534 534
 	 * @param bool   $echo
535 535
 	 * @return string
536 536
 	 */
537
-	function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
537
+	function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
538 538
 		// set and filter date and time formats when a range is returned
539
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
540
-		$date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format );
539
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
540
+		$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format);
541 541
 		// get the start and end date with NO time portion
542
-		$the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID );
543
-		$the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID );
542
+		$the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID);
543
+		$the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID);
544 544
 		// now we can determine if date range spans more than one day
545
-		if ( $the_event_date != $the_event_end_date ) {
546
-			$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
547
-			$time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format );
545
+		if ($the_event_date != $the_event_end_date) {
546
+			$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
547
+			$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format);
548 548
 			$html = sprintf(
549
-				__( '%1$s - %2$s', 'event_espresso' ),
550
-				EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ),
551
-				EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID )
549
+				__('%1$s - %2$s', 'event_espresso'),
550
+				EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID),
551
+				EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID)
552 552
 			);
553 553
 		} else {
554 554
 			// set and filter date and time formats when only a single datetime is returned
555
-			$single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' );
556
-			$single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' );
557
-			$single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format );
558
-			$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format );
559
-			$html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID );
555
+			$single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format');
556
+			$single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format');
557
+			$single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format);
558
+			$single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format);
559
+			$html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID);
560 560
 		}
561
-		if ( $echo ) {
561
+		if ($echo) {
562 562
 			echo $html;
563 563
 			return '';
564 564
 		}
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 }
568 568
 
569 569
 
570
-if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) {
570
+if ( ! function_exists('espresso_event_date_as_calendar_page')) {
571 571
 	/**
572 572
 	 * espresso_event_date_as_calendar_page
573 573
 	 * returns the primary date for an event, stylized to appear as the page of a calendar
@@ -575,15 +575,15 @@  discard block
 block discarded – undo
575 575
 	 * @param bool $EVT_ID
576 576
 	 * @return string
577 577
 	 */
578
-	function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) {
579
-		EEH_Event_View::event_date_as_calendar_page( $EVT_ID );
578
+	function espresso_event_date_as_calendar_page($EVT_ID = FALSE) {
579
+		EEH_Event_View::event_date_as_calendar_page($EVT_ID);
580 580
 	}
581 581
 }
582 582
 
583 583
 
584 584
 
585 585
 
586
-if ( ! function_exists( 'espresso_event_link_url' )) {
586
+if ( ! function_exists('espresso_event_link_url')) {
587 587
 	/**
588 588
 	 * espresso_event_link_url
589 589
 	 *
@@ -591,18 +591,18 @@  discard block
 block discarded – undo
591 591
 	 * @param bool $echo
592 592
 	 * @return string
593 593
 	 */
594
-	function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) {
595
-		if ( $echo ) {
596
-			echo EEH_Event_View::event_link_url( $EVT_ID );
594
+	function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) {
595
+		if ($echo) {
596
+			echo EEH_Event_View::event_link_url($EVT_ID);
597 597
 			return '';
598 598
 		}
599
-		return EEH_Event_View::event_link_url( $EVT_ID );
599
+		return EEH_Event_View::event_link_url($EVT_ID);
600 600
 	}
601 601
 }
602 602
 
603 603
 
604 604
 
605
-if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) {
605
+if ( ! function_exists('espresso_event_has_content_or_excerpt')) {
606 606
 	/**
607 607
 	 *    espresso_event_has_content_or_excerpt
608 608
 	 *
@@ -610,15 +610,15 @@  discard block
 block discarded – undo
610 610
 	 * @param bool $EVT_ID
611 611
 	 * @return    boolean
612 612
 	 */
613
-	function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) {
614
-		return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID );
613
+	function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) {
614
+		return EEH_Event_View::event_has_content_or_excerpt($EVT_ID);
615 615
 	}
616 616
 }
617 617
 
618 618
 
619 619
 
620 620
 
621
-if ( ! function_exists( 'espresso_event_content_or_excerpt' )) {
621
+if ( ! function_exists('espresso_event_content_or_excerpt')) {
622 622
 	/**
623 623
 	 * espresso_event_content_or_excerpt
624 624
 	 *
@@ -627,18 +627,18 @@  discard block
 block discarded – undo
627 627
 	 * @param bool $echo
628 628
 	 * @return string
629 629
 	 */
630
-	function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) {
631
-		if ( $echo ) {
632
-			echo EEH_Event_View::event_content_or_excerpt( $num_words, $more );
630
+	function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) {
631
+		if ($echo) {
632
+			echo EEH_Event_View::event_content_or_excerpt($num_words, $more);
633 633
 			return '';
634 634
 		}
635
-		return EEH_Event_View::event_content_or_excerpt( $num_words, $more );
635
+		return EEH_Event_View::event_content_or_excerpt($num_words, $more);
636 636
 	}
637 637
 }
638 638
 
639 639
 
640 640
 
641
-if ( ! function_exists( 'espresso_event_phone' )) {
641
+if ( ! function_exists('espresso_event_phone')) {
642 642
 	/**
643 643
 	 * espresso_event_phone
644 644
 	 *
@@ -646,18 +646,18 @@  discard block
 block discarded – undo
646 646
 	 * @param bool $echo
647 647
 	 * @return string
648 648
 	 */
649
-	function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) {
650
-		if ( $echo ) {
651
-			echo EEH_Event_View::event_phone( $EVT_ID );
649
+	function espresso_event_phone($EVT_ID = 0, $echo = TRUE) {
650
+		if ($echo) {
651
+			echo EEH_Event_View::event_phone($EVT_ID);
652 652
 			return '';
653 653
 		}
654
-		return EEH_Event_View::event_phone( $EVT_ID );
654
+		return EEH_Event_View::event_phone($EVT_ID);
655 655
 	}
656 656
 }
657 657
 
658 658
 
659 659
 
660
-if ( ! function_exists( 'espresso_edit_event_link' )) {
660
+if ( ! function_exists('espresso_edit_event_link')) {
661 661
 	/**
662 662
 	 * espresso_edit_event_link
663 663
 	 * returns a link to edit an event
@@ -666,39 +666,39 @@  discard block
 block discarded – undo
666 666
 	 * @param bool $echo
667 667
 	 * @return string
668 668
 	 */
669
-	function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) {
670
-		if ( $echo ) {
671
-			echo EEH_Event_View::edit_event_link( $EVT_ID );
669
+	function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) {
670
+		if ($echo) {
671
+			echo EEH_Event_View::edit_event_link($EVT_ID);
672 672
 			return '';
673 673
 		}
674
-		return EEH_Event_View::edit_event_link( $EVT_ID );
674
+		return EEH_Event_View::edit_event_link($EVT_ID);
675 675
 	}
676 676
 }
677 677
 
678 678
 
679
-if ( ! function_exists( 'espresso_organization_name' )) {
679
+if ( ! function_exists('espresso_organization_name')) {
680 680
 	/**
681 681
 	 * espresso_organization_name
682 682
 	 * @param bool $echo
683 683
 	 * @return string
684 684
 	 */
685 685
 	function espresso_organization_name($echo = TRUE) {
686
-		if($echo){
687
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
686
+		if ($echo) {
687
+			echo EE_Registry::instance()->CFG->organization->get_pretty('name');
688 688
 			return '';
689 689
 		}
690
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
690
+		return EE_Registry::instance()->CFG->organization->get_pretty('name');
691 691
 	}
692 692
 }
693 693
 
694
-if ( ! function_exists( 'espresso_organization_address' )) {
694
+if ( ! function_exists('espresso_organization_address')) {
695 695
 	/**
696 696
 	 * espresso_organization_address
697 697
 	 * @param string $type
698 698
 	 * @return string
699 699
 	 */
700
-	function espresso_organization_address( $type = 'inline' ) {
701
-		if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) {
700
+	function espresso_organization_address($type = 'inline') {
701
+		if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
702 702
 			$address = new EventEspresso\core\domain\entities\GenericAddress(
703 703
 				EE_Registry::instance()->CFG->organization->address_1,
704 704
 				EE_Registry::instance()->CFG->organization->address_2,
@@ -707,129 +707,129 @@  discard block
 block discarded – undo
707 707
 				EE_Registry::instance()->CFG->organization->zip,
708 708
 				EE_Registry::instance()->CFG->organization->CNT_ISO
709 709
 			);
710
-			return EEH_Address::format( $address, $type );
710
+			return EEH_Address::format($address, $type);
711 711
 		}
712 712
 		return '';
713 713
 	}
714 714
 }
715 715
 
716
-if ( ! function_exists( 'espresso_organization_email' )) {
716
+if ( ! function_exists('espresso_organization_email')) {
717 717
 	/**
718 718
 	 * espresso_organization_email
719 719
 	 * @param bool $echo
720 720
 	 * @return string
721 721
 	 */
722
-	function espresso_organization_email( $echo = TRUE ) {
723
-		if($echo){
724
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
722
+	function espresso_organization_email($echo = TRUE) {
723
+		if ($echo) {
724
+			echo EE_Registry::instance()->CFG->organization->get_pretty('email');
725 725
 			return '';
726 726
 		}
727
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
727
+		return EE_Registry::instance()->CFG->organization->get_pretty('email');
728 728
 	}
729 729
 }
730 730
 
731
-if ( ! function_exists( 'espresso_organization_logo_url' )) {
731
+if ( ! function_exists('espresso_organization_logo_url')) {
732 732
 	/**
733 733
 	 * espresso_organization_logo_url
734 734
 	 * @param bool $echo
735 735
 	 * @return string
736 736
 	 */
737
-	function espresso_organization_logo_url( $echo = TRUE ) {
738
-		if($echo){
739
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
737
+	function espresso_organization_logo_url($echo = TRUE) {
738
+		if ($echo) {
739
+			echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
740 740
 			return '';
741 741
 		}
742
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
742
+		return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
743 743
 	}
744 744
 }
745 745
 
746
-if ( ! function_exists( 'espresso_organization_facebook' )) {
746
+if ( ! function_exists('espresso_organization_facebook')) {
747 747
 	/**
748 748
 	 * espresso_organization_facebook
749 749
 	 * @param bool $echo
750 750
 	 * @return string
751 751
 	 */
752
-	function espresso_organization_facebook( $echo = TRUE ) {
753
-		if($echo){
754
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
752
+	function espresso_organization_facebook($echo = TRUE) {
753
+		if ($echo) {
754
+			echo EE_Registry::instance()->CFG->organization->get_pretty('facebook');
755 755
 			return '';
756 756
 		}
757
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
757
+		return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
758 758
 	}
759 759
 }
760 760
 
761
-if ( ! function_exists( 'espresso_organization_twitter' )) {
761
+if ( ! function_exists('espresso_organization_twitter')) {
762 762
 	/**
763 763
 	 * espresso_organization_twitter
764 764
 	 * @param bool $echo
765 765
 	 * @return string
766 766
 	 */
767
-	function espresso_organization_twitter( $echo = TRUE ) {
768
-		if($echo){
769
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
767
+	function espresso_organization_twitter($echo = TRUE) {
768
+		if ($echo) {
769
+			echo EE_Registry::instance()->CFG->organization->get_pretty('twitter');
770 770
 			return '';
771 771
 		}
772
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
772
+		return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
773 773
 	}
774 774
 }
775 775
 
776
-if ( ! function_exists( 'espresso_organization_linkedin' )) {
776
+if ( ! function_exists('espresso_organization_linkedin')) {
777 777
 	/**
778 778
 	 * espresso_organization_linkedin
779 779
 	 * @param bool $echo
780 780
 	 * @return string
781 781
 	 */
782
-	function espresso_organization_linkedin( $echo = TRUE ) {
783
-		if($echo){
784
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
782
+	function espresso_organization_linkedin($echo = TRUE) {
783
+		if ($echo) {
784
+			echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
785 785
 			return '';
786 786
 		}
787
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
787
+		return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
788 788
 	}
789 789
 }
790 790
 
791
-if ( ! function_exists( 'espresso_organization_pinterest' )) {
791
+if ( ! function_exists('espresso_organization_pinterest')) {
792 792
 	/**
793 793
 	 * espresso_organization_pinterest
794 794
 	 * @param bool $echo
795 795
 	 * @return string
796 796
 	 */
797
-	function espresso_organization_pinterest( $echo = TRUE ) {
798
-		if($echo){
799
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
797
+	function espresso_organization_pinterest($echo = TRUE) {
798
+		if ($echo) {
799
+			echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
800 800
 			return '';
801 801
 		}
802
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
802
+		return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
803 803
 	}
804 804
 }
805 805
 
806
-if ( ! function_exists( 'espresso_organization_google' )) {
806
+if ( ! function_exists('espresso_organization_google')) {
807 807
 	/**
808 808
 	 * espresso_organization_google
809 809
 	 * @param bool $echo
810 810
 	 * @return string
811 811
 	 */
812
-	function espresso_organization_google( $echo = TRUE ) {
813
-		if($echo){
814
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
812
+	function espresso_organization_google($echo = TRUE) {
813
+		if ($echo) {
814
+			echo EE_Registry::instance()->CFG->organization->get_pretty('google');
815 815
 			return '';
816 816
 		}
817
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
817
+		return EE_Registry::instance()->CFG->organization->get_pretty('google');
818 818
 	}
819 819
 }
820 820
 
821
-if ( ! function_exists( 'espresso_organization_instagram' )) {
821
+if ( ! function_exists('espresso_organization_instagram')) {
822 822
 	/**
823 823
 	 * espresso_organization_instagram
824 824
 	 * @param bool $echo
825 825
 	 * @return string
826 826
 	 */
827
-	function espresso_organization_instagram( $echo = TRUE ) {
828
-		if($echo){
829
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
827
+	function espresso_organization_instagram($echo = TRUE) {
828
+		if ($echo) {
829
+			echo EE_Registry::instance()->CFG->organization->get_pretty('instagram');
830 830
 			return '';
831 831
 		}
832
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
832
+		return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
833 833
 	}
834 834
 }
835 835
 
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 
840 840
 
841 841
 
842
-if ( ! function_exists( 'espresso_event_venues' )) {
842
+if ( ! function_exists('espresso_event_venues')) {
843 843
 	/**
844 844
 	 * espresso_event_venues
845 845
 	 *
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 
854 854
 
855 855
 
856
-if ( ! function_exists( 'espresso_venue_id' )) {
856
+if ( ! function_exists('espresso_venue_id')) {
857 857
 	/**
858 858
 	 *    espresso_venue_name
859 859
 	 *
@@ -861,15 +861,15 @@  discard block
 block discarded – undo
861 861
 	 * @param     int $EVT_ID
862 862
 	 * @return    string
863 863
 	 */
864
-	function espresso_venue_id( $EVT_ID = 0 ) {
865
-		$venue = EEH_Venue_View::get_venue( $EVT_ID );
864
+	function espresso_venue_id($EVT_ID = 0) {
865
+		$venue = EEH_Venue_View::get_venue($EVT_ID);
866 866
 		return $venue instanceof EE_Venue ? $venue->ID() : 0;
867 867
 	}
868 868
 }
869 869
 
870 870
 
871 871
 
872
-if ( ! function_exists( 'espresso_is_venue_private' ) ) {
872
+if ( ! function_exists('espresso_is_venue_private')) {
873 873
 	/**
874 874
 	 * Return whether a venue is private or not.
875 875
 	 * @see EEH_Venue_View::get_venue() for more info on expected return results.
@@ -878,45 +878,45 @@  discard block
 block discarded – undo
878 878
 	 *
879 879
 	 * @return bool | null
880 880
 	 */
881
-	function espresso_is_venue_private( $VNU_ID = 0 ) {
882
-		return EEH_Venue_View::is_venue_private( $VNU_ID );
881
+	function espresso_is_venue_private($VNU_ID = 0) {
882
+		return EEH_Venue_View::is_venue_private($VNU_ID);
883 883
 	}
884 884
 }
885 885
 
886 886
 
887 887
 
888
-if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) {
888
+if ( ! function_exists('espresso_venue_is_password_protected')) {
889 889
 	/**
890 890
 	 * returns true or false if a venue is password protected or not
891 891
 	 *
892 892
 	 * @param int     $VNU_ID optional, the venue id to check.
893 893
 	 * @return string
894 894
 	 */
895
-	function espresso_venue_is_password_protected( $VNU_ID = 0 ) {
896
-		EE_Registry::instance()->load_helper( 'Venue_View' );
897
-		return EEH_Venue_View::is_venue_password_protected( $VNU_ID );
895
+	function espresso_venue_is_password_protected($VNU_ID = 0) {
896
+		EE_Registry::instance()->load_helper('Venue_View');
897
+		return EEH_Venue_View::is_venue_password_protected($VNU_ID);
898 898
 	}
899 899
 }
900 900
 
901 901
 
902 902
 
903
-if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) {
903
+if ( ! function_exists('espresso_password_protected_venue_form')) {
904 904
 	/**
905 905
 	 * Returns a password form if venue is password protected.
906 906
 	 *
907 907
 	 * @param int     $VNU_ID optional, the venue id to check.
908 908
 	 * @return string
909 909
 	 */
910
-	function espresso_password_protected_venue_form( $VNU_ID = 0 ) {
911
-		EE_Registry::instance()->load_helper( 'Venue_View' );
912
-		return EEH_Venue_View::password_protected_venue_form( $VNU_ID );
910
+	function espresso_password_protected_venue_form($VNU_ID = 0) {
911
+		EE_Registry::instance()->load_helper('Venue_View');
912
+		return EEH_Venue_View::password_protected_venue_form($VNU_ID);
913 913
 	}
914 914
 }
915 915
 
916 916
 
917 917
 
918 918
 
919
-if ( ! function_exists( 'espresso_venue_name' )) {
919
+if ( ! function_exists('espresso_venue_name')) {
920 920
 	/**
921 921
 	 *    espresso_venue_name
922 922
 	 *
@@ -926,19 +926,19 @@  discard block
 block discarded – undo
926 926
 	 * @param bool   $echo
927 927
 	 * @return    string
928 928
 	 */
929
-	function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) {
930
-		if($echo){
931
-			echo EEH_Venue_View::venue_name( $link_to, $VNU_ID );
929
+	function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) {
930
+		if ($echo) {
931
+			echo EEH_Venue_View::venue_name($link_to, $VNU_ID);
932 932
 			return '';
933 933
 		}
934
-		return EEH_Venue_View::venue_name( $link_to, $VNU_ID );
934
+		return EEH_Venue_View::venue_name($link_to, $VNU_ID);
935 935
 	}
936 936
 }
937 937
 
938 938
 
939 939
 
940 940
 
941
-if ( ! function_exists( 'espresso_venue_link' )) {
941
+if ( ! function_exists('espresso_venue_link')) {
942 942
 	/**
943 943
 	 * 	espresso_venue_link
944 944
 	 *
@@ -947,14 +947,14 @@  discard block
 block discarded – undo
947 947
 	 *  @param 	string 	$text
948 948
 	 *  @return 	string
949 949
 	 */
950
-	function espresso_venue_link( $VNU_ID = 0, $text = '' ) {
951
-		return EEH_Venue_View::venue_details_link( $VNU_ID, $text );
950
+	function espresso_venue_link($VNU_ID = 0, $text = '') {
951
+		return EEH_Venue_View::venue_details_link($VNU_ID, $text);
952 952
 	}
953 953
 }
954 954
 
955 955
 
956 956
 
957
-if ( ! function_exists( 'espresso_venue_description' )) {
957
+if ( ! function_exists('espresso_venue_description')) {
958 958
 	/**
959 959
 	 *    espresso_venue_description
960 960
 	 *
@@ -963,17 +963,17 @@  discard block
 block discarded – undo
963 963
 	 * @param bool $echo
964 964
 	 * @return    string
965 965
 	 */
966
-	function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) {
967
-		if($echo){
968
-			echo EEH_Venue_View::venue_description( $VNU_ID );
966
+	function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) {
967
+		if ($echo) {
968
+			echo EEH_Venue_View::venue_description($VNU_ID);
969 969
 			return '';
970 970
 		}
971
-		return EEH_Venue_View::venue_description( $VNU_ID );
971
+		return EEH_Venue_View::venue_description($VNU_ID);
972 972
 	}
973 973
 }
974 974
 
975 975
 
976
-if ( ! function_exists( 'espresso_venue_excerpt' )) {
976
+if ( ! function_exists('espresso_venue_excerpt')) {
977 977
 	/**
978 978
 	 *    espresso_venue_excerpt
979 979
 	 *
@@ -982,18 +982,18 @@  discard block
 block discarded – undo
982 982
 	 * @param bool $echo
983 983
 	 * @return    string
984 984
 	 */
985
-	function espresso_venue_excerpt( $VNU_ID = 0,  $echo = TRUE ) {
986
-		if ( $echo ) {
987
-			echo EEH_Venue_View::venue_excerpt( $VNU_ID );
985
+	function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) {
986
+		if ($echo) {
987
+			echo EEH_Venue_View::venue_excerpt($VNU_ID);
988 988
 			return '';
989 989
 		}
990
-		return EEH_Venue_View::venue_excerpt( $VNU_ID );
990
+		return EEH_Venue_View::venue_excerpt($VNU_ID);
991 991
 	}
992 992
 }
993 993
 
994 994
 
995 995
 
996
-if ( ! function_exists( 'espresso_venue_categories' )) {
996
+if ( ! function_exists('espresso_venue_categories')) {
997 997
 	/**
998 998
 	 * espresso_venue_categories
999 999
 	 * returns the terms associated with a venue
@@ -1003,17 +1003,17 @@  discard block
 block discarded – undo
1003 1003
 	 * @param bool $echo
1004 1004
 	 * @return string
1005 1005
 	 */
1006
-	function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE,  $echo = TRUE ) {
1007
-		if ( $echo ) {
1008
-			echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1006
+	function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
1007
+		if ($echo) {
1008
+			echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1009 1009
 			return '';
1010 1010
 		}
1011
-		return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1011
+		return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1012 1012
 	}
1013 1013
 }
1014 1014
 
1015 1015
 
1016
-if ( ! function_exists( 'espresso_venue_address' )) {
1016
+if ( ! function_exists('espresso_venue_address')) {
1017 1017
 	/**
1018 1018
 	 * espresso_venue_address
1019 1019
 	 * returns a formatted block of html  for displaying a venue's address
@@ -1023,17 +1023,17 @@  discard block
 block discarded – undo
1023 1023
 	 * @param bool   $echo
1024 1024
 	 * @return string
1025 1025
 	 */
1026
-	function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1027
-		if ( $echo ) {
1028
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID );
1026
+	function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1027
+		if ($echo) {
1028
+			echo EEH_Venue_View::venue_address($type, $VNU_ID);
1029 1029
 			return '';
1030 1030
 		}
1031
-		return EEH_Venue_View::venue_address( $type, $VNU_ID );
1031
+		return EEH_Venue_View::venue_address($type, $VNU_ID);
1032 1032
 	}
1033 1033
 }
1034 1034
 
1035 1035
 
1036
-if ( ! function_exists( 'espresso_venue_raw_address' )) {
1036
+if ( ! function_exists('espresso_venue_raw_address')) {
1037 1037
 	/**
1038 1038
 	 * espresso_venue_address
1039 1039
 	 * returns an UN-formatted string containing a venue's address
@@ -1043,17 +1043,17 @@  discard block
 block discarded – undo
1043 1043
 	 * @param bool     $echo
1044 1044
 	 * @return string
1045 1045
 	 */
1046
-	function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1047
-		if ( $echo ) {
1048
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1046
+	function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1047
+		if ($echo) {
1048
+			echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1049 1049
 			return '';
1050 1050
 		}
1051
-		return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1051
+		return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1052 1052
 	}
1053 1053
 }
1054 1054
 
1055 1055
 
1056
-if ( ! function_exists( 'espresso_venue_has_address' )) {
1056
+if ( ! function_exists('espresso_venue_has_address')) {
1057 1057
 	/**
1058 1058
 	 * espresso_venue_has_address
1059 1059
 	 * returns TRUE or FALSE if a Venue has address information
@@ -1061,13 +1061,13 @@  discard block
 block discarded – undo
1061 1061
 	 * @param int $VNU_ID
1062 1062
 	 * @return bool
1063 1063
 	 */
1064
-	function espresso_venue_has_address( $VNU_ID = 0 ) {
1065
-		return EEH_Venue_View::venue_has_address( $VNU_ID );
1064
+	function espresso_venue_has_address($VNU_ID = 0) {
1065
+		return EEH_Venue_View::venue_has_address($VNU_ID);
1066 1066
 	}
1067 1067
 }
1068 1068
 
1069 1069
 
1070
-if ( ! function_exists( 'espresso_venue_gmap' )) {
1070
+if ( ! function_exists('espresso_venue_gmap')) {
1071 1071
 	/**
1072 1072
 	 * espresso_venue_gmap
1073 1073
 	 * returns a google map for the venue address
@@ -1078,17 +1078,17 @@  discard block
 block discarded – undo
1078 1078
 	 * @param bool     $echo
1079 1079
 	 * @return string
1080 1080
 	 */
1081
-	function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE  ) {
1082
-		if ( $echo ) {
1083
-			echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1081
+	function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) {
1082
+		if ($echo) {
1083
+			echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1084 1084
 			return '';
1085 1085
 		}
1086
-		return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1086
+		return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1087 1087
 	}
1088 1088
 }
1089 1089
 
1090 1090
 
1091
-if ( ! function_exists( 'espresso_venue_phone' )) {
1091
+if ( ! function_exists('espresso_venue_phone')) {
1092 1092
 	/**
1093 1093
 	 * espresso_venue_phone
1094 1094
 	 *
@@ -1096,18 +1096,18 @@  discard block
 block discarded – undo
1096 1096
 	 * @param bool $echo
1097 1097
 	 * @return string
1098 1098
 	 */
1099
-	function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) {
1100
-		if ( $echo ) {
1101
-			echo EEH_Venue_View::venue_phone( $VNU_ID );
1099
+	function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) {
1100
+		if ($echo) {
1101
+			echo EEH_Venue_View::venue_phone($VNU_ID);
1102 1102
 			return '';
1103 1103
 		}
1104
-		return EEH_Venue_View::venue_phone( $VNU_ID );
1104
+		return EEH_Venue_View::venue_phone($VNU_ID);
1105 1105
 	}
1106 1106
 }
1107 1107
 
1108 1108
 
1109 1109
 
1110
-if ( ! function_exists( 'espresso_venue_website' )) {
1110
+if ( ! function_exists('espresso_venue_website')) {
1111 1111
 	/**
1112 1112
 	 * espresso_venue_website
1113 1113
 	 *
@@ -1115,18 +1115,18 @@  discard block
 block discarded – undo
1115 1115
 	 * @param bool $echo
1116 1116
 	 * @return string
1117 1117
 	 */
1118
-	function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) {
1119
-		if ( $echo ) {
1120
-			echo EEH_Venue_View::venue_website_link( $VNU_ID );
1118
+	function espresso_venue_website($VNU_ID = 0, $echo = TRUE) {
1119
+		if ($echo) {
1120
+			echo EEH_Venue_View::venue_website_link($VNU_ID);
1121 1121
 			return '';
1122 1122
 		}
1123
-		return EEH_Venue_View::venue_website_link( $VNU_ID );
1123
+		return EEH_Venue_View::venue_website_link($VNU_ID);
1124 1124
 	}
1125 1125
 }
1126 1126
 
1127 1127
 
1128 1128
 
1129
-if ( ! function_exists( 'espresso_edit_venue_link' )) {
1129
+if ( ! function_exists('espresso_edit_venue_link')) {
1130 1130
 	/**
1131 1131
 	 * espresso_edit_venue_link
1132 1132
 	 *
@@ -1134,12 +1134,12 @@  discard block
 block discarded – undo
1134 1134
 	 * @param bool $echo
1135 1135
 	 * @return string
1136 1136
 	 */
1137
-	function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) {
1138
-		if($echo){
1139
-			echo EEH_Venue_View::edit_venue_link( $VNU_ID );
1137
+	function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) {
1138
+		if ($echo) {
1139
+			echo EEH_Venue_View::edit_venue_link($VNU_ID);
1140 1140
 			return '';
1141 1141
 		}
1142
-		return EEH_Venue_View::edit_venue_link( $VNU_ID );
1142
+		return EEH_Venue_View::edit_venue_link($VNU_ID);
1143 1143
 	}
1144 1144
 }
1145 1145
 
Please login to merge, or discard this patch.
modules/ticket_selector/EED_Ticket_Selector.module.php 2 patches
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class EED_Ticket_Selector extends  EED_Module {
24 24
 
25
-    /**
26
-     * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector
27
-     */
28
-    private static $ticket_selector;
25
+	/**
26
+	 * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector
27
+	 */
28
+	private static $ticket_selector;
29 29
 
30
-    /**
31
-     * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button
32
-     */
33
-    private static $iframe_embed_button;
30
+	/**
31
+	 * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button
32
+	 */
33
+	private static $iframe_embed_button;
34 34
 
35 35
 
36 36
 
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 		// routing
62 62
 		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
63 63
 		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
64
-        EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
-        add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
64
+		EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
+		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
66 66
 		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
67
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
69
-        EED_Ticket_Selector::loadIframeAssets();
70
-    }
67
+		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
+		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
69
+		EED_Ticket_Selector::loadIframeAssets();
70
+	}
71 71
 
72 72
 
73 73
 
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
 			10
87 87
 		);
88 88
 
89
-        /**
90
-         * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
91
-         * registrations work.
92
-         */
89
+		/**
90
+		 * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
91
+		 * registrations work.
92
+		 */
93 93
 		add_action(
94
-		    'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
95
-            array('EED_Ticket_Selector', 'set_definitions'),
96
-            10
97
-        );
98
-    }
94
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
95
+			array('EED_Ticket_Selector', 'set_definitions'),
96
+			10
97
+		);
98
+	}
99 99
 
100 100
 
101 101
 
@@ -106,34 +106,34 @@  discard block
 block discarded – undo
106 106
 	 *  @return 	void
107 107
 	 */
108 108
 	public static function set_definitions() {
109
-	    // don't do this twice
110
-	    if(defined('TICKET_SELECTOR_ASSETS_URL')) {
111
-	        return;
112
-        }
109
+		// don't do this twice
110
+		if(defined('TICKET_SELECTOR_ASSETS_URL')) {
111
+			return;
112
+		}
113 113
 		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
114 114
 		define(
115
-		    'TICKET_SELECTOR_TEMPLATES_PATH',
116
-            str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS
117
-        );
115
+			'TICKET_SELECTOR_TEMPLATES_PATH',
116
+			str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS
117
+		);
118 118
 		//if config is not set, initialize
119 119
 		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) {
120
-            \EED_Ticket_Selector::instance()->set_config();
121
-            \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
120
+			\EED_Ticket_Selector::instance()->set_config();
121
+			\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
122 122
 		}
123 123
 	}
124 124
 
125 125
 
126 126
 
127 127
 	/**
128
-     * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector
129
-     */
130
-    public static function ticketSelector()
131
-    {
132
-        if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
133
-            EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector();
134
-        }
135
-        return EED_Ticket_Selector::$ticket_selector;
136
-    }
128
+	 * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector
129
+	 */
130
+	public static function ticketSelector()
131
+	{
132
+		if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
133
+			EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector();
134
+		}
135
+		return EED_Ticket_Selector::$ticket_selector;
136
+	}
137 137
 
138 138
 
139 139
 	/**
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 
187 187
 
188 188
 
189
-    /**
190
-     *    creates buttons for selecting number of attendees for an event
191
-     *
192
-     * @access    public
193
-     * @param    WP_Post|int $event
194
-     * @param    bool        $view_details
195
-     * @return    string
196
-     * @throws \EE_Error
197
-     */
189
+	/**
190
+	 *    creates buttons for selecting number of attendees for an event
191
+	 *
192
+	 * @access    public
193
+	 * @param    WP_Post|int $event
194
+	 * @param    bool        $view_details
195
+	 * @return    string
196
+	 * @throws \EE_Error
197
+	 */
198 198
 	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
199 199
 		return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details );
200 200
 	}
@@ -215,244 +215,244 @@  discard block
 block discarded – undo
215 215
 
216 216
 
217 217
 
218
-    /**
219
-     * cancel_ticket_selections
220
-     *
221
-     * @access        public
222
-     * @return        string
223
-     */
224
-    public static function cancel_ticket_selections()
225
-    {
226
-        $form = new ProcessTicketSelector();
227
-        return $form->cancelTicketSelections();
228
-    }
218
+	/**
219
+	 * cancel_ticket_selections
220
+	 *
221
+	 * @access        public
222
+	 * @return        string
223
+	 */
224
+	public static function cancel_ticket_selections()
225
+	{
226
+		$form = new ProcessTicketSelector();
227
+		return $form->cancelTicketSelections();
228
+	}
229 229
 
230 230
 
231 231
 
232 232
 	/**
233
-	* @return void
234
-	*/
233
+	 * @return void
234
+	 */
235 235
 	public static function translate_js_strings() {
236
-        EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
237
-            'please select a datetime', 'event_espresso'
238
-        );
239
-    }
236
+		EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
237
+			'please select a datetime', 'event_espresso'
238
+		);
239
+	}
240 240
 
241 241
 
242 242
 
243 243
 	/**
244
-	* 	load js
245
-	*
246
-	* 	@access 		public
247
-	* 	@return 		void
248
-	*/
244
+	 * 	load js
245
+	 *
246
+	 * 	@access 		public
247
+	 * 	@return 		void
248
+	 */
249 249
 	public static function load_tckt_slctr_assets() {
250 250
 		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
251
-            // add some style
252
-            wp_register_style(
253
-                'ticket_selector',
254
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
255
-                array(),
256
-                EVENT_ESPRESSO_VERSION
257
-            );
258
-            wp_enqueue_style('ticket_selector');
259
-            // make it dance
260
-            wp_register_script(
261
-                'ticket_selector',
262
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
263
-                array('espresso_core'),
264
-                EVENT_ESPRESSO_VERSION,
265
-                TRUE
266
-            );
251
+			// add some style
252
+			wp_register_style(
253
+				'ticket_selector',
254
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
255
+				array(),
256
+				EVENT_ESPRESSO_VERSION
257
+			);
258
+			wp_enqueue_style('ticket_selector');
259
+			// make it dance
260
+			wp_register_script(
261
+				'ticket_selector',
262
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
263
+				array('espresso_core'),
264
+				EVENT_ESPRESSO_VERSION,
265
+				TRUE
266
+			);
267 267
 			wp_enqueue_script('ticket_selector');
268
-            require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
269
-            \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
270
-        }
268
+			require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
269
+			\EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
270
+		}
271
+	}
272
+
273
+
274
+
275
+	/**
276
+	 * @return void
277
+	 */
278
+	public static function loadIframeAssets()
279
+	{
280
+		// for event lists
281
+		add_filter(
282
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
283
+			array('EED_Ticket_Selector', 'iframeCss')
284
+		);
285
+		add_filter(
286
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
287
+			array('EED_Ticket_Selector', 'iframeJs')
288
+		);
289
+		// for ticket selectors
290
+		add_filter(
291
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
292
+			array('EED_Ticket_Selector', 'iframeCss')
293
+		);
294
+		add_filter(
295
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
296
+			array('EED_Ticket_Selector', 'iframeJs')
297
+		);
298
+	}
299
+
300
+
301
+
302
+	/**
303
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
304
+	 *
305
+	 * @param array $iframe_css
306
+	 * @return array
307
+	 */
308
+	public static function iframeCss(array $iframe_css)
309
+	{
310
+		$iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
311
+		return $iframe_css;
271 312
 	}
272 313
 
273 314
 
274 315
 
275
-    /**
276
-     * @return void
277
-     */
278
-    public static function loadIframeAssets()
279
-    {
280
-        // for event lists
281
-        add_filter(
282
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
283
-            array('EED_Ticket_Selector', 'iframeCss')
284
-        );
285
-        add_filter(
286
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
287
-            array('EED_Ticket_Selector', 'iframeJs')
288
-        );
289
-        // for ticket selectors
290
-        add_filter(
291
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
292
-            array('EED_Ticket_Selector', 'iframeCss')
293
-        );
294
-        add_filter(
295
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
296
-            array('EED_Ticket_Selector', 'iframeJs')
297
-        );
298
-    }
299
-
300
-
301
-
302
-    /**
303
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
304
-     *
305
-     * @param array $iframe_css
306
-     * @return array
307
-     */
308
-    public static function iframeCss(array $iframe_css)
309
-    {
310
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
311
-        return $iframe_css;
312
-    }
313
-
314
-
315
-
316
-    /**
317
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
318
-     *
319
-     * @param array $iframe_js
320
-     * @return array
321
-     */
322
-    public static function iframeJs(array $iframe_js)
323
-    {
324
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
325
-        return $iframe_js;
326
-    }
316
+	/**
317
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
318
+	 *
319
+	 * @param array $iframe_js
320
+	 * @return array
321
+	 */
322
+	public static function iframeJs(array $iframe_js)
323
+	{
324
+		$iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
325
+		return $iframe_js;
326
+	}
327 327
 
328 328
 
329 329
 	/****************************** DEPRECATED ******************************/
330 330
 
331 331
 
332 332
 
333
-    /**
334
-     * @deprecated
335
-     * @return string
336
-     * @throws \EE_Error
337
-     */
338
-    public static function display_view_details_btn()
339
-    {
340
-        // todo add doing_it_wrong() notice during next major version
341
-        return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
342
-    }
343
-
344
-
345
-
346
-    /**
347
-     * @deprecated
348
-     * @return string
349
-     * @throws \EE_Error
350
-     */
351
-    public static function display_ticket_selector_submit()
352
-    {
353
-        // todo add doing_it_wrong() notice during next major version
354
-        return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
355
-    }
356
-
357
-
358
-
359
-    /**
360
-     * @deprecated
361
-     * @param string $permalink_string
362
-     * @param int    $id
363
-     * @param string $new_title
364
-     * @param string $new_slug
365
-     * @return string
366
-     */
367
-    public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
368
-    {
369
-        // todo add doing_it_wrong() notice during next major version
370
-        if (
371
-        	\EE_Registry::instance()->REQ->get('page') === 'espresso_events'
372
-        	&& \EE_Registry::instance()->REQ->get('action') === 'edit'
373
-        ) {
374
-            $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
375
-            $iframe_embed_button->addEventEditorIframeEmbedButton();
376
-        }
377
-        return '';
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     * @deprecated
384
-     * @param int    $ID
385
-     * @param string $external_url
386
-     * @return string
387
-     */
388
-    public static function ticket_selector_form_open($ID = 0, $external_url = '')
389
-    {
390
-        // todo add doing_it_wrong() notice during next major version
391
-        return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
392
-    }
393
-
394
-
395
-
396
-    /**
397
-     * @deprecated
398
-     * @return string
399
-     */
400
-    public static function ticket_selector_form_close()
401
-    {
402
-        // todo add doing_it_wrong() notice during next major version
403
-        return EED_Ticket_Selector::ticketSelector()->formClose();
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * @deprecated
410
-     * @return string
411
-     */
412
-    public static function no_tkt_slctr_end_dv()
413
-    {
414
-        // todo add doing_it_wrong() notice during next major version
415
-        return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
416
-    }
417
-
418
-
419
-
420
-    /**
421
-     * @deprecated 4.9.13
422
-     * @return string
423
-     */
424
-    public static function tkt_slctr_end_dv()
425
-    {
426
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
427
-    }
428
-
429
-
430
-
431
-    /**
432
-     * @deprecated
433
-     * @return string
434
-     */
435
-    public static function clear_tkt_slctr()
436
-    {
437
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
438
-    }
439
-
440
-
441
-
442
-    /**
443
-     * @deprecated
444
-     */
445
-    public static function load_tckt_slctr_assets_admin()
446
-    {
447
-        // todo add doing_it_wrong() notice during next major version
448
-	    if (
449
-		    \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
450
-		    && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
451
-	    ) {
452
-		    $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
453
-            $iframe_embed_button->embedButtonAssets();
454
-        }
455
-    }
333
+	/**
334
+	 * @deprecated
335
+	 * @return string
336
+	 * @throws \EE_Error
337
+	 */
338
+	public static function display_view_details_btn()
339
+	{
340
+		// todo add doing_it_wrong() notice during next major version
341
+		return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
342
+	}
343
+
344
+
345
+
346
+	/**
347
+	 * @deprecated
348
+	 * @return string
349
+	 * @throws \EE_Error
350
+	 */
351
+	public static function display_ticket_selector_submit()
352
+	{
353
+		// todo add doing_it_wrong() notice during next major version
354
+		return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
355
+	}
356
+
357
+
358
+
359
+	/**
360
+	 * @deprecated
361
+	 * @param string $permalink_string
362
+	 * @param int    $id
363
+	 * @param string $new_title
364
+	 * @param string $new_slug
365
+	 * @return string
366
+	 */
367
+	public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
368
+	{
369
+		// todo add doing_it_wrong() notice during next major version
370
+		if (
371
+			\EE_Registry::instance()->REQ->get('page') === 'espresso_events'
372
+			&& \EE_Registry::instance()->REQ->get('action') === 'edit'
373
+		) {
374
+			$iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
375
+			$iframe_embed_button->addEventEditorIframeEmbedButton();
376
+		}
377
+		return '';
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 * @deprecated
384
+	 * @param int    $ID
385
+	 * @param string $external_url
386
+	 * @return string
387
+	 */
388
+	public static function ticket_selector_form_open($ID = 0, $external_url = '')
389
+	{
390
+		// todo add doing_it_wrong() notice during next major version
391
+		return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
392
+	}
393
+
394
+
395
+
396
+	/**
397
+	 * @deprecated
398
+	 * @return string
399
+	 */
400
+	public static function ticket_selector_form_close()
401
+	{
402
+		// todo add doing_it_wrong() notice during next major version
403
+		return EED_Ticket_Selector::ticketSelector()->formClose();
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * @deprecated
410
+	 * @return string
411
+	 */
412
+	public static function no_tkt_slctr_end_dv()
413
+	{
414
+		// todo add doing_it_wrong() notice during next major version
415
+		return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
416
+	}
417
+
418
+
419
+
420
+	/**
421
+	 * @deprecated 4.9.13
422
+	 * @return string
423
+	 */
424
+	public static function tkt_slctr_end_dv()
425
+	{
426
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
427
+	}
428
+
429
+
430
+
431
+	/**
432
+	 * @deprecated
433
+	 * @return string
434
+	 */
435
+	public static function clear_tkt_slctr()
436
+	{
437
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
438
+	}
439
+
440
+
441
+
442
+	/**
443
+	 * @deprecated
444
+	 */
445
+	public static function load_tckt_slctr_assets_admin()
446
+	{
447
+		// todo add doing_it_wrong() notice during next major version
448
+		if (
449
+			\EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
450
+			&& \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
451
+		) {
452
+			$iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
453
+			$iframe_embed_button->embedButtonAssets();
454
+		}
455
+	}
456 456
 
457 457
 
458 458
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\modules\ticket_selector\TicketSelectorIframe;
4 4
 use EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-	exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	 * @return EED_Ticket_Selector
39 39
 	 */
40 40
 	public static function instance() {
41
-		return parent::get_instance( __CLASS__ );
41
+		return parent::get_instance(__CLASS__);
42 42
 	}
43 43
 
44 44
 
45 45
 
46
-	protected function set_config(){
47
-		$this->set_config_section( 'template_settings' );
48
-		$this->set_config_class( 'EE_Ticket_Selector_Config' );
49
-		$this->set_config_name( 'EED_Ticket_Selector' );
46
+	protected function set_config() {
47
+		$this->set_config_section('template_settings');
48
+		$this->set_config_class('EE_Ticket_Selector_Config');
49
+		$this->set_config_name('EED_Ticket_Selector');
50 50
 	}
51 51
 
52 52
 
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public static function set_hooks() {
61 61
 		// routing
62
-		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
63
-		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
62
+		EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector');
63
+		EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
64 64
         EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
65
-        add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
66
-		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
67
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'translate_js_strings' ), 0 );
68
-        add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
65
+        add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
66
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
67
+        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0);
68
+        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
69 69
         EED_Ticket_Selector::loadIframeAssets();
70 70
     }
71 71
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		// to load assets for "espresso_events" page on the "edit" route (action)
83 83
 		add_action(
84 84
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit',
85
-			array( 'EED_Ticket_Selector', 'ticket_selector_iframe_embed_button' ),
85
+			array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'),
86 86
 			10
87 87
 		);
88 88
 
@@ -107,16 +107,16 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public static function set_definitions() {
109 109
 	    // don't do this twice
110
-	    if(defined('TICKET_SELECTOR_ASSETS_URL')) {
110
+	    if (defined('TICKET_SELECTOR_ASSETS_URL')) {
111 111
 	        return;
112 112
         }
113
-		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
113
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
114 114
 		define(
115 115
 		    'TICKET_SELECTOR_TEMPLATES_PATH',
116
-            str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS
116
+            str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS
117 117
         );
118 118
 		//if config is not set, initialize
119
-		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) {
119
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) {
120 120
             \EED_Ticket_Selector::instance()->set_config();
121 121
             \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config();
122 122
 		}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * 	@param	WP $WP
144 144
 	 * 	@return void
145 145
 	 */
146
-	public function run( $WP ) {}
146
+	public function run($WP) {}
147 147
 
148 148
 
149 149
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @return \EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton
152 152
 	 */
153 153
 	public static function getIframeEmbedButton() {
154
-		if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton ) {
154
+		if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
155 155
 			self::$iframe_embed_button = new TicketSelectorIframeEmbedButton();
156 156
 		}
157 157
 		return self::$iframe_embed_button;
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
      * @return    string
196 196
      * @throws \EE_Error
197 197
      */
198
-	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
199
-		return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details );
198
+	public static function display_ticket_selector($event = NULL, $view_details = FALSE) {
199
+		return EED_Ticket_Selector::ticketSelector()->display($event, $view_details);
200 200
 	}
201 201
 
202 202
 
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
 	* 	@return 		void
248 248
 	*/
249 249
 	public static function load_tckt_slctr_assets() {
250
-		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
250
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) {
251 251
             // add some style
252 252
             wp_register_style(
253 253
                 'ticket_selector',
254
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
254
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css',
255 255
                 array(),
256 256
                 EVENT_ESPRESSO_VERSION
257 257
             );
@@ -259,13 +259,13 @@  discard block
 block discarded – undo
259 259
             // make it dance
260 260
             wp_register_script(
261 261
                 'ticket_selector',
262
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
262
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js',
263 263
                 array('espresso_core'),
264 264
                 EVENT_ESPRESSO_VERSION,
265 265
                 TRUE
266 266
             );
267 267
 			wp_enqueue_script('ticket_selector');
268
-            require_once( EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
268
+            require_once(EE_LIBRARIES.'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php');
269 269
             \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
270 270
         }
271 271
 	}
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      */
308 308
     public static function iframeCss(array $iframe_css)
309 309
     {
310
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
310
+        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css';
311 311
         return $iframe_css;
312 312
     }
313 313
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      */
322 322
     public static function iframeJs(array $iframe_js)
323 323
     {
324
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
324
+        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js';
325 325
         return $iframe_js;
326 326
     }
327 327
 
@@ -446,8 +446,8 @@  discard block
 block discarded – undo
446 446
     {
447 447
         // todo add doing_it_wrong() notice during next major version
448 448
 	    if (
449
-		    \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events'
450
-		    && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit'
449
+		    \EE_Registry::instance()->REQ->get('page') === 'espresso_events'
450
+		    && \EE_Registry::instance()->REQ->get('action') === 'edit'
451 451
 	    ) {
452 452
 		    $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton();
453 453
             $iframe_embed_button->embedButtonAssets();
Please login to merge, or discard this patch.