Completed
Branch BUG-10236-FIX-RESET-CAPABILITI... (cbd980)
by
unknown
26:22 queued 14:04
created
admin_pages/maintenance/templates/ee_system_stati_page.template.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  */
12 12
 function ee_recurse_into_array_for_display($data) {
13 13
 	if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {//is_object($incomplete_class) actually returns false, hence why we check for it
14
-        $data = json_decode(json_encode($data), true);
14
+		$data = json_decode(json_encode($data), true);
15 15
 	}
16 16
 	if (is_array($data)) {
17 17
 		if (EEH_Array::is_associative_array($data)) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 						?>
24 24
 						<tr>
25 25
 							<td>
26
-								<?php echo $data_key;?>
26
+								<?php echo $data_key; ?>
27 27
 							</td>
28 28
 							<td>
29
-								<?php ee_recurse_into_array_for_display($data_values);?>
29
+								<?php ee_recurse_into_array_for_display($data_values); ?>
30 30
 							</td>
31 31
 						</tr>
32 32
 						<?php
@@ -40,19 +40,19 @@  discard block
 block discarded – undo
40 40
 			<ul>
41 41
 				<?php
42 42
 				foreach ($data as $datum) {
43
-					echo "<li>";ee_recurse_into_array_for_display($datum);echo "</li>";
43
+					echo "<li>"; ee_recurse_into_array_for_display($datum); echo "</li>";
44 44
 				}?>
45 45
 			</ul>
46 46
 			<?php
47 47
 		}
48
-	}else {
48
+	} else {
49 49
 		//simple value
50 50
 		echo $data;
51 51
 	}
52 52
 }
53 53
 ?>
54 54
 <h1>
55
-	<?php _e("System Information", "event_espresso");?> <a href="<?php echo $download_system_status_url;?>" class="button-secondary"><?php esc_html_e( 'Download to File', 'event_espresso' );?></a>
55
+	<?php _e("System Information", "event_espresso"); ?> <a href="<?php echo $download_system_status_url; ?>" class="button-secondary"><?php esc_html_e('Download to File', 'event_espresso'); ?></a>
56 56
 </h1>
57 57
 <div class="padding">
58 58
 
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoCheckout.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -21,59 +21,59 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * the actual shortcode tag that gets registered with WordPress
26
-     *
27
-     * @return string
28
-     */
29
-    public function getTag()
30
-    {
31
-        return 'ESPRESSO_CHECKOUT';
32
-    }
33
-
34
-
35
-
36
-    /**
37
-     * the time in seconds to cache the results of the processShortcode() method
38
-     * 0 means the processShortcode() results will NOT be cached at all
39
-     *
40
-     * @return int
41
-     */
42
-    public function cacheExpiration()
43
-    {
44
-        return 0;
45
-    }
46
-
47
-
48
-    /**
49
-     * a place for adding any initialization code that needs to run prior to wp_header().
50
-     * this may be required for shortcodes that utilize a corresponding module,
51
-     * and need to enqueue assets for that module
52
-     *
53
-     * @return void
54
-     * @throws \EE_Error
55
-     */
56
-    public function initializeShortcode()
57
-    {
58
-        global $wp_query;
59
-        EED_Single_Page_Checkout::init($wp_query);
60
-        $this->shortcodeHasBeenInitialized();
61
-    }
62
-
63
-
64
-
65
-    /**
66
-     * callback that runs when the shortcode is encountered in post content.
67
-     * IMPORTANT !!!
68
-     * remember that shortcode content should be RETURNED and NOT echoed out
69
-     *
70
-     * @param array $attributes
71
-     * @return string
72
-     */
73
-    public function processShortcode($attributes = array())
74
-    {
75
-        return EE_Registry::instance()->REQ->get_output();
76
-    }
24
+	/**
25
+	 * the actual shortcode tag that gets registered with WordPress
26
+	 *
27
+	 * @return string
28
+	 */
29
+	public function getTag()
30
+	{
31
+		return 'ESPRESSO_CHECKOUT';
32
+	}
33
+
34
+
35
+
36
+	/**
37
+	 * the time in seconds to cache the results of the processShortcode() method
38
+	 * 0 means the processShortcode() results will NOT be cached at all
39
+	 *
40
+	 * @return int
41
+	 */
42
+	public function cacheExpiration()
43
+	{
44
+		return 0;
45
+	}
46
+
47
+
48
+	/**
49
+	 * a place for adding any initialization code that needs to run prior to wp_header().
50
+	 * this may be required for shortcodes that utilize a corresponding module,
51
+	 * and need to enqueue assets for that module
52
+	 *
53
+	 * @return void
54
+	 * @throws \EE_Error
55
+	 */
56
+	public function initializeShortcode()
57
+	{
58
+		global $wp_query;
59
+		EED_Single_Page_Checkout::init($wp_query);
60
+		$this->shortcodeHasBeenInitialized();
61
+	}
62
+
63
+
64
+
65
+	/**
66
+	 * callback that runs when the shortcode is encountered in post content.
67
+	 * IMPORTANT !!!
68
+	 * remember that shortcode content should be RETURNED and NOT echoed out
69
+	 *
70
+	 * @param array $attributes
71
+	 * @return string
72
+	 */
73
+	public function processShortcode($attributes = array())
74
+	{
75
+		return EE_Registry::instance()->REQ->get_output();
76
+	}
77 77
 
78 78
 
