Completed
Branch master (7421d0)
by
unknown
11:25 queued 06:55
created
core/domain/services/licensing/ActivateLicenseButton.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -7,33 +7,33 @@  discard block
 block discarded – undo
7 7
 
8 8
 class ActivateLicenseButton
9 9
 {
10
-    /**
11
-     * @param PluginLicense $plugin_license
12
-     * @param stdClass|null $license_data
13
-     * @return string
14
-     */
15
-    public static function html(PluginLicense $plugin_license, ?stdClass $license_data): string
16
-    {
17
-        $activate_btn_class   = '';
18
-        $deactivate_btn_class = '';
19
-        $license_status       = $license_data->license ?? '';
20
-        if ($license_status !== 'valid') {
21
-            $deactivate_btn_class = ' ee-license-action-btn--hidden';
22
-        } else {
23
-            $activate_btn_class = ' ee-license-action-btn--hidden';
24
-        }
10
+	/**
11
+	 * @param PluginLicense $plugin_license
12
+	 * @param stdClass|null $license_data
13
+	 * @return string
14
+	 */
15
+	public static function html(PluginLicense $plugin_license, ?stdClass $license_data): string
16
+	{
17
+		$activate_btn_class   = '';
18
+		$deactivate_btn_class = '';
19
+		$license_status       = $license_data->license ?? '';
20
+		if ($license_status !== 'valid') {
21
+			$deactivate_btn_class = ' ee-license-action-btn--hidden';
22
+		} else {
23
+			$activate_btn_class = ' ee-license-action-btn--hidden';
24
+		}
25 25
 
26
-        $activate_btn_label   = esc_html__('activate', 'event_espresso');
27
-        $deactivate_btn_label = esc_html__('deactivate', 'event_espresso');
28
-        $reset_btn_label      = esc_html__('reset/clear this license key', 'event_espresso');
26
+		$activate_btn_label   = esc_html__('activate', 'event_espresso');
27
+		$deactivate_btn_label = esc_html__('deactivate', 'event_espresso');
28
+		$reset_btn_label      = esc_html__('reset/clear this license key', 'event_espresso');
29 29
 
30
-        $item_id        = $plugin_license->itemID();
31
-        $item_name      = $plugin_license->itemName();
32
-        $plugin_slug    = $plugin_license->pluginSlug();
33
-        $min_core_ver   = $plugin_license->minCoreVersion();
34
-        $plugin_version = $plugin_license->version();
35
-        $disabled       = empty($license_data->license_key) ? 'disabled' : '';
36
-        return "
30
+		$item_id        = $plugin_license->itemID();
31
+		$item_name      = $plugin_license->itemName();
32
+		$plugin_slug    = $plugin_license->pluginSlug();
33
+		$min_core_ver   = $plugin_license->minCoreVersion();
34
+		$plugin_version = $plugin_license->version();
35
+		$disabled       = empty($license_data->license_key) ? 'disabled' : '';
36
+		return "
37 37
         <button id='activate-$plugin_slug'
38 38
                 class='ee-license-action-btn ee-license-action-btn__activate$activate_btn_class button button--primary'
39 39
                 data-action='activate_license'
@@ -73,5 +73,5 @@  discard block
 block discarded – undo
73 73
         >
74 74
             <span class='dashicons dashicons-trash'></span>
75 75
         </button>";
76
-    }
76
+	}
77 77
 }
Please login to merge, or discard this patch.
core/domain/services/licensing/LicenseKeysAdminForm.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -14,107 +14,107 @@
 block discarded – undo
14 14
 class LicenseKeysAdminForm extends FormHandler
15 15
 {
16 16
 
17
-    public function __construct(EE_Registry $registry)
18
-    {
19
-        parent::__construct(
20
-            LICENSE_KEYS_LABEL,
21
-            LICENSE_KEYS_LABEL,
22
-            LICENSE_KEYS_PG_SLUG,
23
-            '',
24
-            FormHandler::DO_NOT_SETUP_FORM,
25
-            $registry
26
-        );
27
-    }
17
+	public function __construct(EE_Registry $registry)
18
+	{
19
+		parent::__construct(
20
+			LICENSE_KEYS_LABEL,
21
+			LICENSE_KEYS_LABEL,
22
+			LICENSE_KEYS_PG_SLUG,
23
+			'',
24
+			FormHandler::DO_NOT_SETUP_FORM,
25
+			$registry
26
+		);
27
+	}
28 28
 
29 29
 
30
-    /**
31
-     * @throws EE_Error
32
-     */
33
-    public function generate(): EE_Form_Section_Proper
34
-    {
35
-        $subsections = (array) apply_filters('FHEE__LicenseKeysAdminForm__generate__form_subsections', []);
36
-        ksort($subsections);
37
-        return new EE_Form_Section_Proper(
38
-            [
39
-                'name'            => 'license_keys_admin_form',
40
-                'html_id'         => 'license_keys_admin_form',
41
-                'layout_strategy' => new EE_No_Layout(),
42
-                'subsections'     => $this->addCoreSupportLicenseKey($subsections),
43
-            ]
44
-        );
45
-    }
30
+	/**
31
+	 * @throws EE_Error
32
+	 */
33
+	public function generate(): EE_Form_Section_Proper
34
+	{
35
+		$subsections = (array) apply_filters('FHEE__LicenseKeysAdminForm__generate__form_subsections', []);
36
+		ksort($subsections);
37
+		return new EE_Form_Section_Proper(
38
+			[
39
+				'name'            => 'license_keys_admin_form',
40
+				'html_id'         => 'license_keys_admin_form',
41
+				'layout_strategy' => new EE_No_Layout(),
42
+				'subsections'     => $this->addCoreSupportLicenseKey($subsections),
43
+			]
44
+		);
45
+	}
46 46
 
47 47
 
48
-    private function addCoreSupportLicenseKey(array $subsections): array
49
-    {
50
-        // we want to move the license key input for core to a different location,
51
-        // so to do that we need to copy it, delete the old location, then add re-add to the form
52
-        $core_license_key = $subsections['event_espresso_core'] ?? null;
53
-        unset($subsections['event_espresso_core']);
54
-        $new_subsections = [
55
-            'license_keys_hdr'           => new EE_Form_Section_HTML(
56
-                EEH_HTML::h1(
57
-                    esc_html__('Event Espresso Core License & Support Keys', 'event_espresso'),
58
-                    '',
59
-                    'ee-admin-settings-hdr'
60
-                )
61
-            ),
62
-            'event_espresso_core'        => $core_license_key,
63
-            'support_license_notice'     => new EE_Form_Section_HTML(
64
-                EEH_HTML::br()
65
-                . EEH_HTML::div(
66
-                    '<span class="dashicons dashicons-sos"></span>'
67
-                    . EEH_HTML::span(
68
-                        esc_html__(
69
-                            'Adding a valid Support License Key will enable automatic update notifications and backend updates.',
70
-                            'event_espresso'
71
-                        )
72
-                    ),
73
-                    'support-license-notice-dv',
74
-                    'ee-status-outline ee-status-outline--micro ee-status-outline--info ee-status-bg--info'
75
-                )
76
-                . EEH_HTML::br()
77
-                . EEH_HTML::div(
78
-                    EEH_HTML::span(
79
-                        sprintf(
80
-                            esc_html__(
81
-                                'If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
82
-                                'event_espresso'
83
-                            ),
84
-                            '<strong>',
85
-                            '</strong>'
86
-                        )
87
-                    ),
88
-                    '',
89
-                    'ee-status-outline ee-status-outline--attention'
90
-                )
91
-            ),
92
-            'add-on-license-keys-hdr'    => new EE_Form_Section_HTML(
93
-                EEH_HTML::h2(
94
-                    esc_html__('Add-on License Keys', 'event_espresso'),
95
-                    '',
96
-                    'ee-admin-settings-hdr'
97
-                )
98
-            ),
99
-            'add-on-license-keys-notice' => new EE_Form_Section_HTML(
100
-                EEH_HTML::div(
101
-                    EEH_HTML::span(
102
-                        esc_html__(
103
-                            'Please activate an Event Espresso Core support license key first in order to activate your add-on license keys',
104
-                            'event_espresso'
105
-                        )
106
-                    ),
107
-                    'add-on-license-keys-notice-dv',
108
-                    'ee-status-outline ee-status-outline--micro ee-status-bg--attention',
109
-                    'display: none;'
110
-                )
111
-            ),
112
-        ];
48
+	private function addCoreSupportLicenseKey(array $subsections): array
49
+	{
50
+		// we want to move the license key input for core to a different location,
51
+		// so to do that we need to copy it, delete the old location, then add re-add to the form
52
+		$core_license_key = $subsections['event_espresso_core'] ?? null;
53
+		unset($subsections['event_espresso_core']);
54
+		$new_subsections = [
55
+			'license_keys_hdr'           => new EE_Form_Section_HTML(
56
+				EEH_HTML::h1(
57
+					esc_html__('Event Espresso Core License & Support Keys', 'event_espresso'),
58
+					'',
59
+					'ee-admin-settings-hdr'
60
+				)
61
+			),
62
+			'event_espresso_core'        => $core_license_key,
63
+			'support_license_notice'     => new EE_Form_Section_HTML(
64
+				EEH_HTML::br()
65
+				. EEH_HTML::div(
66
+					'<span class="dashicons dashicons-sos"></span>'
67
+					. EEH_HTML::span(
68
+						esc_html__(
69
+							'Adding a valid Support License Key will enable automatic update notifications and backend updates.',
70
+							'event_espresso'
71
+						)
72
+					),
73
+					'support-license-notice-dv',
74
+					'ee-status-outline ee-status-outline--micro ee-status-outline--info ee-status-bg--info'
75
+				)
76
+				. EEH_HTML::br()
77
+				. EEH_HTML::div(
78
+					EEH_HTML::span(
79
+						sprintf(
80
+							esc_html__(
81
+								'If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
82
+								'event_espresso'
83
+							),
84
+							'<strong>',
85
+							'</strong>'
86
+						)
87
+					),
88
+					'',
89
+					'ee-status-outline ee-status-outline--attention'
90
+				)
91
+			),
92
+			'add-on-license-keys-hdr'    => new EE_Form_Section_HTML(
93
+				EEH_HTML::h2(
94
+					esc_html__('Add-on License Keys', 'event_espresso'),
95
+					'',
96
+					'ee-admin-settings-hdr'
97
+				)
98
+			),
99
+			'add-on-license-keys-notice' => new EE_Form_Section_HTML(
100
+				EEH_HTML::div(
101
+					EEH_HTML::span(
102
+						esc_html__(
103
+							'Please activate an Event Espresso Core support license key first in order to activate your add-on license keys',
104
+							'event_espresso'
105
+						)
106
+					),
107
+					'add-on-license-keys-notice-dv',
108
+					'ee-status-outline ee-status-outline--micro ee-status-bg--attention',
109
+					'display: none;'
110
+				)
111
+			),
112
+		];
113 113
 
114
-        if ($core_license_key instanceof LicenseKeyFormInput && $core_license_key->get_default()) {
115
-            unset ($new_subsections['support_license_notice']);
116
-            unset ($new_subsections['add-on-license-keys-notice']);
117
-        }
118
-        return EEH_Array::insert_into_array($subsections, $new_subsections);
119
-    }
114
+		if ($core_license_key instanceof LicenseKeyFormInput && $core_license_key->get_default()) {
115
+			unset ($new_subsections['support_license_notice']);
116
+			unset ($new_subsections['add-on-license-keys-notice']);
117
+		}
118
+		return EEH_Array::insert_into_array($subsections, $new_subsections);
119
+	}
120 120
 }
