Completed
Branch master (c63335)
by
unknown
17:58 queued 13:20
created
core/CPTs/CptQueryModifier.php 2 patches
Indentation   +578 added lines, -578 removed lines patch added patch discarded remove patch
@@ -30,582 +30,582 @@
 block discarded – undo
30 30
  */
31 31
 class CptQueryModifier
32 32
 {
33
-    /**
34
-     * @var CurrentPage $current_page
35
-     */
36
-    protected $current_page;
37
-
38
-    /**
39
-     * @var string $post_type
40
-     */
41
-    protected $post_type = '';
42
-
43
-    /**
44
-     * CPT details from CustomPostTypeDefinitions for specific post type
45
-     *
46
-     * @var array $cpt_details
47
-     */
48
-    protected $cpt_details = array();
49
-
50
-    /**
51
-     * @var EE_Table_Base[] $model_tables
52
-     */
53
-    protected $model_tables = array();
54
-
55
-    /**
56
-     * @var array $taxonomies
57
-     */
58
-    protected $taxonomies = array();
59
-
60
-    /**
61
-     * meta table for the related CPT
62
-     *
63
-     * @var EE_Secondary_Table $meta_table
64
-     */
65
-    protected $meta_table;
66
-
67
-    /**
68
-     * EEM_CPT_Base model for the related CPT
69
-     *
70
-     * @var EEM_CPT_Base $model
71
-     */
72
-    protected $model;
73
-
74
-    /**
75
-     * @var EE_Request_Handler $request_handler
76
-     */
77
-    protected $request_handler;
78
-
79
-    /**
80
-     * @var WP_Query $wp_query
81
-     */
82
-    protected $wp_query;
83
-
84
-    /**
85
-     * @var LoaderInterface $loader
86
-     */
87
-    protected $loader;
88
-
89
-    /**
90
-     * @var RequestInterface $request
91
-     */
92
-    protected $request;
93
-
94
-
95
-    /**
96
-     * CptQueryModifier constructor
97
-     *
98
-     * @param string             $post_type
99
-     * @param array              $cpt_details
100
-     * @param WP_Query           $WP_Query
101
-     * @param CurrentPage $current_page
102
-     * @param RequestInterface   $request
103
-     * @param LoaderInterface    $loader
104
-     * @throws EE_Error
105
-     */
106
-    public function __construct(
107
-        $post_type,
108
-        array $cpt_details,
109
-        WP_Query $WP_Query,
110
-        CurrentPage $current_page,
111
-        RequestInterface $request,
112
-        LoaderInterface $loader
113
-    ) {
114
-        $this->loader = $loader;
115
-        $this->request = $request;
116
-        $this->current_page = $current_page;
117
-        $this->setWpQuery($WP_Query);
118
-        $this->setPostType($post_type);
119
-        $this->setCptDetails($cpt_details);
120
-        $this->init();
121
-    }
122
-
123
-
124
-    /**
125
-     * @return string
126
-     */
127
-    public function postType()
128
-    {
129
-        return $this->post_type;
130
-    }
131
-
132
-
133
-    /**
134
-     * @param string $post_type
135
-     */
136
-    protected function setPostType($post_type)
137
-    {
138
-        $this->post_type = $post_type;
139
-    }
140
-
141
-
142
-    /**
143
-     * @return array
144
-     */
145
-    public function cptDetails()
146
-    {
147
-        return $this->cpt_details;
148
-    }
149
-
150
-
151
-    /**
152
-     * @param array $cpt_details
153
-     */
154
-    protected function setCptDetails($cpt_details)
155
-    {
156
-        $this->cpt_details = $cpt_details;
157
-    }
158
-
159
-
160
-    /**
161
-     * @return EE_Table_Base[]
162
-     */
163
-    public function modelTables()
164
-    {
165
-        return $this->model_tables;
166
-    }
167
-
168
-
169
-    /**
170
-     * @param EE_Table_Base[] $model_tables
171
-     */
172
-    protected function setModelTables($model_tables)
173
-    {
174
-        $this->model_tables = $model_tables;
175
-    }
176
-
177
-
178
-    /**
179
-     * @return array
180
-     * @throws InvalidArgumentException
181
-     * @throws InvalidDataTypeException
182
-     * @throws InvalidInterfaceException
183
-     */
184
-    public function taxonomies()
185
-    {
186
-        if (empty($this->taxonomies)) {
187
-            $this->initializeTaxonomies();
188
-        }
189
-        return $this->taxonomies;
190
-    }
191
-
192
-
193
-    /**
194
-     * @param array $taxonomies
195
-     */
196
-    protected function setTaxonomies(array $taxonomies)
197
-    {
198
-        $this->taxonomies = $taxonomies;
199
-    }
200
-
201
-
202
-    /**
203
-     * @return EE_Secondary_Table
204
-     */
205
-    public function metaTable()
206
-    {
207
-        return $this->meta_table;
208
-    }
209
-
210
-
211
-    /**
212
-     * @param EE_Secondary_Table $meta_table
213
-     */
214
-    public function setMetaTable(EE_Secondary_Table $meta_table)
215
-    {
216
-        $this->meta_table = $meta_table;
217
-    }
218
-
219
-
220
-    /**
221
-     * @return EEM_Base
222
-     */
223
-    public function model()
224
-    {
225
-        return $this->model;
226
-    }
227
-
228
-
229
-    /**
230
-     * @param EEM_Base $CPT_model
231
-     */
232
-    protected function setModel(EEM_Base $CPT_model)
233
-    {
234
-        $this->model = $CPT_model;
235
-    }
236
-
237
-
238
-    /**
239
-     * @deprecated 4.9.63.p
240
-     * @return EE_Request_Handler
241
-     */
242
-    public function request()
243
-    {
244
-        if (! $this->request_handler instanceof EE_Request_Handler) {
245
-            $this->request_handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler');
246
-        }
247
-        return $this->request_handler;
248
-    }
249
-
250
-
251
-
252
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
253
-
254
-
255
-    /**
256
-     * @return WP_Query
257
-     */
258
-    public function WpQuery()
259
-    {
260
-        return $this->wp_query;
261
-    }
262
-    // phpcs:enable
263
-
264
-
265
-    /**
266
-     * @param WP_Query $wp_query
267
-     */
268
-    public function setWpQuery(WP_Query $wp_query)
269
-    {
270
-        $this->wp_query = $wp_query;
271
-    }
272
-
273
-
274
-    /**
275
-     * @return void
276
-     * @throws InvalidDataTypeException
277
-     * @throws InvalidInterfaceException
278
-     * @throws InvalidArgumentException
279
-     */
280
-    protected function initializeTaxonomies()
281
-    {
282
-        // check if taxonomies have already been set and that this CPT has taxonomies registered for it
283
-        if (
284
-            empty($this->taxonomies)
285
-            && isset($this->cpt_details['args']['taxonomies'])
286
-        ) {
287
-            // if so then grab them, but we want the taxonomy name as the key
288
-            $taxonomies = array_flip($this->cpt_details['args']['taxonomies']);
289
-            // then grab the list of ALL taxonomies
290
-            /** @var CustomTaxonomyDefinitions
291
-             * $taxonomy_definitions
292
-             */
293
-            $taxonomy_definitions = $this->loader->getShared(
294
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions'
295
-            );
296
-            $all_taxonomies = $taxonomy_definitions->getCustomTaxonomyDefinitions();
297
-            foreach ($taxonomies as $taxonomy => &$details) {
298
-                // add details to our taxonomies if they exist
299
-                $details = isset($all_taxonomies[ $taxonomy ])
300
-                    ? $all_taxonomies[ $taxonomy ]
301
-                    : array();
302
-            }
303
-            // ALWAYS unset() variables that were passed by reference
304
-            unset($details);
305
-            $this->setTaxonomies($taxonomies);
306
-        }
307
-    }
308
-
309
-
310
-    /**
311
-     * @since 4.9.63.p
312
-     * @throws EE_Error
313
-     */
314
-    protected function init()
315
-    {
316
-        $this->setAdditionalCptDetails();
317
-        $this->setRequestVarsIfCpt();
318
-        // convert post_type to model name
319
-        $model_name = str_replace('EE_', '', $this->cpt_details['class_name']);
320
-        // load all tables related to CPT
321
-        $this->setupModelsAndTables($model_name);
322
-        // load and instantiate CPT_*_Strategy
323
-        $CPT_Strategy = $this->cptStrategyClass($model_name);
324
-        // !!!!!!!!!!  IMPORTANT !!!!!!!!!!!!
325
-        // here's the list of available filters in the WP_Query object
326
-        // 'posts_where_paged'
327
-        // 'posts_groupby'
328
-        // 'posts_join_paged'
329
-        // 'posts_orderby'
330
-        // 'posts_distinct'
331
-        // 'post_limits'
332
-        // 'posts_fields'
333
-        // 'posts_join'
334
-        add_filter('posts_fields', array($this, 'postsFields'));
335
-        add_filter('posts_join', array($this, 'postsJoin'));
336
-        add_filter(
337
-            'get_' . $this->post_type . '_metadata',
338
-            array($CPT_Strategy, 'get_EE_post_type_metadata'),
339
-            1,
340
-            4
341
-        );
342
-        add_filter('the_posts', array($this, 'thePosts'), 1, 1);
343
-        if ($this->wp_query->is_main_query()) {
344
-            add_filter('get_edit_post_link', array($this, 'getEditPostLink'), 10, 2);
345
-            $this->addTemplateFilters();
346
-        }
347
-    }
348
-
349
-
350
-    /**
351
-     * sets some basic query vars that pertain to the CPT
352
-     *
353
-     * @access protected
354
-     * @return void
355
-     */
356
-    protected function setAdditionalCptDetails()
357
-    {
358
-        // the post or category or term that is triggering EE
359
-        $this->cpt_details['espresso_page'] = $this->current_page->isEspressoPage();
360
-        // requested post name
361
-        $this->cpt_details['post_name'] = $this->request->getRequestParam('post_name');
362
-        // add support for viewing 'private', 'draft', or 'pending' posts
363
-        if (
364
-            isset($this->wp_query->query_vars['p'])
365
-            && $this->wp_query->query_vars['p'] !== 0
366
-            && is_user_logged_in()
367
-            && current_user_can('edit_post', $this->wp_query->query_vars['p'])
368
-        ) {
369
-            // we can just inject directly into the WP_Query object
370
-            $this->wp_query->query['post_status'] = array('publish', 'private', 'draft', 'pending');
371
-            // now set the main 'ee' request var so that the appropriate module can load the appropriate template(s)
372
-            $this->request->setRequestParam('ee', $this->cpt_details['singular_slug']);
373
-        }
374
-    }
375
-
376
-
377
-    /**
378
-     * Checks if we're on a EE-CPT archive-or-single page, and if we've never set the EE request var.
379
-     * If so, sets the 'ee' request variable
380
-     * so other parts of EE can know what CPT is getting queried.
381
-     * To Mike's knowledge, this must be called from during or after the pre_get_posts hook
382
-     * in order for is_archive() and is_single() methods to work properly.
383
-     *
384
-     * @return void
385
-     */
386
-    public function setRequestVarsIfCpt()
387
-    {
388
-        // check if ee action var has been set
389
-        if (! $this->request->requestParamIsSet('ee')) {
390
-            // check that route exists for CPT archive slug
391
-            if (is_archive() && EE_Config::get_route($this->cpt_details['plural_slug'])) {
392
-                // ie: set "ee" to "events"
393
-                $this->request->setRequestParam('ee', $this->cpt_details['plural_slug']);
394
-                // or does it match a single page CPT like /event/
395
-            } elseif (is_single() && EE_Config::get_route($this->cpt_details['singular_slug'])) {
396
-                // ie: set "ee" to "event"
397
-                $this->request->setRequestParam('ee', $this->cpt_details['singular_slug']);
398
-            }
399
-        }
400
-    }
401
-
402
-
403
-    /**
404
-     * setupModelsAndTables
405
-     *
406
-     * @access protected
407
-     * @param string $model_name
408
-     * @throws EE_Error
409
-     */
410
-    protected function setupModelsAndTables($model_name)
411
-    {
412
-        // get CPT table data via CPT Model
413
-        $full_model_name = strpos($model_name, 'EEM_') !== 0
414
-            ? 'EEM_' . $model_name
415
-            : $model_name;
416
-        $model = $this->loader->getShared($full_model_name);
417
-        if (! $model instanceof EEM_Base) {
418
-            throw new EE_Error(
419
-                sprintf(
420
-                    esc_html__(
421
-                        'The "%1$s" model could not be loaded.',
422
-                        'event_espresso'
423
-                    ),
424
-                    $full_model_name
425
-                )
426
-            );
427
-        }
428
-        $this->setModel($model);
429
-        $this->setModelTables($this->model->get_tables());
430
-        $meta_model = $model_name . '_Meta';
431
-        // is there a Meta Table for this CPT?
432
-        if (
433
-            isset($this->cpt_details['tables'][ $meta_model ])
434
-            && $this->cpt_details['tables'][ $meta_model ] instanceof EE_Secondary_Table
435
-        ) {
436
-            $this->setMetaTable($this->cpt_details['tables'][ $meta_model ]);
437
-        }
438
-    }
439
-
440
-
441
-    /**
442
-     * cptStrategyClass
443
-     *
444
-     * @access protected
445
-     * @param  string $model_name
446
-     * @return string
447
-     */
448
-    protected function cptStrategyClass($model_name)
449
-    {
450
-        // creates classname like:  CPT_Event_Strategy
451
-        $CPT_Strategy_class_name = 'EE_CPT_' . $model_name . '_Strategy';
452
-        // load and instantiate
453
-        $CPT_Strategy = $this->loader->getShared(
454
-            $CPT_Strategy_class_name,
455
-            array('WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details)
456
-        );
457
-        if ($CPT_Strategy === null) {
458
-            $CPT_Strategy = $this->loader->getShared(
459
-                'EE_CPT_Default_Strategy',
460
-                array('WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details)
461
-            );
462
-        }
463
-        return $CPT_Strategy;
464
-    }
465
-
466
-
467
-    /**
468
-     * postsFields
469
-     *
470
-     * @access public
471
-     * @param  $SQL
472
-     * @return string
473
-     */
474
-    public function postsFields($SQL)
475
-    {
476
-        // does this CPT have a meta table ?
477
-        if ($this->meta_table instanceof EE_Secondary_Table) {
478
-            // adds something like ", wp_esp_event_meta.* " to WP Query SELECT statement
479
-            $SQL .= ', ' . $this->meta_table->get_table_name() . '.* ';
480
-        }
481
-        remove_filter('posts_fields', array($this, 'postsFields'));
482
-        return $SQL;
483
-    }
484
-
485
-
486
-    /**
487
-     * postsJoin
488
-     *
489
-     * @access public
490
-     * @param  $SQL
491
-     * @return string
492
-     */
493
-    public function postsJoin($SQL)
494
-    {
495
-        // does this CPT have a meta table ?
496
-        if ($this->meta_table instanceof EE_Secondary_Table) {
497
-            global $wpdb;
498
-            // adds something like " LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement
499
-            $SQL .= ' LEFT JOIN '
500
-                    . $this->meta_table->get_table_name()
501
-                    . ' ON ( '
502
-                    . $this->meta_table->get_table_name()
503
-                    . '.'
504
-                    . $this->meta_table->get_fk_on_table()
505
-                    . ' = '
506
-                    . $wpdb->posts
507
-                    . '.ID ) ';
508
-        }
509
-        remove_filter('posts_join', array($this, 'postsJoin'));
510
-        return $SQL;
511
-    }
512
-
513
-
514
-    /**
515
-     * thePosts
516
-     *
517
-     * @access public
518
-     * @param  WP_Post[] $posts
519
-     * @return WP_Post[]
520
-     */
521
-    public function thePosts($posts)
522
-    {
523
-        $CPT_class = $this->cpt_details['class_name'];
524
-        // loop thru posts
525
-        if (is_array($posts) && $this->model instanceof EEM_CPT_Base) {
526
-            foreach ($posts as $post) {
527
-                if ($post->post_type === $this->post_type) {
528
-                    $post->{$CPT_class} = $this->model->instantiate_class_from_post_object($post);
529
-                }
530
-            }
531
-        }
532
-        remove_filter('the_posts', array($this, 'thePosts'), 1);
533
-        return $posts;
534
-    }
535
-
536
-
537
-    /**
538
-     * @param $url
539
-     * @param $ID
540
-     * @return string
541
-     */
542
-    public function getEditPostLink($url, $ID)
543
-    {
544
-        // need to make sure we only edit links if our cpt
545
-        global $post;
546
-        // notice if the cpt is registered with `show_ee_ui` set to false, we take that to mean that the WordPress core ui
547
-        // for interacting with the CPT is desired and there is no EE UI for interacting with the CPT in the admin.
548
-        if (
549
-            ! $post instanceof WP_Post
550
-            || $post->post_type !== $this->post_type
551
-            || (
552
-                isset($this->cpt_details['args']['show_ee_ui'])
553
-                && ! $this->cpt_details['args']['show_ee_ui']
554
-            )
555
-        ) {
556
-            return $url;
557
-        }
558
-        // k made it here so all is good.
559
-        return wp_nonce_url(
560
-            add_query_arg(
561
-                array('page' => $this->post_type, 'post' => $ID, 'action' => 'edit'),
562
-                admin_url('admin.php')
563
-            ),
564
-            'edit',
565
-            'edit_nonce'
566
-        );
567
-    }
568
-
569
-
570
-    /**
571
-     * Execute any template filters.
572
-     * This method is only called if in main query.
573
-     *
574
-     * @return void
575
-     */
576
-    public function addTemplateFilters()
577
-    {
578
-        // if requested cpt supports page_templates and it's the main query
579
-        if (! empty($this->cpt_details['args']['page_templates']) && $this->wp_query->is_main_query()) {
580
-            // then let's hook into the appropriate query_template hook
581
-            add_filter('single_template', array($this, 'singleCptTemplate'));
582
-        }
583
-    }
584
-
585
-
586
-    /**
587
-     * Callback for single_template wp filter.
588
-     * This is used to load the set page_template for a single ee cpt if its set.  If "default" then we load the normal
589
-     * hierarchy.
590
-     *
591
-     * @access public
592
-     * @param string $current_template Existing default template path derived for this page call.
593
-     * @return string the path to the full template file.
594
-     */
595
-    public function singleCptTemplate($current_template)
596
-    {
597
-        $object = get_queried_object();
598
-        // does this called object HAVE a page template set that is something other than the default.
599
-        $template = get_post_meta($object->ID, '_wp_page_template', true);
600
-        // exit early if default or not set or invalid path (accounts for theme changes)
601
-        if (
602
-            $template === 'default'
603
-            || empty($template)
604
-            || ! is_readable(get_stylesheet_directory() . '/' . $template)
605
-        ) {
606
-            return $current_template;
607
-        }
608
-        // made it here so we SHOULD be able to just locate the template and then return it.
609
-        return locate_template(array($template));
610
-    }
33
+	/**
34
+	 * @var CurrentPage $current_page
35
+	 */
36
+	protected $current_page;
37
+
38
+	/**
39
+	 * @var string $post_type
40
+	 */
41
+	protected $post_type = '';
42
+
43
+	/**
44
+	 * CPT details from CustomPostTypeDefinitions for specific post type
45
+	 *
46
+	 * @var array $cpt_details
47
+	 */
48
+	protected $cpt_details = array();
49
+
50
+	/**
51
+	 * @var EE_Table_Base[] $model_tables
52
+	 */
53
+	protected $model_tables = array();
54
+
55
+	/**
56
+	 * @var array $taxonomies
57
+	 */
58
+	protected $taxonomies = array();
59
+
60
+	/**
61
+	 * meta table for the related CPT
62
+	 *
63
+	 * @var EE_Secondary_Table $meta_table
64
+	 */
65
+	protected $meta_table;
66
+
67
+	/**
68
+	 * EEM_CPT_Base model for the related CPT
69
+	 *
70
+	 * @var EEM_CPT_Base $model
71
+	 */
72
+	protected $model;
73
+
74
+	/**
75
+	 * @var EE_Request_Handler $request_handler
76
+	 */
77
+	protected $request_handler;
78
+
79
+	/**
80
+	 * @var WP_Query $wp_query
81
+	 */
82
+	protected $wp_query;
83
+
84
+	/**
85
+	 * @var LoaderInterface $loader
86
+	 */
87
+	protected $loader;
88
+
89
+	/**
90
+	 * @var RequestInterface $request
91
+	 */
92
+	protected $request;
93
+
94
+
95
+	/**
96
+	 * CptQueryModifier constructor
97
+	 *
98
+	 * @param string             $post_type
99
+	 * @param array              $cpt_details
100
+	 * @param WP_Query           $WP_Query
101
+	 * @param CurrentPage $current_page
102
+	 * @param RequestInterface   $request
103
+	 * @param LoaderInterface    $loader
104
+	 * @throws EE_Error
105
+	 */
106
+	public function __construct(
107
+		$post_type,
108
+		array $cpt_details,
109
+		WP_Query $WP_Query,
110
+		CurrentPage $current_page,
111
+		RequestInterface $request,
112
+		LoaderInterface $loader
113
+	) {
114
+		$this->loader = $loader;
115
+		$this->request = $request;
116
+		$this->current_page = $current_page;
117
+		$this->setWpQuery($WP_Query);
118
+		$this->setPostType($post_type);
119
+		$this->setCptDetails($cpt_details);
120
+		$this->init();
121
+	}
122
+
123
+
124
+	/**
125
+	 * @return string
126
+	 */
127
+	public function postType()
128
+	{
129
+		return $this->post_type;
130
+	}
131
+
132
+
133
+	/**
134
+	 * @param string $post_type
135
+	 */
136
+	protected function setPostType($post_type)
137
+	{
138
+		$this->post_type = $post_type;
139
+	}
140
+
141
+
142
+	/**
143
+	 * @return array
144
+	 */
145
+	public function cptDetails()
146
+	{
147
+		return $this->cpt_details;
148
+	}
149
+
150
+
151
+	/**
152
+	 * @param array $cpt_details
153
+	 */
154
+	protected function setCptDetails($cpt_details)
155
+	{
156
+		$this->cpt_details = $cpt_details;
157
+	}
158
+
159
+
160
+	/**
161
+	 * @return EE_Table_Base[]
162
+	 */
163
+	public function modelTables()
164
+	{
165
+		return $this->model_tables;
166
+	}
167
+
168
+
169
+	/**
170
+	 * @param EE_Table_Base[] $model_tables
171
+	 */
172
+	protected function setModelTables($model_tables)
173
+	{
174
+		$this->model_tables = $model_tables;
175
+	}
176
+
177
+
178
+	/**
179
+	 * @return array
180
+	 * @throws InvalidArgumentException
181
+	 * @throws InvalidDataTypeException
182
+	 * @throws InvalidInterfaceException
183
+	 */
184
+	public function taxonomies()
185
+	{
186
+		if (empty($this->taxonomies)) {
187
+			$this->initializeTaxonomies();
188
+		}
189
+		return $this->taxonomies;
190
+	}
191
+
192
+
193
+	/**
194
+	 * @param array $taxonomies
195
+	 */
196
+	protected function setTaxonomies(array $taxonomies)
197
+	{
198
+		$this->taxonomies = $taxonomies;
199
+	}
200
+
201
+
202
+	/**
203
+	 * @return EE_Secondary_Table
204
+	 */
205
+	public function metaTable()
206
+	{
207
+		return $this->meta_table;
208
+	}
209
+
210
+
211
+	/**
212
+	 * @param EE_Secondary_Table $meta_table
213
+	 */
214
+	public function setMetaTable(EE_Secondary_Table $meta_table)
215
+	{
216
+		$this->meta_table = $meta_table;
217
+	}
218
+
219
+
220
+	/**
221
+	 * @return EEM_Base
222
+	 */
223
+	public function model()
224
+	{
225
+		return $this->model;
226
+	}
227
+
228
+
229
+	/**
230
+	 * @param EEM_Base $CPT_model
231
+	 */
232
+	protected function setModel(EEM_Base $CPT_model)
233
+	{
234
+		$this->model = $CPT_model;
235
+	}
236
+
237
+
238
+	/**
239
+	 * @deprecated 4.9.63.p
240
+	 * @return EE_Request_Handler
241
+	 */
242
+	public function request()
243
+	{
244
+		if (! $this->request_handler instanceof EE_Request_Handler) {
245
+			$this->request_handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler');
246
+		}
247
+		return $this->request_handler;
248
+	}
249
+
250
+
251
+
252
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
253
+
254
+
255
+	/**
256
+	 * @return WP_Query
257
+	 */
258
+	public function WpQuery()
259
+	{
260
+		return $this->wp_query;
261
+	}
262
+	// phpcs:enable
263
+
264
+
265
+	/**
266
+	 * @param WP_Query $wp_query
267
+	 */
268
+	public function setWpQuery(WP_Query $wp_query)
269
+	{
270
+		$this->wp_query = $wp_query;
271
+	}
272
+
273
+
274
+	/**
275
+	 * @return void
276
+	 * @throws InvalidDataTypeException
277
+	 * @throws InvalidInterfaceException
278
+	 * @throws InvalidArgumentException
279
+	 */
280
+	protected function initializeTaxonomies()
281
+	{
282
+		// check if taxonomies have already been set and that this CPT has taxonomies registered for it
283
+		if (
284
+			empty($this->taxonomies)
285
+			&& isset($this->cpt_details['args']['taxonomies'])
286
+		) {
287
+			// if so then grab them, but we want the taxonomy name as the key
288
+			$taxonomies = array_flip($this->cpt_details['args']['taxonomies']);
289
+			// then grab the list of ALL taxonomies
290
+			/** @var CustomTaxonomyDefinitions
291
+			 * $taxonomy_definitions
292
+			 */
293
+			$taxonomy_definitions = $this->loader->getShared(
294
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions'
295
+			);
296
+			$all_taxonomies = $taxonomy_definitions->getCustomTaxonomyDefinitions();
297
+			foreach ($taxonomies as $taxonomy => &$details) {
298
+				// add details to our taxonomies if they exist
299
+				$details = isset($all_taxonomies[ $taxonomy ])
300
+					? $all_taxonomies[ $taxonomy ]
301
+					: array();
302
+			}
303
+			// ALWAYS unset() variables that were passed by reference
304
+			unset($details);
305
+			$this->setTaxonomies($taxonomies);
306
+		}
307
+	}
308
+
309
+
310
+	/**
311
+	 * @since 4.9.63.p
312
+	 * @throws EE_Error
313
+	 */
314
+	protected function init()
315
+	{
316
+		$this->setAdditionalCptDetails();
317
+		$this->setRequestVarsIfCpt();
318
+		// convert post_type to model name
319
+		$model_name = str_replace('EE_', '', $this->cpt_details['class_name']);
320
+		// load all tables related to CPT
321
+		$this->setupModelsAndTables($model_name);
322
+		// load and instantiate CPT_*_Strategy
323
+		$CPT_Strategy = $this->cptStrategyClass($model_name);
324
+		// !!!!!!!!!!  IMPORTANT !!!!!!!!!!!!
325
+		// here's the list of available filters in the WP_Query object
326
+		// 'posts_where_paged'
327
+		// 'posts_groupby'
328
+		// 'posts_join_paged'
329
+		// 'posts_orderby'
330
+		// 'posts_distinct'
331
+		// 'post_limits'
332
+		// 'posts_fields'
333
+		// 'posts_join'
334
+		add_filter('posts_fields', array($this, 'postsFields'));
335
+		add_filter('posts_join', array($this, 'postsJoin'));
336
+		add_filter(
337
+			'get_' . $this->post_type . '_metadata',
338
+			array($CPT_Strategy, 'get_EE_post_type_metadata'),
339
+			1,
340
+			4
341
+		);
342
+		add_filter('the_posts', array($this, 'thePosts'), 1, 1);
343
+		if ($this->wp_query->is_main_query()) {
344
+			add_filter('get_edit_post_link', array($this, 'getEditPostLink'), 10, 2);
345
+			$this->addTemplateFilters();
346
+		}
347
+	}
348
+
349
+
350
+	/**
351
+	 * sets some basic query vars that pertain to the CPT
352
+	 *
353
+	 * @access protected
354
+	 * @return void
355
+	 */
356
+	protected function setAdditionalCptDetails()
357
+	{
358
+		// the post or category or term that is triggering EE
359
+		$this->cpt_details['espresso_page'] = $this->current_page->isEspressoPage();
360
+		// requested post name
361
+		$this->cpt_details['post_name'] = $this->request->getRequestParam('post_name');
362
+		// add support for viewing 'private', 'draft', or 'pending' posts
363
+		if (
364
+			isset($this->wp_query->query_vars['p'])
365
+			&& $this->wp_query->query_vars['p'] !== 0
366
+			&& is_user_logged_in()
367
+			&& current_user_can('edit_post', $this->wp_query->query_vars['p'])
368
+		) {
369
+			// we can just inject directly into the WP_Query object
370
+			$this->wp_query->query['post_status'] = array('publish', 'private', 'draft', 'pending');
371
+			// now set the main 'ee' request var so that the appropriate module can load the appropriate template(s)
372
+			$this->request->setRequestParam('ee', $this->cpt_details['singular_slug']);
373
+		}
374
+	}
375
+
376
+
377
+	/**
378
+	 * Checks if we're on a EE-CPT archive-or-single page, and if we've never set the EE request var.
379
+	 * If so, sets the 'ee' request variable
380
+	 * so other parts of EE can know what CPT is getting queried.
381
+	 * To Mike's knowledge, this must be called from during or after the pre_get_posts hook
382
+	 * in order for is_archive() and is_single() methods to work properly.
383
+	 *
384
+	 * @return void
385
+	 */
386
+	public function setRequestVarsIfCpt()
387
+	{
388
+		// check if ee action var has been set
389
+		if (! $this->request->requestParamIsSet('ee')) {
390
+			// check that route exists for CPT archive slug
391
+			if (is_archive() && EE_Config::get_route($this->cpt_details['plural_slug'])) {
392
+				// ie: set "ee" to "events"
393
+				$this->request->setRequestParam('ee', $this->cpt_details['plural_slug']);
394
+				// or does it match a single page CPT like /event/
395
+			} elseif (is_single() && EE_Config::get_route($this->cpt_details['singular_slug'])) {
396
+				// ie: set "ee" to "event"
397
+				$this->request->setRequestParam('ee', $this->cpt_details['singular_slug']);
398
+			}
399
+		}
400
+	}
401
+
402
+
403
+	/**
404
+	 * setupModelsAndTables
405
+	 *
406
+	 * @access protected
407
+	 * @param string $model_name
408
+	 * @throws EE_Error
409
+	 */
410
+	protected function setupModelsAndTables($model_name)
411
+	{
412
+		// get CPT table data via CPT Model
413
+		$full_model_name = strpos($model_name, 'EEM_') !== 0
414
+			? 'EEM_' . $model_name
415
+			: $model_name;
416
+		$model = $this->loader->getShared($full_model_name);
417
+		if (! $model instanceof EEM_Base) {
418
+			throw new EE_Error(
419
+				sprintf(
420
+					esc_html__(
421
+						'The "%1$s" model could not be loaded.',
422
+						'event_espresso'
423
+					),
424
+					$full_model_name
425
+				)
426
+			);
427
+		}
428
+		$this->setModel($model);
429
+		$this->setModelTables($this->model->get_tables());
430
+		$meta_model = $model_name . '_Meta';
431
+		// is there a Meta Table for this CPT?
432
+		if (
433
+			isset($this->cpt_details['tables'][ $meta_model ])
434
+			&& $this->cpt_details['tables'][ $meta_model ] instanceof EE_Secondary_Table
435
+		) {
436
+			$this->setMetaTable($this->cpt_details['tables'][ $meta_model ]);
437
+		}
438
+	}
439
+
440
+
441
+	/**
442
+	 * cptStrategyClass
443
+	 *
444
+	 * @access protected
445
+	 * @param  string $model_name
446
+	 * @return string
447
+	 */
448
+	protected function cptStrategyClass($model_name)
449
+	{
450
+		// creates classname like:  CPT_Event_Strategy
451
+		$CPT_Strategy_class_name = 'EE_CPT_' . $model_name . '_Strategy';
452
+		// load and instantiate
453
+		$CPT_Strategy = $this->loader->getShared(
454
+			$CPT_Strategy_class_name,
455
+			array('WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details)
456
+		);
457
+		if ($CPT_Strategy === null) {
458
+			$CPT_Strategy = $this->loader->getShared(
459
+				'EE_CPT_Default_Strategy',
460
+				array('WP_Query' => $this->wp_query, 'CPT' => $this->cpt_details)
461
+			);
462
+		}
463
+		return $CPT_Strategy;
464
+	}
465
+
466
+
467
+	/**
468
+	 * postsFields
469
+	 *
470
+	 * @access public
471
+	 * @param  $SQL
472
+	 * @return string
473
+	 */
474
+	public function postsFields($SQL)
475
+	{
476
+		// does this CPT have a meta table ?
477
+		if ($this->meta_table instanceof EE_Secondary_Table) {
478
+			// adds something like ", wp_esp_event_meta.* " to WP Query SELECT statement
479
+			$SQL .= ', ' . $this->meta_table->get_table_name() . '.* ';
480
+		}
481
+		remove_filter('posts_fields', array($this, 'postsFields'));
482
+		return $SQL;
483
+	}
484
+
485
+
486
+	/**
487
+	 * postsJoin
488
+	 *
489
+	 * @access public
490
+	 * @param  $SQL
491
+	 * @return string
492
+	 */
493
+	public function postsJoin($SQL)
494
+	{
495
+		// does this CPT have a meta table ?
496
+		if ($this->meta_table instanceof EE_Secondary_Table) {
497
+			global $wpdb;
498
+			// adds something like " LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement
499
+			$SQL .= ' LEFT JOIN '
500
+					. $this->meta_table->get_table_name()
501
+					. ' ON ( '
502
+					. $this->meta_table->get_table_name()
503
+					. '.'
504
+					. $this->meta_table->get_fk_on_table()
505
+					. ' = '
506
+					. $wpdb->posts
507
+					. '.ID ) ';
508
+		}
509
+		remove_filter('posts_join', array($this, 'postsJoin'));
510
+		return $SQL;
511
+	}
512
+
513
+
514
+	/**
515
+	 * thePosts
516
+	 *
517
+	 * @access public
518
+	 * @param  WP_Post[] $posts
519
+	 * @return WP_Post[]
520
+	 */
521
+	public function thePosts($posts)
522
+	{
523
+		$CPT_class = $this->cpt_details['class_name'];
524
+		// loop thru posts
525
+		if (is_array($posts) && $this->model instanceof EEM_CPT_Base) {
526
+			foreach ($posts as $post) {
527
+				if ($post->post_type === $this->post_type) {
528
+					$post->{$CPT_class} = $this->model->instantiate_class_from_post_object($post);
529
+				}
530
+			}
531
+		}
532
+		remove_filter('the_posts', array($this, 'thePosts'), 1);
533
+		return $posts;
534
+	}
535
+
536
+
537
+	/**
538
+	 * @param $url
539
+	 * @param $ID
540
+	 * @return string
541
+	 */
542
+	public function getEditPostLink($url, $ID)
543
+	{
544
+		// need to make sure we only edit links if our cpt
545
+		global $post;
546
+		// notice if the cpt is registered with `show_ee_ui` set to false, we take that to mean that the WordPress core ui
547
+		// for interacting with the CPT is desired and there is no EE UI for interacting with the CPT in the admin.
548
+		if (
549
+			! $post instanceof WP_Post
550
+			|| $post->post_type !== $this->post_type
551
+			|| (
552
+				isset($this->cpt_details['args']['show_ee_ui'])
553
+				&& ! $this->cpt_details['args']['show_ee_ui']
554
+			)
555
+		) {
556
+			return $url;
557
+		}
558
+		// k made it here so all is good.
559
+		return wp_nonce_url(
560
+			add_query_arg(
561
+				array('page' => $this->post_type, 'post' => $ID, 'action' => 'edit'),
562
+				admin_url('admin.php')
563
+			),
564
+			'edit',
565
+			'edit_nonce'
566
+		);
567
+	}
568
+
569
+
570
+	/**
571
+	 * Execute any template filters.
572
+	 * This method is only called if in main query.
573
+	 *
574
+	 * @return void
575
+	 */
576
+	public function addTemplateFilters()
577
+	{
578
+		// if requested cpt supports page_templates and it's the main query
579
+		if (! empty($this->cpt_details['args']['page_templates']) && $this->wp_query->is_main_query()) {
580
+			// then let's hook into the appropriate query_template hook
581
+			add_filter('single_template', array($this, 'singleCptTemplate'));
582
+		}
583
+	}
584
+
585
+
586
+	/**
587
+	 * Callback for single_template wp filter.
588
+	 * This is used to load the set page_template for a single ee cpt if its set.  If "default" then we load the normal
589
+	 * hierarchy.
590
+	 *
591
+	 * @access public
592
+	 * @param string $current_template Existing default template path derived for this page call.
593
+	 * @return string the path to the full template file.
594
+	 */
595
+	public function singleCptTemplate($current_template)
596
+	{
597
+		$object = get_queried_object();
598
+		// does this called object HAVE a page template set that is something other than the default.
599
+		$template = get_post_meta($object->ID, '_wp_page_template', true);
600
+		// exit early if default or not set or invalid path (accounts for theme changes)
601
+		if (
602
+			$template === 'default'
603
+			|| empty($template)
604
+			|| ! is_readable(get_stylesheet_directory() . '/' . $template)
605
+		) {
606
+			return $current_template;
607
+		}
608
+		// made it here so we SHOULD be able to just locate the template and then return it.
609
+		return locate_template(array($template));
610
+	}
611 611
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public function request()
243 243
     {
244
-        if (! $this->request_handler instanceof EE_Request_Handler) {
244
+        if ( ! $this->request_handler instanceof EE_Request_Handler) {
245 245
             $this->request_handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler');
246 246
         }
247 247
         return $this->request_handler;
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
             $all_taxonomies = $taxonomy_definitions->getCustomTaxonomyDefinitions();
297 297
             foreach ($taxonomies as $taxonomy => &$details) {
298 298
                 // add details to our taxonomies if they exist
299
-                $details = isset($all_taxonomies[ $taxonomy ])
300
-                    ? $all_taxonomies[ $taxonomy ]
299
+                $details = isset($all_taxonomies[$taxonomy])
300
+                    ? $all_taxonomies[$taxonomy]
301 301
                     : array();
302 302
             }
303 303
             // ALWAYS unset() variables that were passed by reference
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         add_filter('posts_fields', array($this, 'postsFields'));
335 335
         add_filter('posts_join', array($this, 'postsJoin'));
336 336
         add_filter(
337
-            'get_' . $this->post_type . '_metadata',
337
+            'get_'.$this->post_type.'_metadata',
338 338
             array($CPT_Strategy, 'get_EE_post_type_metadata'),
339 339
             1,
340 340
             4
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     public function setRequestVarsIfCpt()
387 387
     {
388 388
         // check if ee action var has been set
389
-        if (! $this->request->requestParamIsSet('ee')) {
389
+        if ( ! $this->request->requestParamIsSet('ee')) {
390 390
             // check that route exists for CPT archive slug
391 391
             if (is_archive() && EE_Config::get_route($this->cpt_details['plural_slug'])) {
392 392
                 // ie: set "ee" to "events"
@@ -411,10 +411,10 @@  discard block
 block discarded – undo
411 411
     {
412 412
         // get CPT table data via CPT Model
413 413
         $full_model_name = strpos($model_name, 'EEM_') !== 0
414
-            ? 'EEM_' . $model_name
414
+            ? 'EEM_'.$model_name
415 415
             : $model_name;
416 416
         $model = $this->loader->getShared($full_model_name);
417
-        if (! $model instanceof EEM_Base) {
417
+        if ( ! $model instanceof EEM_Base) {
418 418
             throw new EE_Error(
419 419
                 sprintf(
420 420
                     esc_html__(
@@ -427,13 +427,13 @@  discard block
 block discarded – undo
427 427
         }
428 428
         $this->setModel($model);
429 429
         $this->setModelTables($this->model->get_tables());
430
-        $meta_model = $model_name . '_Meta';
430
+        $meta_model = $model_name.'_Meta';
431 431
         // is there a Meta Table for this CPT?
432 432
         if (
433
-            isset($this->cpt_details['tables'][ $meta_model ])
434
-            && $this->cpt_details['tables'][ $meta_model ] instanceof EE_Secondary_Table
433
+            isset($this->cpt_details['tables'][$meta_model])
434
+            && $this->cpt_details['tables'][$meta_model] instanceof EE_Secondary_Table
435 435
         ) {
436
-            $this->setMetaTable($this->cpt_details['tables'][ $meta_model ]);
436
+            $this->setMetaTable($this->cpt_details['tables'][$meta_model]);
437 437
         }
438 438
     }
439 439
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
     protected function cptStrategyClass($model_name)
449 449
     {
450 450
         // creates classname like:  CPT_Event_Strategy
451
-        $CPT_Strategy_class_name = 'EE_CPT_' . $model_name . '_Strategy';
451
+        $CPT_Strategy_class_name = 'EE_CPT_'.$model_name.'_Strategy';
452 452
         // load and instantiate
453 453
         $CPT_Strategy = $this->loader->getShared(
454 454
             $CPT_Strategy_class_name,
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
         // does this CPT have a meta table ?
477 477
         if ($this->meta_table instanceof EE_Secondary_Table) {
478 478
             // adds something like ", wp_esp_event_meta.* " to WP Query SELECT statement
479
-            $SQL .= ', ' . $this->meta_table->get_table_name() . '.* ';
479
+            $SQL .= ', '.$this->meta_table->get_table_name().'.* ';
480 480
         }
481 481
         remove_filter('posts_fields', array($this, 'postsFields'));
482 482
         return $SQL;
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
     public function addTemplateFilters()
577 577
     {
578 578
         // if requested cpt supports page_templates and it's the main query
579
-        if (! empty($this->cpt_details['args']['page_templates']) && $this->wp_query->is_main_query()) {
579
+        if ( ! empty($this->cpt_details['args']['page_templates']) && $this->wp_query->is_main_query()) {
580 580
             // then let's hook into the appropriate query_template hook
581 581
             add_filter('single_template', array($this, 'singleCptTemplate'));
582 582
         }
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
         if (
602 602
             $template === 'default'
603 603
             || empty($template)
604
-            || ! is_readable(get_stylesheet_directory() . '/' . $template)
604
+            || ! is_readable(get_stylesheet_directory().'/'.$template)
605 605
         ) {
606 606
             return $current_template;
607 607
         }
Please login to merge, or discard this patch.
core/EE_Cron_Tasks.core.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public static function instance()
40 40
     {
41
-        if (! self::$_instance instanceof EE_Cron_Tasks) {
41
+        if ( ! self::$_instance instanceof EE_Cron_Tasks) {
42 42
             self::$_instance = new self();
43 43
         }
44 44
         return self::$_instance;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
              */
73 73
             add_action(
74 74
                 'AHEE__EE_System__load_core_configuration__complete',
75
-                function () {
75
+                function() {
76 76
                     EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true;
77 77
                     EE_Registry::instance()->NET_CFG->update_config(true, false);
78 78
                     add_option('ee_disabled_wp_cron_check', 1, '', false);
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
             'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
125 125
         );
126 126
         $crons = (array) get_option('cron');
127
-        if (! is_array($crons)) {
127
+        if ( ! is_array($crons)) {
128 128
             return;
129 129
         }
130 130
         foreach ($crons as $timestamp => $cron) {
131 131
             /** @var array[] $cron */
132 132
             foreach ($ee_crons as $ee_cron) {
133
-                if (isset($cron[ $ee_cron ]) && is_array($cron[ $ee_cron ])) {
133
+                if (isset($cron[$ee_cron]) && is_array($cron[$ee_cron])) {
134 134
                     do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron');
135
-                    foreach ($cron[ $ee_cron ] as $ee_cron_details) {
136
-                        if (! empty($ee_cron_details['args'])) {
135
+                    foreach ($cron[$ee_cron] as $ee_cron_details) {
136
+                        if ( ! empty($ee_cron_details['args'])) {
137 137
                             do_action(
138 138
                                 'AHEE_log',
139 139
                                 __CLASS__,
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     public static function reschedule_cron_for_transactions_if_maintenance_mode($cron_task, array $TXN_IDs)
162 162
     {
163
-        if (! method_exists('EE_Cron_Tasks', $cron_task)) {
163
+        if ( ! method_exists('EE_Cron_Tasks', $cron_task)) {
164 164
             throw new DomainException(
165 165
                 sprintf(
166 166
                     esc_html__('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'),
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             );
170 170
         }
171 171
         // reschedule the cron if we can't hit the db right now
172
-        if (! EE_Maintenance_Mode::instance()->models_can_query()) {
172
+        if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
173 173
             foreach ($TXN_IDs as $TXN_ID => $additional_vars) {
174 174
                 // ensure $additional_vars is an array
175 175
                 $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
     {
251 251
         do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
252 252
         if (absint($TXN_ID)) {
253
-            self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID;
253
+            self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID;
254 254
             add_action(
255 255
                 'shutdown',
256 256
                 array('EE_Cron_Tasks', 'update_transaction_with_payment'),
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         EE_Registry::instance()->load_model('Transaction');
298 298
         foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) {
299 299
             // reschedule the cron if we can't hit the db right now
300
-            if (! EE_Maintenance_Mode::instance()->models_can_query()) {
300
+            if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
301 301
                 // reset cron job for updating the TXN
302 302
                 EE_Cron_Tasks::schedule_update_transaction_with_payment(
303 303
                     time() + EE_Cron_Tasks::reschedule_timeout,
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
                 // now try to update the TXN with any payments
314 314
                 $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true);
315 315
             }
316
-            unset(self::$_update_transactions_with_payment[ $TXN_ID ]);
316
+            unset(self::$_update_transactions_with_payment[$TXN_ID]);
317 317
         }
318 318
     }
319 319
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
     public static function expired_transaction_check($TXN_ID = 0)
375 375
     {
376 376
         if (absint($TXN_ID)) {
377
-            self::$_expired_transactions[ $TXN_ID ] = $TXN_ID;
377
+            self::$_expired_transactions[$TXN_ID] = $TXN_ID;
378 378
             add_action(
379 379
                 'shutdown',
380 380
                 array('EE_Cron_Tasks', 'process_expired_transactions'),
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
                         break;
503 503
                 }
504 504
             }
505
-            unset(self::$_expired_transactions[ $TXN_ID ]);
505
+            unset(self::$_expired_transactions[$TXN_ID]);
506 506
         }
507 507
     }
508 508
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
             $reg_config = LoaderFactory::getLoader()->load('EE_Registration_Config');
550 550
             $time_diff_for_comparison = apply_filters(
551 551
                 'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison',
552
-                '-' . $reg_config->gateway_log_lifespan
552
+                '-'.$reg_config->gateway_log_lifespan
553 553
             );
554 554
             EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison));
555 555
         }
Please login to merge, or discard this patch.
Indentation   +600 added lines, -600 removed lines patch added patch discarded remove patch
@@ -14,607 +14,607 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Cron_Tasks extends EE_Base
16 16
 {
17
-    /**
18
-     * WordPress doesn't allow duplicate crons within 10 minutes of the original,
19
-     * so we'll set our retry time for just over 10 minutes to avoid that
20
-     */
21
-    const reschedule_timeout = 605;
22
-
23
-
24
-    /**
25
-     * @var EE_Cron_Tasks
26
-     */
27
-    private static $_instance;
28
-
29
-
30
-    /**
31
-     * @return EE_Cron_Tasks
32
-     * @throws ReflectionException
33
-     * @throws EE_Error
34
-     * @throws InvalidArgumentException
35
-     * @throws InvalidInterfaceException
36
-     * @throws InvalidDataTypeException
37
-     */
38
-    public static function instance()
39
-    {
40
-        if (! self::$_instance instanceof EE_Cron_Tasks) {
41
-            self::$_instance = new self();
42
-        }
43
-        return self::$_instance;
44
-    }
45
-
46
-
47
-    /**
48
-     * @access private
49
-     * @throws InvalidDataTypeException
50
-     * @throws InvalidInterfaceException
51
-     * @throws InvalidArgumentException
52
-     * @throws EE_Error
53
-     * @throws ReflectionException
54
-     */
55
-    private function __construct()
56
-    {
57
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
58
-        // verify that WP Cron is enabled
59
-        if (
60
-            defined('DISABLE_WP_CRON')
61
-            && DISABLE_WP_CRON
62
-            && is_admin()
63
-            && ! get_option('ee_disabled_wp_cron_check')
64
-        ) {
65
-            /**
66
-             * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before
67
-             * config is loaded.
68
-             * This is intentionally using a anonymous function so that its not easily de-registered.  Client code
69
-             * wanting to not have this functionality can just register its own action at a priority after this one to
70
-             * reverse any changes.
71
-             */
72
-            add_action(
73
-                'AHEE__EE_System__load_core_configuration__complete',
74
-                function () {
75
-                    EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true;
76
-                    EE_Registry::instance()->NET_CFG->update_config(true, false);
77
-                    add_option('ee_disabled_wp_cron_check', 1, '', false);
78
-                }
79
-            );
80
-        }
81
-        // UPDATE TRANSACTION WITH PAYMENT
82
-        add_action(
83
-            'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
84
-            array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'),
85
-            10,
86
-            2
87
-        );
88
-        // ABANDONED / EXPIRED TRANSACTION CHECK
89
-        add_action(
90
-            'AHEE__EE_Cron_Tasks__expired_transaction_check',
91
-            array('EE_Cron_Tasks', 'expired_transaction_check'),
92
-            10,
93
-            1
94
-        );
95
-        // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA
96
-        add_action(
97
-            'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
98
-            array('EE_Cron_Tasks', 'clean_out_junk_transactions')
99
-        );
100
-        // logging
101
-        add_action(
102
-            'AHEE__EE_System__load_core_configuration__complete',
103
-            array('EE_Cron_Tasks', 'log_scheduled_ee_crons')
104
-        );
105
-        EE_Registry::instance()->load_lib('Messages_Scheduler');
106
-        // clean out old gateway logs
107
-        add_action(
108
-            'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs',
109
-            array('EE_Cron_Tasks', 'clean_out_old_gateway_logs')
110
-        );
111
-    }
112
-
113
-
114
-    /**
115
-     * @access protected
116
-     * @return void
117
-     */
118
-    public static function log_scheduled_ee_crons()
119
-    {
120
-        $ee_crons = array(
121
-            'AHEE__EE_Cron_Tasks__update_transaction_with_payment',
122
-            'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
123
-            'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
124
-        );
125
-        $crons = (array) get_option('cron');
126
-        if (! is_array($crons)) {
127
-            return;
128
-        }
129
-        foreach ($crons as $timestamp => $cron) {
130
-            /** @var array[] $cron */
131
-            foreach ($ee_crons as $ee_cron) {
132
-                if (isset($cron[ $ee_cron ]) && is_array($cron[ $ee_cron ])) {
133
-                    do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron');
134
-                    foreach ($cron[ $ee_cron ] as $ee_cron_details) {
135
-                        if (! empty($ee_cron_details['args'])) {
136
-                            do_action(
137
-                                'AHEE_log',
138
-                                __CLASS__,
139
-                                __FUNCTION__,
140
-                                print_r($ee_cron_details['args'], true),
141
-                                "{$ee_cron} args"
142
-                            );
143
-                        }
144
-                    }
145
-                }
146
-            }
147
-        }
148
-    }
149
-
150
-
151
-    /**
152
-     * reschedule_cron_for_transactions_if_maintenance_mode
153
-     * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes
154
-     *
155
-     * @param string $cron_task
156
-     * @param array  $TXN_IDs
157
-     * @return bool
158
-     * @throws DomainException
159
-     */
160
-    public static function reschedule_cron_for_transactions_if_maintenance_mode($cron_task, array $TXN_IDs)
161
-    {
162
-        if (! method_exists('EE_Cron_Tasks', $cron_task)) {
163
-            throw new DomainException(
164
-                sprintf(
165
-                    esc_html__('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'),
166
-                    $cron_task
167
-                )
168
-            );
169
-        }
170
-        // reschedule the cron if we can't hit the db right now
171
-        if (! EE_Maintenance_Mode::instance()->models_can_query()) {
172
-            foreach ($TXN_IDs as $TXN_ID => $additional_vars) {
173
-                // ensure $additional_vars is an array
174
-                $additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars);
175
-                // reset cron job for the TXN
176
-                call_user_func_array(
177
-                    array('EE_Cron_Tasks', $cron_task),
178
-                    array_merge(
179
-                        array(
180
-                            time() + (10 * MINUTE_IN_SECONDS),
181
-                            $TXN_ID,
182
-                        ),
183
-                        $additional_vars
184
-                    )
185
-                );
186
-            }
187
-            return true;
188
-        }
189
-        return false;
190
-    }
191
-
192
-
193
-
194
-
195
-    /****************  UPDATE TRANSACTION WITH PAYMENT ****************/
196
-
197
-
198
-    /**
199
-     * array of TXN IDs and the payment
200
-     *
201
-     * @var array
202
-     */
203
-    protected static $_update_transactions_with_payment = array();
204
-
205
-
206
-    /**
207
-     * schedule_update_transaction_with_payment
208
-     * sets a wp_schedule_single_event() for updating any TXNs that may
209
-     * require updating due to recently received payments
210
-     *
211
-     * @param int $timestamp
212
-     * @param int $TXN_ID
213
-     * @param int $PAY_ID
214
-     */
215
-    public static function schedule_update_transaction_with_payment(
216
-        $timestamp,
217
-        $TXN_ID,
218
-        $PAY_ID
219
-    ) {
220
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
221
-        // validate $TXN_ID and $timestamp
222
-        $TXN_ID = absint($TXN_ID);
223
-        $timestamp = absint($timestamp);
224
-        if ($TXN_ID && $timestamp) {
225
-            wp_schedule_single_event(
226
-                $timestamp,
227
-                'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
228
-                array($TXN_ID, $PAY_ID)
229
-            );
230
-        }
231
-    }
232
-
233
-
234
-    /**
235
-     * setup_update_for_transaction_with_payment
236
-     * this is the callback for the action hook:
237
-     * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment'
238
-     * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment().
239
-     * The passed TXN_ID and associated payment gets added to an array, and then
240
-     * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into
241
-     * 'shutdown' which will actually handle the processing of any
242
-     * transactions requiring updating, because doing so now would be too early
243
-     * and the required resources may not be available
244
-     *
245
-     * @param int $TXN_ID
246
-     * @param int $PAY_ID
247
-     */
248
-    public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0)
249
-    {
250
-        do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
251
-        if (absint($TXN_ID)) {
252
-            self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID;
253
-            add_action(
254
-                'shutdown',
255
-                array('EE_Cron_Tasks', 'update_transaction_with_payment'),
256
-                5
257
-            );
258
-        }
259
-    }
260
-
261
-
262
-    /**
263
-     * update_transaction_with_payment
264
-     * loops through the self::$_abandoned_transactions array
265
-     * and attempts to finalize any TXNs that have not been completed
266
-     * but have had their sessions expired, most likely due to a user not
267
-     * returning from an off-site payment gateway
268
-     *
269
-     * @throws EE_Error
270
-     * @throws DomainException
271
-     * @throws InvalidDataTypeException
272
-     * @throws InvalidInterfaceException
273
-     * @throws InvalidArgumentException
274
-     * @throws ReflectionException
275
-     * @throws RuntimeException
276
-     */
277
-    public static function update_transaction_with_payment()
278
-    {
279
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
280
-        if (
17
+	/**
18
+	 * WordPress doesn't allow duplicate crons within 10 minutes of the original,
19
+	 * so we'll set our retry time for just over 10 minutes to avoid that
20
+	 */
21
+	const reschedule_timeout = 605;
22
+
23
+
24
+	/**
25
+	 * @var EE_Cron_Tasks
26
+	 */
27
+	private static $_instance;
28
+
29
+
30
+	/**
31
+	 * @return EE_Cron_Tasks
32
+	 * @throws ReflectionException
33
+	 * @throws EE_Error
34
+	 * @throws InvalidArgumentException
35
+	 * @throws InvalidInterfaceException
36
+	 * @throws InvalidDataTypeException
37
+	 */
38
+	public static function instance()
39
+	{
40
+		if (! self::$_instance instanceof EE_Cron_Tasks) {
41
+			self::$_instance = new self();
42
+		}
43
+		return self::$_instance;
44
+	}
45
+
46
+
47
+	/**
48
+	 * @access private
49
+	 * @throws InvalidDataTypeException
50
+	 * @throws InvalidInterfaceException
51
+	 * @throws InvalidArgumentException
52
+	 * @throws EE_Error
53
+	 * @throws ReflectionException
54
+	 */
55
+	private function __construct()
56
+	{
57
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
58
+		// verify that WP Cron is enabled
59
+		if (
60
+			defined('DISABLE_WP_CRON')
61
+			&& DISABLE_WP_CRON
62
+			&& is_admin()
63
+			&& ! get_option('ee_disabled_wp_cron_check')
64
+		) {
65
+			/**
66
+			 * This needs to be delayed until after the config is loaded because EE_Cron_Tasks is constructed before
67
+			 * config is loaded.
68
+			 * This is intentionally using a anonymous function so that its not easily de-registered.  Client code
69
+			 * wanting to not have this functionality can just register its own action at a priority after this one to
70
+			 * reverse any changes.
71
+			 */
72
+			add_action(
73
+				'AHEE__EE_System__load_core_configuration__complete',
74
+				function () {
75
+					EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request = true;
76
+					EE_Registry::instance()->NET_CFG->update_config(true, false);
77
+					add_option('ee_disabled_wp_cron_check', 1, '', false);
78
+				}
79
+			);
80
+		}
81
+		// UPDATE TRANSACTION WITH PAYMENT
82
+		add_action(
83
+			'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
84
+			array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'),
85
+			10,
86
+			2
87
+		);
88
+		// ABANDONED / EXPIRED TRANSACTION CHECK
89
+		add_action(
90
+			'AHEE__EE_Cron_Tasks__expired_transaction_check',
91
+			array('EE_Cron_Tasks', 'expired_transaction_check'),
92
+			10,
93
+			1
94
+		);
95
+		// CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA
96
+		add_action(
97
+			'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
98
+			array('EE_Cron_Tasks', 'clean_out_junk_transactions')
99
+		);
100
+		// logging
101
+		add_action(
102
+			'AHEE__EE_System__load_core_configuration__complete',
103
+			array('EE_Cron_Tasks', 'log_scheduled_ee_crons')
104
+		);
105
+		EE_Registry::instance()->load_lib('Messages_Scheduler');
106
+		// clean out old gateway logs
107
+		add_action(
108
+			'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs',
109
+			array('EE_Cron_Tasks', 'clean_out_old_gateway_logs')
110
+		);
111
+	}
112
+
113
+
114
+	/**
115
+	 * @access protected
116
+	 * @return void
117
+	 */
118
+	public static function log_scheduled_ee_crons()
119
+	{
120
+		$ee_crons = array(
121
+			'AHEE__EE_Cron_Tasks__update_transaction_with_payment',
122
+			'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
123
+			'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
124
+		);
125
+		$crons = (array) get_option('cron');
126
+		if (! is_array($crons)) {
127
+			return;
128
+		}
129
+		foreach ($crons as $timestamp => $cron) {
130
+			/** @var array[] $cron */
131
+			foreach ($ee_crons as $ee_cron) {
132
+				if (isset($cron[ $ee_cron ]) && is_array($cron[ $ee_cron ])) {
133
+					do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron');
134
+					foreach ($cron[ $ee_cron ] as $ee_cron_details) {
135
+						if (! empty($ee_cron_details['args'])) {
136
+							do_action(
137
+								'AHEE_log',
138
+								__CLASS__,
139
+								__FUNCTION__,
140
+								print_r($ee_cron_details['args'], true),
141
+								"{$ee_cron} args"
142
+							);
143
+						}
144
+					}
145
+				}
146
+			}
147
+		}
148
+	}
149
+
150
+
151
+	/**
152
+	 * reschedule_cron_for_transactions_if_maintenance_mode
153
+	 * if Maintenance Mode is active, this will reschedule a cron to run again in 10 minutes
154
+	 *
155
+	 * @param string $cron_task
156
+	 * @param array  $TXN_IDs
157
+	 * @return bool
158
+	 * @throws DomainException
159
+	 */
160
+	public static function reschedule_cron_for_transactions_if_maintenance_mode($cron_task, array $TXN_IDs)
161
+	{
162
+		if (! method_exists('EE_Cron_Tasks', $cron_task)) {
163
+			throw new DomainException(
164
+				sprintf(
165
+					esc_html__('"%1$s" is not valid method on EE_Cron_Tasks.', 'event_espresso'),
166
+					$cron_task
167
+				)
168
+			);
169
+		}
170
+		// reschedule the cron if we can't hit the db right now
171
+		if (! EE_Maintenance_Mode::instance()->models_can_query()) {
172
+			foreach ($TXN_IDs as $TXN_ID => $additional_vars) {
173
+				// ensure $additional_vars is an array
174
+				$additional_vars = is_array($additional_vars) ? $additional_vars : array($additional_vars);
175
+				// reset cron job for the TXN
176
+				call_user_func_array(
177
+					array('EE_Cron_Tasks', $cron_task),
178
+					array_merge(
179
+						array(
180
+							time() + (10 * MINUTE_IN_SECONDS),
181
+							$TXN_ID,
182
+						),
183
+						$additional_vars
184
+					)
185
+				);
186
+			}
187
+			return true;
188
+		}
189
+		return false;
190
+	}
191
+
192
+
193
+
194
+
195
+	/****************  UPDATE TRANSACTION WITH PAYMENT ****************/
196
+
197
+
198
+	/**
199
+	 * array of TXN IDs and the payment
200
+	 *
201
+	 * @var array
202
+	 */
203
+	protected static $_update_transactions_with_payment = array();
204
+
205
+
206
+	/**
207
+	 * schedule_update_transaction_with_payment
208
+	 * sets a wp_schedule_single_event() for updating any TXNs that may
209
+	 * require updating due to recently received payments
210
+	 *
211
+	 * @param int $timestamp
212
+	 * @param int $TXN_ID
213
+	 * @param int $PAY_ID
214
+	 */
215
+	public static function schedule_update_transaction_with_payment(
216
+		$timestamp,
217
+		$TXN_ID,
218
+		$PAY_ID
219
+	) {
220
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
221
+		// validate $TXN_ID and $timestamp
222
+		$TXN_ID = absint($TXN_ID);
223
+		$timestamp = absint($timestamp);
224
+		if ($TXN_ID && $timestamp) {
225
+			wp_schedule_single_event(
226
+				$timestamp,
227
+				'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
228
+				array($TXN_ID, $PAY_ID)
229
+			);
230
+		}
231
+	}
232
+
233
+
234
+	/**
235
+	 * setup_update_for_transaction_with_payment
236
+	 * this is the callback for the action hook:
237
+	 * 'AHEE__EE_Cron_Tasks__update_transaction_with_payment'
238
+	 * which is setup by EE_Cron_Tasks::schedule_update_transaction_with_payment().
239
+	 * The passed TXN_ID and associated payment gets added to an array, and then
240
+	 * the EE_Cron_Tasks::update_transaction_with_payment() function is hooked into
241
+	 * 'shutdown' which will actually handle the processing of any
242
+	 * transactions requiring updating, because doing so now would be too early
243
+	 * and the required resources may not be available
244
+	 *
245
+	 * @param int $TXN_ID
246
+	 * @param int $PAY_ID
247
+	 */
248
+	public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0)
249
+	{
250
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
251
+		if (absint($TXN_ID)) {
252
+			self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID;
253
+			add_action(
254
+				'shutdown',
255
+				array('EE_Cron_Tasks', 'update_transaction_with_payment'),
256
+				5
257
+			);
258
+		}
259
+	}
260
+
261
+
262
+	/**
263
+	 * update_transaction_with_payment
264
+	 * loops through the self::$_abandoned_transactions array
265
+	 * and attempts to finalize any TXNs that have not been completed
266
+	 * but have had their sessions expired, most likely due to a user not
267
+	 * returning from an off-site payment gateway
268
+	 *
269
+	 * @throws EE_Error
270
+	 * @throws DomainException
271
+	 * @throws InvalidDataTypeException
272
+	 * @throws InvalidInterfaceException
273
+	 * @throws InvalidArgumentException
274
+	 * @throws ReflectionException
275
+	 * @throws RuntimeException
276
+	 */
277
+	public static function update_transaction_with_payment()
278
+	{
279
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
280
+		if (
281 281
 // are there any TXNs that need cleaning up ?
282
-            empty(self::$_update_transactions_with_payment)
283
-            // reschedule the cron if we can't hit the db right now
284
-            || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode(
285
-                'schedule_update_transaction_with_payment',
286
-                self::$_update_transactions_with_payment
287
-            )
288
-        ) {
289
-            return;
290
-        }
291
-        /** @type EE_Payment_Processor $payment_processor */
292
-        $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
293
-        // set revisit flag for payment processor
294
-        $payment_processor->set_revisit();
295
-        // load EEM_Transaction
296
-        EE_Registry::instance()->load_model('Transaction');
297
-        foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) {
298
-            // reschedule the cron if we can't hit the db right now
299
-            if (! EE_Maintenance_Mode::instance()->models_can_query()) {
300
-                // reset cron job for updating the TXN
301
-                EE_Cron_Tasks::schedule_update_transaction_with_payment(
302
-                    time() + EE_Cron_Tasks::reschedule_timeout,
303
-                    $TXN_ID,
304
-                    $PAY_ID
305
-                );
306
-                continue;
307
-            }
308
-            $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
309
-            $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
310
-            // verify transaction
311
-            if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) {
312
-                // now try to update the TXN with any payments
313
-                $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true);
314
-            }
315
-            unset(self::$_update_transactions_with_payment[ $TXN_ID ]);
316
-        }
317
-    }
318
-
319
-
320
-
321
-    /************  END OF UPDATE TRANSACTION WITH PAYMENT  ************/
322
-
323
-
324
-    /*****************  EXPIRED TRANSACTION CHECK *****************/
325
-
326
-
327
-    /**
328
-     * array of TXN IDs
329
-     *
330
-     * @var array
331
-     */
332
-    protected static $_expired_transactions = array();
333
-
334
-
335
-    /**
336
-     * schedule_expired_transaction_check
337
-     * sets a wp_schedule_single_event() for following up on TXNs after their session has expired
338
-     *
339
-     * @param int $timestamp
340
-     * @param int $TXN_ID
341
-     */
342
-    public static function schedule_expired_transaction_check(
343
-        $timestamp,
344
-        $TXN_ID
345
-    ) {
346
-        // validate $TXN_ID and $timestamp
347
-        $TXN_ID = absint($TXN_ID);
348
-        $timestamp = absint($timestamp);
349
-        if ($TXN_ID && $timestamp) {
350
-            wp_schedule_single_event(
351
-                $timestamp,
352
-                'AHEE__EE_Cron_Tasks__expired_transaction_check',
353
-                array($TXN_ID)
354
-            );
355
-        }
356
-    }
357
-
358
-
359
-    /**
360
-     * expired_transaction_check
361
-     * this is the callback for the action hook:
362
-     * 'AHEE__EE_Cron_Tasks__transaction_session_expiration_check'
363
-     * which is utilized by wp_schedule_single_event()
364
-     * in \EED_Single_Page_Checkout::_initialize_transaction().
365
-     * The passed TXN_ID gets added to an array, and then the
366
-     * process_expired_transactions() function is hooked into
367
-     * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the
368
-     * processing of any failed transactions, because doing so now would be
369
-     * too early and the required resources may not be available
370
-     *
371
-     * @param int $TXN_ID
372
-     */
373
-    public static function expired_transaction_check($TXN_ID = 0)
374
-    {
375
-        if (absint($TXN_ID)) {
376
-            self::$_expired_transactions[ $TXN_ID ] = $TXN_ID;
377
-            add_action(
378
-                'shutdown',
379
-                array('EE_Cron_Tasks', 'process_expired_transactions'),
380
-                5
381
-            );
382
-        }
383
-    }
384
-
385
-
386
-    /**
387
-     * process_expired_transactions
388
-     * loops through the self::$_expired_transactions array and processes any failed TXNs
389
-     *
390
-     * @throws EE_Error
391
-     * @throws InvalidDataTypeException
392
-     * @throws InvalidInterfaceException
393
-     * @throws InvalidArgumentException
394
-     * @throws ReflectionException
395
-     * @throws DomainException
396
-     * @throws RuntimeException
397
-     */
398
-    public static function process_expired_transactions()
399
-    {
400
-        if (
282
+			empty(self::$_update_transactions_with_payment)
283
+			// reschedule the cron if we can't hit the db right now
284
+			|| EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode(
285
+				'schedule_update_transaction_with_payment',
286
+				self::$_update_transactions_with_payment
287
+			)
288
+		) {
289
+			return;
290
+		}
291
+		/** @type EE_Payment_Processor $payment_processor */
292
+		$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
293
+		// set revisit flag for payment processor
294
+		$payment_processor->set_revisit();
295
+		// load EEM_Transaction
296
+		EE_Registry::instance()->load_model('Transaction');
297
+		foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) {
298
+			// reschedule the cron if we can't hit the db right now
299
+			if (! EE_Maintenance_Mode::instance()->models_can_query()) {
300
+				// reset cron job for updating the TXN
301
+				EE_Cron_Tasks::schedule_update_transaction_with_payment(
302
+					time() + EE_Cron_Tasks::reschedule_timeout,
303
+					$TXN_ID,
304
+					$PAY_ID
305
+				);
306
+				continue;
307
+			}
308
+			$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
309
+			$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
310
+			// verify transaction
311
+			if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) {
312
+				// now try to update the TXN with any payments
313
+				$payment_processor->update_txn_based_on_payment($transaction, $payment, true, true);
314
+			}
315
+			unset(self::$_update_transactions_with_payment[ $TXN_ID ]);
316
+		}
317
+	}
318
+
319
+
320
+
321
+	/************  END OF UPDATE TRANSACTION WITH PAYMENT  ************/
322
+
323
+
324
+	/*****************  EXPIRED TRANSACTION CHECK *****************/
325
+
326
+
327
+	/**
328
+	 * array of TXN IDs
329
+	 *
330
+	 * @var array
331
+	 */
332
+	protected static $_expired_transactions = array();
333
+
334
+
335
+	/**
336
+	 * schedule_expired_transaction_check
337
+	 * sets a wp_schedule_single_event() for following up on TXNs after their session has expired
338
+	 *
339
+	 * @param int $timestamp
340
+	 * @param int $TXN_ID
341
+	 */
342
+	public static function schedule_expired_transaction_check(
343
+		$timestamp,
344
+		$TXN_ID
345
+	) {
346
+		// validate $TXN_ID and $timestamp
347
+		$TXN_ID = absint($TXN_ID);
348
+		$timestamp = absint($timestamp);
349
+		if ($TXN_ID && $timestamp) {
350
+			wp_schedule_single_event(
351
+				$timestamp,
352
+				'AHEE__EE_Cron_Tasks__expired_transaction_check',
353
+				array($TXN_ID)
354
+			);
355
+		}
356
+	}
357
+
358
+
359
+	/**
360
+	 * expired_transaction_check
361
+	 * this is the callback for the action hook:
362
+	 * 'AHEE__EE_Cron_Tasks__transaction_session_expiration_check'
363
+	 * which is utilized by wp_schedule_single_event()
364
+	 * in \EED_Single_Page_Checkout::_initialize_transaction().
365
+	 * The passed TXN_ID gets added to an array, and then the
366
+	 * process_expired_transactions() function is hooked into
367
+	 * 'AHEE__EE_System__core_loaded_and_ready' which will actually handle the
368
+	 * processing of any failed transactions, because doing so now would be
369
+	 * too early and the required resources may not be available
370
+	 *
371
+	 * @param int $TXN_ID
372
+	 */
373
+	public static function expired_transaction_check($TXN_ID = 0)
374
+	{
375
+		if (absint($TXN_ID)) {
376
+			self::$_expired_transactions[ $TXN_ID ] = $TXN_ID;
377
+			add_action(
378
+				'shutdown',
379
+				array('EE_Cron_Tasks', 'process_expired_transactions'),
380
+				5
381
+			);
382
+		}
383
+	}
384
+
385
+
386
+	/**
387
+	 * process_expired_transactions
388
+	 * loops through the self::$_expired_transactions array and processes any failed TXNs
389
+	 *
390
+	 * @throws EE_Error
391
+	 * @throws InvalidDataTypeException
392
+	 * @throws InvalidInterfaceException
393
+	 * @throws InvalidArgumentException
394
+	 * @throws ReflectionException
395
+	 * @throws DomainException
396
+	 * @throws RuntimeException
397
+	 */
398
+	public static function process_expired_transactions()
399
+	{
400
+		if (
401 401
 // are there any TXNs that need cleaning up ?
402
-            empty(self::$_expired_transactions)
403
-            // reschedule the cron if we can't hit the db right now
404
-            || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode(
405
-                'schedule_expired_transaction_check',
406
-                self::$_expired_transactions
407
-            )
408
-        ) {
409
-            return;
410
-        }
411
-        /** @type EE_Transaction_Processor $transaction_processor */
412
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
413
-        // set revisit flag for txn processor
414
-        $transaction_processor->set_revisit();
415
-        // load EEM_Transaction
416
-        EE_Registry::instance()->load_model('Transaction');
417
-        foreach (self::$_expired_transactions as $TXN_ID) {
418
-            $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
419
-            // verify transaction and whether it is failed or not
420
-            if ($transaction instanceof EE_Transaction) {
421
-                switch ($transaction->status_ID()) {
422
-                    // Completed TXNs
423
-                    case EEM_Transaction::complete_status_code:
424
-                        // Don't update the transaction/registrations if the Primary Registration is Not Approved.
425
-                        $primary_registration = $transaction->primary_registration();
426
-                        if (
427
-                            $primary_registration instanceof EE_Registration
428
-                            && $primary_registration->status_ID() !== EEM_Registration::status_id_not_approved
429
-                        ) {
430
-                            /** @type EE_Transaction_Processor $transaction_processor */
431
-                            $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
432
-                            $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
433
-                                $transaction,
434
-                                $transaction->last_payment()
435
-                            );
436
-                            do_action(
437
-                                'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction',
438
-                                $transaction
439
-                            );
440
-                        }
441
-                        break;
442
-                    // Overpaid TXNs
443
-                    case EEM_Transaction::overpaid_status_code:
444
-                        do_action(
445
-                            'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction',
446
-                            $transaction
447
-                        );
448
-                        break;
449
-                    // Incomplete TXNs
450
-                    case EEM_Transaction::incomplete_status_code:
451
-                        do_action(
452
-                            'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction',
453
-                            $transaction
454
-                        );
455
-                        // todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions
456
-                        break;
457
-                    // Abandoned TXNs
458
-                    case EEM_Transaction::abandoned_status_code:
459
-                        // run hook before updating transaction, primarily so
460
-                        // EED_Ticket_Sales_Monitor::process_abandoned_transactions() can release reserved tickets
461
-                        do_action(
462
-                            'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction',
463
-                            $transaction
464
-                        );
465
-                        // don't finalize the TXN if it has already been completed
466
-                        if ($transaction->all_reg_steps_completed() !== true) {
467
-                            /** @type EE_Payment_Processor $payment_processor */
468
-                            $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
469
-                            // let's simulate an IPN here which will trigger any notifications that need to go out
470
-                            $payment_processor->update_txn_based_on_payment(
471
-                                $transaction,
472
-                                $transaction->last_payment(),
473
-                                true,
474
-                                true
475
-                            );
476
-                        }
477
-                        break;
478
-                    // Failed TXNs
479
-                    case EEM_Transaction::failed_status_code:
480
-                        do_action(
481
-                            'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction',
482
-                            $transaction
483
-                        );
484
-                        // todo :
485
-                        // perform garbage collection here and remove clean_out_junk_transactions()
486
-                        // $registrations = $transaction->registrations();
487
-                        // if (! empty($registrations)) {
488
-                        //     foreach ($registrations as $registration) {
489
-                        //         if ($registration instanceof EE_Registration) {
490
-                        //             $delete_registration = true;
491
-                        //             if ($registration->attendee() instanceof EE_Attendee) {
492
-                        //                 $delete_registration = false;
493
-                        //             }
494
-                        //             if ($delete_registration) {
495
-                        //                 $registration->delete_permanently();
496
-                        //                 $registration->delete_related_permanently();
497
-                        //             }
498
-                        //         }
499
-                        //     }
500
-                        // }
501
-                        break;
502
-                }
503
-            }
504
-            unset(self::$_expired_transactions[ $TXN_ID ]);
505
-        }
506
-    }
507
-
508
-
509
-
510
-    /*************  END OF EXPIRED TRANSACTION CHECK  *************/
511
-
512
-
513
-    /************* START CLEAN UP BOT TRANSACTIONS **********************/
514
-
515
-
516
-    /**
517
-     * callback for 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'
518
-     * which is setup during activation to run on an hourly cron
519
-     *
520
-     * @throws EE_Error
521
-     * @throws InvalidArgumentException
522
-     * @throws InvalidDataTypeException
523
-     * @throws InvalidInterfaceException
524
-     * @throws DomainException
525
-     */
526
-    public static function clean_out_junk_transactions()
527
-    {
528
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
529
-            EED_Ticket_Sales_Monitor::reset_reservation_counts();
530
-            EEM_Transaction::instance('')->delete_junk_transactions();
531
-            EEM_Registration::instance('')->delete_registrations_with_no_transaction();
532
-            EEM_Line_Item::instance('')->delete_line_items_with_no_transaction();
533
-        }
534
-    }
535
-
536
-
537
-    /**
538
-     * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that.
539
-     *
540
-     * @throws EE_Error
541
-     * @throws InvalidDataTypeException
542
-     * @throws InvalidInterfaceException
543
-     * @throws InvalidArgumentException
544
-     */
545
-    public static function clean_out_old_gateway_logs()
546
-    {
547
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
548
-            $reg_config = LoaderFactory::getLoader()->load('EE_Registration_Config');
549
-            $time_diff_for_comparison = apply_filters(
550
-                'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison',
551
-                '-' . $reg_config->gateway_log_lifespan
552
-            );
553
-            EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison));
554
-        }
555
-    }
556
-
557
-
558
-    /*****************  FINALIZE ABANDONED TRANSACTIONS *****************/
559
-
560
-
561
-    /**
562
-     * @var array
563
-     */
564
-    protected static $_abandoned_transactions = array();
565
-
566
-
567
-    /**
568
-     * @deprecated
569
-     * @param int $timestamp
570
-     * @param int $TXN_ID
571
-     */
572
-    public static function schedule_finalize_abandoned_transactions_check($timestamp, $TXN_ID)
573
-    {
574
-        EE_Cron_Tasks::schedule_expired_transaction_check($timestamp, $TXN_ID);
575
-    }
576
-
577
-
578
-    /**
579
-     * @deprecated
580
-     * @param int $TXN_ID
581
-     */
582
-    public static function check_for_abandoned_transactions($TXN_ID = 0)
583
-    {
584
-        EE_Cron_Tasks::expired_transaction_check($TXN_ID);
585
-    }
586
-
587
-
588
-    /**
589
-     * @deprecated
590
-     * @throws EE_Error
591
-     * @throws DomainException
592
-     * @throws InvalidDataTypeException
593
-     * @throws InvalidInterfaceException
594
-     * @throws InvalidArgumentException
595
-     * @throws ReflectionException
596
-     * @throws RuntimeException
597
-     */
598
-    public static function finalize_abandoned_transactions()
599
-    {
600
-        do_action('AHEE_log', __CLASS__, __FUNCTION__);
601
-        if (
402
+			empty(self::$_expired_transactions)
403
+			// reschedule the cron if we can't hit the db right now
404
+			|| EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode(
405
+				'schedule_expired_transaction_check',
406
+				self::$_expired_transactions
407
+			)
408
+		) {
409
+			return;
410
+		}
411
+		/** @type EE_Transaction_Processor $transaction_processor */
412
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
413
+		// set revisit flag for txn processor
414
+		$transaction_processor->set_revisit();
415
+		// load EEM_Transaction
416
+		EE_Registry::instance()->load_model('Transaction');
417
+		foreach (self::$_expired_transactions as $TXN_ID) {
418
+			$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
419
+			// verify transaction and whether it is failed or not
420
+			if ($transaction instanceof EE_Transaction) {
421
+				switch ($transaction->status_ID()) {
422
+					// Completed TXNs
423
+					case EEM_Transaction::complete_status_code:
424
+						// Don't update the transaction/registrations if the Primary Registration is Not Approved.
425
+						$primary_registration = $transaction->primary_registration();
426
+						if (
427
+							$primary_registration instanceof EE_Registration
428
+							&& $primary_registration->status_ID() !== EEM_Registration::status_id_not_approved
429
+						) {
430
+							/** @type EE_Transaction_Processor $transaction_processor */
431
+							$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
432
+							$transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
433
+								$transaction,
434
+								$transaction->last_payment()
435
+							);
436
+							do_action(
437
+								'AHEE__EE_Cron_Tasks__process_expired_transactions__completed_transaction',
438
+								$transaction
439
+							);
440
+						}
441
+						break;
442
+					// Overpaid TXNs
443
+					case EEM_Transaction::overpaid_status_code:
444
+						do_action(
445
+							'AHEE__EE_Cron_Tasks__process_expired_transactions__overpaid_transaction',
446
+							$transaction
447
+						);
448
+						break;
449
+					// Incomplete TXNs
450
+					case EEM_Transaction::incomplete_status_code:
451
+						do_action(
452
+							'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction',
453
+							$transaction
454
+						);
455
+						// todo : move business logic into EE_Transaction_Processor for finalizing abandoned transactions
456
+						break;
457
+					// Abandoned TXNs
458
+					case EEM_Transaction::abandoned_status_code:
459
+						// run hook before updating transaction, primarily so
460
+						// EED_Ticket_Sales_Monitor::process_abandoned_transactions() can release reserved tickets
461
+						do_action(
462
+							'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction',
463
+							$transaction
464
+						);
465
+						// don't finalize the TXN if it has already been completed
466
+						if ($transaction->all_reg_steps_completed() !== true) {
467
+							/** @type EE_Payment_Processor $payment_processor */
468
+							$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
469
+							// let's simulate an IPN here which will trigger any notifications that need to go out
470
+							$payment_processor->update_txn_based_on_payment(
471
+								$transaction,
472
+								$transaction->last_payment(),
473
+								true,
474
+								true
475
+							);
476
+						}
477
+						break;
478
+					// Failed TXNs
479
+					case EEM_Transaction::failed_status_code:
480
+						do_action(
481
+							'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction',
482
+							$transaction
483
+						);
484
+						// todo :
485
+						// perform garbage collection here and remove clean_out_junk_transactions()
486
+						// $registrations = $transaction->registrations();
487
+						// if (! empty($registrations)) {
488
+						//     foreach ($registrations as $registration) {
489
+						//         if ($registration instanceof EE_Registration) {
490
+						//             $delete_registration = true;
491
+						//             if ($registration->attendee() instanceof EE_Attendee) {
492
+						//                 $delete_registration = false;
493
+						//             }
494
+						//             if ($delete_registration) {
495
+						//                 $registration->delete_permanently();
496
+						//                 $registration->delete_related_permanently();
497
+						//             }
498
+						//         }
499
+						//     }
500
+						// }
501
+						break;
502
+				}
503
+			}
504
+			unset(self::$_expired_transactions[ $TXN_ID ]);
505
+		}
506
+	}
507
+
508
+
509
+
510
+	/*************  END OF EXPIRED TRANSACTION CHECK  *************/
511
+
512
+
513
+	/************* START CLEAN UP BOT TRANSACTIONS **********************/
514
+
515
+
516
+	/**
517
+	 * callback for 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'
518
+	 * which is setup during activation to run on an hourly cron
519
+	 *
520
+	 * @throws EE_Error
521
+	 * @throws InvalidArgumentException
522
+	 * @throws InvalidDataTypeException
523
+	 * @throws InvalidInterfaceException
524
+	 * @throws DomainException
525
+	 */
526
+	public static function clean_out_junk_transactions()
527
+	{
528
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
529
+			EED_Ticket_Sales_Monitor::reset_reservation_counts();
530
+			EEM_Transaction::instance('')->delete_junk_transactions();
531
+			EEM_Registration::instance('')->delete_registrations_with_no_transaction();
532
+			EEM_Line_Item::instance('')->delete_line_items_with_no_transaction();
533
+		}
534
+	}
535
+
536
+
537
+	/**
538
+	 * Deletes old gateway logs. After about a week we usually don't need them for debugging. But folks can filter that.
539
+	 *
540
+	 * @throws EE_Error
541
+	 * @throws InvalidDataTypeException
542
+	 * @throws InvalidInterfaceException
543
+	 * @throws InvalidArgumentException
544
+	 */
545
+	public static function clean_out_old_gateway_logs()
546
+	{
547
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
548
+			$reg_config = LoaderFactory::getLoader()->load('EE_Registration_Config');
549
+			$time_diff_for_comparison = apply_filters(
550
+				'FHEE__EE_Cron_Tasks__clean_out_old_gateway_logs__time_diff_for_comparison',
551
+				'-' . $reg_config->gateway_log_lifespan
552
+			);
553
+			EEM_Change_Log::instance()->delete_gateway_logs_older_than(new DateTime($time_diff_for_comparison));
554
+		}
555
+	}
556
+
557
+
558
+	/*****************  FINALIZE ABANDONED TRANSACTIONS *****************/
559
+
560
+
561
+	/**
562
+	 * @var array
563
+	 */
564
+	protected static $_abandoned_transactions = array();
565
+
566
+
567
+	/**
568
+	 * @deprecated
569
+	 * @param int $timestamp
570
+	 * @param int $TXN_ID
571
+	 */
572
+	public static function schedule_finalize_abandoned_transactions_check($timestamp, $TXN_ID)
573
+	{
574
+		EE_Cron_Tasks::schedule_expired_transaction_check($timestamp, $TXN_ID);
575
+	}
576
+
577
+
578
+	/**
579
+	 * @deprecated
580
+	 * @param int $TXN_ID
581
+	 */
582
+	public static function check_for_abandoned_transactions($TXN_ID = 0)
583
+	{
584
+		EE_Cron_Tasks::expired_transaction_check($TXN_ID);
585
+	}
586
+
587
+
588
+	/**
589
+	 * @deprecated
590
+	 * @throws EE_Error
591
+	 * @throws DomainException
592
+	 * @throws InvalidDataTypeException
593
+	 * @throws InvalidInterfaceException
594
+	 * @throws InvalidArgumentException
595
+	 * @throws ReflectionException
596
+	 * @throws RuntimeException
597
+	 */
598
+	public static function finalize_abandoned_transactions()
599
+	{
600
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
601
+		if (
602 602
 // are there any TXNs that need cleaning up ?
603
-            empty(self::$_abandoned_transactions)
604
-            // reschedule the cron if we can't hit the db right now
605
-            || EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode(
606
-                'schedule_expired_transaction_check',
607
-                self::$_abandoned_transactions
608
-            )
609
-        ) {
610
-            return;
611
-        }
612
-        // combine our arrays of transaction IDs
613
-        self::$_expired_transactions = self::$_abandoned_transactions + self::$_expired_transactions;
614
-        // and deal with abandoned transactions here now...
615
-        EE_Cron_Tasks::process_expired_transactions();
616
-    }
617
-
618
-
619
-    /*************  END OF FINALIZE ABANDONED TRANSACTIONS  *************/
603
+			empty(self::$_abandoned_transactions)
604
+			// reschedule the cron if we can't hit the db right now
605
+			|| EE_Cron_Tasks::reschedule_cron_for_transactions_if_maintenance_mode(
606
+				'schedule_expired_transaction_check',
607
+				self::$_abandoned_transactions
608
+			)
609
+		) {
610
+			return;
611
+		}
612
+		// combine our arrays of transaction IDs
613
+		self::$_expired_transactions = self::$_abandoned_transactions + self::$_expired_transactions;
614
+		// and deal with abandoned transactions here now...
615
+		EE_Cron_Tasks::process_expired_transactions();
616
+	}
617
+
618
+
619
+	/*************  END OF FINALIZE ABANDONED TRANSACTIONS  *************/
620 620
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Template_Validator.helper.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public static function verify_is_array_of($variable_to_test, $name_of_variable, $class_name, $allow_null = 'allow_null')
42 42
     {
43
-        if (!WP_DEBUG) {
43
+        if ( ! WP_DEBUG) {
44 44
             return;
45 45
         }
46
-        self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null'));
46
+        self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null'));
47 47
         if ('allow_null' == $allow_null && is_null($variable_to_test)) {
48 48
             return;
49 49
         }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public static function verify_isnt_null($variable_to_test, $name_of_variable)
68 68
     {
69
-        if (!WP_DEBUG) {
69
+        if ( ! WP_DEBUG) {
70 70
             return;
71 71
         }
72 72
         if ($variable_to_test == null && $variable_to_test != 0 && $variable_to_test != false) {
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public static function verify_is_true($expression_to_test, $expression_string_representation)
88 88
     {
89
-        if (!WP_DEBUG) {
89
+        if ( ! WP_DEBUG) {
90 90
             return;
91 91
         }
92
-        if (!$expression_to_test) {
92
+        if ( ! $expression_to_test) {
93 93
             $error[] = esc_html__('Template error.', 'event_espresso');
94 94
             $error[] = esc_html__("%s evaluated to false, but it must be true!", 'event_espresso');
95 95
             throw new EE_Error(sprintf(implode(",", $error), $expression_string_representation));
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public static function verify_instanceof($variable_to_test, $name_of_variable, $class_name, $allow_null = 'do_not_allow_null')
112 112
     {
113
-        if (!WP_DEBUG) {
113
+        if ( ! WP_DEBUG) {
114 114
             return;
115 115
         }
116
-        self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null'));
116
+        self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null'));
117 117
         if ($allow_null == 'allow_null' && is_null($variable_to_test)) {
118 118
             return;
119 119
         }
120
-        if ($variable_to_test == null ||  ! ( $variable_to_test instanceof $class_name )) {
120
+        if ($variable_to_test == null || ! ($variable_to_test instanceof $class_name)) {
121 121
             $msg[] = esc_html__('Variable %s is not of the correct type.', 'event_espresso');
122 122
             $msg[] = esc_html__("It should be of type %s", 'event_espresso');
123 123
             throw new EE_Error(sprintf(implode(",", $msg), $name_of_variable, $name_of_variable, $class_name));
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
      */
139 139
     public static function verify_is_array($variable_to_test, $variable_name, $allow_empty = 'allow_empty')
140 140
     {
141
-        if (!WP_DEBUG) {
141
+        if ( ! WP_DEBUG) {
142 142
             return;
143 143
         }
144
-        self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty'));
144
+        self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty', 'do_not_allow_empty'));
145 145
         if (empty($variable_to_test) && 'allow_empty' == $allow_empty) {
146 146
             return;
147 147
         }
148
-        if (!is_array($variable_to_test)) {
148
+        if ( ! is_array($variable_to_test)) {
149 149
             $error[] = esc_html__('Variable %s should be an array, but it is not.', 'event_espresso');
150 150
             $error[] = esc_html__("Its value is, instead '%s'", 'event_espresso');
151 151
             throw new EE_Error(sprintf(implode(",", $error), $variable_name, $variable_name, $variable_to_test));
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public static function verify_argument_is_one_of($variable_to_test, $variable_name, $string_options)
170 170
     {
171
-        if (!WP_DEBUG) {
171
+        if ( ! WP_DEBUG) {
172 172
             return;
173 173
         }
174
-        if (!in_array($variable_to_test, $string_options)) {
174
+        if ( ! in_array($variable_to_test, $string_options)) {
175 175
             $msg[0] = esc_html__('Malconfigured template.', 'event_espresso');
176 176
             $msg[1] = esc_html__("Variable named '%s' was set to '%s'. It can only be one of '%s'", 'event_espresso');
177 177
             throw new EE_Error(sprintf(implode("||", $msg), $variable_name, $variable_to_test, implode("', '", $string_options)));
Please login to merge, or discard this patch.
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -24,152 +24,152 @@
 block discarded – undo
24 24
  */
25 25
 class EEH_Template_Validator
26 26
 {
27
-    /**
28
-     * Throws an EE_Error if $variabel_to_test isn't an array of objects of class $class_name
29
-     * @param mixed $variable_to_test
30
-     * @param string $name_of_variable helpful in throwing intelligent errors
31
-     * @param string $class_name eg EE_Answer, EE_Transaction, etc.
32
-     * @param string $allow_null one of 'allow_null', or 'do_not_allow_null'
33
-     * @return void
34
-     * @throws EE_Error (indirectly)
35
-     */
36
-    public static function verify_is_array_of($variable_to_test, $name_of_variable, $class_name, $allow_null = 'allow_null')
37
-    {
38
-        if (!WP_DEBUG) {
39
-            return;
40
-        }
41
-        self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null'));
42
-        if ('allow_null' == $allow_null && is_null($variable_to_test)) {
43
-            return;
44
-        }
45
-        self::verify_is_array($variable_to_test, $name_of_variable);
46
-        foreach ($variable_to_test as $key => $array_element) {
47
-            self::verify_instanceof($array_element, $key, $class_name);
48
-        }
49
-    }
50
-
51
-
52
-
53
-
54
-
55
-    /**
56
-     * throws an EE_Error if $variable_to_test is null
57
-     * @param mixed $variable_to_test
58
-     * @param string $name_of_variable helpful for throwing intelligent errors
59
-     * @return void
60
-     * @throws EE_Error
61
-     */
62
-    public static function verify_isnt_null($variable_to_test, $name_of_variable)
63
-    {
64
-        if (!WP_DEBUG) {
65
-            return;
66
-        }
67
-        if ($variable_to_test == null && $variable_to_test != 0 && $variable_to_test != false) {
68
-            $error[] = esc_html__('Variable named %s is null.', 'event_espresso');
69
-            $error[] = esc_html__("Consider looking at the stack trace to see why it wasn't set.", 'event_espresso');
70
-            throw new EE_Error(sprintf(implode(",", $error), $name_of_variable, $name_of_variable));
71
-        }
72
-    }
73
-
74
-    /**
75
-     * When WP_DEBUG is activted, throws an error if $expression_to_test is false.
76
-     * @param boolean $expression_to_test
77
-     * @param string $expression_string_representation a string representation of your expression
78
-     * for example, if your expression were $var1==23, then this should be '$var1==23'
79
-     * @return void
80
-     * @throws EE_Error
81
-     */
82
-    public static function verify_is_true($expression_to_test, $expression_string_representation)
83
-    {
84
-        if (!WP_DEBUG) {
85
-            return;
86
-        }
87
-        if (!$expression_to_test) {
88
-            $error[] = esc_html__('Template error.', 'event_espresso');
89
-            $error[] = esc_html__("%s evaluated to false, but it must be true!", 'event_espresso');
90
-            throw new EE_Error(sprintf(implode(",", $error), $expression_string_representation));
91
-        }
92
-    }
93
-
94
-
95
-
96
-
97
-
98
-    /**
99
-     * For verifying that a variable is indeed an object of class $class_name
100
-     * @param mixed $variable_to_test
101
-     * @param string $name_of_variable helpful when throwing errors
102
-     * @param string $class_name eg, EE_Answer,
103
-     * @return void
104
-     * @throws EE_Error
105
-     */
106
-    public static function verify_instanceof($variable_to_test, $name_of_variable, $class_name, $allow_null = 'do_not_allow_null')
107
-    {
108
-        if (!WP_DEBUG) {
109
-            return;
110
-        }
111
-        self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null'));
112
-        if ($allow_null == 'allow_null' && is_null($variable_to_test)) {
113
-            return;
114
-        }
115
-        if ($variable_to_test == null ||  ! ( $variable_to_test instanceof $class_name )) {
116
-            $msg[] = esc_html__('Variable %s is not of the correct type.', 'event_espresso');
117
-            $msg[] = esc_html__("It should be of type %s", 'event_espresso');
118
-            throw new EE_Error(sprintf(implode(",", $msg), $name_of_variable, $name_of_variable, $class_name));
119
-        }
120
-    }
121
-
122
-
123
-
124
-
125
-
126
-    /**
127
-     * For verifying that a variable is indeed an array, else throw an EE_Error
128
-     * @param type $variable_to_test
129
-     * @param type $variable_name
130
-     * @param type $allow_empty one of 'allow_empty' or 'do_not_allow_empty'
131
-     * @return void
132
-     * @throws EE_Error
133
-     */
134
-    public static function verify_is_array($variable_to_test, $variable_name, $allow_empty = 'allow_empty')
135
-    {
136
-        if (!WP_DEBUG) {
137
-            return;
138
-        }
139
-        self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty'));
140
-        if (empty($variable_to_test) && 'allow_empty' == $allow_empty) {
141
-            return;
142
-        }
143
-        if (!is_array($variable_to_test)) {
144
-            $error[] = esc_html__('Variable %s should be an array, but it is not.', 'event_espresso');
145
-            $error[] = esc_html__("Its value is, instead '%s'", 'event_espresso');
146
-            throw new EE_Error(sprintf(implode(",", $error), $variable_name, $variable_name, $variable_to_test));
147
-        }
148
-    }
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-    /**
157
-     * for verifying that a variable is one of the string optiosn supplied
158
-     * @param mixed $variable_to_test
159
-     * @param mixed $variable_name the name you've given the variable. Eg, '$foo'. THis helps in producing better error messages
160
-     * @param array $string_options an array of acceptable values
161
-     * @return void
162
-     * @throws EE_Error
163
-     */
164
-    public static function verify_argument_is_one_of($variable_to_test, $variable_name, $string_options)
165
-    {
166
-        if (!WP_DEBUG) {
167
-            return;
168
-        }
169
-        if (!in_array($variable_to_test, $string_options)) {
170
-            $msg[0] = esc_html__('Malconfigured template.', 'event_espresso');
171
-            $msg[1] = esc_html__("Variable named '%s' was set to '%s'. It can only be one of '%s'", 'event_espresso');
172
-            throw new EE_Error(sprintf(implode("||", $msg), $variable_name, $variable_to_test, implode("', '", $string_options)));
173
-        }
174
-    }
27
+	/**
28
+	 * Throws an EE_Error if $variabel_to_test isn't an array of objects of class $class_name
29
+	 * @param mixed $variable_to_test
30
+	 * @param string $name_of_variable helpful in throwing intelligent errors
31
+	 * @param string $class_name eg EE_Answer, EE_Transaction, etc.
32
+	 * @param string $allow_null one of 'allow_null', or 'do_not_allow_null'
33
+	 * @return void
34
+	 * @throws EE_Error (indirectly)
35
+	 */
36
+	public static function verify_is_array_of($variable_to_test, $name_of_variable, $class_name, $allow_null = 'allow_null')
37
+	{
38
+		if (!WP_DEBUG) {
39
+			return;
40
+		}
41
+		self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null'));
42
+		if ('allow_null' == $allow_null && is_null($variable_to_test)) {
43
+			return;
44
+		}
45
+		self::verify_is_array($variable_to_test, $name_of_variable);
46
+		foreach ($variable_to_test as $key => $array_element) {
47
+			self::verify_instanceof($array_element, $key, $class_name);
48
+		}
49
+	}
50
+
51
+
52
+
53
+
54
+
55
+	/**
56
+	 * throws an EE_Error if $variable_to_test is null
57
+	 * @param mixed $variable_to_test
58
+	 * @param string $name_of_variable helpful for throwing intelligent errors
59
+	 * @return void
60
+	 * @throws EE_Error
61
+	 */
62
+	public static function verify_isnt_null($variable_to_test, $name_of_variable)
63
+	{
64
+		if (!WP_DEBUG) {
65
+			return;
66
+		}
67
+		if ($variable_to_test == null && $variable_to_test != 0 && $variable_to_test != false) {
68
+			$error[] = esc_html__('Variable named %s is null.', 'event_espresso');
69
+			$error[] = esc_html__("Consider looking at the stack trace to see why it wasn't set.", 'event_espresso');
70
+			throw new EE_Error(sprintf(implode(",", $error), $name_of_variable, $name_of_variable));
71
+		}
72
+	}
73
+
74
+	/**
75
+	 * When WP_DEBUG is activted, throws an error if $expression_to_test is false.
76
+	 * @param boolean $expression_to_test
77
+	 * @param string $expression_string_representation a string representation of your expression
78
+	 * for example, if your expression were $var1==23, then this should be '$var1==23'
79
+	 * @return void
80
+	 * @throws EE_Error
81
+	 */
82
+	public static function verify_is_true($expression_to_test, $expression_string_representation)
83
+	{
84
+		if (!WP_DEBUG) {
85
+			return;
86
+		}
87
+		if (!$expression_to_test) {
88
+			$error[] = esc_html__('Template error.', 'event_espresso');
89
+			$error[] = esc_html__("%s evaluated to false, but it must be true!", 'event_espresso');
90
+			throw new EE_Error(sprintf(implode(",", $error), $expression_string_representation));
91
+		}
92
+	}
93
+
94
+
95
+
96
+
97
+
98
+	/**
99
+	 * For verifying that a variable is indeed an object of class $class_name
100
+	 * @param mixed $variable_to_test
101
+	 * @param string $name_of_variable helpful when throwing errors
102
+	 * @param string $class_name eg, EE_Answer,
103
+	 * @return void
104
+	 * @throws EE_Error
105
+	 */
106
+	public static function verify_instanceof($variable_to_test, $name_of_variable, $class_name, $allow_null = 'do_not_allow_null')
107
+	{
108
+		if (!WP_DEBUG) {
109
+			return;
110
+		}
111
+		self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null'));
112
+		if ($allow_null == 'allow_null' && is_null($variable_to_test)) {
113
+			return;
114
+		}
115
+		if ($variable_to_test == null ||  ! ( $variable_to_test instanceof $class_name )) {
116
+			$msg[] = esc_html__('Variable %s is not of the correct type.', 'event_espresso');
117
+			$msg[] = esc_html__("It should be of type %s", 'event_espresso');
118
+			throw new EE_Error(sprintf(implode(",", $msg), $name_of_variable, $name_of_variable, $class_name));
119
+		}
120
+	}
121
+
122
+
123
+
124
+
125
+
126
+	/**
127
+	 * For verifying that a variable is indeed an array, else throw an EE_Error
128
+	 * @param type $variable_to_test
129
+	 * @param type $variable_name
130
+	 * @param type $allow_empty one of 'allow_empty' or 'do_not_allow_empty'
131
+	 * @return void
132
+	 * @throws EE_Error
133
+	 */
134
+	public static function verify_is_array($variable_to_test, $variable_name, $allow_empty = 'allow_empty')
135
+	{
136
+		if (!WP_DEBUG) {
137
+			return;
138
+		}
139
+		self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty'));
140
+		if (empty($variable_to_test) && 'allow_empty' == $allow_empty) {
141
+			return;
142
+		}
143
+		if (!is_array($variable_to_test)) {
144
+			$error[] = esc_html__('Variable %s should be an array, but it is not.', 'event_espresso');
145
+			$error[] = esc_html__("Its value is, instead '%s'", 'event_espresso');
146
+			throw new EE_Error(sprintf(implode(",", $error), $variable_name, $variable_name, $variable_to_test));
147
+		}
148
+	}
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+	/**
157
+	 * for verifying that a variable is one of the string optiosn supplied
158
+	 * @param mixed $variable_to_test
159
+	 * @param mixed $variable_name the name you've given the variable. Eg, '$foo'. THis helps in producing better error messages
160
+	 * @param array $string_options an array of acceptable values
161
+	 * @return void
162
+	 * @throws EE_Error
163
+	 */
164
+	public static function verify_argument_is_one_of($variable_to_test, $variable_name, $string_options)
165
+	{
166
+		if (!WP_DEBUG) {
167
+			return;
168
+		}
169
+		if (!in_array($variable_to_test, $string_options)) {
170
+			$msg[0] = esc_html__('Malconfigured template.', 'event_espresso');
171
+			$msg[1] = esc_html__("Variable named '%s' was set to '%s'. It can only be one of '%s'", 'event_espresso');
172
+			throw new EE_Error(sprintf(implode("||", $msg), $variable_name, $variable_to_test, implode("', '", $string_options)));
173
+		}
174
+	}
175 175
 }
Please login to merge, or discard this patch.
core/exceptions/InvalidStatusException.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@
 block discarded – undo
7 7
 
8 8
 class InvalidStatusException extends InvalidArgumentException
9 9
 {
10
-    /**
11
-     * InvalidStatusException constructor.
12
-     * @param string $status the invalid status id that was supplied
13
-     * @param string $domain the name of the domain, model, or class that the status belongs to
14
-     * @param string $message custom message
15
-     * @param int $code
16
-     * @param Exception|null $previous
17
-     */
18
-    public function __construct($status, $domain, $message = '', $code = 0, Exception $previous = null)
19
-    {
20
-        if (empty($message)) {
21
-            $message = sprintf(
22
-                esc_html__(
23
-                    '"%1$s" is not a valid %2$s status',
24
-                    'event_espresso'
25
-                ),
26
-                $status,
27
-                $domain
28
-            );
29
-        }
30
-        parent::__construct($message, $code, $previous);
31
-    }
10
+	/**
11
+	 * InvalidStatusException constructor.
12
+	 * @param string $status the invalid status id that was supplied
13
+	 * @param string $domain the name of the domain, model, or class that the status belongs to
14
+	 * @param string $message custom message
15
+	 * @param int $code
16
+	 * @param Exception|null $previous
17
+	 */
18
+	public function __construct($status, $domain, $message = '', $code = 0, Exception $previous = null)
19
+	{
20
+		if (empty($message)) {
21
+			$message = sprintf(
22
+				esc_html__(
23
+					'"%1$s" is not a valid %2$s status',
24
+					'event_espresso'
25
+				),
26
+				$status,
27
+				$domain
28
+			);
29
+		}
30
+		parent::__construct($message, $code, $previous);
31
+	}
32 32
 }
Please login to merge, or discard this patch.
core/exceptions/InvalidDataTypeException.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     {
32 32
         if (empty($message)) {
33 33
             $expected = strpos(' was expected.', $expected) === false
34
-                ? $this->addIndefiniteArticle($expected) . ' was expected.'
34
+                ? $this->addIndefiniteArticle($expected).' was expected.'
35 35
                 : $expected;
36 36
             $message = sprintf(
37 37
                 esc_html__(
@@ -56,6 +56,6 @@  discard block
 block discarded – undo
56 56
         if (strtolower($string) === 'null') {
57 57
             return $string;
58 58
         }
59
-        return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string;
59
+        return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ').$string;
60 60
     }
61 61
 }
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -15,46 +15,46 @@
 block discarded – undo
15 15
  */
16 16
 class InvalidDataTypeException extends InvalidArgumentException
17 17
 {
18
-    /**
19
-     * InvalidDataTypeException constructor
20
-     *
21
-     * @param string    $var_name  name of the variable that was of the wrong type ie: "$my_var"
22
-     * @param mixed     $variable  the actual variable that was of the wrong data type, ie: $my_var
23
-     * @param string    $expected  data type we wanted ie: "integer", "string", "array", etc.
24
-     *                             or an entire rewrite of: "{something something} was expected."
25
-     * @param string    $message
26
-     * @param int       $code
27
-     * @param Exception $previous
28
-     */
29
-    public function __construct($var_name, $variable, $expected, $message = '', $code = 0, Exception $previous = null)
30
-    {
31
-        if (empty($message)) {
32
-            $expected = strpos(' was expected.', $expected) === false
33
-                ? $this->addIndefiniteArticle($expected) . ' was expected.'
34
-                : $expected;
35
-            $message = sprintf(
36
-                esc_html__(
37
-                    'The supplied data for "%1$s" was %2$s, but %3$s',
38
-                    'event_espresso'
39
-                ),
40
-                $var_name,
41
-                $this->addIndefiniteArticle(gettype($variable)),
42
-                $expected
43
-            );
44
-        }
45
-        parent::__construct($message, $code, $previous);
46
-    }
18
+	/**
19
+	 * InvalidDataTypeException constructor
20
+	 *
21
+	 * @param string    $var_name  name of the variable that was of the wrong type ie: "$my_var"
22
+	 * @param mixed     $variable  the actual variable that was of the wrong data type, ie: $my_var
23
+	 * @param string    $expected  data type we wanted ie: "integer", "string", "array", etc.
24
+	 *                             or an entire rewrite of: "{something something} was expected."
25
+	 * @param string    $message
26
+	 * @param int       $code
27
+	 * @param Exception $previous
28
+	 */
29
+	public function __construct($var_name, $variable, $expected, $message = '', $code = 0, Exception $previous = null)
30
+	{
31
+		if (empty($message)) {
32
+			$expected = strpos(' was expected.', $expected) === false
33
+				? $this->addIndefiniteArticle($expected) . ' was expected.'
34
+				: $expected;
35
+			$message = sprintf(
36
+				esc_html__(
37
+					'The supplied data for "%1$s" was %2$s, but %3$s',
38
+					'event_espresso'
39
+				),
40
+				$var_name,
41
+				$this->addIndefiniteArticle(gettype($variable)),
42
+				$expected
43
+			);
44
+		}
45
+		parent::__construct($message, $code, $previous);
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * @param $string
51
-     * @return string
52
-     */
53
-    protected function addIndefiniteArticle($string)
54
-    {
55
-        if (strtolower($string) === 'null') {
56
-            return $string;
57
-        }
58
-        return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string;
59
-    }
49
+	/**
50
+	 * @param $string
51
+	 * @return string
52
+	 */
53
+	protected function addIndefiniteArticle($string)
54
+	{
55
+		if (strtolower($string) === 'null') {
56
+			return $string;
57
+		}
58
+		return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string;
59
+	}
60 60
 }
Please login to merge, or discard this patch.
payment_methods/Paypal_Express/templates/paypal_express_intro.template.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 printf(
4
-    esc_html__(
5
-        'PayPal Express (Express Checkout) is an off-site payment method for accepting payments via PayPal and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.',
6
-        'event_espresso'
7
-    ),
8
-    '<a href="https://eventespresso.com/go/paypalexpress/" target="_blank">',
9
-    '</a>'
4
+	esc_html__(
5
+		'PayPal Express (Express Checkout) is an off-site payment method for accepting payments via PayPal and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.',
6
+		'event_espresso'
7
+	),
8
+	'<a href="https://eventespresso.com/go/paypalexpress/" target="_blank">',
9
+	'</a>'
10 10
 );
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EE_Paypal_Standard_Form.form.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $paypal_calculates_taxes = $this->get_input_value('paypal_taxes');
68 68
         $paypal_requests_address_info = $this->get_input_value('shipping_details');
69 69
         if (
70
-            ( $paypal_calculates_shipping || $paypal_calculates_taxes ) &&
70
+            ($paypal_calculates_shipping || $paypal_calculates_taxes) &&
71 71
             $paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none
72 72
         ) {
73 73
             // they want paypal to calculate taxes or shipping. They need to ask for
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
                 sprintf(
81 81
                     esc_html__('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'),
82 82
                     strip_tags($shipping_details_input->html_label_text()),
83
-                    isset($shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ])
84
-                        ? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ]
83
+                    isset($shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional])
84
+                        ? $shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional]
85 85
                         : esc_html__('Unknown', 'event_espresso')
86 86
                 ),
87 87
                 __FILE__,
Please login to merge, or discard this patch.
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -13,78 +13,78 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Paypal_Standard_Form extends EE_Payment_Method_Form
15 15
 {
16
-    /**
17
-     * @param EE_PMT_Paypal_Standard $payment_method_type
18
-     */
19
-    public function __construct($payment_method_type)
20
-    {
21
-        parent::__construct(
22
-            array(
23
-                'payment_method_type'          => $payment_method_type,
24
-                'extra_meta_inputs'            => array(
25
-                    'paypal_id'        => new EE_Text_Input(array(
26
-                        'html_label_text' => sprintf(esc_html__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()),
27
-                        'html_help_text'  => esc_html__("Typically [email protected]", 'event_espresso'),
28
-                        'required'        => true
29
-                    )),
30
-                    'image_url'        => new EE_Admin_File_Uploader_Input(array(
31
-                        'html_help_text'  => esc_html__("Used for your business/personal logo on the PayPal page", 'event_espresso'),
32
-                        'html_label_text' => esc_html__('Image URL', 'event_espresso')
33
-                    )),
34
-                    'paypal_taxes'     => new EE_Yes_No_Input(array(
35
-                        'html_label_text' => sprintf(esc_html__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
36
-                        'html_help_text'  => esc_html__('Whether Paypal should add taxes to the order', 'event_espresso'),
37
-                        'default'         => false
38
-                    )),
39
-                    'paypal_shipping'  => new EE_Yes_No_Input(array(
40
-                        'html_label_text' => sprintf(esc_html__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
41
-                        'html_help_text'  => esc_html__('Whether Paypal should add shipping surcharges', 'event_espresso'),
42
-                        'default'         => false
43
-                    )),
44
-                    'shipping_details' => new EE_Select_Input(array(
45
-                        EE_PMT_Paypal_Standard::shipping_info_none     => esc_html__("Do not prompt for an address", 'event_espresso'),
46
-                        EE_PMT_Paypal_Standard::shipping_info_optional => esc_html__("Prompt for an address, but do not require it", 'event_espresso'),
47
-                        EE_PMT_Paypal_Standard::shipping_info_required => esc_html__("Prompt for an address, and require it", 'event_espresso')
48
-                    ))
49
-                )
50
-            )
51
-        );
52
-    }
16
+	/**
17
+	 * @param EE_PMT_Paypal_Standard $payment_method_type
18
+	 */
19
+	public function __construct($payment_method_type)
20
+	{
21
+		parent::__construct(
22
+			array(
23
+				'payment_method_type'          => $payment_method_type,
24
+				'extra_meta_inputs'            => array(
25
+					'paypal_id'        => new EE_Text_Input(array(
26
+						'html_label_text' => sprintf(esc_html__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()),
27
+						'html_help_text'  => esc_html__("Typically [email protected]", 'event_espresso'),
28
+						'required'        => true
29
+					)),
30
+					'image_url'        => new EE_Admin_File_Uploader_Input(array(
31
+						'html_help_text'  => esc_html__("Used for your business/personal logo on the PayPal page", 'event_espresso'),
32
+						'html_label_text' => esc_html__('Image URL', 'event_espresso')
33
+					)),
34
+					'paypal_taxes'     => new EE_Yes_No_Input(array(
35
+						'html_label_text' => sprintf(esc_html__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
36
+						'html_help_text'  => esc_html__('Whether Paypal should add taxes to the order', 'event_espresso'),
37
+						'default'         => false
38
+					)),
39
+					'paypal_shipping'  => new EE_Yes_No_Input(array(
40
+						'html_label_text' => sprintf(esc_html__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
41
+						'html_help_text'  => esc_html__('Whether Paypal should add shipping surcharges', 'event_espresso'),
42
+						'default'         => false
43
+					)),
44
+					'shipping_details' => new EE_Select_Input(array(
45
+						EE_PMT_Paypal_Standard::shipping_info_none     => esc_html__("Do not prompt for an address", 'event_espresso'),
46
+						EE_PMT_Paypal_Standard::shipping_info_optional => esc_html__("Prompt for an address, but do not require it", 'event_espresso'),
47
+						EE_PMT_Paypal_Standard::shipping_info_required => esc_html__("Prompt for an address, and require it", 'event_espresso')
48
+					))
49
+				)
50
+			)
51
+		);
52
+	}
53 53
 
54 54
 
55 55
 
56
-    /**
57
-     * @param array $req_data
58
-     * @throws EE_Error
59
-     */
60
-    public function _normalize($req_data)
61
-    {
62
-        parent::_normalize($req_data);
63
-        $paypal_calculates_shipping = $this->get_input_value('paypal_shipping');
64
-        $paypal_calculates_taxes = $this->get_input_value('paypal_taxes');
65
-        $paypal_requests_address_info = $this->get_input_value('shipping_details');
66
-        if (
67
-            ( $paypal_calculates_shipping || $paypal_calculates_taxes ) &&
68
-            $paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none
69
-        ) {
70
-            // they want paypal to calculate taxes or shipping. They need to ask for
71
-            // address info, otherwise paypal can't calculate taxes or shipping
72
-            /** @type EE_Select_Input $shipping_details_input */
73
-            $shipping_details_input = $this->get_input('shipping_details');
74
-            $shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional);
75
-            $shipping_details_input_options = $shipping_details_input->options();
76
-            EE_Error::add_attention(
77
-                sprintf(
78
-                    esc_html__('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'),
79
-                    strip_tags($shipping_details_input->html_label_text()),
80
-                    isset($shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ])
81
-                        ? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ]
82
-                        : esc_html__('Unknown', 'event_espresso')
83
-                ),
84
-                __FILE__,
85
-                __FUNCTION__,
86
-                __LINE__
87
-            );
88
-        }
89
-    }
56
+	/**
57
+	 * @param array $req_data
58
+	 * @throws EE_Error
59
+	 */
60
+	public function _normalize($req_data)
61
+	{
62
+		parent::_normalize($req_data);
63
+		$paypal_calculates_shipping = $this->get_input_value('paypal_shipping');
64
+		$paypal_calculates_taxes = $this->get_input_value('paypal_taxes');
65
+		$paypal_requests_address_info = $this->get_input_value('shipping_details');
66
+		if (
67
+			( $paypal_calculates_shipping || $paypal_calculates_taxes ) &&
68
+			$paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none
69
+		) {
70
+			// they want paypal to calculate taxes or shipping. They need to ask for
71
+			// address info, otherwise paypal can't calculate taxes or shipping
72
+			/** @type EE_Select_Input $shipping_details_input */
73
+			$shipping_details_input = $this->get_input('shipping_details');
74
+			$shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional);
75
+			$shipping_details_input_options = $shipping_details_input->options();
76
+			EE_Error::add_attention(
77
+				sprintf(
78
+					esc_html__('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'),
79
+					strip_tags($shipping_details_input->html_label_text()),
80
+					isset($shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ])
81
+						? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ]
82
+						: esc_html__('Unknown', 'event_espresso')
83
+				),
84
+				__FILE__,
85
+				__FUNCTION__,
86
+				__LINE__
87
+			);
88
+		}
89
+	}
90 90
 }
Please login to merge, or discard this patch.
payment_methods/Check/EE_PMT_Check.pm.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
         $this->_pretty_name = esc_html__("Check", 'event_espresso');
23 23
         $this->_default_description = esc_html__('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso');
24 24
         parent::__construct($pm_instance);
25
-        $this->_default_button_url = $this->file_url() . 'lib/check-logo.png';
25
+        $this->_default_button_url = $this->file_url().'lib/check-logo.png';
26 26
     }
27 27
 
28 28
 
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
         if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
49 49
             $organization = EE_Registry::instance()->CFG->organization;
50 50
             $organization_name = $organization->get_pretty('name');
51
-            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
52
-            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
51
+            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1').'<br />' : '';
52
+            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2').'<br />' : '';
53 53
             $default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
54
-            $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
54
+            $default_address .= ($organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
55 55
             $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
56
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
57
-            $default_address .=  $state ? $state->name() . '<br />' : '';
58
-            $default_address .= $country ? $country->name() . '<br />' : '';
56
+            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO);
57
+            $default_address .= $state ? $state->name().'<br />' : '';
58
+            $default_address .= $country ? $country->name().'<br />' : '';
59 59
             $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
60 60
         } else {
61 61
             $default_address = 'unknown';
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                 'payment_instructions' => new EE_Text_Area_Input(array(
71 71
                     'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
72 72
                     'default' => esc_html__("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
73
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
73
+                    'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
74 74
                 )),
75 75
                 'payable_to' => new EE_Text_Input(array(
76 76
                     'html_label_text' =>  sprintf(esc_html__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 'address_to_send_payment' => new EE_Text_Area_Input(array(
80 80
                     'html_label_text' =>  sprintf(esc_html__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
81 81
                     'default' => $default_address,
82
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
82
+                    'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
83 83
                 )),
84 84
             ),
85 85
             'exclude' => array('PMD_debug_mode')
Please login to merge, or discard this patch.
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -11,131 +11,131 @@
 block discarded – undo
11 11
  */
12 12
 class EE_PMT_Check extends EE_PMT_Base
13 13
 {
14
-    /**
15
-     * @param EE_Payment_Method|null $pm_instance
16
-     * @throws ReflectionException
17
-     * @throws EE_Error
18
-     */
19
-    public function __construct($pm_instance = null)
20
-    {
21
-        $this->_pretty_name = esc_html__("Check", 'event_espresso');
22
-        $this->_default_description = esc_html__('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso');
23
-        parent::__construct($pm_instance);
24
-        $this->_default_button_url = $this->file_url() . 'lib/check-logo.png';
25
-    }
14
+	/**
15
+	 * @param EE_Payment_Method|null $pm_instance
16
+	 * @throws ReflectionException
17
+	 * @throws EE_Error
18
+	 */
19
+	public function __construct($pm_instance = null)
20
+	{
21
+		$this->_pretty_name = esc_html__("Check", 'event_espresso');
22
+		$this->_default_description = esc_html__('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso');
23
+		parent::__construct($pm_instance);
24
+		$this->_default_button_url = $this->file_url() . 'lib/check-logo.png';
25
+	}
26 26
 
27 27
 
28 28
 
29
-    /**
30
-     * Creates the billing form for this payment method type
31
-     * @param EE_Transaction|null $transaction
32
-     * @return EE_Billing_Info_Form|null
33
-     * @throws EE_Error
34
-     * @throws ReflectionException
35
-     */
36
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
37
-    {    return null;
38
-    }
29
+	/**
30
+	 * Creates the billing form for this payment method type
31
+	 * @param EE_Transaction|null $transaction
32
+	 * @return EE_Billing_Info_Form|null
33
+	 * @throws EE_Error
34
+	 * @throws ReflectionException
35
+	 */
36
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
37
+	{    return null;
38
+	}
39 39
 
40 40
 
41 41
 
42
-    /**
43
-     * Overrides parent to dynamically set some defaults, but only when the form is requested
44
-     *
45
-     * @return EE_Payment_Method_Form
46
-     * @throws EE_Error
47
-     * @throws ReflectionException
48
-     */
49
-    public function generate_new_settings_form()
50
-    {
51
-        if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
52
-            $organization = EE_Registry::instance()->CFG->organization;
53
-            $organization_name = $organization->get_pretty('name');
54
-            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
55
-            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
56
-            $default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
57
-            $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
58
-            $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
59
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
60
-            $default_address .=  $state ? $state->name() . '<br />' : '';
61
-            $default_address .= $country ? $country->name() . '<br />' : '';
62
-            $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
63
-        } else {
64
-            $default_address = 'unknown';
65
-            $organization_name = 'unknown';
66
-        }
67
-            return new EE_Payment_Method_Form(array(
68
-            'extra_meta_inputs' => array(
69
-                'check_title' => new EE_Text_Input(array(
70
-                    'html_label_text' =>  sprintf(esc_html__("Title %s", "event_espresso"), $this->get_help_tab_link()),
71
-                    'default' =>  esc_html__("Check/Money Order Payments", 'event_espresso'),
72
-                )),
73
-                'payment_instructions' => new EE_Text_Area_Input(array(
74
-                    'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
75
-                    'default' => esc_html__("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
76
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
77
-                )),
78
-                'payable_to' => new EE_Text_Input(array(
79
-                    'html_label_text' =>  sprintf(esc_html__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
80
-                    'default' => $organization_name
81
-                )),
82
-                'address_to_send_payment' => new EE_Text_Area_Input(array(
83
-                    'html_label_text' =>  sprintf(esc_html__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
84
-                    'default' => $default_address,
85
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
86
-                )),
87
-            ),
88
-            'exclude' => array('PMD_debug_mode')
89
-            ));
90
-    }
42
+	/**
43
+	 * Overrides parent to dynamically set some defaults, but only when the form is requested
44
+	 *
45
+	 * @return EE_Payment_Method_Form
46
+	 * @throws EE_Error
47
+	 * @throws ReflectionException
48
+	 */
49
+	public function generate_new_settings_form()
50
+	{
51
+		if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
52
+			$organization = EE_Registry::instance()->CFG->organization;
53
+			$organization_name = $organization->get_pretty('name');
54
+			$default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
55
+			$default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
56
+			$default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
57
+			$default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
58
+			$state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
59
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
60
+			$default_address .=  $state ? $state->name() . '<br />' : '';
61
+			$default_address .= $country ? $country->name() . '<br />' : '';
62
+			$default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
63
+		} else {
64
+			$default_address = 'unknown';
65
+			$organization_name = 'unknown';
66
+		}
67
+			return new EE_Payment_Method_Form(array(
68
+			'extra_meta_inputs' => array(
69
+				'check_title' => new EE_Text_Input(array(
70
+					'html_label_text' =>  sprintf(esc_html__("Title %s", "event_espresso"), $this->get_help_tab_link()),
71
+					'default' =>  esc_html__("Check/Money Order Payments", 'event_espresso'),
72
+				)),
73
+				'payment_instructions' => new EE_Text_Area_Input(array(
74
+					'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
75
+					'default' => esc_html__("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
76
+					'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
77
+				)),
78
+				'payable_to' => new EE_Text_Input(array(
79
+					'html_label_text' =>  sprintf(esc_html__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
80
+					'default' => $organization_name
81
+				)),
82
+				'address_to_send_payment' => new EE_Text_Area_Input(array(
83
+					'html_label_text' =>  sprintf(esc_html__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
84
+					'default' => $default_address,
85
+					'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
86
+				)),
87
+			),
88
+			'exclude' => array('PMD_debug_mode')
89
+			));
90
+	}
91 91
 
92 92
 
93 93
 
94
-    /**
95
-     * Adds the help tab
96
-     *
97
-     * @return array
98
-     * @see EE_PMT_Base::help_tabs_config()
99
-     */
100
-    public function help_tabs_config()
101
-    {
102
-        return array(
103
-            $this->get_help_tab_name() => array(
104
-                        'title' => esc_html__('Check Settings', 'event_espresso'),
105
-                        'filename' => 'payment_methods_overview_check'
106
-                        ),
107
-        );
108
-    }
94
+	/**
95
+	 * Adds the help tab
96
+	 *
97
+	 * @return array
98
+	 * @see EE_PMT_Base::help_tabs_config()
99
+	 */
100
+	public function help_tabs_config()
101
+	{
102
+		return array(
103
+			$this->get_help_tab_name() => array(
104
+						'title' => esc_html__('Check Settings', 'event_espresso'),
105
+						'filename' => 'payment_methods_overview_check'
106
+						),
107
+		);
108
+	}
109 109
 
110 110
 
111 111
 
112
-    /**
113
-     * For adding any html output ab ove the payment overview.
114
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
115
-     * Other gateways may want to override this, such as offline gateways.
116
-     *
117
-     * @param EE_Payment $payment
118
-     * @return string
119
-     * @throws EE_Error
120
-     * @throws ReflectionException
121
-     */
122
-    public function payment_overview_content(EE_Payment $payment)
123
-    {
124
-        $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
125
-        $template_vars = array_merge(
126
-            array(
127
-                            'payment_method' => $this->_pm_instance,
128
-                            'payment' => $payment,
129
-                            'check_title' => '',
130
-                            'payment_instructions' => '',
131
-                            'payable_to' => '',
132
-                            'address_to_send_payment' => '',
133
-                            ),
134
-            $extra_meta_for_payment_method
135
-        );
136
-        return EEH_Template::locate_template(
137
-            'payment_methods/Check/templates/check_payment_details_content.template.php',
138
-            $template_vars
139
-        );
140
-    }
112
+	/**
113
+	 * For adding any html output ab ove the payment overview.
114
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
115
+	 * Other gateways may want to override this, such as offline gateways.
116
+	 *
117
+	 * @param EE_Payment $payment
118
+	 * @return string
119
+	 * @throws EE_Error
120
+	 * @throws ReflectionException
121
+	 */
122
+	public function payment_overview_content(EE_Payment $payment)
123
+	{
124
+		$extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
125
+		$template_vars = array_merge(
126
+			array(
127
+							'payment_method' => $this->_pm_instance,
128
+							'payment' => $payment,
129
+							'check_title' => '',
130
+							'payment_instructions' => '',
131
+							'payable_to' => '',
132
+							'address_to_send_payment' => '',
133
+							),
134
+			$extra_meta_for_payment_method
135
+		);
136
+		return EEH_Template::locate_template(
137
+			'payment_methods/Check/templates/check_payment_details_content.template.php',
138
+			$template_vars
139
+		);
140
+	}
141 141
 }
Please login to merge, or discard this patch.
admin_pages/registrations/qtips/Registration_List_Table_Tips.lib.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
                . esc_html__(
85 85
                    'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
86 86
                    'event_espresso'
87
-               ) . '</p>';
87
+               ).'</p>';
88 88
     }
89 89
 
90 90
 
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class Registration_List_Table_Tips extends EE_Qtip_Config
15 15
 {
16
-    protected function _set_tips_array()
17
-    {
18
-        $this->_qtipsa = array(
19
-            0 => array(
20
-                'content_id' => 'registration-trash-lock',
21
-                'target'     => '.ee-lock-icon',
22
-                'content'    => $this->_registration_trash_message(),
23
-            ),
24
-            /** removing status strips for now because they are triggered anywhere on the row. */
25
-            /**1 => array(
16
+	protected function _set_tips_array()
17
+	{
18
+		$this->_qtipsa = array(
19
+			0 => array(
20
+				'content_id' => 'registration-trash-lock',
21
+				'target'     => '.ee-lock-icon',
22
+				'content'    => $this->_registration_trash_message(),
23
+			),
24
+			/** removing status strips for now because they are triggered anywhere on the row. */
25
+			/**1 => array(
26 26
              * 'content_id' => 'registration-status-' . EEM_Registration::status_id_approved,
27 27
              * 'target' => '.reg-status-' . EEM_Registration::status_id_approved,
28 28
              * 'content' => $this->_registration_status_legend(EEM_Registration::status_id_approved),
@@ -72,37 +72,37 @@  discard block
 block discarded – undo
72 72
              * )
73 73
              * )
74 74
              * )/**/
75
-        );
76
-    }
75
+		);
76
+	}
77 77
 
78 78
 
79
-    private function _registration_trash_message()
80
-    {
81
-        return '<p>'
82
-               . esc_html__(
83
-                   'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
84
-                   'event_espresso'
85
-               ) . '</p>';
86
-    }
79
+	private function _registration_trash_message()
80
+	{
81
+		return '<p>'
82
+			   . esc_html__(
83
+				   'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
84
+				   'event_espresso'
85
+			   ) . '</p>';
86
+	}
87 87
 
88 88
 
89
-    /**
90
-     * output the relevant ee-status-legend with the designated status highlighted.
91
-     *
92
-     * @param  EEM_Registration constant $status What status is set (by class)
93
-     * @return string         The status legend with the related status highlighted
94
-     */
95
-    private function _registration_status_legend($status)
96
-    {
89
+	/**
90
+	 * output the relevant ee-status-legend with the designated status highlighted.
91
+	 *
92
+	 * @param  EEM_Registration constant $status What status is set (by class)
93
+	 * @return string         The status legend with the related status highlighted
94
+	 */
95
+	private function _registration_status_legend($status)
96
+	{
97 97
 
98
-        $status_array = array(
99
-            'approved_status' => EEM_Registration::status_id_approved,
100
-            'pending_status' => EEM_Registration::status_id_pending_payment,
101
-            'not_approved' => EEM_Registration::status_id_not_approved,
102
-            'declined_status' => EEM_Registration::status_id_declined,
103
-            'cancelled_status' => EEM_Registration::status_id_cancelled,
104
-        );
98
+		$status_array = array(
99
+			'approved_status' => EEM_Registration::status_id_approved,
100
+			'pending_status' => EEM_Registration::status_id_pending_payment,
101
+			'not_approved' => EEM_Registration::status_id_not_approved,
102
+			'declined_status' => EEM_Registration::status_id_declined,
103
+			'cancelled_status' => EEM_Registration::status_id_cancelled,
104
+		);
105 105
 
106
-        return EEH_Template::status_legend($status_array, $status);
107
-    }
106
+		return EEH_Template::status_legend($status_array, $status);
107
+	}
108 108
 }
Please login to merge, or discard this patch.