79 79
 
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoTxnPage.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -27,92 +27,92 @@
 block discarded – undo
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * the actual shortcode tag that gets registered with WordPress
32
-     *
33
-     * @return string
34
-     */
35
-    public function getTag()
36
-    {
37
-        return 'ESPRESSO_TXN_PAGE';
38
-    }
39
-
40
-
41
-
42
-    /**
43
-     * the time in seconds to cache the results of the processShortcode() method
44
-     * 0 means the processShortcode() results will NOT be cached at all
45
-     *
46
-     * @return int
47
-     */
48
-    public function cacheExpiration()
49
-    {
50
-        return 0;
51
-    }
52
-
53
-
54
-    /**
55
-     * a place for adding any initialization code that needs to run prior to wp_header().
56
-     * this may be required for shortcodes that utilize a corresponding module,
57
-     * and need to enqueue assets for that module
58
-     *
59
-     * @return void
60
-     * @throws \Exception
61
-     * @throws \EE_Error
62
-     */
63
-    public function initializeShortcode()
64
-    {
65
-        $transaction = null;
66
-        if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
67
-            /** @var EEM_Transaction $EEM_Transaction */
68
-            $EEM_Transaction = EE_Registry::instance()->load_model('Transaction');
69
-            $transaction = $EEM_Transaction->get_transaction_from_reg_url_link();
70
-        }
71
-        if ($transaction instanceof EE_Transaction) {
72
-            $payment_method = null;
73
-            $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null);
74
-            if ($payment_method_slug) {
75
-                $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug);
76
-            }
77
-            if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) {
78
-                $gateway = $payment_method->type_obj()->get_gateway();
79
-                if (
80
-                    $gateway instanceof EE_Offsite_Gateway
81
-                    && $gateway->handle_IPN_in_this_request(
82
-                        \EE_Registry::instance()->REQ->params(),
83
-                        true
84
-                    )
85
-                ) {
86
-                    /** @type EE_Payment_Processor $payment_processor */
87
-                    $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
88
-                    $payment_processor->process_ipn($_REQUEST, $transaction, $payment_method);
89
-                }
90
-            }
91
-            //allow gateways to add a filter to stop rendering the page
92
-            if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) {
93
-                exit;
94
-            }
95
-        }
96
-        $this->shortcodeHasBeenInitialized();
97
-    }
98
-
99
-
100
-
101
-    /**
102
-     * callback that runs when the shortcode is encountered in post content.
103
-     * IMPORTANT !!!
104
-     * remember that shortcode content should be RETURNED and NOT echoed out
105
-     *
106
-     * @param array $attributes
107
-     * @return string
108
-     */
109
-    public function processShortcode($attributes = array())
110
-    {
111
-        return esc_html__(
112
-            'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.',
113
-            'event_espresso'
114
-        );
115
-    }
30
+	/**
31
+	 * the actual shortcode tag that gets registered with WordPress
32
+	 *
33
+	 * @return string
34
+	 */
35
+	public function getTag()
36
+	{
37
+		return 'ESPRESSO_TXN_PAGE';
38
+	}
39
+
40
+
41
+
42
+	/**
43
+	 * the time in seconds to cache the results of the processShortcode() method
44
+	 * 0 means the processShortcode() results will NOT be cached at all
45
+	 *
46
+	 * @return int
47
+	 */
48
+	public function cacheExpiration()
49
+	{
50
+		return 0;
51
+	}
52
+
53
+
54
+	/**
55
+	 * a place for adding any initialization code that needs to run prior to wp_header().
56
+	 * this may be required for shortcodes that utilize a corresponding module,
57
+	 * and need to enqueue assets for that module
58
+	 *
59
+	 * @return void
60
+	 * @throws \Exception
61
+	 * @throws \EE_Error
62
+	 */
63
+	public function initializeShortcode()
64
+	{
65
+		$transaction = null;
66
+		if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
67
+			/** @var EEM_Transaction $EEM_Transaction */
68
+			$EEM_Transaction = EE_Registry::instance()->load_model('Transaction');
69
+			$transaction = $EEM_Transaction->get_transaction_from_reg_url_link();
70
+		}
71
+		if ($transaction instanceof EE_Transaction) {
72
+			$payment_method = null;
73
+			$payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null);
74
+			if ($payment_method_slug) {
75
+				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug);
76
+			}
77
+			if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) {
78
+				$gateway = $payment_method->type_obj()->get_gateway();
79
+				if (
80
+					$gateway instanceof EE_Offsite_Gateway
81
+					&& $gateway->handle_IPN_in_this_request(
82
+						\EE_Registry::instance()->REQ->params(),
83
+						true
84
+					)
85
+				) {
86
+					/** @type EE_Payment_Processor $payment_processor */
87
+					$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
88
+					$payment_processor->process_ipn($_REQUEST, $transaction, $payment_method);
89
+				}
90
+			}
91
+			//allow gateways to add a filter to stop rendering the page
92
+			if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) {
93
+				exit;
94
+			}
95
+		}
96
+		$this->shortcodeHasBeenInitialized();
97
+	}
98
+
99
+
100
+
101
+	/**
102
+	 * callback that runs when the shortcode is encountered in post content.
103
+	 * IMPORTANT !!!
104
+	 * remember that shortcode content should be RETURNED and NOT echoed out
105
+	 *
106
+	 * @param array $attributes
107
+	 * @return string
108
+	 */
109
+	public function processShortcode($attributes = array())
110
+	{
111
+		return esc_html__(
112
+			'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.',
113
+			'event_espresso'
114
+		);
115
+	}
116 116
 }
117 117
 // End of file EspressoTxnPage.php
118 118
 // Location: EventEspresso\core\domain\entities\shortcodes/EspressoTxnPage.php
119 119
\ No newline at end of file
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoThankYou.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -20,75 +20,75 @@
 block discarded – undo
20 20
 class EspressoThankYou extends EspressoShortcode
21 21
 {
22 22
 
23
-    /**
24
-     * @var boolean $is_thank_you_page
25
-     */
26
-    private $is_thank_you_page = false;
27
-
28
-    /**
29
-     * the actual shortcode tag that gets registered with WordPress
30
-     *
31
-     * @return string
32
-     */
33
-    public function getTag()
34
-    {
35
-        return 'ESPRESSO_THANK_YOU';
36
-    }
37
-
38
-
39
-
40
-    /**
41
-     * the time in seconds to cache the results of the processShortcode() method
42
-     * 0 means the processShortcode() results will NOT be cached at all
43
-     *
44
-     * @return int
45
-     */
46
-    public function cacheExpiration()
47
-    {
48
-        return 0;
49
-    }
50
-
51
-
52
-    /**
53
-     * a place for adding any initialization code that needs to run prior to wp_header().
54
-     * this may be required for shortcodes that utilize a corresponding module,
55
-     * and need to enqueue assets for that module
56
-     *
57
-     * @return void
58
-     * @throws \EE_Error
59
-     */
60
-    public function initializeShortcode()
61
-    {
62
-        global $wp_query;
63
-        if (empty($wp_query->posts) || count($wp_query->posts) > 1) {
64
-            return;
65
-        }
66
-        $post = reset($wp_query->posts);
67
-        if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) {
68
-            return;
69
-        }
70
-        $this->is_thank_you_page = true;
71
-        \EED_Thank_You_Page::instance()->load_resources();
72
-        $this->shortcodeHasBeenInitialized();
73
-    }
74
-
75
-
76
-
77
-    /**
78
-     * callback that runs when the shortcode is encountered in post content.
79
-     * IMPORTANT !!!
80
-     * remember that shortcode content should be RETURNED and NOT echoed out
81
-     *
82
-     * @param array $attributes
83
-     * @return string
84
-     * @throws \EE_Error
85
-     */
86
-    public function processShortcode($attributes = array())
87
-    {
88
-        return $this->is_thank_you_page
89
-            ? \EED_Thank_You_Page::instance()->thank_you_page_results()
90
-            : '';
91
-    }
23
+	/**
24
+	 * @var boolean $is_thank_you_page
25
+	 */
26
+	private $is_thank_you_page = false;
27
+
28
+	/**
29
+	 * the actual shortcode tag that gets registered with WordPress
30
+	 *
31
+	 * @return string
32
+	 */
33
+	public function getTag()
34
+	{
35
+		return 'ESPRESSO_THANK_YOU';
36
+	}
37
+
38
+
39
+
40
+	/**
41
+	 * the time in seconds to cache the results of the processShortcode() method
42
+	 * 0 means the processShortcode() results will NOT be cached at all
43
+	 *
44
+	 * @return int
45
+	 */
46
+	public function cacheExpiration()
47
+	{
48
+		return 0;
49
+	}
50
+
51
+
52
+	/**
53
+	 * a place for adding any initialization code that needs to run prior to wp_header().
54
+	 * this may be required for shortcodes that utilize a corresponding module,
55
+	 * and need to enqueue assets for that module
56
+	 *
57
+	 * @return void
58
+	 * @throws \EE_Error
59
+	 */
60
+	public function initializeShortcode()
61
+	{
62
+		global $wp_query;
63
+		if (empty($wp_query->posts) || count($wp_query->posts) > 1) {
64
+			return;
65
+		}
66
+		$post = reset($wp_query->posts);
67
+		if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) {
68
+			return;
69
+		}
70
+		$this->is_thank_you_page = true;
71
+		\EED_Thank_You_Page::instance()->load_resources();
72
+		$this->shortcodeHasBeenInitialized();
73
+	}
74
+
75
+
76
+
77
+	/**
78
+	 * callback that runs when the shortcode is encountered in post content.
79
+	 * IMPORTANT !!!
80
+	 * remember that shortcode content should be RETURNED and NOT echoed out
81
+	 *
82
+	 * @param array $attributes
83
+	 * @return string
84
+	 * @throws \EE_Error
85
+	 */
86
+	public function processShortcode($attributes = array())
87
+	{
88
+		return $this->is_thank_you_page
89
+			? \EED_Thank_You_Page::instance()->thank_you_page_results()
90
+			: '';
91
+	}
92 92
 
93 93
 
94 94
 
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoEvents.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -34,134 +34,134 @@
 block discarded – undo
34 34
 
35 35
 
36 36
 