Please login to merge, or discard this patch.
core/domain/entities/editor/blocks/EventAttendees.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -20,175 +20,175 @@
 block discarded – undo
20 20
  */
21 21
 class EventAttendees extends Block
22 22
 {
23
-    const BLOCK_TYPE = 'event-attendees';
23
+	const BLOCK_TYPE = 'event-attendees';
24 24
 
25
-    /**
26
-     * @var EventAttendeesBlockRenderer $renderer
27
-     */
28
-    protected $renderer;
25
+	/**
26
+	 * @var EventAttendeesBlockRenderer $renderer
27
+	 */
28
+	protected $renderer;
29 29
 
30 30
 
31
-    /**
32
-     * EventAttendees constructor.
33
-     *
34
-     * @param CoreBlocksAssetManager      $block_asset_manager
35
-     * @param RequestInterface            $request
36
-     * @param EventAttendeesBlockRenderer $renderer
37
-     */
38
-    public function __construct(
39
-        CoreBlocksAssetManager $block_asset_manager,
40
-        RequestInterface $request,
41
-        EventAttendeesBlockRenderer $renderer
42
-    ) {
43
-        parent::__construct($block_asset_manager, $request);
44
-        $this->renderer = $renderer;
45
-    }
31
+	/**
32
+	 * EventAttendees constructor.
33
+	 *
34
+	 * @param CoreBlocksAssetManager      $block_asset_manager
35
+	 * @param RequestInterface            $request
36
+	 * @param EventAttendeesBlockRenderer $renderer
37
+	 */
38
+	public function __construct(
39
+		CoreBlocksAssetManager $block_asset_manager,
40
+		RequestInterface $request,
41
+		EventAttendeesBlockRenderer $renderer
42
+	) {
43
+		parent::__construct($block_asset_manager, $request);
44
+		$this->renderer = $renderer;
45
+	}
46 46
 
47 47
 
48
-    /**
49
-     * Perform any early setup required by the block
50
-     * including setting the block type and supported post types
51
-     *
52
-     * @return void
53
-     */
54
-    public function initialize()
55
-    {
56
-        $this->setBlockType(EventAttendees::BLOCK_TYPE);
57
-        $this->setSupportedRoutes(
58
-            array(
59
-                'EventEspresso\core\domain\entities\routing\specifications\admin\WordPressPostTypeEditor',
60
-                'EventEspresso\core\domain\entities\routing\specifications\frontend\EspressoBlockRenderer',
61
-                'EventEspresso\core\domain\entities\routing\specifications\frontend\AnyFrontendRequest'
62
-            )
63
-        );
64
-        $EVT_ID = $this->request->getRequestParam('page') === 'espresso_events'
65
-            ? $this->request->getRequestParam('post', 0, 'int')
66
-            : 0;
67
-        $this->setAttributes(
68
-            array(
69
-                'eventId'           => array(
70
-                    'type'    => 'number',
71
-                    'default' => $EVT_ID,
72
-                ),
73
-                'datetimeId'        => array(
74
-                    'type'    => 'number',
75
-                    'default' => 0,
76
-                ),
77
-                'ticketId'          => array(
78
-                    'type'    => 'number',
79
-                    'default' => 0,
80
-                ),
81
-                'status'            => array(
82
-                    'type'    => 'string',
83
-                    'default' => RegStatus::APPROVED,
84
-                ),
85
-                'limit'             => array(
86
-                    'type'    => 'number',
87
-                    'default' => 100,
88
-                ),
89
-                'order' => array(
90
-                    'type' => 'string',
91
-                    'default' => 'ASC'
92
-                ),
93
-                'orderBy' => array(
94
-                    'type' => 'string',
95
-                    'default' => 'lastThenFirstName',
96
-                ),
97
-                'showGravatar'      => array(
98
-                    'type'    => 'boolean',
99
-                    'default' => false,
100
-                ),
101
-                'avatarClass' => array(
102
-                    'type' => 'string',
103
-                    'default' => 'contact',
104
-                ),
105
-                'avatarSize' => array(
106
-                    'type' => 'number',
107
-                    'default' => 24,
108
-                ),
109
-                'displayOnArchives' => array(
110
-                    'type'    => 'boolean',
111
-                    'default' => false,
112
-                ),
113
-            )
114
-        );
115
-        $this->setDynamic();
116
-    }
48
+	/**
49
+	 * Perform any early setup required by the block
50
+	 * including setting the block type and supported post types
51
+	 *
52
+	 * @return void
53
+	 */
54
+	public function initialize()
55
+	{
56
+		$this->setBlockType(EventAttendees::BLOCK_TYPE);
57
+		$this->setSupportedRoutes(
58
+			array(
59
+				'EventEspresso\core\domain\entities\routing\specifications\admin\WordPressPostTypeEditor',
60
+				'EventEspresso\core\domain\entities\routing\specifications\frontend\EspressoBlockRenderer',
61
+				'EventEspresso\core\domain\entities\routing\specifications\frontend\AnyFrontendRequest'
62
+			)
63
+		);
64
+		$EVT_ID = $this->request->getRequestParam('page') === 'espresso_events'
65
+			? $this->request->getRequestParam('post', 0, 'int')
66
+			: 0;
67
+		$this->setAttributes(
68
+			array(
69
+				'eventId'           => array(
70
+					'type'    => 'number',
71
+					'default' => $EVT_ID,
72
+				),
73
+				'datetimeId'        => array(
74
+					'type'    => 'number',
75
+					'default' => 0,
76
+				),
77
+				'ticketId'          => array(
78
+					'type'    => 'number',
79
+					'default' => 0,
80
+				),
81
+				'status'            => array(
82
+					'type'    => 'string',
83
+					'default' => RegStatus::APPROVED,
84
+				),
85
+				'limit'             => array(
86
+					'type'    => 'number',
87
+					'default' => 100,
88
+				),
89
+				'order' => array(
90
+					'type' => 'string',
91
+					'default' => 'ASC'
92
+				),
93
+				'orderBy' => array(
94
+					'type' => 'string',
95
+					'default' => 'lastThenFirstName',
96
+				),
97
+				'showGravatar'      => array(
98
+					'type'    => 'boolean',
99
+					'default' => false,
100
+				),
101
+				'avatarClass' => array(
102
+					'type' => 'string',
103
+					'default' => 'contact',
104
+				),
105
+				'avatarSize' => array(
106
+					'type' => 'number',
107
+					'default' => 24,
108
+				),
109
+				'displayOnArchives' => array(
110
+					'type'    => 'boolean',
111
+					'default' => false,
112
+				),
113
+			)
114
+		);
115
+		$this->setDynamic();
116
+	}
117 117
 
118 118
 
119
-    /**
120
-     * Returns an array where the key corresponds to the incoming attribute name from the WP block
121
-     * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode
122
-     *
123
-     * @since 4.9.71.p
124
-     * @return array
125
-     */
126
-    private function getAttributesMap()
127
-    {
128
-        return array(
129
-            'event'             => 'sanitize_text_field',
130
-            'datetime'          => 'sanitize_text_field',
131
-            'ticket'            => 'sanitize_text_field',
132
-            'eventId'           => 'absint',
133
-            'datetimeId'        => 'absint',
134
-            'ticketId'          => 'absint',
135
-            'status'            => 'sanitize_text_field',
136
-            'limit'             => 'intval',
137
-            'showGravatar'      => 'bool',
138
-            'avatarClass'       => 'sanitize_text_field',
139
-            'avatarSize'        => 'absint',
140
-            'displayOnArchives' => 'bool',
141
-            'order' => 'sanitize_text_field',
142
-            'orderBy' => 'sanitize_text_field',
143
-        );
144
-    }
119
+	/**
120
+	 * Returns an array where the key corresponds to the incoming attribute name from the WP block
121
+	 * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode
122
+	 *
123
+	 * @since 4.9.71.p
124
+	 * @return array
125
+	 */
126
+	private function getAttributesMap()
127
+	{
128
+		return array(
129
+			'event'             => 'sanitize_text_field',
130
+			'datetime'          => 'sanitize_text_field',
131
+			'ticket'            => 'sanitize_text_field',
132
+			'eventId'           => 'absint',
133
+			'datetimeId'        => 'absint',
134
+			'ticketId'          => 'absint',
135
+			'status'            => 'sanitize_text_field',
136
+			'limit'             => 'intval',
137
+			'showGravatar'      => 'bool',
138
+			'avatarClass'       => 'sanitize_text_field',
139
+			'avatarSize'        => 'absint',
140
+			'displayOnArchives' => 'bool',
141
+			'order' => 'sanitize_text_field',
142
+			'orderBy' => 'sanitize_text_field',
143
+		);
144
+	}
145 145
 
146 146
 
147
-    /**
148
-     * Sanitizes attributes.
149
-     *
150
-     * @param array $attributes
151
-     * @return array
152
-     */
153
-    private function sanitizeAttributes(array $attributes)
154
-    {
155
-        $sanitized_attributes = array();
156
-        foreach ($attributes as $attribute => $value) {
157
-            $convert = $this->getAttributesMap();
158
-            if (isset($convert[ $attribute ])) {
159
-                $sanitize = $convert[ $attribute ];
160
-                if ($sanitize === 'bool') {
161
-                    $sanitized_attributes[ $attribute ] = filter_var(
162
-                        $value,
163
-                        FILTER_VALIDATE_BOOLEAN
164
-                    );
165
-                } else {
166
-                    $sanitized_attributes[ $attribute ] = $sanitize($value);
167
-                }
168
-                // don't pass along attributes with a 0 value
169
-                if ($sanitized_attributes[ $attribute ] === 0) {
170
-                    unset($sanitized_attributes[ $attribute ]);
171
-                }
172
-            }
173
-        }
174
-        return $attributes;
175
-    }
147
+	/**
148
+	 * Sanitizes attributes.
149
+	 *
150
+	 * @param array $attributes
151
+	 * @return array
152
+	 */
153
+	private function sanitizeAttributes(array $attributes)
154
+	{
155
+		$sanitized_attributes = array();
156
+		foreach ($attributes as $attribute => $value) {
157
+			$convert = $this->getAttributesMap();
158
+			if (isset($convert[ $attribute ])) {
159
+				$sanitize = $convert[ $attribute ];
160
+				if ($sanitize === 'bool') {
161
+					$sanitized_attributes[ $attribute ] = filter_var(
162
+						$value,
163
+						FILTER_VALIDATE_BOOLEAN
164
+					);
165
+				} else {
166
+					$sanitized_attributes[ $attribute ] = $sanitize($value);
167
+				}
168
+				// don't pass along attributes with a 0 value
169
+				if ($sanitized_attributes[ $attribute ] === 0) {
170
+					unset($sanitized_attributes[ $attribute ]);
171
+				}
172
+			}
173
+		}
174
+		return $attributes;
175
+	}
176 176
 
177 177
 
178
-    /**
179
-     * Returns the rendered HTML for the block
180
-     *
181
-     * @param array $attributes
182
-     * @return string
183
-     * @throws DomainException
184
-     * @throws EE_Error
185
-     */
186
-    public function renderBlock(array $attributes = array())
187
-    {
188
-        $attributes = $this->sanitizeAttributes($attributes);
189
-        if (! (bool) $attributes['displayOnArchives'] && (is_archive() || is_front_page() || is_home())) {
190
-            return '';
191
-        }
192
-        return $this->renderer->render($attributes);
193
-    }
178
+	/**
179
+	 * Returns the rendered HTML for the block
180
+	 *
181
+	 * @param array $attributes
182
+	 * @return string
183
+	 * @throws DomainException
184
+	 * @throws EE_Error
185
+	 */
186
+	public function renderBlock(array $attributes = array())
187
+	{
188
+		$attributes = $this->sanitizeAttributes($attributes);
189
+		if (! (bool) $attributes['displayOnArchives'] && (is_archive() || is_front_page() || is_home())) {
190
+			return '';
191
+		}
192
+		return $this->renderer->render($attributes);
193
+	}
194 194
 }
Please login to merge, or discard this patch.
core/domain/entities/contexts/RequestTypeContext.php 1 patch
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -15,185 +15,185 @@
 block discarded – undo
15 15
  */
16 16
 class RequestTypeContext extends Context
17 17
 {
18
-    /**
19
-     * indicates that the current request involves some form of activation
20
-     */
21
-    const ACTIVATION = 'activation-request';
22
-
23
-    /**
24
-     * indicates that the current request is for the admin but is not being made via AJAX
25
-     */
26
-    const ADMIN = 'non-ajax-admin-request';
27
-
28
-    /**
29
-     * indicates that the current request is for the admin AND is being made via AJAX
30
-     */
31
-    const AJAX_ADMIN = 'admin-ajax-request';
32
-
33
-    /**
34
-     * indicates that the current request is for the frontend AND is being made via AJAX
35
-     */
36
-    const AJAX_FRONT = 'frontend-ajax-request';
37
-
38
-    /**
39
-     * indicates that the current request is for the WP Heartbeat
40
-     */
41
-    const AJAX_HEARTBEAT = 'admin-ajax-heartbeat';
42
-
43
-    /**
44
-     * indicates that the current request is being made via AJAX, but is NOT for EE
45
-     */
46
-    const AJAX_OTHER = 'other-ajax-request';
47
-
48
-    /**
49
-     * indicates that the current request is for the EE REST API
50
-     */
51
-    const API = 'rest-api';
52
-
53
-    /**
54
-     * indicates that the current request is from the command line
55
-     */
56
-    const CLI = 'command-line';
57
-
58
-    /**
59
-     * indicates that the current request is for a WP_Cron
60
-     */
61
-    const CRON = 'wp-cron';
62
-
63
-    /**
64
-     * indicates that the current request is for a feed (ie: RSS)
65
-     */
66
-    const FEED = 'feed-request';
67
-
68
-    /**
69
-     * indicates that the current request is for the frontend but is not being made via AJAX
70
-     */
71
-    const FRONTEND = 'non-ajax-frontend-request';
72
-
73
-    /**
74
-     * indicates that the current request is for content that is to be displayed within an iframe
75
-     */
76
-    const IFRAME = 'iframe-request';
77
-
78
-    /**
79
-     * indicates that the current request is for the EE GraphQL manager
80
-     */
81
-    const GQL = 'graphql';
82
-
83
-    /**
84
-     * indicates that the current request is for the WP REST API
85
-     */
86
-    const WP_API = 'wp-rest-api';
87
-
88
-    /**
89
-     * indicates that the current request is a loopback sent from WP core to test for errors
90
-     */
91
-    const WP_SCRAPE = 'wordpress-scrape';
92
-
93
-    /**
94
-     * @var boolean $is_activation
95
-     */
96
-    private bool $is_activation = false;
97
-
98
-    /**
99
-     * @var boolean $is_unit_testing
100
-     */
101
-    private bool $is_unit_testing = false;
102
-
103
-    /**
104
-     * @var array $valid_request_types
105
-     */
106
-    private array $valid_request_types = array();
107
-
108
-
109
-    /**
110
-     * RequestTypeContext constructor.
111
-     *
112
-     * @param string $slug
113
-     * @param string $description
114
-     * @throws InvalidArgumentException
115
-     */
116
-    public function __construct($slug, $description)
117
-    {
118
-        parent::__construct($slug, $description);
119
-        if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
120
-            throw new InvalidArgumentException(
121
-                sprintf(
122
-                    esc_html__(
123
-                        'The RequestTypeContext slug must be one of the following values: %1$s %2$s',
124
-                        'event_espresso'
125
-                    ),
126
-                    '<br />',
127
-                    var_export($this->validRequestTypes(), true)
128
-                )
129
-            );
130
-        }
131
-    }
132
-
133
-
134
-    /**
135
-     * @return array
136
-     */
137
-    public function validRequestTypes(): array
138
-    {
139
-        if (empty($this->valid_request_types)) {
140
-            $this->valid_request_types = apply_filters(
141
-                'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes',
142
-                array(
143
-                    RequestTypeContext::ACTIVATION,
144
-                    RequestTypeContext::ADMIN,
145
-                    RequestTypeContext::AJAX_ADMIN,
146
-                    RequestTypeContext::AJAX_FRONT,
147
-                    RequestTypeContext::AJAX_HEARTBEAT,
148
-                    RequestTypeContext::AJAX_OTHER,
149
-                    RequestTypeContext::API,
150
-                    RequestTypeContext::CLI,
151
-                    RequestTypeContext::CRON,
152
-                    RequestTypeContext::FEED,
153
-                    RequestTypeContext::FRONTEND,
154
-                    RequestTypeContext::GQL,
155
-                    RequestTypeContext::IFRAME,
156
-                    RequestTypeContext::WP_API,
157
-                    RequestTypeContext::WP_SCRAPE,
158
-                )
159
-            );
160
-        }
161
-        return $this->valid_request_types;
162
-    }
163
-
164
-
165
-    /**
166
-     * @return bool
167
-     */
168
-    public function isActivation(): bool
169
-    {
170
-        return $this->is_activation || $this->slug() === RequestTypeContext::ACTIVATION;
171
-    }
172
-
173
-
174
-    /**
175
-     * @param bool $is_activation
176
-     */
177
-    public function setIsActivation(bool $is_activation = false)
178
-    {
179
-        $this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN);
180
-    }
181
-
182
-
183
-    /**
184
-     * @return bool
185
-     */
186
-    public function isUnitTesting(): bool
187
-    {
188
-        return $this->is_unit_testing;
189
-    }
190
-
191
-
192
-    /**
193
-     * @param bool $is_unit_testing
194
-     */
195
-    public function setIsUnitTesting(bool $is_unit_testing = false)
196
-    {
197
-        $this->is_unit_testing = filter_var($is_unit_testing, FILTER_VALIDATE_BOOLEAN);
198
-    }
18
+	/**
19
+	 * indicates that the current request involves some form of activation
20
+	 */
21
+	const ACTIVATION = 'activation-request';
22
+
23
+	/**
24
+	 * indicates that the current request is for the admin but is not being made via AJAX
25
+	 */
26
+	const ADMIN = 'non-ajax-admin-request';
27
+
28
+	/**
29
+	 * indicates that the current request is for the admin AND is being made via AJAX
30
+	 */
31
+	const AJAX_ADMIN = 'admin-ajax-request';
32
+
33
+	/**
34
+	 * indicates that the current request is for the frontend AND is being made via AJAX
35
+	 */
36
+	const AJAX_FRONT = 'frontend-ajax-request';
37
+
38
+	/**
39
+	 * indicates that the current request is for the WP Heartbeat
40
+	 */
41
+	const AJAX_HEARTBEAT = 'admin-ajax-heartbeat';
42
+
43
+	/**
44
+	 * indicates that the current request is being made via AJAX, but is NOT for EE
45
+	 */
46
+	const AJAX_OTHER = 'other-ajax-request';
47
+
48
+	/**
49
+	 * indicates that the current request is for the EE REST API
50
+	 */
51
+	const API = 'rest-api';
52
+
53
+	/**
54
+	 * indicates that the current request is from the command line
55
+	 */
56
+	const CLI = 'command-line';
57
+
58
+	/**
59
+	 * indicates that the current request is for a WP_Cron
60
+	 */
61
+	const CRON = 'wp-cron';
62
+
63
+	/**
64
+	 * indicates that the current request is for a feed (ie: RSS)
65
+	 */
66
+	const FEED = 'feed-request';
67
+
68
+	/**
69
+	 * indicates that the current request is for the frontend but is not being made via AJAX
70
+	 */
71
+	const FRONTEND = 'non-ajax-frontend-request';
72
+
73
+	/**
74
+	 * indicates that the current request is for content that is to be displayed within an iframe
75
+	 */
76
+	const IFRAME = 'iframe-request';
77
+
78
+	/**
79
+	 * indicates that the current request is for the EE GraphQL manager
80
+	 */
81
+	const GQL = 'graphql';
82
+
83
+	/**
84
+	 * indicates that the current request is for the WP REST API
85
+	 */
86
+	const WP_API = 'wp-rest-api';
87
+
88
+	/**
89
+	 * indicates that the current request is a loopback sent from WP core to test for errors
90
+	 */
91
+	const WP_SCRAPE = 'wordpress-scrape';
92
+
93
+	/**
94
+	 * @var boolean $is_activation
95
+	 */
96
+	private bool $is_activation = false;
97
+
98
+	/**
99
+	 * @var boolean $is_unit_testing
100
+	 */
101
+	private bool $is_unit_testing = false;
102
+
103
+	/**
104
+	 * @var array $valid_request_types
105
+	 */
106
+	private array $valid_request_types = array();
107
+
108
+
109
+	/**
110
+	 * RequestTypeContext constructor.
111
+	 *
112
+	 * @param string $slug
113
+	 * @param string $description
114
+	 * @throws InvalidArgumentException
115
+	 */
116
+	public function __construct($slug, $description)
117
+	{
118
+		parent::__construct($slug, $description);
119
+		if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
120
+			throw new InvalidArgumentException(
121
+				sprintf(
122
+					esc_html__(
123
+						'The RequestTypeContext slug must be one of the following values: %1$s %2$s',
124
+						'event_espresso'
125
+					),
126
+					'<br />',
127
+					var_export($this->validRequestTypes(), true)
128
+				)
129
+			);
130
+		}
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return array
136
+	 */
137
+	public function validRequestTypes(): array
138
+	{
139
+		if (empty($this->valid_request_types)) {
140
+			$this->valid_request_types = apply_filters(
141
+				'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes',
142
+				array(
143
+					RequestTypeContext::ACTIVATION,
144
+					RequestTypeContext::ADMIN,
145
+					RequestTypeContext::AJAX_ADMIN,
146
+					RequestTypeContext::AJAX_FRONT,
147
+					RequestTypeContext::AJAX_HEARTBEAT,
148
+					RequestTypeContext::AJAX_OTHER,
149
+					RequestTypeContext::API,
150
+					RequestTypeContext::CLI,
151
+					RequestTypeContext::CRON,
152
+					RequestTypeContext::FEED,
153
+					RequestTypeContext::FRONTEND,
154
+					RequestTypeContext::GQL,
155
+					RequestTypeContext::IFRAME,
156
+					RequestTypeContext::WP_API,
157
+					RequestTypeContext::WP_SCRAPE,
158
+				)
159
+			);
160
+		}
161
+		return $this->valid_request_types;
162
+	}
163
+
164
+
165
+	/**
166
+	 * @return bool
167
+	 */
168
+	public function isActivation(): bool
169
+	{
170
+		return $this->is_activation || $this->slug() === RequestTypeContext::ACTIVATION;
171
+	}
172
+
173
+
174
+	/**
175
+	 * @param bool $is_activation
176
+	 */
177
+	public function setIsActivation(bool $is_activation = false)
178
+	{
179
+		$this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN);
180
+	}
181
+
182
+
183
+	/**
184
+	 * @return bool
185
+	 */
186
+	public function isUnitTesting(): bool
187
+	{
188
+		return $this->is_unit_testing;
189
+	}
190
+
191
+
192
+	/**
193
+	 * @param bool $is_unit_testing
194
+	 */
195
+	public function setIsUnitTesting(bool $is_unit_testing = false)
196
+	{
197
+		$this->is_unit_testing = filter_var($is_unit_testing, FILTER_VALIDATE_BOOLEAN);
198
+	}
199 199
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/handlers/admin/EspressoLegacyAdmin.php 1 patch
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -17,146 +17,146 @@
 block discarded – undo