37
-    /**
38
-     * the actual shortcode tag that gets registered with WordPress
39
-     *
40
-     * @return string
41
-     */
42
-    public function getTag()
43
-    {
44
-        return 'ESPRESSO_EVENTS';
45
-    }
46
-
47
-
48
-
49
-    /**
50
-     * the time in seconds to cache the results of the processShortcode() method
51
-     * 0 means the processShortcode() results will NOT be cached at all
52
-     *
53
-     * @return int
54
-     */
55
-    public function cacheExpiration()
56
-    {
57
-        return MINUTE_IN_SECONDS * 15;
58
-    }
59
-
60
-
61
-
62
-    /**
63
-     * a place for adding any initialization code that needs to run prior to wp_header().
64
-     * this may be required for shortcodes that utilize a corresponding module,
65
-     * and need to enqueue assets for that module
66
-     *
67
-     * @return void
68
-     */
69
-    public function initializeShortcode()
70
-    {
71
-        EED_Events_Archive::instance()->event_list();
72
-        $this->shortcodeHasBeenInitialized();
73
-    }
74
-
75
-
76
-
77
-    /**
78
-     * callback that runs when the shortcode is encountered in post content.
79
-     * IMPORTANT !!!
80
-     * remember that shortcode content should be RETURNED and NOT echoed out
81
-     *
82
-     * @param array $attributes
83
-     * @return string
84
-     */
85
-    public function processShortcode($attributes = array())
86
-    {
87
-        // grab attributes and merge with defaults
88
-        $attributes = $this->getAttributes($attributes);
89
-        // make sure we use the_excerpt()
90
-        add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true');
91
-        // apply query filters
92
-        add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
93
-        // run the query
94
-        global $wp_query;
95
-        // yes we have to overwrite the main wp query, but it's ok...
96
-        // we're going to reset it again below, so everything will be Hunky Dory (amazing album)
97
-        $wp_query = new EventListQuery($attributes);
98
-        // check what template is loaded and load filters accordingly
99
-        EED_Events_Archive::instance()->template_include('loop-espresso_events.php');
100
-        // load our template
101
-        $event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), true, true);
102
-        // now reset the query and postdata
103
-        wp_reset_query();
104
-        wp_reset_postdata();
105
-        EED_Events_Archive::remove_all_events_archive_filters();
106
-        // remove query filters
107
-        remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
108
-        // pull our content from the output buffer and return it
109
-        return $event_list;
110
-    }
111
-
112
-
113
-
114
-    /**
115
-     * merge incoming attributes with filtered defaults
116
-     *
117
-     * @param array $attributes
118
-     * @return array
119
-     */
120
-    private function getAttributes(array $attributes)
121
-    {
122
-        return array_merge(
123
-            (array)apply_filters(
124
-                'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts',
125
-                array(
126
-                    'title'         => '',
127
-                    'limit'         => 10,
128
-                    'css_class'     => '',
129
-                    'show_expired'  => false,
130
-                    'month'         => '',
131
-                    'category_slug' => '',
132
-                    'order_by'      => 'start_date',
133
-                    'sort'          => 'ASC',
134
-                    'show_title'    => true,
135
-                )
136
-            ),
137
-            $attributes
138
-        );
139
-    }
140
-
141
-
142
-
143
-    /**
144
-     * array for defining custom attribute sanitization callbacks,
145
-     * where keys match keys in your attributes array,
146
-     * and values represent the sanitization function you wish to be applied to that attribute.
147
-     * So for example, if you had an integer attribute named "event_id"
148
-     * that you wanted to be sanitized using absint(),
149
-     * then you would pass the following for your $custom_sanitization array:
150
-     *      array('event_id' => 'absint')
151
-     *
152
-     * @return array
153
-     */
154
-    protected function customAttributeSanitizationMap()
155
-    {
156
-        // the following get sanitized/whitelisted in EEH_Event_Query
157
-        return array(
158
-            'category_slug' => 'skip_sanitization',
159
-            'show_expired'  => 'skip_sanitization',
160
-            'order_by'      => 'skip_sanitization',
161
-            'month'         => 'skip_sanitization',
162
-            'sort'          => 'skip_sanitization',
163
-        );
164
-    }
37
+	/**
38
+	 * the actual shortcode tag that gets registered with WordPress
39
+	 *
40
+	 * @return string
41
+	 */
42
+	public function getTag()
43
+	{
44
+		return 'ESPRESSO_EVENTS';
45
+	}
46
+
47
+
48
+
49
+	/**
50
+	 * the time in seconds to cache the results of the processShortcode() method
51
+	 * 0 means the processShortcode() results will NOT be cached at all
52
+	 *
53
+	 * @return int
54
+	 */
55
+	public function cacheExpiration()
56
+	{
57
+		return MINUTE_IN_SECONDS * 15;
58
+	}
59
+
60
+
61
+
62
+	/**
63
+	 * a place for adding any initialization code that needs to run prior to wp_header().
64
+	 * this may be required for shortcodes that utilize a corresponding module,
65
+	 * and need to enqueue assets for that module
66
+	 *
67
+	 * @return void
68
+	 */
69
+	public function initializeShortcode()
70
+	{
71
+		EED_Events_Archive::instance()->event_list();
72
+		$this->shortcodeHasBeenInitialized();
73
+	}
74
+
75
+
76
+
77
+	/**
78
+	 * callback that runs when the shortcode is encountered in post content.
79
+	 * IMPORTANT !!!
80
+	 * remember that shortcode content should be RETURNED and NOT echoed out
81
+	 *
82
+	 * @param array $attributes
83
+	 * @return string
84
+	 */
85
+	public function processShortcode($attributes = array())
86
+	{
87
+		// grab attributes and merge with defaults
88
+		$attributes = $this->getAttributes($attributes);
89
+		// make sure we use the_excerpt()
90
+		add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true');
91
+		// apply query filters
92
+		add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
93
+		// run the query
94
+		global $wp_query;
95
+		// yes we have to overwrite the main wp query, but it's ok...
96
+		// we're going to reset it again below, so everything will be Hunky Dory (amazing album)
97
+		$wp_query = new EventListQuery($attributes);
98
+		// check what template is loaded and load filters accordingly
99
+		EED_Events_Archive::instance()->template_include('loop-espresso_events.php');
100
+		// load our template
101
+		$event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), true, true);
102
+		// now reset the query and postdata
103
+		wp_reset_query();
104
+		wp_reset_postdata();
105
+		EED_Events_Archive::remove_all_events_archive_filters();
106
+		// remove query filters
107
+		remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
108
+		// pull our content from the output buffer and return it
109
+		return $event_list;
110
+	}
111
+
112
+
113
+
114
+	/**
115
+	 * merge incoming attributes with filtered defaults
116
+	 *
117
+	 * @param array $attributes
118
+	 * @return array
119
+	 */
120
+	private function getAttributes(array $attributes)
121
+	{
122
+		return array_merge(
123
+			(array)apply_filters(
124
+				'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts',
125
+				array(
126
+					'title'         => '',
127
+					'limit'         => 10,
128
+					'css_class'     => '',
129
+					'show_expired'  => false,
130
+					'month'         => '',
131
+					'category_slug' => '',
132
+					'order_by'      => 'start_date',
133
+					'sort'          => 'ASC',
134
+					'show_title'    => true,
135
+				)
136
+			),
137
+			$attributes
138
+		);
139
+	}
140
+
141
+
142
+
143
+	/**
144
+	 * array for defining custom attribute sanitization callbacks,
145
+	 * where keys match keys in your attributes array,
146
+	 * and values represent the sanitization function you wish to be applied to that attribute.
147
+	 * So for example, if you had an integer attribute named "event_id"
148
+	 * that you wanted to be sanitized using absint(),
149
+	 * then you would pass the following for your $custom_sanitization array:
150
+	 *      array('event_id' => 'absint')
151
+	 *
152
+	 * @return array
153
+	 */
154
+	protected function customAttributeSanitizationMap()
155
+	{
156
+		// the following get sanitized/whitelisted in EEH_Event_Query
157
+		return array(
158
+			'category_slug' => 'skip_sanitization',
159
+			'show_expired'  => 'skip_sanitization',
160
+			'order_by'      => 'skip_sanitization',
161
+			'month'         => 'skip_sanitization',
162
+			'sort'          => 'skip_sanitization',
163
+		);
164
+	}
165 165
 
166 166
 
167 167
 
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoCancelled.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -24,79 +24,79 @@
 block discarded – undo
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * the actual shortcode tag that gets registered with WordPress
29
-     *
30
-     * @return string
31
-     */
32
-    public function getTag()
33
-    {
34
-        return 'ESPRESSO_CANCELLED';
35
-    }
36
-
37
-
38
-
39
-    /**
40
-     * the time in seconds to cache the results of the processShortcode() method
41
-     * 0 means the processShortcode() results will NOT be cached at all
42
-     *
43
-     * @return int
44
-     */
45
-    public function cacheExpiration()
46
-    {
47
-        return 0;
48
-    }
49
-
50
-
51
-    /**
52
-     * a place for adding any initialization code that needs to run prior to wp_header().
53
-     * this may be required for shortcodes that utilize a corresponding module,
54
-     * and need to enqueue assets for that module
55
-     *
56
-     * @return void
57
-     */
58
-    public function initializeShortcode()
59
-    {
60
-        $this->shortcodeHasBeenInitialized();
61
-    }
62
-
63
-
64
-    /**
65
-     * callback that runs when the shortcode is encountered in post content.
66
-     * IMPORTANT !!!
67
-     * remember that shortcode content should be RETURNED and NOT echoed out
68
-     *
69
-     * @param array $attributes
70
-     * @return string
71
-     * @throws \EE_Error
72
-     */
73
-    public function processShortcode($attributes = array())
74
-    {
75
-        $transaction = EE_Registry::instance()->SSN->get_session_data('transaction');
76
-        if ($transaction instanceof EE_Transaction) {
77
-            do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', $transaction);
78
-            $registrations = $transaction->registrations();
79
-            foreach ($registrations as $registration) {
80
-                if ($registration instanceof EE_Registration) {
81
-                    do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__registration', $registration);
82
-                }
83
-            }
84
-        }
85
-        do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__clear_session');
86
-        // remove all unwanted records from the db
87
-        if (EE_Registry::instance()->CART instanceof EE_Cart) {
88
-            EE_Registry::instance()->CART->delete_cart();
89
-        }
90
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
91
-        return sprintf(
92
-            __(
93
-                '%sAll unsaved registration information entered during this session has been deleted.%s',
94
-                'event_espresso'
95
-            ),
96
-            '<p class="ee-registrations-cancelled-pg ee-attention">',
97
-            '</p>'
98
-        );
99
-    }
27
+	/**
28
+	 * the actual shortcode tag that gets registered with WordPress
29
+	 *
30
+	 * @return string
31
+	 */
32
+	public function getTag()
33
+	{
34
+		return 'ESPRESSO_CANCELLED';
35
+	}
36
+
37
+
38
+
39
+	/**
40
+	 * the time in seconds to cache the results of the processShortcode() method
41
+	 * 0 means the processShortcode() results will NOT be cached at all
42
+	 *
43
+	 * @return int
44
+	 */
45
+	public function cacheExpiration()
46
+	{
47
+		return 0;
48
+	}
49
+
50
+
51
+	/**
52
+	 * a place for adding any initialization code that needs to run prior to wp_header().
53
+	 * this may be required for shortcodes that utilize a corresponding module,
54
+	 * and need to enqueue assets for that module
55
+	 *
56
+	 * @return void
57
+	 */
58
+	public function initializeShortcode()
59
+	{
60
+		$this->shortcodeHasBeenInitialized();
61
+	}
62
+
63
+
64
+	/**
65
+	 * callback that runs when the shortcode is encountered in post content.
66
+	 * IMPORTANT !!!
67
+	 * remember that shortcode content should be RETURNED and NOT echoed out
68
+	 *
69
+	 * @param array $attributes
70
+	 * @return string
71
+	 * @throws \EE_Error
72
+	 */
73
+	public function processShortcode($attributes = array())
74
+	{
75
+		$transaction = EE_Registry::instance()->SSN->get_session_data('transaction');
76
+		if ($transaction instanceof EE_Transaction) {
77
+			do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', $transaction);
78
+			$registrations = $transaction->registrations();
79
+			foreach ($registrations as $registration) {
80
+				if ($registration instanceof EE_Registration) {
81
+					do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__registration', $registration);
82
+				}
83
+			}
84
+		}
85
+		do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__clear_session');
86
+		// remove all unwanted records from the db
87
+		if (EE_Registry::instance()->CART instanceof EE_Cart) {
88
+			EE_Registry::instance()->CART->delete_cart();
89
+		}
90
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
91
+		return sprintf(
92
+			__(
93
+				'%sAll unsaved registration information entered during this session has been deleted.%s',
94
+				'event_espresso'
95
+			),
96
+			'<p class="ee-registrations-cancelled-pg ee-attention">',
97
+			'</p>'
98
+		);
99
+	}
100 100
 
101 101
 }
102 102
 // End of file EspressoCancelled.php
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoEventAttendees.php 1 patch
Indentation   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -28,245 +28,245 @@
 block discarded – undo
28 28
 class EspressoEventAttendees extends EspressoShortcode