17 17
  */
18 18
 class EspressoLegacyAdmin extends AdminRoute
19 19
 {
20
-    /**
21
-     * @var LegacyAccountingAssetManager $asset_manager
22
-     */
23
-    protected $asset_manager;
20
+	/**
21
+	 * @var LegacyAccountingAssetManager $asset_manager
22
+	 */
23
+	protected $asset_manager;
24 24
 
25 25
 
26
-    /**
27
-     * returns true if the current request matches this route
28
-     *
29
-     * @return bool
30
-     * @since   5.0.0.p
31
-     */
32
-    public function matchesCurrentRequest(): bool
33
-    {
34
-        global $pagenow;
35
-        $page = $this->request->getRequestParam('page');
36
-        return ($pagenow === 'admin.php' || $pagenow === 'admin-ajax.php')
37
-               && (
38
-                   $page === 'pricing'
39
-                   || str_contains($page, 'espresso')
40
-                   || apply_filters(
41
-                       'FHEE__EspressoLegacyAdmin__matchesCurrentRequest__page',
42
-                       false,
43
-                       $page
44
-                   )
45
-               )
46
-               && parent::matchesCurrentRequest();
47
-    }
26
+	/**
27
+	 * returns true if the current request matches this route
28
+	 *
29
+	 * @return bool
30
+	 * @since   5.0.0.p
31
+	 */
32
+	public function matchesCurrentRequest(): bool
33
+	{
34
+		global $pagenow;
35
+		$page = $this->request->getRequestParam('page');
36
+		return ($pagenow === 'admin.php' || $pagenow === 'admin-ajax.php')
37
+			   && (
38
+				   $page === 'pricing'
39
+				   || str_contains($page, 'espresso')
40
+				   || apply_filters(
41
+					   'FHEE__EspressoLegacyAdmin__matchesCurrentRequest__page',
42
+					   false,
43
+					   $page
44
+				   )
45
+			   )
46
+			   && parent::matchesCurrentRequest();
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * @since 5.0.0.p
52
-     */
53
-    protected function registerDependencies()
54
-    {
55
-        $asset_manger_dependencies = [
56
-            'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
57
-            'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object,
58
-            'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
59
-        ];
60
-        $this->dependency_map->registerDependencies(JqueryAssetManager::class, $asset_manger_dependencies);
61
-        $this->dependency_map->registerDependencies(EspressoLegacyAdminAssetManager::class, $asset_manger_dependencies);
62
-        $this->dependency_map->registerDependencies(
63
-            LegacyAccountingAssetManager::class,
64
-            ['EE_Currency_Config' => EE_Dependency_Map::load_from_cache] + $asset_manger_dependencies
65
-        );
66
-        $this->dependency_map->registerDependencies(
67
-            'EE_Admin_Transactions_List_Table',
68
-            [
69
-                null,
70
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
71
-            ]
72
-        );
73
-        $this->dependency_map->registerDependencies(
74
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings',
75
-            ['EE_Registration_Config' => EE_Dependency_Map::load_from_cache]
76
-        );
77
-        $this->dependency_map->registerDependencies(
78
-            'EventEspresso\admin_pages\general_settings\OrganizationSettings',
79
-            [
80
-                'EE_Registry'                                                  => EE_Dependency_Map::load_from_cache,
81
-                'EE_Organization_Config'                                       => EE_Dependency_Map::load_from_cache,
82
-                'EE_Core_Config'                                               => EE_Dependency_Map::load_from_cache,
83
-                'EE_Network_Core_Config'                                       => EE_Dependency_Map::load_from_cache,
84
-                'EventEspresso\core\services\address\CountrySubRegionDao'      => EE_Dependency_Map::load_from_cache,
85
-                'EventEspresso\core\domain\services\capabilities\FeatureFlags' => EE_Dependency_Map::load_from_cache,
86
-            ]
87
-        );
88
-        $this->dependency_map->registerDependencies(
89
-            'EventEspresso\core\services\address\CountrySubRegionDao',
90
-            [
91
-                'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
92
-                'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache,
93
-            ]
94
-        );
95
-        $this->dependency_map->registerDependencies(
96
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
97
-            [
98
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
99
-                'EEM_Registration'                            => EE_Dependency_Map::load_from_cache,
100
-                null,
101
-            ]
102
-        );
103
-        $this->dependency_map->registerDependencies(
104
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
105
-            [
106
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
107
-                'EEM_Attendee'                                => EE_Dependency_Map::load_from_cache,
108
-            ]
109
-        );
110
-        $this->dependency_map->registerDependencies(
111
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
112
-            [
113
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
114
-                'EEM_Datetime'                                => EE_Dependency_Map::load_from_cache,
115
-            ]
116
-        );
117
-        $this->dependency_map->registerDependencies(
118
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
119
-            [
120
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
121
-                'EEM_Event'                                   => EE_Dependency_Map::load_from_cache,
122
-            ]
123
-        );
124
-        $this->dependency_map->registerDependencies(
125
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
126
-            [
127
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
128
-                'EEM_Ticket'                                  => EE_Dependency_Map::load_from_cache,
129
-            ]
130
-        );
131
-        $this->dependency_map->registerDependencies(
132
-            'EventEspresso\core\services\admin\AdminListTableFilters',
133
-            [
134
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
135
-            ]
136
-        );
137
-    }
50
+	/**
51
+	 * @since 5.0.0.p
52
+	 */
53
+	protected function registerDependencies()
54
+	{
55
+		$asset_manger_dependencies = [
56
+			'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
57
+			'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object,
58
+			'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
59
+		];
60
+		$this->dependency_map->registerDependencies(JqueryAssetManager::class, $asset_manger_dependencies);
61
+		$this->dependency_map->registerDependencies(EspressoLegacyAdminAssetManager::class, $asset_manger_dependencies);
62
+		$this->dependency_map->registerDependencies(
63
+			LegacyAccountingAssetManager::class,
64
+			['EE_Currency_Config' => EE_Dependency_Map::load_from_cache] + $asset_manger_dependencies
65
+		);
66
+		$this->dependency_map->registerDependencies(
67
+			'EE_Admin_Transactions_List_Table',
68
+			[
69
+				null,
70
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
71
+			]
72
+		);
73
+		$this->dependency_map->registerDependencies(
74
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings',
75
+			['EE_Registration_Config' => EE_Dependency_Map::load_from_cache]
76
+		);
77
+		$this->dependency_map->registerDependencies(
78
+			'EventEspresso\admin_pages\general_settings\OrganizationSettings',
79
+			[
80
+				'EE_Registry'                                                  => EE_Dependency_Map::load_from_cache,
81
+				'EE_Organization_Config'                                       => EE_Dependency_Map::load_from_cache,
82
+				'EE_Core_Config'                                               => EE_Dependency_Map::load_from_cache,
83
+				'EE_Network_Core_Config'                                       => EE_Dependency_Map::load_from_cache,
84
+				'EventEspresso\core\services\address\CountrySubRegionDao'      => EE_Dependency_Map::load_from_cache,
85
+				'EventEspresso\core\domain\services\capabilities\FeatureFlags' => EE_Dependency_Map::load_from_cache,
86
+			]
87
+		);
88
+		$this->dependency_map->registerDependencies(
89
+			'EventEspresso\core\services\address\CountrySubRegionDao',
90
+			[
91
+				'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
92
+				'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache,
93
+			]
94
+		);
95
+		$this->dependency_map->registerDependencies(
96
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
97
+			[
98
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
99
+				'EEM_Registration'                            => EE_Dependency_Map::load_from_cache,
100
+				null,
101
+			]
102
+		);
103
+		$this->dependency_map->registerDependencies(
104
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
105
+			[
106
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
107
+				'EEM_Attendee'                                => EE_Dependency_Map::load_from_cache,
108
+			]
109
+		);
110
+		$this->dependency_map->registerDependencies(
111
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
112
+			[
113
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
114
+				'EEM_Datetime'                                => EE_Dependency_Map::load_from_cache,
115
+			]
116
+		);
117
+		$this->dependency_map->registerDependencies(
118
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
119
+			[
120
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
121
+				'EEM_Event'                                   => EE_Dependency_Map::load_from_cache,
122
+			]
123
+		);
124
+		$this->dependency_map->registerDependencies(
125
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
126
+			[
127
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
128
+				'EEM_Ticket'                                  => EE_Dependency_Map::load_from_cache,
129
+			]
130
+		);
131
+		$this->dependency_map->registerDependencies(
132
+			'EventEspresso\core\services\admin\AdminListTableFilters',
133
+			[
134
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
135
+			]
136
+		);
137
+	}
138 138
 
139 139
 
140
-    /**
141
-     * implements logic required to run during request
142
-     *
143
-     * @return bool
144
-     * @since   5.0.0.p
145
-     */
146
-    protected function requestHandler(): bool
147
-    {
148
-        add_filter(
149
-            'admin_body_class',
150
-            function ($classes) {
151
-                if (strpos($classes, 'espresso-admin') === false) {
152
-                    $classes .= ' espresso-admin';
153
-                }
154
-                return $classes;
155
-            }
156
-        );
157
-        $this->loader->getShared(JqueryAssetManager::class);
158
-        $this->loader->getShared(EspressoLegacyAdminAssetManager::class);
159
-        $this->loader->getShared(LegacyAccountingAssetManager::class);
160
-        return true;
161
-    }
140
+	/**
141
+	 * implements logic required to run during request
142
+	 *
143
+	 * @return bool
144
+	 * @since   5.0.0.p
145
+	 */
146
+	protected function requestHandler(): bool
147
+	{
148
+		add_filter(
149
+			'admin_body_class',
150
+			function ($classes) {
151
+				if (strpos($classes, 'espresso-admin') === false) {
152
+					$classes .= ' espresso-admin';
153
+				}
154
+				return $classes;
155
+			}
156
+		);
157
+		$this->loader->getShared(JqueryAssetManager::class);
158
+		$this->loader->getShared(EspressoLegacyAdminAssetManager::class);
159
+		$this->loader->getShared(LegacyAccountingAssetManager::class);
160
+		return true;
161
+	}
162 162
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/data_nodes/core/Locale.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -16,30 +16,30 @@
 block discarded – undo
16 16
  */
17 17
 class Locale extends JsonDataNode
18 18
 {
19
-    const NODE_NAME = 'locale';
19
+	const NODE_NAME = 'locale';
20 20
 
21 21
 
22
-    /**
23
-     * @param JsonDataNodeValidator $validator
24
-     */
25
-    public function __construct(JsonDataNodeValidator $validator)
26
-    {
27
-        parent::__construct($validator);
28
-        $this->setNodeName(Locale::NODE_NAME);
29
-    }
22
+	/**
23
+	 * @param JsonDataNodeValidator $validator
24
+	 */
25
+	public function __construct(JsonDataNodeValidator $validator)
26
+	{
27
+		parent::__construct($validator);
28
+		$this->setNodeName(Locale::NODE_NAME);
29
+	}
30 30
 
31
-    /**
32
-     * @inheritDoc
33
-     */
34
-    public function initialize()
35
-    {
36
-        $this->addData('user', get_user_locale());
37
-        $this->addData('site', get_locale());
38
-        $this->addData('siteTimezone', [
39
-            'city'   => EEH_DTT_Helper::get_timezone_string_for_display(),
40
-            'name'   => EEH_DTT_Helper::get_valid_timezone_string(wp_timezone_string()),
41
-            'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
42
-        ]);
43
-        $this->setInitialized(true);
44
-    }
31
+	/**
32
+	 * @inheritDoc
33
+	 */
34
+	public function initialize()
35
+	{
36
+		$this->addData('user', get_user_locale());
37
+		$this->addData('site', get_locale());
38
+		$this->addData('siteTimezone', [
39
+			'city'   => EEH_DTT_Helper::get_timezone_string_for_display(),
40
+			'name'   => EEH_DTT_Helper::get_valid_timezone_string(wp_timezone_string()),
41
+			'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
42
+		]);
43
+		$this->setInitialized(true);
44
+	}
45 45
 }
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoCancelled.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -21,83 +21,83 @@
 block discarded – undo
21 21
  */
22 22
 class EspressoCancelled extends EspressoShortcode
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_CANCELLED';
32
-    }
24
+	/**
25
+	 * the actual shortcode tag that gets registered with WordPress
26
+	 *
27
+	 * @return string
28
+	 */
29
+	public function getTag()
30
+	{
31
+		return 'ESPRESSO_CANCELLED';
32
+	}
33 33
 
34 34
 
35
-    /**
36
-     * the time in seconds to cache the results of the processShortcode() method
37
-     * 0 means the processShortcode() results will NOT be cached at all
38
-     *
39
-     * @return int
40
-     */
41
-    public function cacheExpiration()
42
-    {
43
-        return 0;
44
-    }
35
+	/**
36
+	 * the time in seconds to cache the results of the processShortcode() method
37
+	 * 0 means the processShortcode() results will NOT be cached at all
38
+	 *
39
+	 * @return int
40
+	 */
41
+	public function cacheExpiration()
42
+	{
43
+		return 0;
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * a place for adding any initialization code that needs to run prior to wp_header().
49
-     * this may be required for shortcodes that utilize a corresponding module,
50
-     * and need to enqueue assets for that module
51
-     *
52
-     * @return void
53
-     */
54
-    public function initializeShortcode()
55
-    {
56
-        $this->shortcodeHasBeenInitialized();
57
-    }
47
+	/**
48
+	 * a place for adding any initialization code that needs to run prior to wp_header().
49
+	 * this may be required for shortcodes that utilize a corresponding module,
50
+	 * and need to enqueue assets for that module
51
+	 *
52
+	 * @return void
53
+	 */
54
+	public function initializeShortcode()
55
+	{
56
+		$this->shortcodeHasBeenInitialized();
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * callback that runs when the shortcode is encountered in post content.
62
-     * IMPORTANT !!!
63
-     * remember that shortcode content should be RETURNED and NOT echoed out
64
-     *
65
-     * @param array|string $attributes
66
-     * @return string
67
-     * @throws EE_Error
68
-     * @throws ReflectionException
69
-     */
70
-    public function processShortcode($attributes = array())
71
-    {
72
-        $session = EE_Registry::instance()->SSN;
73
-        if (! $session instanceof EE_Session) {
74
-            return '';
75
-        }
76
-        $transaction = $session->get_session_data('transaction');
77
-        if ($transaction instanceof EE_Transaction) {
78
-            do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', $transaction);
79
-            $registrations = $transaction->registrations();
80
-            foreach ($registrations as $registration) {
81
-                if ($registration instanceof EE_Registration) {
82
-                    do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__registration', $registration);
83
-                }
84
-            }
85
-        }
86
-        do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__clear_session');
87
-        // remove all unwanted records from the db
88
-        if ($session->cart() instanceof EE_Cart) {
89
-            $session->cart()->delete_cart();
90
-        }
91
-        $session->clear_session(__CLASS__, __FUNCTION__);
92
-        // phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText
93
-        return sprintf(
94
-            esc_html__(
95
-                '%sAll unsaved registration information entered during this session has been deleted.%s',
96
-                'event_espresso'
97
-            ),
98
-            '<p class="ee-registrations-cancelled-pg ee-attention">',
99
-            '</p>'
100
-        );
101
-        // phpcs:enable
102
-    }
60
+	/**
61
+	 * callback that runs when the shortcode is encountered in post content.
62
+	 * IMPORTANT !!!
63
+	 * remember that shortcode content should be RETURNED and NOT echoed out
64
+	 *
65
+	 * @param array|string $attributes
66
+	 * @return string
67
+	 * @throws EE_Error
68
+	 * @throws ReflectionException
69
+	 */
70
+	public function processShortcode($attributes = array())
71
+	{
72
+		$session = EE_Registry::instance()->SSN;
73
+		if (! $session instanceof EE_Session) {
74
+			return '';
75
+		}
76
+		$transaction = $session->get_session_data('transaction');
77
+		if ($transaction instanceof EE_Transaction) {
78
+			do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', $transaction);
79
+			$registrations = $transaction->registrations();
80
+			foreach ($registrations as $registration) {
81
+				if ($registration instanceof EE_Registration) {
82
+					do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__registration', $registration);
83
+				}
84
+			}
85
+		}
86
+		do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__clear_session');
87
+		// remove all unwanted records from the db
88
+		if ($session->cart() instanceof EE_Cart) {
89
+			$session->cart()->delete_cart();
90
+		}
91
+		$session->clear_session(__CLASS__, __FUNCTION__);
92
+		// phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText
93
+		return sprintf(
94
+			esc_html__(
95
+				'%sAll unsaved registration information entered during this session has been deleted.%s',
96
+				'event_espresso'
97
+			),
98
+			'<p class="ee-registrations-cancelled-pg ee-attention">',
99
+			'</p>'
100
+		);
101
+		// phpcs:enable
102
+	}
103 103
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
     public function processShortcode($attributes = array())
71 71
     {
72 72
         $session = EE_Registry::instance()->SSN;
73
-        if (! $session instanceof EE_Session) {
73
+        if ( ! $session instanceof EE_Session) {
74 74
             return '';
75 75
         }
76 76
         $transaction = $session->get_session_data('transaction');
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoEventAttendees.php 1 patch
Indentation   +313 added lines, -313 removed lines patch added patch discarded remove patch
@@ -33,342 +33,342 @@
 block discarded – undo
33 33
  */
34 34
 class EspressoEventAttendees extends EspressoShortcode
35 35
 {
36
-    private $query_params = array(
37
-        0 => array(),
38
-    );
36
+	private $query_params = array(
37
+		0 => array(),
38
+	);
39 39
 
40
-    private $template_args = array(
41
-        'contacts' => array(),
42
-        'event'    => null,
43
-        'datetime' => null,
44
-        'ticket'   => null,
45
-    );
40
+	private $template_args = array(
41
+		'contacts' => array(),
42
+		'event'    => null,
43
+		'datetime' => null,
44
+		'ticket'   => null,
45
+	);
46 46
 
47
-    /**
48
-     * the actual shortcode tag that gets registered with WordPress
49
-     *
50
-     * @return string
51
-     */
52
-    public function getTag()
53
-    {
54
-        return 'ESPRESSO_EVENT_ATTENDEES';
55
-    }
47
+	/**
48
+	 * the actual shortcode tag that gets registered with WordPress
49
+	 *
50
+	 * @return string
51
+	 */
52
+	public function getTag()
53
+	{
54
+		return 'ESPRESSO_EVENT_ATTENDEES';
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * the time in seconds to cache the results of the processShortcode() method
60
-     * 0 means the processShortcode() results will NOT be cached at all
61
-     *
62
-     * @return int
63
-     */
64
-    public function cacheExpiration()
65
-    {
66
-        return 0;
67
-    }
58
+	/**
59
+	 * the time in seconds to cache the results of the processShortcode() method
60
+	 * 0 means the processShortcode() results will NOT be cached at all
61
+	 *
62
+	 * @return int
63
+	 */
64
+	public function cacheExpiration()
65
+	{
66
+		return 0;
67
+	}
68 68
 
69 69
 
70
-    /**
71
-     * a place for adding any initialization code that needs to run prior to wp_header().
72
-     * this may be required for shortcodes that utilize a corresponding module,
73
-     * and need to enqueue assets for that module
74
-     *
75
-     * @return void
76
-     */
77
-    public function initializeShortcode()
78
-    {
79
-        $this->shortcodeHasBeenInitialized();
80
-    }
70
+	/**
71
+	 * a place for adding any initialization code that needs to run prior to wp_header().
72
+	 * this may be required for shortcodes that utilize a corresponding module,
73
+	 * and need to enqueue assets for that module
74
+	 *
75
+	 * @return void
76
+	 */
77
+	public function initializeShortcode()
78
+	{
79
+		$this->shortcodeHasBeenInitialized();
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event.
85
-     *  [ESPRESSO_EVENT_ATTENDEES]
86
-     *  - defaults to attendees for earliest active event, or earliest upcoming event.
87
-     *  [ESPRESSO_EVENT_ATTENDEES event_id=123]
88
-     *  - attendees for specific event.
89
-     *  [ESPRESSO_EVENT_ATTENDEES datetime_id=245]
90
-     *  - attendees for a specific datetime.
91
-     *  [ESPRESSO_EVENT_ATTENDEES ticket_id=123]
92
-     *  - attendees for a specific ticket.
93
-     *  [ESPRESSO_EVENT_ATTENDEES status=all]
94
-     *  - specific registration status (use status id) or all for all attendees regardless of status.
95
-     *  Note default is to only return approved attendees
96
-     *  [ESPRESSO_EVENT_ATTENDEES show_gravatar=true]
97
-     *  - default is to not return gravatar.  Otherwise if this is set then return gravatar for email address given.
98
-     *  [ESPRESSO_EVENT_ATTENDEES display_on_archives=true]
99
-     *  - default is to not display attendees list on archive pages.
100
-     * Note: because of the relationship between event_id, ticket_id, and datetime_id:
101
-     * If more than one of those params is included, then preference is given to the following:
102
-     *  - event_id is used whenever its present and any others are ignored.
103
-     *  - if no event_id then datetime is used whenever its present and any others are ignored.
104
-     *  - otherwise ticket_id is used if present.
105
-     *
106
-     * @param array|string $attributes
107
-     * @return string
108
-     * @throws EE_Error
109
-     * @throws InvalidDataTypeException
110
-     * @throws InvalidInterfaceException
111
-     * @throws InvalidArgumentException
112
-     * @throws DomainException
113
-     * @throws ReflectionException
114
-     */
115
-    public function processShortcode($attributes = array())
116
-    {
117
-        // grab attributes and merge with defaults
118
-        $attributes = $this->getAttributes((array) $attributes);
119
-        $attributes['limit'] = (int) $attributes['limit'];
120
-        $display_on_archives = filter_var($attributes['display_on_archives'], FILTER_VALIDATE_BOOLEAN);
121
-        // don't display on archives unless 'display_on_archives' is true
122
-        if ($attributes['limit'] === 0 || (! $display_on_archives && is_archive())) {
123
-            return '';
124
-        }
125
-        try {
126
-            $this->setBaseTemplateArguments($attributes);
127
-            $this->validateEntities($attributes);
128
-            $this->setBaseQueryParams();
129
-        } catch (EntityNotFoundException $e) {
130
-            if (WP_DEBUG) {
131
-                return '<div class="important-notice ee-error">'
132
-                       . $e->getMessage()
133
-                       . '</div>';
134
-            }
135
-            return '';
136
-        }
137
-        $this->setAdditionalQueryParams($attributes);
138
-        // get contacts!
139
-        $this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params);
140
-        // all set let's load up the template and return.
141
-        return EEH_Template::locate_template(
142
-            'loop-espresso_event_attendees.php',
143
-            $this->template_args
144
-        );
145
-    }
83
+	/**
84
+	 * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event.
85
+	 *  [ESPRESSO_EVENT_ATTENDEES]
86
+	 *  - defaults to attendees for earliest active event, or earliest upcoming event.
87
+	 *  [ESPRESSO_EVENT_ATTENDEES event_id=123]
88
+	 *  - attendees for specific event.
89
+	 *  [ESPRESSO_EVENT_ATTENDEES datetime_id=245]
90
+	 *  - attendees for a specific datetime.
91
+	 *  [ESPRESSO_EVENT_ATTENDEES ticket_id=123]
92
+	 *  - attendees for a specific ticket.
93
+	 *  [ESPRESSO_EVENT_ATTENDEES status=all]
94
+	 *  - specific registration status (use status id) or all for all attendees regardless of status.
95
+	 *  Note default is to only return approved attendees
96
+	 *  [ESPRESSO_EVENT_ATTENDEES show_gravatar=true]
97
+	 *  - default is to not return gravatar.  Otherwise if this is set then return gravatar for email address given.
98
+	 *  [ESPRESSO_EVENT_ATTENDEES display_on_archives=true]
99
+	 *  - default is to not display attendees list on archive pages.
100
+	 * Note: because of the relationship between event_id, ticket_id, and datetime_id:
101
+	 * If more than one of those params is included, then preference is given to the following:
102
+	 *  - event_id is used whenever its present and any others are ignored.
103
+	 *  - if no event_id then datetime is used whenever its present and any others are ignored.
104
+	 *  - otherwise ticket_id is used if present.
105
+	 *
106
+	 * @param array|string $attributes
107
+	 * @return string
108
+	 * @throws EE_Error
109
+	 * @throws InvalidDataTypeException
110
+	 * @throws InvalidInterfaceException
111
+	 * @throws InvalidArgumentException
112
+	 * @throws DomainException
113
+	 * @throws ReflectionException
114
+	 */
115
+	public function processShortcode($attributes = array())
116
+	{
117
+		// grab attributes and merge with defaults
118
+		$attributes = $this->getAttributes((array) $attributes);
119
+		$attributes['limit'] = (int) $attributes['limit'];
120
+		$display_on_archives = filter_var($attributes['display_on_archives'], FILTER_VALIDATE_BOOLEAN);
121
+		// don't display on archives unless 'display_on_archives' is true
122
+		if ($attributes['limit'] === 0 || (! $display_on_archives && is_archive())) {
123
+			return '';
124
+		}
125
+		try {
126
+			$this->setBaseTemplateArguments($attributes);
127
+			$this->validateEntities($attributes);
128
+			$this->setBaseQueryParams();
129
+		} catch (EntityNotFoundException $e) {
130
+			if (WP_DEBUG) {
131
+				return '<div class="important-notice ee-error">'
132
+					   . $e->getMessage()
133
+					   . '</div>';
134
+			}
135
+			return '';
136
+		}
137
+		$this->setAdditionalQueryParams($attributes);
138
+		// get contacts!
139
+		$this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params);
140
+		// all set let's load up the template and return.
141
+		return EEH_Template::locate_template(
142
+			'loop-espresso_event_attendees.php',
143
+			$this->template_args
144
+		);
145
+	}
146 146
 
147 147
 
148
-    /**
149
-     * merge incoming attributes with filtered defaults
150
-     *
151
-     * @param array $attributes
152
-     * @return array
153
-     */
154
-    private function getAttributes(array $attributes): array
155
-    {
156
-        return (array) apply_filters(
157
-            'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts',
158
-            $attributes + array(
159
-                'event_id'            => null,
160
-                'datetime_id'         => null,
161
-                'ticket_id'           => null,
162
-                'status'              => RegStatus::APPROVED,
163
-                'show_gravatar'       => false,
164
-                'display_on_archives' => false,
165
-                'limit'               => 999,
166
-            )
167
-        );
168
-    }
148
+	/**
149
+	 * merge incoming attributes with filtered defaults
150
+	 *
151
+	 * @param array $attributes
152
+	 * @return array
153
+	 */
154
+	private function getAttributes(array $attributes): array
155
+	{
156
+		return (array) apply_filters(
157
+			'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts',
158
+			$attributes + array(
159
+				'event_id'            => null,
160
+				'datetime_id'         => null,
161
+				'ticket_id'           => null,
162
+				'status'              => RegStatus::APPROVED,
163
+				'show_gravatar'       => false,
164
+				'display_on_archives' => false,
165
+				'limit'               => 999,
166
+			)
167
+		);
168
+	}
169 169
 
170 170
 
171
-    /**
172
-     * Set all the base template arguments from the incoming attributes.
173
-     * * Note: because of the relationship between event_id, ticket_id, and datetime_id:
174
-     * If more than one of those params is included, then preference is given to the following:
175
-     *  - event_id is used whenever its present and any others are ignored.
176
-     *  - if no event_id then datetime is used whenever its present and any others are ignored.
177
-     *  - otherwise ticket_id is used if present.
178
-     *
179
-     * @param array $attributes
180
-     * @throws EE_Error
181
-     * @throws InvalidDataTypeException
182
-     * @throws InvalidInterfaceException
183
-     * @throws InvalidArgumentException
184
-     * @throws ReflectionException
185
-     */
186
-    private function setBaseTemplateArguments(array $attributes)
187
-    {
188
-        $this->template_args['show_gravatar'] = $attributes['show_gravatar'];
189
-        $this->template_args['event'] = $this->getEvent($attributes);
190
-        $this->template_args['datetime'] = empty($attributes['event_id'])
191
-            ? $this->getDatetime($attributes)
192
-            : null;
193
-        $this->template_args['ticket'] = empty($attributes['datetime_id']) && empty($attributes['event_id'])
194
-            ? $this->getTicket($attributes)
195
-            : null;
196
-    }
171
+	/**
172
+	 * Set all the base template arguments from the incoming attributes.
173
+	 * * Note: because of the relationship between event_id, ticket_id, and datetime_id:
174
+	 * If more than one of those params is included, then preference is given to the following:
175
+	 *  - event_id is used whenever its present and any others are ignored.
176
+	 *  - if no event_id then datetime is used whenever its present and any others are ignored.
177
+	 *  - otherwise ticket_id is used if present.
178
+	 *
179
+	 * @param array $attributes
180
+	 * @throws EE_Error
181
+	 * @throws InvalidDataTypeException
182
+	 * @throws InvalidInterfaceException
183
+	 * @throws InvalidArgumentException
184
+	 * @throws ReflectionException
185
+	 */
186
+	private function setBaseTemplateArguments(array $attributes)
187
+	{
188
+		$this->template_args['show_gravatar'] = $attributes['show_gravatar'];
189
+		$this->template_args['event'] = $this->getEvent($attributes);
190
+		$this->template_args['datetime'] = empty($attributes['event_id'])
191
+			? $this->getDatetime($attributes)
192
+			: null;
193
+		$this->template_args['ticket'] = empty($attributes['datetime_id']) && empty($attributes['event_id'])
194
+			? $this->getTicket($attributes)
195
+			: null;
196
+	}
197 197
 
198 198
 
199
-    /**
200
-     * Validates the presence of entities for the given attribute values.
201
-     *
202
-     * @param array $attributes
203
-     * @throws EntityNotFoundException
204
-     */
205
-    private function validateEntities(array $attributes)
206
-    {
207
-        if (
208
-            ! $this->template_args['event'] instanceof EE_Event
209
-            || (
210
-                empty($attributes['event_id'])
211
-                && $attributes['datetime_id']
212
-                && ! $this->template_args['datetime'] instanceof EE_Datetime
213
-            )
214
-            || (
215
-                empty($attributes['event_id'])
216
-                && empty($attributes['datetime_id'])
217
-                && $attributes['ticket_id']
218
-                && ! $this->template_args['ticket'] instanceof EE_Ticket
219
-            )
220
-        ) {
221
-            throw new EntityNotFoundException(
222
-                '',
223
-                '',
224
-                esc_html__(
225
-                    '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.',
226
-                    'event_espresso'
227
-                )
228
-            );
229
-        }
230
-    }
199
+	/**
200
+	 * Validates the presence of entities for the given attribute values.
201
+	 *
202
+	 * @param array $attributes
203
+	 * @throws EntityNotFoundException
204
+	 */
205
+	private function validateEntities(array $attributes)
206
+	{
207
+		if (
208
+			! $this->template_args['event'] instanceof EE_Event
209
+			|| (
210
+				empty($attributes['event_id'])
211
+				&& $attributes['datetime_id']
212
+				&& ! $this->template_args['datetime'] instanceof EE_Datetime
213
+			)
214
+			|| (
215
+				empty($attributes['event_id'])
216
+				&& empty($attributes['datetime_id'])
217
+				&& $attributes['ticket_id']
218
+				&& ! $this->template_args['ticket'] instanceof EE_Ticket
219
+			)
220
+		) {
221
+			throw new EntityNotFoundException(
222
+				'',
223
+				'',
224
+				esc_html__(
225
+					'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.',
226
+					'event_espresso'
227
+				)
228
+			);
229
+		}
230
+	}
231 231
 
232 232
 
233
-    /**
234
-     * Sets the query params for the base query elements.
235
-     */
236
-    private function setBaseQueryParams()
237
-    {
238
-        switch (true) {
239
-            case $this->template_args['datetime'] instanceof EE_Datetime:
240
-                $this->query_params = array(
241
-                    0                          => array(
242
-                        'Registration.Ticket.Datetime.DTT_ID' => $this->template_args['datetime']->ID(),
243
-                    ),
244
-                    'default_where_conditions' => 'this_model_only',
245
-                );
246
-                break;
247
-            case $this->template_args['ticket'] instanceof EE_Ticket:
248
-                $this->query_params[0] = array(
249
-                    'Registration.TKT_ID' => $this->template_args['ticket']->ID(),
250
-                );
251
-                break;
252
-            case $this->template_args['event'] instanceof EE_Event:
253
-                $this->query_params[0] = array(
254
-                    'Registration.EVT_ID' => $this->template_args['event']->ID(),
255
-                );
256
-                break;
257
-        }
258
-    }
233
+	/**
234
+	 * Sets the query params for the base query elements.
235
+	 */
236
+	private function setBaseQueryParams()
237
+	{
238
+		switch (true) {
239
+			case $this->template_args['datetime'] instanceof EE_Datetime:
240
+				$this->query_params = array(
241
+					0                          => array(
242
+						'Registration.Ticket.Datetime.DTT_ID' => $this->template_args['datetime']->ID(),
243
+					),
244
+					'default_where_conditions' => 'this_model_only',
245
+				);
246
+				break;
247
+			case $this->template_args['ticket'] instanceof EE_Ticket:
248
+				$this->query_params[0] = array(
249
+					'Registration.TKT_ID' => $this->template_args['ticket']->ID(),
250
+				);
251
+				break;
252
+			case $this->template_args['event'] instanceof EE_Event:
253
+				$this->query_params[0] = array(
254
+					'Registration.EVT_ID' => $this->template_args['event']->ID(),
255
+				);
256
+				break;
257
+		}
258
+	}
259 259
 
260 260
 
261
-    /**
262
-     * @param array $attributes
263
-     * @return EE_Event|null
264
-     * @throws EE_Error
265
-     * @throws InvalidDataTypeException
266
-     * @throws InvalidInterfaceException
267
-     * @throws InvalidArgumentException
268
-     * @throws ReflectionException
269
-     */
270
-    private function getEvent(array $attributes): ?EE_Event
271
-    {
272
-        switch (true) {
273
-            case ! empty($attributes['event_id']):
274
-                $event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']);
275
-                break;
276
-            case ! empty($attributes['datetime_id']):
277
-                $event = EEM_Event::instance()->get_one(array(
278
-                    array(
279
-                        'Datetime.DTT_ID' => $attributes['datetime_id'],
280
-                    ),
281
-                ));
282
-                break;
283
-            case ! empty($attributes['ticket_id']):
284
-                $event = EEM_Event::instance()->get_one(array(
285
-                    array(
286
-                        'Datetime.Ticket.TKT_ID' => $attributes['ticket_id'],
287
-                    ),
288
-                    'default_where_conditions' => 'none'
289
-                ));
290
-                break;
291
-            case is_espresso_event():
292
-                $event = EEH_Event_View::get_event();
293
-                break;
294
-            default:
295
-                // one last shot...
296
-                // try getting the earliest active event
297
-                $events = EEM_Event::instance()->get_active_events(array(
298
-                    'limit'    => 1,
299
-                    'order_by' => array('Datetime.DTT_EVT_start' => 'ASC'),
300
-                ));
301
-                //  if none then get the next upcoming
302
-                $events = empty($events)
303
-                    ? EEM_Event::instance()->get_upcoming_events(array(
304
-                        'limit'    => 1,
305
-                        'order_by' => array('Datetime.DTT_EVT_start' => 'ASC'),
306
-                    ))
307
-                    : $events;
308
-                $event = reset($events);
309
-        }
261
+	/**
262
+	 * @param array $attributes
263
+	 * @return EE_Event|null
264
+	 * @throws EE_Error
265
+	 * @throws InvalidDataTypeException
266
+	 * @throws InvalidInterfaceException
267
+	 * @throws InvalidArgumentException
268
+	 * @throws ReflectionException
269
+	 */
270
+	private function getEvent(array $attributes): ?EE_Event
271
+	{
272
+		switch (true) {
273
+			case ! empty($attributes['event_id']):
274
+				$event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']);
275
+				break;
276
+			case ! empty($attributes['datetime_id']):
277
+				$event = EEM_Event::instance()->get_one(array(
278
+					array(
279
+						'Datetime.DTT_ID' => $attributes['datetime_id'],
280
+					),
281
+				));
282
+				break;
283
+			case ! empty($attributes['ticket_id']):
284
+				$event = EEM_Event::instance()->get_one(array(
285
+					array(
286
+						'Datetime.Ticket.TKT_ID' => $attributes['ticket_id'],
287
+					),
288
+					'default_where_conditions' => 'none'
289
+				));
290
+				break;
291
+			case is_espresso_event():
292
+				$event = EEH_Event_View::get_event();
293
+				break;
294
+			default:
295
+				// one last shot...
296
+				// try getting the earliest active event
297
+				$events = EEM_Event::instance()->get_active_events(array(
298
+					'limit'    => 1,
299
+					'order_by' => array('Datetime.DTT_EVT_start' => 'ASC'),
300
+				));
301
+				//  if none then get the next upcoming
302
+				$events = empty($events)
303
+					? EEM_Event::instance()->get_upcoming_events(array(
304
+						'limit'    => 1,
305
+						'order_by' => array('Datetime.DTT_EVT_start' => 'ASC'),
306
+					))
307
+					: $events;
308
+				$event = reset($events);
309
+		}
310 310
 
311
-        return $event instanceof EE_Event ? $event : null;
312
-    }
311
+		return $event instanceof EE_Event ? $event : null;
312
+	}
313 313
 
314 314
 
315
-    /**
316
-     * @param array $attributes
317
-     * @return EE_Datetime|null
318
-     * @throws EE_Error
319
-     * @throws InvalidDataTypeException
320
-     * @throws InvalidInterfaceException
321
-     * @throws InvalidArgumentException
322
-     */
323
-    private function getDatetime(array $attributes): ?EE_Datetime
324
-    {
325
-        if (! empty($attributes['datetime_id'])) {
326
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']);
327
-            if ($datetime instanceof EE_Datetime) {
328
-                return $datetime;
329
-            }
330
-        }
331
-        return null;
332
-    }
315
+	/**
316
+	 * @param array $attributes
317
+	 * @return EE_Datetime|null
318
+	 * @throws EE_Error
319
+	 * @throws InvalidDataTypeException
320
+	 * @throws InvalidInterfaceException
321
+	 * @throws InvalidArgumentException
322
+	 */
323
+	private function getDatetime(array $attributes): ?EE_Datetime
324
+	{
325
+		if (! empty($attributes['datetime_id'])) {
326
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']);
327
+			if ($datetime instanceof EE_Datetime) {
328
+				return $datetime;
329
+			}
330
+		}
331
+		return null;
332
+	}
333 333
 
334 334
 
335
-    /**
336
-     * @param array $attributes
337
-     * @return EE_Base_Class|EE_Ticket|null
338
-     * @throws EE_Error
339
-     * @throws InvalidDataTypeException
340
-     * @throws InvalidInterfaceException
341
-     * @throws InvalidArgumentException
342
-     */
343
-    private function getTicket(array $attributes)
344
-    {
345
-        if (! empty($attributes['ticket_id'])) {
346
-            $ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']);
347
-            if ($ticket instanceof EE_Ticket) {
348
-                return $ticket;
349
-            }
350
-        }
351
-        return null;
352
-    }
335
+	/**
336
+	 * @param array $attributes
337
+	 * @return EE_Base_Class|EE_Ticket|null
338
+	 * @throws EE_Error
339
+	 * @throws InvalidDataTypeException
340
+	 * @throws InvalidInterfaceException
341
+	 * @throws InvalidArgumentException
342
+	 */
343
+	private function getTicket(array $attributes)
344
+	{
345
+		if (! empty($attributes['ticket_id'])) {
346
+			$ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']);
347
+			if ($ticket instanceof EE_Ticket) {
348
+				return $ticket;
349
+			}
350
+		}
351
+		return null;
352
+	}
353 353
 
354 354
 
355
-    /**
356
-     * @param array $attributes
357
-     * @throws EE_Error
358
-     */
359
-    private function setAdditionalQueryParams(array $attributes)
360
-    {
361
-        $reg_status_array = EEM_Registration::reg_status_array();
362
-        if (isset($reg_status_array[ $attributes['status'] ])) {
363
-            $this->query_params[0]['Registration.STS_ID'] = $attributes['status'];
364
-        }
365
-        if (absint($attributes['limit'])) {
366
-            $this->query_params['limit'] = $attributes['limit'];
367
-        }
368
-        $this->query_params['group_by'] = array('ATT_ID');
369
-        $this->query_params['order_by'] = (array) apply_filters(
370
-            'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by',
371
-            array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC')
372
-        );
373
-    }
355
+	/**
356
+	 * @param array $attributes
357
+	 * @throws EE_Error
358
+	 */
359
+	private function setAdditionalQueryParams(array $attributes)
360
+	{
361
+		$reg_status_array = EEM_Registration::reg_status_array();
362
+		if (isset($reg_status_array[ $attributes['status'] ])) {
363
+			$this->query_params[0]['Registration.STS_ID'] = $attributes['status'];
364
+		}
365
+		if (absint($attributes['limit'])) {
366
+			$this->query_params['limit'] = $attributes['limit'];
367
+		}
368
+		$this->query_params['group_by'] = array('ATT_ID');
369
+		$this->query_params['order_by'] = (array) apply_filters(
370
+			'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by',
371
+			array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC')
372
+		);
373
+	}
374 374
 }
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoEvents.php 1 patch
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -30,131 +30,131 @@
 block discarded – undo
30 30
  */
31 31
 class EspressoEvents extends EspressoShortcode
32 32
 {
33
-    /**
34
-     * the actual shortcode tag that gets registered with WordPress
35
-     *
36
-     * @return string
37
-     */
38
-    public function getTag()
39
-    {
40
-        return 'ESPRESSO_EVENTS';
41
-    }
33
+	/**
34
+	 * the actual shortcode tag that gets registered with WordPress
35
+	 *
36
+	 * @return string
37
+	 */
38
+	public function getTag()
39
+	{
40
+		return 'ESPRESSO_EVENTS';
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * the time in seconds to cache the results of the processShortcode() method
46
-     * 0 means the processShortcode() results will NOT be cached at all
47
-     *
48
-     * @return int
49
-     */
50
-    public function cacheExpiration()
51
-    {
52
-        return 0;
53
-    }
44
+	/**
45
+	 * the time in seconds to cache the results of the processShortcode() method
46
+	 * 0 means the processShortcode() results will NOT be cached at all
47
+	 *
48
+	 * @return int
49
+	 */
50
+	public function cacheExpiration()
51
+	{
52
+		return 0;
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     * a place for adding any initialization code that needs to run prior to wp_header().
58
-     * this may be required for shortcodes that utilize a corresponding module,
59
-     * and need to enqueue assets for that module
60
-     *
61
-     * @return void
62
-     * @throws EE_Error
63
-     * @throws ReflectionException
64
-     */
65
-    public function initializeShortcode()
66
-    {
67
-        EED_Events_Archive::instance()->event_list();
68
-        $this->shortcodeHasBeenInitialized();
69
-    }
56
+	/**
57
+	 * a place for adding any initialization code that needs to run prior to wp_header().
58
+	 * this may be required for shortcodes that utilize a corresponding module,
59
+	 * and need to enqueue assets for that module
60
+	 *
61
+	 * @return void
62
+	 * @throws EE_Error
63
+	 * @throws ReflectionException
64
+	 */
65
+	public function initializeShortcode()
66
+	{
67
+		EED_Events_Archive::instance()->event_list();
68
+		$this->shortcodeHasBeenInitialized();
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * callback that runs when the shortcode is encountered in post content.
74
-     * IMPORTANT !!!
75
-     * remember that shortcode content should be RETURNED and NOT echoed out
76
-     *
77
-     * @param array|string $attributes
78
-     * @return string
79
-     * @throws EE_Error
80
-     * @throws ReflectionException
81
-     */
82
-    public function processShortcode($attributes = array())
83
-    {
84
-        // grab attributes and merge with defaults
85
-        $attributes = $this->getAttributes((array) $attributes);
86
-        // make sure we use the_excerpt()
87
-        add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true');
88
-        // apply query filters
89
-        add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
90
-        // run the query
91
-        global $wp_query;
92
-        // yes we have to overwrite the main wp query, but it's ok...
93
-        // we're going to reset it again below, so everything will be Hunky Dory (amazing album)
94
-        $wp_query = new EventListQuery($attributes);
95
-        // check what template is loaded and load filters accordingly
96
-        EED_Events_Archive::instance()->template_include('loop-espresso_events.php');
97
-        // load our template
98
-        $event_list = EEH_Template::locate_template('loop-espresso_events.php');
99
-        // now reset the query and post data
100
-        wp_reset_query();
101
-        wp_reset_postdata();
102
-        EED_Events_Archive::remove_all_events_archive_filters();
103
-        // remove query filters
104
-        remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
105
-        // pull our content from the output buffer and return it
106
-        return $event_list;
107
-    }
72
+	/**
73
+	 * callback that runs when the shortcode is encountered in post content.
74
+	 * IMPORTANT !!!
75
+	 * remember that shortcode content should be RETURNED and NOT echoed out
76
+	 *
77
+	 * @param array|string $attributes
78
+	 * @return string
79
+	 * @throws EE_Error
80
+	 * @throws ReflectionException
81
+	 */
82
+	public function processShortcode($attributes = array())
83
+	{
84
+		// grab attributes and merge with defaults
85
+		$attributes = $this->getAttributes((array) $attributes);
86
+		// make sure we use the_excerpt()
87
+		add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true');
88
+		// apply query filters
89
+		add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
90
+		// run the query
91
+		global $wp_query;
92
+		// yes we have to overwrite the main wp query, but it's ok...
93
+		// we're going to reset it again below, so everything will be Hunky Dory (amazing album)
94
+		$wp_query = new EventListQuery($attributes);
95
+		// check what template is loaded and load filters accordingly
96
+		EED_Events_Archive::instance()->template_include('loop-espresso_events.php');
97
+		// load our template
98
+		$event_list = EEH_Template::locate_template('loop-espresso_events.php');
99
+		// now reset the query and post data
100
+		wp_reset_query();
101
+		wp_reset_postdata();
102
+		EED_Events_Archive::remove_all_events_archive_filters();
103
+		// remove query filters
104
+		remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true');
105
+		// pull our content from the output buffer and return it
106
+		return $event_list;
107
+	}
108 108
 
109 109
 
110
-    /**
111
-     * merge incoming attributes with filtered defaults
112
-     *
113
-     * @param array $attributes
114
-     * @return array
115
-     */
116
-    private function getAttributes(array $attributes): array
117
-    {
118
-        return array_merge(
119
-            (array) apply_filters(
120
-                'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts',
121
-                array(
122
-                    'title'         => '',
123
-                    'limit'         => 10,
124
-                    'css_class'     => '',
125
-                    'show_expired'  => false,
126
-                    'month'         => '',
127
-                    'category_slug' => '',
128
-                    'order_by'      => 'start_date',
129
-                    'sort'          => 'ASC',
130
-                    'show_title'    => true,
131
-                )
132
-            ),
133
-            $attributes
134
-        );
135
-    }
110
+	/**
111
+	 * merge incoming attributes with filtered defaults
112
+	 *
113
+	 * @param array $attributes
114
+	 * @return array
115
+	 */
116
+	private function getAttributes(array $attributes): array
117
+	{
118
+		return array_merge(
119
+			(array) apply_filters(
120
+				'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts',
121
+				array(
122
+					'title'         => '',
123
+					'limit'         => 10,
124
+					'css_class'     => '',
125
+					'show_expired'  => false,
126
+					'month'         => '',
127
+					'category_slug' => '',
128
+					'order_by'      => 'start_date',
129
+					'sort'          => 'ASC',
130
+					'show_title'    => true,
131
+				)
132
+			),
133
+			$attributes
134
+		);
135
+	}
136 136
 
137 137
 
138
-    /**
139
-     * array for defining custom attribute sanitization callbacks,
140
-     * where keys match keys in your attributes array,
141
-     * and values represent the sanitization function you wish to be applied to that attribute.
142
-     * So for example, if you had an integer attribute named "event_id"
143
-     * that you wanted to be sanitized using absint(),
144
-     * then you would pass the following for your $custom_sanitization array:
145
-     *      array('event_id' => 'absint')
146
-     *
147
-     * @return array
148
-     */
149
-    protected function customAttributeSanitizationMap(): array
150
-    {
151
-        // the following get sanitized/whitelisted in EEH_Event_Query
152
-        return array(
153
-            'category_slug' => 'skip_sanitization',
154
-            'show_expired'  => 'skip_sanitization',
155
-            'order_by'      => 'skip_sanitization',
156
-            'month'         => 'skip_sanitization',
157
-            'sort'          => 'skip_sanitization',
158
-        );
159
-    }
138
+	/**
139
+	 * array for defining custom attribute sanitization callbacks,
140
+	 * where keys match keys in your attributes array,
141
+	 * and values represent the sanitization function you wish to be applied to that attribute.
142
+	 * So for example, if you had an integer attribute named "event_id"
143
+	 * that you wanted to be sanitized using absint(),
144
+	 * then you would pass the following for your $custom_sanitization array:
145
+	 *      array('event_id' => 'absint')
146
+	 *
147
+	 * @return array
148
+	 */
149
+	protected function customAttributeSanitizationMap(): array
150
+	{
151
+		// the following get sanitized/whitelisted in EEH_Event_Query
152
+		return array(
153
+			'category_slug' => 'skip_sanitization',
154
+			'show_expired'  => 'skip_sanitization',
155
+			'order_by'      => 'skip_sanitization',
156
+			'month'         => 'skip_sanitization',
157
+			'sort'          => 'skip_sanitization',
158
+		);
159
+	}
160 160
 }
Please login to merge, or discard this patch.