29 29
 {
30 30
 
31
-    private $query_params = array(
32
-        0 => array()
33
-    );
34
-
35
-    private $template_args = array(
36
-        'contacts'      => array(),
37
-        'event'         => null,
38
-        'datetime'      => null,
39
-        'ticket'        => null,
40
-    );
41
-
42
-    /**
43
-     * the actual shortcode tag that gets registered with WordPress
44
-     *
45
-     * @return string
46
-     */
47
-    public function getTag()
48
-    {
49
-        return 'ESPRESSO_EVENT_ATTENDEES';
50
-    }
51
-
52
-
53
-
54
-    /**
55
-     * the time in seconds to cache the results of the processShortcode() method
56
-     * 0 means the processShortcode() results will NOT be cached at all
57
-     *
58
-     * @return int
59
-     */
60
-    public function cacheExpiration()
61
-    {
62
-        return HOUR_IN_SECONDS;
63
-    }
64
-
65
-
66
-
67
-    /**
68
-     * a place for adding any initialization code that needs to run prior to wp_header().
69
-     * this may be required for shortcodes that utilize a corresponding module,
70
-     * and need to enqueue assets for that module
71
-     *
72
-     * @return void
73
-     */
74
-    public function initializeShortcode()
75
-    {
76
-        $this->shortcodeHasBeenInitialized();
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event.
83
-     *  [ESPRESSO_EVENT_ATTENDEES] - defaults to attendees for earliest active event, or earliest upcoming event.
84
-     *  [ESPRESSO_EVENT_ATTENDEES event_id=123] - attendees for specific event.
85
-     *  [ESPRESSO_EVENT_ATTENDEES datetime_id=245] - attendees for a specific datetime.
86
-     *  [ESPRESSO_EVENT_ATTENDEES ticket_id=123] - attendees for a specific ticket.
87
-     *  [ESPRESSO_EVENT_ATTENDEES status=all] - specific registration status (use status id) or all for all attendees
88
-     *                                          regardless of status.  Note default is to only return approved attendees
89
-     *  [ESPRESSO_EVENT_ATTENDEES show_gravatar=true] - default is to not return gravatar.  Otherwise if this is set
90
-     *                                                  then return gravatar for email address given.
91
-     *  Note: because of the relationship between event_id, ticket_id, and datetime_id.
92
-     * If more than one of those params is included then preference is given to the following:
93
-     *  - event_id is used whenever its present and any others are ignored.
94
-     *  - if no event_id then datetime is used whenever its present and any others are ignored.
95
-     *  - otherwise ticket_id is used if present.
96
-     *
97
-     * @param array $attributes
98
-     * @return string
99
-     * @throws \EE_Error
100
-     */
101
-    public function processShortcode($attributes = array())
102
-    {
103
-        // grab attributes and merge with defaults
104
-        $attributes = $this->getAttributes((array)$attributes);
105
-        // add attributes to template args
106
-        $this->template_args['show_gravatar'] = $attributes['show_gravatar'];
107
-        // add required objects: event, datetime, and ticket
108
-        $this->template_args['event'] = $this->getEventAndQueryParams($attributes);
109
-        $this->template_args['datetime'] = $this->getDatetimeAndQueryParams($attributes);
110
-        $this->template_args['ticket'] = $this->getTicketAndQueryParams($attributes);
111
-
112
-        // if any of the above objects is invalid or missing,
113
-        // then there was an invalid parameter or the shortcode was used incorrectly
114
-        // so when WP_DEBUG is set and true, we'll show a message,
115
-        // otherwise we'll just return an empty string.
116
-         if (
117
-            ! $this->template_args['event'] instanceof EE_Event
118
-            || empty($this->query_params[0])
119
-            || ($attributes['datetime_id'] && ! $this->template_args['datetime'] instanceof EE_Datetime)
120
-            || ($attributes['ticket_id'] && ! $this->template_args['ticket'] instanceof EE_Ticket)
121
-        ) {
122
-            if (WP_DEBUG) {
123
-                return '<div class="important-notice ee-attention">'
124
-                       . esc_html__('The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly.  Please double check the arguments you used for any typos.  In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.',
125
-                        'event_espresso')
126
-                       . '</div>';
127
-            } else {
128
-                return '';
129
-            }
130
-        }
131
-        $this->setAdditionalQueryParams($attributes);
132
-        //get contacts!
133
-        $this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params);
134
-        //all set let's load up the template and return.
135
-        return EEH_Template::locate_template('loop-espresso_event_attendees.php', $this->template_args, true, true);
136
-    }
137
-
138
-
139
-
140
-    /**
141
-     * merge incoming attributes with filtered defaults
142
-     *
143
-     * @param array $attributes
144
-     * @return array
145
-     */
146
-    private function getAttributes(array $attributes)
147
-    {
148
-        return array_merge(
149
-            (array) apply_filters(
150
-                'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts',
151
-                array(
152
-                    'event_id'      => null,
153
-                    'datetime_id'   => null,
154
-                    'ticket_id'     => null,
155
-                    'status'        => EEM_Registration::status_id_approved,
156
-                    'show_gravatar' => false
157
-                )
158
-            ),
159
-            $attributes
160
-        );
161
-    }
162
-
163
-
164
-
165
-    /**
166
-     * @param array $attributes
167
-     * @return EE_Event|null
168
-     * @throws \EE_Error
169
-     */
170
-    private function getEventAndQueryParams(array $attributes){
171
-        if ( ! empty($attributes['event_id'])) {
172
-            $event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']);
173
-            if ($event instanceof EE_Event) {
174
-                $this->query_params[0]['Registration.EVT_ID'] = $attributes['event_id'];
175
-                return $event;
176
-            }
177
-        }
178
-        //seems like is_espresso_event_single() isn't working as expected. So using alternate method.
179
-        if (is_single() && is_espresso_event()) {
180
-            $event = EEH_Event_View::get_event();
181
-            if ($event instanceof EE_Event) {
182
-                $this->query_params[0]['Registration.EVT_ID'] = $event->ID();
183
-                return $event;
184
-            }
185
-        }
186
-        // one last shot...
187
-        // try getting the earliest active event
188
-        $events = EEM_Event::instance()->get_active_events(array(
189
-            'limit'    => 1,
190
-            'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')
191
-        ));
192
-        //  if none then get the next upcoming
193
-        $events = empty($events)
194
-            ? EEM_Event::instance()->get_upcoming_events(array(
195
-                'limit'    => 1,
196
-                'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')
197
-            ))
198
-            : $events;
199
-        $event = reset($events);
200
-        if ($event instanceof EE_Event) {
201
-            $this->query_params[0]['Registration.EVT_ID'] = $event->ID();
202
-            return $event;
203
-        }
204
-        return null;
205
-    }
206
-
207
-
208
-
209
-    /**
210
-     * @param array $attributes
211
-     * @return EE_Datetime|null
212
-     */
213
-    private function getDatetimeAndQueryParams(array $attributes)
214
-    {
215
-        if ( ! empty($attributes['datetime_id'])) {
216
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']);
217
-            if ($datetime instanceof EE_Datetime) {
218
-                $this->query_params[0]['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetime_id'];
219
-                $this->query_params['default_where_conditions'] = 'this_model_only';
220
-                if ( ! $this->template_args['event'] instanceof EE_Event) {
221
-                    $this->template_args['event'] = $datetime->event();
222
-                }
223
-                return $datetime;
224
-            }
225
-        }
226
-        return null;
227
-    }
228
-
229
-
230
-
231
-    /**
232
-     * @param array $attributes
233
-     * @return \EE_Base_Class|null
234
-     * @throws \EE_Error
235
-     */
236
-    private function getTicketAndQueryParams(array $attributes)
237
-    {
238
-        if ( ! empty($attributes['ticket_id']) && empty($attributes['event_id']) && empty($attributes['datetime_id'])) {
239
-            $ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']);
240
-            if ($ticket instanceof EE_Ticket) {
241
-                $this->query_params[0]['Registration.TKT_ID'] = $attributes['ticket_id'];
242
-                if ( ! $this->template_args['event'] instanceof EE_Event) {
243
-                    $this->template_args['event'] = $ticket->first_datetime() instanceof EE_Datetime
244
-                        ? $ticket->first_datetime()->event()
245
-                        : null;
246
-                }
247
-                return $ticket;
248
-            }
249
-        }
250
-        return null;
251
-    }
252
-
253
-
254
-
255
-    /**
256
-     * @param array $attributes
257
-     */
258
-    private function setAdditionalQueryParams(array $attributes)
259
-    {
260
-        $reg_status_array = EEM_Registration::reg_status_array();
261
-        if ($attributes['status'] !== 'all' && isset($reg_status_array[$attributes['status']])) {
262
-            $this->query_params[0]['Registration.STS_ID'] = $attributes['status'];
263
-        }
264
-        $this->query_params['group_by'] = array('ATT_ID');
265
-        $this->query_params['order_by'] = (array) apply_filters(
266
-            'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by',
267
-            array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC')
268
-        );
269
-    }
31
+	private $query_params = array(
32
+		0 => array()
33
+	);
34
+
35
+	private $template_args = array(
36
+		'contacts'      => array(),
37
+		'event'         => null,
38
+		'datetime'      => null,
39
+		'ticket'        => null,
40
+	);
41
+
42
+	/**
43
+	 * the actual shortcode tag that gets registered with WordPress
44
+	 *
45
+	 * @return string
46
+	 */
47
+	public function getTag()
48
+	{
49
+		return 'ESPRESSO_EVENT_ATTENDEES';
50
+	}
51
+
52
+
53
+
54
+	/**
55
+	 * the time in seconds to cache the results of the processShortcode() method
56
+	 * 0 means the processShortcode() results will NOT be cached at all
57
+	 *
58
+	 * @return int
59
+	 */
60
+	public function cacheExpiration()
61
+	{
62
+		return HOUR_IN_SECONDS;
63
+	}
64
+
65
+
66
+
67
+	/**
68
+	 * a place for adding any initialization code that needs to run prior to wp_header().
69
+	 * this may be required for shortcodes that utilize a corresponding module,
70
+	 * and need to enqueue assets for that module
71
+	 *
72
+	 * @return void
73
+	 */
74
+	public function initializeShortcode()
75
+	{
76
+		$this->shortcodeHasBeenInitialized();
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event.
83
+	 *  [ESPRESSO_EVENT_ATTENDEES] - defaults to attendees for earliest active event, or earliest upcoming event.
84
+	 *  [ESPRESSO_EVENT_ATTENDEES event_id=123] - attendees for specific event.
85
+	 *  [ESPRESSO_EVENT_ATTENDEES datetime_id=245] - attendees for a specific datetime.
86
+	 *  [ESPRESSO_EVENT_ATTENDEES ticket_id=123] - attendees for a specific ticket.
87
+	 *  [ESPRESSO_EVENT_ATTENDEES status=all] - specific registration status (use status id) or all for all attendees
88
+	 *                                          regardless of status.  Note default is to only return approved attendees
89
+	 *  [ESPRESSO_EVENT_ATTENDEES show_gravatar=true] - default is to not return gravatar.  Otherwise if this is set
90
+	 *                                                  then return gravatar for email address given.
91
+	 *  Note: because of the relationship between event_id, ticket_id, and datetime_id.
92
+	 * If more than one of those params is included then preference is given to the following:
93
+	 *  - event_id is used whenever its present and any others are ignored.
94
+	 *  - if no event_id then datetime is used whenever its present and any others are ignored.
95
+	 *  - otherwise ticket_id is used if present.
96
+	 *
97
+	 * @param array $attributes
98
+	 * @return string
99
+	 * @throws \EE_Error
100
+	 */
101
+	public function processShortcode($attributes = array())
102
+	{
103
+		// grab attributes and merge with defaults
104
+		$attributes = $this->getAttributes((array)$attributes);
105
+		// add attributes to template args
106
+		$this->template_args['show_gravatar'] = $attributes['show_gravatar'];
107
+		// add required objects: event, datetime, and ticket
108
+		$this->template_args['event'] = $this->getEventAndQueryParams($attributes);
109
+		$this->template_args['datetime'] = $this->getDatetimeAndQueryParams($attributes);
110
+		$this->template_args['ticket'] = $this->getTicketAndQueryParams($attributes);
111
+
112
+		// if any of the above objects is invalid or missing,
113
+		// then there was an invalid parameter or the shortcode was used incorrectly
114
+		// so when WP_DEBUG is set and true, we'll show a message,
115
+		// otherwise we'll just return an empty string.
116
+		 if (
117
+			! $this->template_args['event'] instanceof EE_Event
118
+			|| empty($this->query_params[0])
119
+			|| ($attributes['datetime_id'] && ! $this->template_args['datetime'] instanceof EE_Datetime)
120
+			|| ($attributes['ticket_id'] && ! $this->template_args['ticket'] instanceof EE_Ticket)
121
+		) {
122
+			if (WP_DEBUG) {
123
+				return '<div class="important-notice ee-attention">'
124
+					   . esc_html__('The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly.  Please double check the arguments you used for any typos.  In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.',
125
+						'event_espresso')
126
+					   . '</div>';
127
+			} else {
128
+				return '';
129
+			}
130
+		}
131
+		$this->setAdditionalQueryParams($attributes);
132
+		//get contacts!
133
+		$this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params);
134
+		//all set let's load up the template and return.
135
+		return EEH_Template::locate_template('loop-espresso_event_attendees.php', $this->template_args, true, true);
136
+	}
137
+
138
+
139
+
140
+	/**
141
+	 * merge incoming attributes with filtered defaults
142
+	 *
143
+	 * @param array $attributes
144
+	 * @return array
145
+	 */
146
+	private function getAttributes(array $attributes)
147
+	{
148
+		return array_merge(
149
+			(array) apply_filters(
150
+				'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts',
151
+				array(
152
+					'event_id'      => null,
153
+					'datetime_id'   => null,
154
+					'ticket_id'     => null,
155
+					'status'        => EEM_Registration::status_id_approved,
156
+					'show_gravatar' => false
157
+				)
158
+			),
159
+			$attributes
160
+		);
161
+	}
162
+
163
+
164
+
165
+	/**
166
+	 * @param array $attributes
167
+	 * @return EE_Event|null
168
+	 * @throws \EE_Error
169
+	 */
170
+	private function getEventAndQueryParams(array $attributes){
171
+		if ( ! empty($attributes['event_id'])) {
172
+			$event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']);
173
+			if ($event instanceof EE_Event) {
174
+				$this->query_params[0]['Registration.EVT_ID'] = $attributes['event_id'];
175
+				return $event;
176
+			}
177
+		}
178
+		//seems like is_espresso_event_single() isn't working as expected. So using alternate method.
179
+		if (is_single() && is_espresso_event()) {
180
+			$event = EEH_Event_View::get_event();
181
+			if ($event instanceof EE_Event) {
182
+				$this->query_params[0]['Registration.EVT_ID'] = $event->ID();
183
+				return $event;
184
+			}
185
+		}
186
+		// one last shot...
187
+		// try getting the earliest active event
188
+		$events = EEM_Event::instance()->get_active_events(array(
189
+			'limit'    => 1,
190
+			'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')
191
+		));
192
+		//  if none then get the next upcoming
193
+		$events = empty($events)
194
+			? EEM_Event::instance()->get_upcoming_events(array(
195
+				'limit'    => 1,
196
+				'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')
197
+			))
198
+			: $events;
199
+		$event = reset($events);
200
+		if ($event instanceof EE_Event) {
201
+			$this->query_params[0]['Registration.EVT_ID'] = $event->ID();
202
+			return $event;
203
+		}
204
+		return null;
205
+	}
206
+
207
+
208
+
209
+	/**
210
+	 * @param array $attributes
211
+	 * @return EE_Datetime|null
212
+	 */
213
+	private function getDatetimeAndQueryParams(array $attributes)
214
+	{
215
+		if ( ! empty($attributes['datetime_id'])) {
216
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']);
217
+			if ($datetime instanceof EE_Datetime) {
218
+				$this->query_params[0]['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetime_id'];
219
+				$this->query_params['default_where_conditions'] = 'this_model_only';
220
+				if ( ! $this->template_args['event'] instanceof EE_Event) {
221
+					$this->template_args['event'] = $datetime->event();
222
+				}
223
+				return $datetime;
224
+			}
225
+		}
226
+		return null;
227
+	}
228
+
229
+
230
+
231
+	/**
232
+	 * @param array $attributes
233
+	 * @return \EE_Base_Class|null
234
+	 * @throws \EE_Error
235
+	 */
236
+	private function getTicketAndQueryParams(array $attributes)
237
+	{
238
+		if ( ! empty($attributes['ticket_id']) && empty($attributes['event_id']) && empty($attributes['datetime_id'])) {
239
+			$ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']);
240
+			if ($ticket instanceof EE_Ticket) {
241
+				$this->query_params[0]['Registration.TKT_ID'] = $attributes['ticket_id'];
242
+				if ( ! $this->template_args['event'] instanceof EE_Event) {
243
+					$this->template_args['event'] = $ticket->first_datetime() instanceof EE_Datetime
244
+						? $ticket->first_datetime()->event()
245
+						: null;
246
+				}
247
+				return $ticket;
248
+			}
249
+		}
250
+		return null;
251
+	}
252
+
253
+
254
+
255
+	/**
256
+	 * @param array $attributes
257
+	 */
258
+	private function setAdditionalQueryParams(array $attributes)
259
+	{
260
+		$reg_status_array = EEM_Registration::reg_status_array();
261
+		if ($attributes['status'] !== 'all' && isset($reg_status_array[$attributes['status']])) {
262
+			$this->query_params[0]['Registration.STS_ID'] = $attributes['status'];
263
+		}
264
+		$this->query_params['group_by'] = array('ATT_ID');
265
+		$this->query_params['order_by'] = (array) apply_filters(
266
+			'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by',
267
+			array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC')
268
+		);
269
+	}
270 270
 
271 271
 
272 272
 
Please login to merge, or discard this patch.
core/services/shortcodes/ShortcodeInterface.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -8,44 +8,44 @@
 block discarded – undo
8 8
 interface ShortcodeInterface
9 9
 {
10 10
 
11
-    /**
12
-     * the actual shortcode tag that gets registered with WordPress
13
-     *
14
-     * @return string
15
-     */
16
-    public function getTag();
17
-
18
-    /**
19
-     * the length of time in seconds to cache the results of the processShortcode() method
20
-     * 0 means the processShortcode() results will NOT be cached at all
21
-     *
22
-     * @return int
23
-     */
24
-    public function cacheExpiration();
25
-
26
-    /**
27
-     * a place for adding any initialization code that needs to run prior to wp_header().
28
-     * this may be required for shortcodes that utilize a corresponding module,
29
-     * and need to enqueue assets for that module
30
-     *
31
-     * !!! IMPORTANT !!!
32
-     * After performing any logic within this method required for initialization
33
-     *         $this->shortcodeHasBeenInitialized();
34
-     * should be called to ensure that the shortcode is setup correctly.
35
-     *
36
-     * @return void
37
-     */
38
-    public function initializeShortcode();
39
-
40
-    /**
41
-     * callback that runs when the shortcode is encountered in post content.
42
-     * IMPORTANT !!!
43
-     * remember that shortcode content should be RETURNED and NOT echoed out
44
-     *
45
-     * @param array $attributes
46
-     * @return string
47
-     */
48
-    public function processShortcode($attributes = array());
11
+	/**
12
+	 * the actual shortcode tag that gets registered with WordPress
13
+	 *
14
+	 * @return string
15
+	 */
16
+	public function getTag();
17
+
18
+	/**
19
+	 * the length of time in seconds to cache the results of the processShortcode() method
20
+	 * 0 means the processShortcode() results will NOT be cached at all
21
+	 *
22
+	 * @return int
23
+	 */
24
+	public function cacheExpiration();
25
+
26
+	/**
27
+	 * a place for adding any initialization code that needs to run prior to wp_header().
28
+	 * this may be required for shortcodes that utilize a corresponding module,
29
+	 * and need to enqueue assets for that module
30
+	 *
31
+	 * !!! IMPORTANT !!!
32
+	 * After performing any logic within this method required for initialization
33
+	 *         $this->shortcodeHasBeenInitialized();
34
+	 * should be called to ensure that the shortcode is setup correctly.
35
+	 *
36
+	 * @return void
37
+	 */
38
+	public function initializeShortcode();
39
+
40
+	/**
41
+	 * callback that runs when the shortcode is encountered in post content.
42
+	 * IMPORTANT !!!
43
+	 * remember that shortcode content should be RETURNED and NOT echoed out
44
+	 *
45
+	 * @param array $attributes
46
+	 * @return string
47
+	 */
48
+	public function processShortcode($attributes = array());
49 49
 
50 50
 }
51 51
 // End of file ShortcodeInterface.php
Please login to merge, or discard this patch.
core/services/shortcodes/EspressoShortcode.php 2 patches
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -20,219 +20,219 @@
 block discarded – undo
20 20
 abstract class EspressoShortcode implements ShortcodeInterface
21 21
 {
22 22
 
23
-    /**
24
-     * transient prefix
25
-     *
26
-     * @type string
27
-     */
28
-    const CACHE_TRANSIENT_PREFIX = 'ee_sc_';
29
-
30
-    /**
31
-     * @var PostRelatedCacheManager $cache_manager
32
-     */
33
-    private $cache_manager;
34
-
35
-    /**
36
-     * true if ShortcodeInterface::initializeShortcode() has been called
37
-     * if false, then that will get called before processing
38
-     *
39
-     * @var boolean $initialized
40
-     */
41
-    private $initialized = false;
42
-
43
-
44
-
45
-    /**
46
-     * EspressoShortcode constructor
47
-     *
48
-     * @param PostRelatedCacheManager $cache_manager
49
-     */
50
-    public function __construct(PostRelatedCacheManager $cache_manager)
51
-    {
52
-        $this->cache_manager = $cache_manager;
53
-    }
54
-
55
-
56
-
57
-    /**
58
-     * @return void
59
-     */
60
-    public function shortcodeHasBeenInitialized()
61
-    {
62
-        $this->initialized = true;
63
-    }
64
-
65
-
66
-
67
-    /**
68
-     * enqueues scripts then processes the shortcode
69
-     *
70
-     * @param array $attributes
71
-     * @return string
72
-     * @throws \EE_Error
73
-     */
74
-    final public function processShortcodeCallback($attributes = array())
75
-    {
76
-        if ($this instanceof EnqueueAssetsInterface) {
77
-            if (is_admin()) {
78
-                $this->enqueueAdminScripts();
79
-            } else {
80
-                $this->enqueueScripts();
81
-            }
82
-        }
83
-        return $this->shortcodeContent(
84
-            $this->sanitizeAttributes((array)$attributes)
85
-        );
86
-    }
87
-
88
-
89
-
90
-    /**
91
-     * If shortcode caching is enabled for the shortcode,
92
-     * and cached results exist, then that will be returned
93
-     * else new content will be generated.
94
-     * If caching is enabled, then the new content will be cached for later.
95
-     *
96
-     * @param array $attributes
97
-     * @return mixed|string
98
-     * @throws \EE_Error
99
-     */
100
-    private function shortcodeContent(array $attributes)
101
-    {
102
-        $shortcode = $this;
103
-        $post_ID = $this->currentPostID();
104
-        // something like "SC_EVENTS-123"
105
-        $cache_ID = $this->shortcodeCacheID($post_ID);
106
-        $this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID);
107
-        return $this->cache_manager->get(
108
-            $cache_ID,
109
-            // serialized attributes
110
-            wp_json_encode($attributes),
111
-            // Closure for generating content if cache is expired
112
-            function () use ($shortcode, $attributes) {
113
-                if($shortcode->initialized === false){
114
-                    $shortcode->initializeShortcode();
115
-                }
116
-                return $shortcode->processShortcode($attributes);
117
-            },
118
-            // filterable cache expiration set by each shortcode
119
-            apply_filters(
120
-                'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration',
121
-                $this->cacheExpiration(),
122
-                $this->getTag(),
123
-                $this
124
-            )
125
-        );
126
-    }
127
-
128
-
129
-
130
-    /**
131
-     * @return int
132
-     * @throws \EE_Error
133
-     */
134
-    private function currentPostID()
135
-    {
136
-        // try to get EE_Event any way we can
137
-        $event = EEH_Event_View::get_event();
138
-        // then get some kind of ID
139
-        if ($event instanceof \EE_Event) {
140
-            $post_ID = $event->ID();
141
-        } else {
142
-            global $post;
143
-            $post_ID = $post->ID;
144
-        }
145
-        return $post_ID;
146
-    }
147
-
148
-
149
-
150
-    /**
151
-     * @param int $post_ID
152
-     * @return string
153
-     * @throws \EE_Error
154
-     */
155
-    private function shortcodeCacheID($post_ID)
156
-    {
157
-        $tag = str_replace('ESPRESSO_', '', $this->getTag());
158
-        return "SC_{$tag}-{$post_ID}";
159
-    }
160
-
161
-
162
-
163
-    /**
164
-     * array for defining custom attribute sanitization callbacks,
165
-     * where keys match keys in your attributes array,
166
-     * and values represent the sanitization function you wish to be applied to that attribute.
167
-     * So for example, if you had an integer attribute named "event_id"
168
-     * that you wanted to be sanitized using absint(),
169
-     * then you would return the following:
170
-     *      array('event_id' => 'absint')
171
-     * Entering 'skip_sanitization' for the callback value
172
-     * means that no sanitization will be applied
173
-     * on the assumption that the attribute
174
-     * will be sanitized at some point... right?
175
-     * You wouldn't pass around unsanitized attributes would you?
176
-     * That would be very Tom Foolery of you!!!
177
-     *
178
-     * @return array
179
-     */
180
-    protected function customAttributeSanitizationMap()
181
-    {
182
-        return array();
183
-    }
184
-
185
-
186
-
187
-    /**
188
-     * Performs basic sanitization on shortcode attributes
189
-     * Since incoming attributes from the shortcode usage in the WP editor will all be strings,
190
-     * most attributes will by default be sanitized using the sanitize_text_field() function.
191
-     * This can be overridden using the customAttributeSanitizationMap() method (see above),
192
-     * all other attributes would be sanitized using the defaults in the switch statement below
193
-     *
194
-     * @param array $attributes
195
-     * @return array
196
-     */
197
-    private function sanitizeAttributes(array $attributes)
198
-    {
199
-        $custom_sanitization = $this->customAttributeSanitizationMap();
200
-        foreach ($attributes as $key => $value) {
201
-            // is a custom sanitization callback specified ?
202
-            if (isset($custom_sanitization[$key])) {
203
-                $callback = $custom_sanitization[$key];
204
-                if ($callback === 'skip_sanitization') {
205
-                    $attributes[$key] = $value;
206
-                    continue;
207
-                }
208
-                if (function_exists($callback)) {
209
-                    $attributes[$key] = $callback($value);
210
-                    continue;
211
-                }
212
-            }
213
-            switch (true) {
214
-                case $value === null :
215
-                case is_int($value) :
216
-                case is_float($value) :
217
-                    // typical booleans
218
-                case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) :
219
-                    $attributes[$key] = $value;
220
-                    break;
221
-                case is_string($value) :
222
-                    $attributes[$key] = sanitize_text_field($value);
223
-                    break;
224
-                case is_array($value) :
225
-                    $attributes[$key] = $this->sanitizeAttributes($value);
226
-                    break;
227
-                default :
228
-                    // only remaining data types are Object and Resource
229
-                    // which are not allowed as shortcode attributes
230
-                    $attributes[$key] = null;
231
-                    break;
232
-            }
233
-        }
234
-        return $attributes;
235
-    }
23
+	/**
24
+	 * transient prefix
25
+	 *
26
+	 * @type string
27
+	 */
28
+	const CACHE_TRANSIENT_PREFIX = 'ee_sc_';
29
+
30
+	/**
31
+	 * @var PostRelatedCacheManager $cache_manager
32
+	 */
33
+	private $cache_manager;
34
+
35
+	/**
36
+	 * true if ShortcodeInterface::initializeShortcode() has been called
37
+	 * if false, then that will get called before processing
38
+	 *
39
+	 * @var boolean $initialized
40
+	 */
41
+	private $initialized = false;
42
+
43
+
44
+
45
+	/**
46
+	 * EspressoShortcode constructor
47
+	 *
48
+	 * @param PostRelatedCacheManager $cache_manager
49
+	 */
50
+	public function __construct(PostRelatedCacheManager $cache_manager)
51
+	{
52
+		$this->cache_manager = $cache_manager;
53
+	}
54
+
55
+
56
+
57
+	/**
58
+	 * @return void
59
+	 */
60
+	public function shortcodeHasBeenInitialized()
61
+	{
62
+		$this->initialized = true;
63
+	}
64
+
65
+
66
+
67
+	/**
68
+	 * enqueues scripts then processes the shortcode
69
+	 *
70
+	 * @param array $attributes
71
+	 * @return string
72
+	 * @throws \EE_Error
73
+	 */
74
+	final public function processShortcodeCallback($attributes = array())
75
+	{
76
+		if ($this instanceof EnqueueAssetsInterface) {
77
+			if (is_admin()) {
78
+				$this->enqueueAdminScripts();
79
+			} else {
80
+				$this->enqueueScripts();
81
+			}
82
+		}
83
+		return $this->shortcodeContent(
84
+			$this->sanitizeAttributes((array)$attributes)
85
+		);
86
+	}
87
+
88
+
89
+
90
+	/**
91
+	 * If shortcode caching is enabled for the shortcode,
92
+	 * and cached results exist, then that will be returned
93
+	 * else new content will be generated.
94
+	 * If caching is enabled, then the new content will be cached for later.
95
+	 *
96
+	 * @param array $attributes
97
+	 * @return mixed|string
98
+	 * @throws \EE_Error
99
+	 */
100
+	private function shortcodeContent(array $attributes)
101
+	{
102
+		$shortcode = $this;
103
+		$post_ID = $this->currentPostID();
104
+		// something like "SC_EVENTS-123"
105
+		$cache_ID = $this->shortcodeCacheID($post_ID);
106
+		$this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID);
107
+		return $this->cache_manager->get(
108
+			$cache_ID,
109
+			// serialized attributes
110
+			wp_json_encode($attributes),
111
+			// Closure for generating content if cache is expired
112
+			function () use ($shortcode, $attributes) {
113
+				if($shortcode->initialized === false){
114
+					$shortcode->initializeShortcode();
115
+				}
116
+				return $shortcode->processShortcode($attributes);
117
+			},
118
+			// filterable cache expiration set by each shortcode
119
+			apply_filters(
120
+				'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration',
121
+				$this->cacheExpiration(),
122
+				$this->getTag(),
123
+				$this
124
+			)
125
+		);
126
+	}
127
+
128
+
129
+
130
+	/**
131
+	 * @return int
132
+	 * @throws \EE_Error
133
+	 */
134
+	private function currentPostID()
135
+	{
136
+		// try to get EE_Event any way we can
137
+		$event = EEH_Event_View::get_event();
138
+		// then get some kind of ID
139
+		if ($event instanceof \EE_Event) {
140
+			$post_ID = $event->ID();
141
+		} else {
142
+			global $post;
143
+			$post_ID = $post->ID;
144
+		}
145
+		return $post_ID;
146
+	}
147
+
148
+
149
+
150
+	/**
151
+	 * @param int $post_ID
152
+	 * @return string
153
+	 * @throws \EE_Error
154
+	 */
155
+	private function shortcodeCacheID($post_ID)
156
+	{
157
+		$tag = str_replace('ESPRESSO_', '', $this->getTag());
158
+		return "SC_{$tag}-{$post_ID}";
159
+	}
160
+
161
+
162
+
163
+	/**
164
+	 * array for defining custom attribute sanitization callbacks,
165
+	 * where keys match keys in your attributes array,
166
+	 * and values represent the sanitization function you wish to be applied to that attribute.
167
+	 * So for example, if you had an integer attribute named "event_id"
168
+	 * that you wanted to be sanitized using absint(),
169
+	 * then you would return the following:
170
+	 *      array('event_id' => 'absint')
171
+	 * Entering 'skip_sanitization' for the callback value
172
+	 * means that no sanitization will be applied
173
+	 * on the assumption that the attribute
174
+	 * will be sanitized at some point... right?
175
+	 * You wouldn't pass around unsanitized attributes would you?
176
+	 * That would be very Tom Foolery of you!!!
177
+	 *
178
+	 * @return array
179
+	 */
180
+	protected function customAttributeSanitizationMap()
181
+	{
182
+		return array();
183
+	}
184
+
185
+
186
+
187
+	/**
188
+	 * Performs basic sanitization on shortcode attributes
189
+	 * Since incoming attributes from the shortcode usage in the WP editor will all be strings,
190
+	 * most attributes will by default be sanitized using the sanitize_text_field() function.
191
+	 * This can be overridden using the customAttributeSanitizationMap() method (see above),
192
+	 * all other attributes would be sanitized using the defaults in the switch statement below
193
+	 *
194
+	 * @param array $attributes
195
+	 * @return array
196
+	 */
197
+	private function sanitizeAttributes(array $attributes)
198
+	{
199
+		$custom_sanitization = $this->customAttributeSanitizationMap();
200
+		foreach ($attributes as $key => $value) {
201
+			// is a custom sanitization callback specified ?
202
+			if (isset($custom_sanitization[$key])) {
203
+				$callback = $custom_sanitization[$key];
204
+				if ($callback === 'skip_sanitization') {
205
+					$attributes[$key] = $value;
206
+					continue;
207
+				}
208
+				if (function_exists($callback)) {
209
+					$attributes[$key] = $callback($value);
210
+					continue;
211
+				}
212
+			}
213
+			switch (true) {
214
+				case $value === null :
215
+				case is_int($value) :
216
+				case is_float($value) :
217
+					// typical booleans
218
+				case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) :
219
+					$attributes[$key] = $value;
220
+					break;
221
+				case is_string($value) :
222
+					$attributes[$key] = sanitize_text_field($value);
223
+					break;
224
+				case is_array($value) :
225
+					$attributes[$key] = $this->sanitizeAttributes($value);
226
+					break;
227
+				default :
228
+					// only remaining data types are Object and Resource
229
+					// which are not allowed as shortcode attributes
230
+					$attributes[$key] = null;
231
+					break;
232
+			}
233
+		}
234
+		return $attributes;
235
+	}
236 236
 
237 237
 
238 238
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             }
82 82
         }
83 83
         return $this->shortcodeContent(
84
-            $this->sanitizeAttributes((array)$attributes)
84
+            $this->sanitizeAttributes((array) $attributes)
85 85
         );
86 86
     }
87 87
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
             // serialized attributes
110 110
             wp_json_encode($attributes),
111 111
             // Closure for generating content if cache is expired
112
-            function () use ($shortcode, $attributes) {
113
-                if($shortcode->initialized === false){
112
+            function() use ($shortcode, $attributes) {
113
+                if ($shortcode->initialized === false) {
114 114
                     $shortcode->initializeShortcode();
115 115
                 }
116 116
                 return $shortcode->processShortcode($attributes);
Please login to merge, or discard this patch.