Completed
Branch FET/paypal-smart-button2 (052e8d)
by
unknown
102:07 queued 88:11
created
admin_pages/general_settings/OrganizationSettings.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,6 @@
 block discarded – undo
12 12
 use EE_Error;
13 13
 use EE_Form_Section_HTML;
14 14
 use EE_Form_Section_Proper;
15
-use EE_License_Key_Display_Strategy;
16 15
 use EE_Network_Core_Config;
17 16
 use EE_Organization_Config;
18 17
 use EE_Registry;
Please login to merge, or discard this patch.
Indentation   +469 added lines, -469 removed lines patch added patch discarded remove patch
@@ -40,494 +40,494 @@
 block discarded – undo
40 40
 class OrganizationSettings extends FormHandler
41 41
 {
42 42
 
43
-    /**
44
-     * @var EE_Organization_Config
45
-     */
46
-    protected $organization_config;
43
+	/**
44
+	 * @var EE_Organization_Config
45
+	 */
46
+	protected $organization_config;
47 47
 
48
-    /**
49
-     * @var EE_Core_Config
50
-     */
51
-    protected $core_config;
48
+	/**
49
+	 * @var EE_Core_Config
50
+	 */
51
+	protected $core_config;
52 52
 
53 53
 
54
-    /**
55
-     * @var EE_Network_Core_Config
56
-     */
57
-    protected $network_core_config;
54
+	/**
55
+	 * @var EE_Network_Core_Config
56
+	 */
57
+	protected $network_core_config;
58 58
 
59
-    /**
60
-     * Form constructor.
61
-     *
62
-     * @param EE_Registry             $registry
63
-     * @param EE_Organization_Config  $organization_config
64
-     * @param EE_Core_Config          $core_config
65
-     * @param EE_Network_Core_Config $network_core_config
66
-     * @throws InvalidArgumentException
67
-     * @throws InvalidDataTypeException
68
-     * @throws DomainException
69
-     */
70
-    public function __construct(
71
-        EE_Registry $registry,
72
-        EE_Organization_Config $organization_config,
73
-        EE_Core_Config $core_config,
74
-        EE_Network_Core_Config $network_core_config
75
-    ) {
76
-        $this->organization_config = $organization_config;
77
-        $this->core_config = $core_config;
78
-        $this->network_core_config = $network_core_config;
79
-        parent::__construct(
80
-            esc_html__('Your Organization Settings', 'event_espresso'),
81
-            esc_html__('Your Organization Settings', 'event_espresso'),
82
-            'organization_settings',
83
-            '',
84
-            FormHandler::DO_NOT_SETUP_FORM,
85
-            $registry
86
-        );
87
-    }
59
+	/**
60
+	 * Form constructor.
61
+	 *
62
+	 * @param EE_Registry             $registry
63
+	 * @param EE_Organization_Config  $organization_config
64
+	 * @param EE_Core_Config          $core_config
65
+	 * @param EE_Network_Core_Config $network_core_config
66
+	 * @throws InvalidArgumentException
67
+	 * @throws InvalidDataTypeException
68
+	 * @throws DomainException
69
+	 */
70
+	public function __construct(
71
+		EE_Registry $registry,
72
+		EE_Organization_Config $organization_config,
73
+		EE_Core_Config $core_config,
74
+		EE_Network_Core_Config $network_core_config
75
+	) {
76
+		$this->organization_config = $organization_config;
77
+		$this->core_config = $core_config;
78
+		$this->network_core_config = $network_core_config;
79
+		parent::__construct(
80
+			esc_html__('Your Organization Settings', 'event_espresso'),
81
+			esc_html__('Your Organization Settings', 'event_espresso'),
82
+			'organization_settings',
83
+			'',
84
+			FormHandler::DO_NOT_SETUP_FORM,
85
+			$registry
86
+		);
87
+	}
88 88
 
89 89
 
90 90
 
91
-    /**
92
-     * creates and returns the actual form
93
-     *
94
-     * @return EE_Form_Section_Proper
95
-     * @throws EE_Error
96
-     */
97
-    public function generate()
98
-    {
99
-        $form = new EE_Form_Section_Proper(
100
-            array(
101
-                'name'            => 'organization_settings',
102
-                'html_id'         => 'organization_settings',
103
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
104
-                'subsections'     => array(
105
-                    'site_license_key_hdr' => new EE_Form_Section_HTML(
106
-                        EEH_HTML::h2(
107
-                            esc_html__('Your Event Espresso License Key', 'event_espresso')
108
-                            . ' '
109
-                            . EEH_HTML::span(
110
-                                EEH_Template::get_help_tab_link('site_license_key_info'),
111
-                                'help_tour_activation'
112
-                            ),
113
-                            '',
114
-                            'site-license-key-hdr'
115
-                        )
116
-                    ),
117
-                    'site_license_key'     => $this->getSiteLicenseKeyField(),
118
-                    'contact_information_hdr'        => new EE_Form_Section_HTML(
119
-                        EEH_HTML::h2(
120
-                            esc_html__('Contact Information', 'event_espresso')
121
-                            . ' '
122
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
123
-                            '',
124
-                            'contact-information-hdr'
125
-                        )
126
-                    ),
127
-                    'organization_name'      => new EE_Text_Input(
128
-                        array(
129
-                            'html_name' => 'organization_name',
130
-                            'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
131
-                            'html_help_text'  => esc_html__(
132
-                                'Displayed on all emails and invoices.',
133
-                                'event_espresso'
134
-                            ),
135
-                            'default'         => $this->organization_config->get_pretty('name'),
136
-                            'required'        => false,
137
-                        )
138
-                    ),
139
-                    'organization_address_1'      => new EE_Text_Input(
140
-                        array(
141
-                            'html_name' => 'organization_address_1',
142
-                            'html_label_text' => esc_html__('Street Address', 'event_espresso'),
143
-                            'default'         => $this->organization_config->get_pretty('address_1'),
144
-                            'required'        => false,
145
-                        )
146
-                    ),
147
-                    'organization_address_2'      => new EE_Text_Input(
148
-                        array(
149
-                            'html_name' => 'organization_address_2',
150
-                            'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
151
-                            'default'         => $this->organization_config->get_pretty('address_2'),
152
-                            'required'        => false,
153
-                        )
154
-                    ),
155
-                    'organization_city'      => new EE_Text_Input(
156
-                        array(
157
-                            'html_name' => 'organization_city',
158
-                            'html_label_text' => esc_html__('City', 'event_espresso'),
159
-                            'default'         => $this->organization_config->get_pretty('city'),
160
-                            'required'        => false,
161
-                        )
162
-                    ),
163
-                    'organization_state'      => new EE_State_Select_Input(
164
-                        null,
165
-                        array(
166
-                            'html_name' => 'organization_state',
167
-                            'html_label_text' => esc_html__('State/Province', 'event_espresso'),
168
-                            'default'         => $this->organization_config->STA_ID,
169
-                            'required'        => false,
170
-                        )
171
-                    ),
172
-                    'organization_country'      => new EE_Country_Select_Input(
173
-                        null,
174
-                        array(
175
-                            'html_name' => 'organization_country',
176
-                            'html_label_text' => esc_html__('Country', 'event_espresso'),
177
-                            'default'         => $this->organization_config->CNT_ISO,
178
-                            'required'        => false,
179
-                        )
180
-                    ),
181
-                    'organization_zip'      => new EE_Text_Input(
182
-                        array(
183
-                            'html_name' => 'organization_zip',
184
-                            'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
185
-                            'default'         => $this->organization_config->get_pretty('zip'),
186
-                            'required'        => false,
187
-                        )
188
-                    ),
189
-                    'organization_email'      => new EE_Text_Input(
190
-                        array(
191
-                            'html_name' => 'organization_email',
192
-                            'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
193
-                            'html_help_text'  => sprintf(
194
-                                esc_html__(
195
-                                    'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
196
-                                    'event_espresso'
197
-                                ),
198
-                                '<code>[CO_FORMATTED_EMAIL]</code>',
199
-                                '<code>[CO_EMAIL]</code>'
200
-                            ),
201
-                            'default'         => $this->organization_config->get_pretty('email'),
202
-                            'required'        => false,
203
-                        )
204
-                    ),
205
-                    'organization_phone'      => new EE_Text_Input(
206
-                        array(
207
-                            'html_name' => 'organization_phone',
208
-                            'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
209
-                            'html_help_text'  => esc_html__(
210
-                                'The phone number for your organization.',
211
-                                'event_espresso'
212
-                            ),
213
-                            'default'         => $this->organization_config->get_pretty('phone'),
214
-                            'required'        => false,
215
-                        )
216
-                    ),
217
-                    'organization_vat'      => new EE_Text_Input(
218
-                        array(
219
-                            'html_name' => 'organization_vat',
220
-                            'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
221
-                            'html_help_text'  => esc_html__(
222
-                                'The VAT/Tax Number may be displayed on invoices and receipts.',
223
-                                'event_espresso'
224
-                            ),
225
-                            'default'         => $this->organization_config->get_pretty('vat'),
226
-                            'required'        => false,
227
-                        )
228
-                    ),
229
-                    'company_logo_hdr'        => new EE_Form_Section_HTML(
230
-                        EEH_HTML::h2(
231
-                            esc_html__('Company Logo', 'event_espresso')
232
-                            . ' '
233
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
234
-                            '',
235
-                            'company-logo-hdr'
236
-                        )
237
-                    ),
238
-                    'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
239
-                        array(
240
-                            'html_name' => 'organization_logo_url',
241
-                            'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
242
-                            'html_help_text'  => esc_html__(
243
-                                'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
244
-                                'event_espresso'
245
-                            ),
246
-                            'default'         => $this->organization_config->get_pretty('logo_url'),
247
-                            'required'        => false,
248
-                        )
249
-                    ),
250
-                    'social_links_hdr'        => new EE_Form_Section_HTML(
251
-                        EEH_HTML::h2(
252
-                            esc_html__('Social Links', 'event_espresso')
253
-                            . ' '
254
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
255
-                            . EEH_HTML::br()
256
-                            . EEH_HTML::p(
257
-                                esc_html__(
258
-                                    'Enter any links to social accounts for your organization here',
259
-                                    'event_espresso'
260
-                                ),
261
-                                '',
262
-                                'description'
263
-                            ),
264
-                            '',
265
-                            'social-links-hdr'
266
-                        )
267
-                    ),
268
-                    'organization_facebook'      => new EE_Text_Input(
269
-                        array(
270
-                            'html_name' => 'organization_facebook',
271
-                            'html_label_text' => esc_html__('Facebook', 'event_espresso'),
272
-                            'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
273
-                            'default'         => $this->organization_config->get_pretty('facebook'),
274
-                            'required'        => false,
275
-                        )
276
-                    ),
277
-                    'organization_twitter'      => new EE_Text_Input(
278
-                        array(
279
-                            'html_name' => 'organization_twitter',
280
-                            'html_label_text' => esc_html__('Twitter', 'event_espresso'),
281
-                            'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
282
-                            'default'         => $this->organization_config->get_pretty('twitter'),
283
-                            'required'        => false,
284
-                        )
285
-                    ),
286
-                    'organization_linkedin'      => new EE_Text_Input(
287
-                        array(
288
-                            'html_name' => 'organization_linkedin',
289
-                            'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
290
-                            'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
291
-                            'default'         => $this->organization_config->get_pretty('linkedin'),
292
-                            'required'        => false,
293
-                        )
294
-                    ),
295
-                    'organization_pinterest'      => new EE_Text_Input(
296
-                        array(
297
-                            'html_name' => 'organization_pinterest',
298
-                            'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
299
-                            'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
300
-                            'default'         => $this->organization_config->get_pretty('pinterest'),
301
-                            'required'        => false,
302
-                        )
303
-                    ),
304
-                    'organization_google'      => new EE_Text_Input(
305
-                        array(
306
-                            'html_name' => 'organization_google',
307
-                            'html_label_text' => esc_html__('Google+', 'event_espresso'),
308
-                            'other_html_attributes' => ' placeholder="google.com/+profilename"',
309
-                            'default'         => $this->organization_config->get_pretty('google'),
310
-                            'required'        => false,
311
-                        )
312
-                    ),
313
-                    'organization_instagram'      => new EE_Text_Input(
314
-                        array(
315
-                            'html_name' => 'organization_instagram',
316
-                            'html_label_text' => esc_html__('Instagram', 'event_espresso'),
317
-                            'other_html_attributes' => ' placeholder="instagram.com/handle"',
318
-                            'default'         => $this->organization_config->get_pretty('instagram'),
319
-                            'required'        => false,
320
-                        )
321
-                    ),
322
-                ),
323
-            )
324
-        );
325
-        if (is_main_site()) {
326
-            $form->add_subsections(
327
-                array(
328
-                    'uxip_optin_hdr'  => new EE_Form_Section_HTML(
329
-                        $this->uxipOptinText()
330
-                    ),
331
-                    'ueip_optin' => new EE_Checkbox_Multi_Input(
332
-                        array(
333
-                            true => __('Yes! I want to help improve Event Espresso!', 'event_espresso')
334
-                        ),
335
-                        array(
336
-                            'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
337
-                            'html_label_text' => esc_html__(
338
-                                'UXIP Opt In?',
339
-                                'event_espresso'
340
-                            ),
341
-                            'default'         => isset($this->core_config->ee_ueip_optin)
342
-                                ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
343
-                                : false,
344
-                            'required'        => false,
345
-                        )
346
-                    ),
347
-                ),
348
-                'organization_instagram',
349
-                false
350
-            );
351
-        }
352
-        return $form;
353
-    }
91
+	/**
92
+	 * creates and returns the actual form
93
+	 *
94
+	 * @return EE_Form_Section_Proper
95
+	 * @throws EE_Error
96
+	 */
97
+	public function generate()
98
+	{
99
+		$form = new EE_Form_Section_Proper(
100
+			array(
101
+				'name'            => 'organization_settings',
102
+				'html_id'         => 'organization_settings',
103
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
104
+				'subsections'     => array(
105
+					'site_license_key_hdr' => new EE_Form_Section_HTML(
106
+						EEH_HTML::h2(
107
+							esc_html__('Your Event Espresso License Key', 'event_espresso')
108
+							. ' '
109
+							. EEH_HTML::span(
110
+								EEH_Template::get_help_tab_link('site_license_key_info'),
111
+								'help_tour_activation'
112
+							),
113
+							'',
114
+							'site-license-key-hdr'
115
+						)
116
+					),
117
+					'site_license_key'     => $this->getSiteLicenseKeyField(),
118
+					'contact_information_hdr'        => new EE_Form_Section_HTML(
119
+						EEH_HTML::h2(
120
+							esc_html__('Contact Information', 'event_espresso')
121
+							. ' '
122
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
123
+							'',
124
+							'contact-information-hdr'
125
+						)
126
+					),
127
+					'organization_name'      => new EE_Text_Input(
128
+						array(
129
+							'html_name' => 'organization_name',
130
+							'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
131
+							'html_help_text'  => esc_html__(
132
+								'Displayed on all emails and invoices.',
133
+								'event_espresso'
134
+							),
135
+							'default'         => $this->organization_config->get_pretty('name'),
136
+							'required'        => false,
137
+						)
138
+					),
139
+					'organization_address_1'      => new EE_Text_Input(
140
+						array(
141
+							'html_name' => 'organization_address_1',
142
+							'html_label_text' => esc_html__('Street Address', 'event_espresso'),
143
+							'default'         => $this->organization_config->get_pretty('address_1'),
144
+							'required'        => false,
145
+						)
146
+					),
147
+					'organization_address_2'      => new EE_Text_Input(
148
+						array(
149
+							'html_name' => 'organization_address_2',
150
+							'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
151
+							'default'         => $this->organization_config->get_pretty('address_2'),
152
+							'required'        => false,
153
+						)
154
+					),
155
+					'organization_city'      => new EE_Text_Input(
156
+						array(
157
+							'html_name' => 'organization_city',
158
+							'html_label_text' => esc_html__('City', 'event_espresso'),
159
+							'default'         => $this->organization_config->get_pretty('city'),
160
+							'required'        => false,
161
+						)
162
+					),
163
+					'organization_state'      => new EE_State_Select_Input(
164
+						null,
165
+						array(
166
+							'html_name' => 'organization_state',
167
+							'html_label_text' => esc_html__('State/Province', 'event_espresso'),
168
+							'default'         => $this->organization_config->STA_ID,
169
+							'required'        => false,
170
+						)
171
+					),
172
+					'organization_country'      => new EE_Country_Select_Input(
173
+						null,
174
+						array(
175
+							'html_name' => 'organization_country',
176
+							'html_label_text' => esc_html__('Country', 'event_espresso'),
177
+							'default'         => $this->organization_config->CNT_ISO,
178
+							'required'        => false,
179
+						)
180
+					),
181
+					'organization_zip'      => new EE_Text_Input(
182
+						array(
183
+							'html_name' => 'organization_zip',
184
+							'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
185
+							'default'         => $this->organization_config->get_pretty('zip'),
186
+							'required'        => false,
187
+						)
188
+					),
189
+					'organization_email'      => new EE_Text_Input(
190
+						array(
191
+							'html_name' => 'organization_email',
192
+							'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
193
+							'html_help_text'  => sprintf(
194
+								esc_html__(
195
+									'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
196
+									'event_espresso'
197
+								),
198
+								'<code>[CO_FORMATTED_EMAIL]</code>',
199
+								'<code>[CO_EMAIL]</code>'
200
+							),
201
+							'default'         => $this->organization_config->get_pretty('email'),
202
+							'required'        => false,
203
+						)
204
+					),
205
+					'organization_phone'      => new EE_Text_Input(
206
+						array(
207
+							'html_name' => 'organization_phone',
208
+							'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
209
+							'html_help_text'  => esc_html__(
210
+								'The phone number for your organization.',
211
+								'event_espresso'
212
+							),
213
+							'default'         => $this->organization_config->get_pretty('phone'),
214
+							'required'        => false,
215
+						)
216
+					),
217
+					'organization_vat'      => new EE_Text_Input(
218
+						array(
219
+							'html_name' => 'organization_vat',
220
+							'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
221
+							'html_help_text'  => esc_html__(
222
+								'The VAT/Tax Number may be displayed on invoices and receipts.',
223
+								'event_espresso'
224
+							),
225
+							'default'         => $this->organization_config->get_pretty('vat'),
226
+							'required'        => false,
227
+						)
228
+					),
229
+					'company_logo_hdr'        => new EE_Form_Section_HTML(
230
+						EEH_HTML::h2(
231
+							esc_html__('Company Logo', 'event_espresso')
232
+							. ' '
233
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
234
+							'',
235
+							'company-logo-hdr'
236
+						)
237
+					),
238
+					'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
239
+						array(
240
+							'html_name' => 'organization_logo_url',
241
+							'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
242
+							'html_help_text'  => esc_html__(
243
+								'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
244
+								'event_espresso'
245
+							),
246
+							'default'         => $this->organization_config->get_pretty('logo_url'),
247
+							'required'        => false,
248
+						)
249
+					),
250
+					'social_links_hdr'        => new EE_Form_Section_HTML(
251
+						EEH_HTML::h2(
252
+							esc_html__('Social Links', 'event_espresso')
253
+							. ' '
254
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
255
+							. EEH_HTML::br()
256
+							. EEH_HTML::p(
257
+								esc_html__(
258
+									'Enter any links to social accounts for your organization here',
259
+									'event_espresso'
260
+								),
261
+								'',
262
+								'description'
263
+							),
264
+							'',
265
+							'social-links-hdr'
266
+						)
267
+					),
268
+					'organization_facebook'      => new EE_Text_Input(
269
+						array(
270
+							'html_name' => 'organization_facebook',
271
+							'html_label_text' => esc_html__('Facebook', 'event_espresso'),
272
+							'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
273
+							'default'         => $this->organization_config->get_pretty('facebook'),
274
+							'required'        => false,
275
+						)
276
+					),
277
+					'organization_twitter'      => new EE_Text_Input(
278
+						array(
279
+							'html_name' => 'organization_twitter',
280
+							'html_label_text' => esc_html__('Twitter', 'event_espresso'),
281
+							'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
282
+							'default'         => $this->organization_config->get_pretty('twitter'),
283
+							'required'        => false,
284
+						)
285
+					),
286
+					'organization_linkedin'      => new EE_Text_Input(
287
+						array(
288
+							'html_name' => 'organization_linkedin',
289
+							'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
290
+							'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
291
+							'default'         => $this->organization_config->get_pretty('linkedin'),
292
+							'required'        => false,
293
+						)
294
+					),
295
+					'organization_pinterest'      => new EE_Text_Input(
296
+						array(
297
+							'html_name' => 'organization_pinterest',
298
+							'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
299
+							'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
300
+							'default'         => $this->organization_config->get_pretty('pinterest'),
301
+							'required'        => false,
302
+						)
303
+					),
304
+					'organization_google'      => new EE_Text_Input(
305
+						array(
306
+							'html_name' => 'organization_google',
307
+							'html_label_text' => esc_html__('Google+', 'event_espresso'),
308
+							'other_html_attributes' => ' placeholder="google.com/+profilename"',
309
+							'default'         => $this->organization_config->get_pretty('google'),
310
+							'required'        => false,
311
+						)
312
+					),
313
+					'organization_instagram'      => new EE_Text_Input(
314
+						array(
315
+							'html_name' => 'organization_instagram',
316
+							'html_label_text' => esc_html__('Instagram', 'event_espresso'),
317
+							'other_html_attributes' => ' placeholder="instagram.com/handle"',
318
+							'default'         => $this->organization_config->get_pretty('instagram'),
319
+							'required'        => false,
320
+						)
321
+					),
322
+				),
323
+			)
324
+		);
325
+		if (is_main_site()) {
326
+			$form->add_subsections(
327
+				array(
328
+					'uxip_optin_hdr'  => new EE_Form_Section_HTML(
329
+						$this->uxipOptinText()
330
+					),
331
+					'ueip_optin' => new EE_Checkbox_Multi_Input(
332
+						array(
333
+							true => __('Yes! I want to help improve Event Espresso!', 'event_espresso')
334
+						),
335
+						array(
336
+							'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
337
+							'html_label_text' => esc_html__(
338
+								'UXIP Opt In?',
339
+								'event_espresso'
340
+							),
341
+							'default'         => isset($this->core_config->ee_ueip_optin)
342
+								? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
343
+								: false,
344
+							'required'        => false,
345
+						)
346
+					),
347
+				),
348
+				'organization_instagram',
349
+				false
350
+			);
351
+		}
352
+		return $form;
353
+	}
354 354
 
355 355
 
356
-    /**
357
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
358
-     * returns a string of HTML that can be directly echoed in a template
359
-     *
360
-     * @return string
361
-     * @throws EE_Error
362
-     * @throws InvalidArgumentException
363
-     * @throws InvalidDataTypeException
364
-     * @throws InvalidInterfaceException
365
-     * @throws LogicException
366
-     */
367
-    public function display()
368
-    {
369
-        $this->form()->enqueue_js();
370
-        return parent::display();
371
-    }
356
+	/**
357
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
358
+	 * returns a string of HTML that can be directly echoed in a template
359
+	 *
360
+	 * @return string
361
+	 * @throws EE_Error
362
+	 * @throws InvalidArgumentException
363
+	 * @throws InvalidDataTypeException
364
+	 * @throws InvalidInterfaceException
365
+	 * @throws LogicException
366
+	 */
367
+	public function display()
368
+	{
369
+		$this->form()->enqueue_js();
370
+		return parent::display();
371
+	}
372 372
 
373 373
 
374
-    /**
375
-     * handles processing the form submission
376
-     * returns true or false depending on whether the form was processed successfully or not
377
-     *
378
-     * @param array $form_data
379
-     * @return bool
380
-     * @throws InvalidFormSubmissionException
381
-     * @throws EE_Error
382
-     * @throws LogicException
383
-     * @throws InvalidArgumentException
384
-     * @throws InvalidDataTypeException
385
-     */
386
-    public function process($form_data = array())
387
-    {
388
-        // process form
389
-        $valid_data = (array) parent::process($form_data);
390
-        if (empty($valid_data)) {
391
-            return false;
392
-        }
374
+	/**
375
+	 * handles processing the form submission
376
+	 * returns true or false depending on whether the form was processed successfully or not
377
+	 *
378
+	 * @param array $form_data
379
+	 * @return bool
380
+	 * @throws InvalidFormSubmissionException
381
+	 * @throws EE_Error
382
+	 * @throws LogicException
383
+	 * @throws InvalidArgumentException
384
+	 * @throws InvalidDataTypeException
385
+	 */
386
+	public function process($form_data = array())
387
+	{
388
+		// process form
389
+		$valid_data = (array) parent::process($form_data);
390
+		if (empty($valid_data)) {
391
+			return false;
392
+		}
393 393
 
394
-        if (is_main_site()) {
395
-            $this->network_core_config->site_license_key = isset($form_data['site_license_key'])
396
-                ? sanitize_text_field($form_data['site_license_key'])
397
-                : $this->network_core_config->site_license_key;
398
-        }
399
-        $this->organization_config->name = isset($form_data['organization_name'])
400
-            ? sanitize_text_field($form_data['organization_name'])
401
-            : $this->organization_config->name;
402
-        $this->organization_config->address_1 = isset($form_data['organization_address_1'])
403
-            ? sanitize_text_field($form_data['organization_address_1'])
404
-            : $this->organization_config->address_1;
405
-        $this->organization_config->address_2 = isset($form_data['organization_address_2'])
406
-            ? sanitize_text_field($form_data['organization_address_2'])
407
-            : $this->organization_config->address_2;
408
-        $this->organization_config->city = isset($form_data['organization_city'])
409
-            ? sanitize_text_field($form_data['organization_city'])
410
-            : $this->organization_config->city;
411
-        $this->organization_config->STA_ID = isset($form_data['organization_state'])
412
-            ? absint($form_data['organization_state'])
413
-            : $this->organization_config->STA_ID;
414
-        $this->organization_config->CNT_ISO = isset($form_data['organization_country'])
415
-            ? sanitize_text_field($form_data['organization_country'])
416
-            : $this->organization_config->CNT_ISO;
417
-        $this->organization_config->zip = isset($form_data['organization_zip'])
418
-            ? sanitize_text_field($form_data['organization_zip'])
419
-            : $this->organization_config->zip;
420
-        $this->organization_config->email = isset($form_data['organization_email'])
421
-            ? sanitize_email($form_data['organization_email'])
422
-            : $this->organization_config->email;
423
-        $this->organization_config->vat = isset($form_data['organization_vat'])
424
-            ? sanitize_text_field($form_data['organization_vat'])
425
-            : $this->organization_config->vat;
426
-        $this->organization_config->phone = isset($form_data['organization_phone'])
427
-            ? sanitize_text_field($form_data['organization_phone'])
428
-            : $this->organization_config->phone;
429
-        $this->organization_config->logo_url = isset($form_data['organization_logo_url'])
430
-            ? esc_url_raw($form_data['organization_logo_url'])
431
-            : $this->organization_config->logo_url;
432
-        $this->organization_config->facebook = isset($form_data['organization_facebook'])
433
-            ? esc_url_raw($form_data['organization_facebook'])
434
-            : $this->organization_config->facebook;
435
-        $this->organization_config->twitter = isset($form_data['organization_twitter'])
436
-            ? esc_url_raw($form_data['organization_twitter'])
437
-            : $this->organization_config->twitter;
438
-        $this->organization_config->linkedin = isset($form_data['organization_linkedin'])
439
-            ? esc_url_raw($form_data['organization_linkedin'])
440
-            : $this->organization_config->linkedin;
441
-        $this->organization_config->pinterest = isset($form_data['organization_pinterest'])
442
-            ? esc_url_raw($form_data['organization_pinterest'])
443
-            : $this->organization_config->pinterest;
444
-        $this->organization_config->google = isset($form_data['organization_google'])
445
-            ? esc_url_raw($form_data['organization_google'])
446
-            : $this->organization_config->google;
447
-        $this->organization_config->instagram = isset($form_data['organization_instagram'])
448
-            ? esc_url_raw($form_data['organization_instagram'])
449
-            : $this->organization_config->instagram;
450
-        $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
451
-            ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
452
-            : false;
453
-        $this->core_config->ee_ueip_has_notified = true;
394
+		if (is_main_site()) {
395
+			$this->network_core_config->site_license_key = isset($form_data['site_license_key'])
396
+				? sanitize_text_field($form_data['site_license_key'])
397
+				: $this->network_core_config->site_license_key;
398
+		}
399
+		$this->organization_config->name = isset($form_data['organization_name'])
400
+			? sanitize_text_field($form_data['organization_name'])
401
+			: $this->organization_config->name;
402
+		$this->organization_config->address_1 = isset($form_data['organization_address_1'])
403
+			? sanitize_text_field($form_data['organization_address_1'])
404
+			: $this->organization_config->address_1;
405
+		$this->organization_config->address_2 = isset($form_data['organization_address_2'])
406
+			? sanitize_text_field($form_data['organization_address_2'])
407
+			: $this->organization_config->address_2;
408
+		$this->organization_config->city = isset($form_data['organization_city'])
409
+			? sanitize_text_field($form_data['organization_city'])
410
+			: $this->organization_config->city;
411
+		$this->organization_config->STA_ID = isset($form_data['organization_state'])
412
+			? absint($form_data['organization_state'])
413
+			: $this->organization_config->STA_ID;
414
+		$this->organization_config->CNT_ISO = isset($form_data['organization_country'])
415
+			? sanitize_text_field($form_data['organization_country'])
416
+			: $this->organization_config->CNT_ISO;
417
+		$this->organization_config->zip = isset($form_data['organization_zip'])
418
+			? sanitize_text_field($form_data['organization_zip'])
419
+			: $this->organization_config->zip;
420
+		$this->organization_config->email = isset($form_data['organization_email'])
421
+			? sanitize_email($form_data['organization_email'])
422
+			: $this->organization_config->email;
423
+		$this->organization_config->vat = isset($form_data['organization_vat'])
424
+			? sanitize_text_field($form_data['organization_vat'])
425
+			: $this->organization_config->vat;
426
+		$this->organization_config->phone = isset($form_data['organization_phone'])
427
+			? sanitize_text_field($form_data['organization_phone'])
428
+			: $this->organization_config->phone;
429
+		$this->organization_config->logo_url = isset($form_data['organization_logo_url'])
430
+			? esc_url_raw($form_data['organization_logo_url'])
431
+			: $this->organization_config->logo_url;
432
+		$this->organization_config->facebook = isset($form_data['organization_facebook'])
433
+			? esc_url_raw($form_data['organization_facebook'])
434
+			: $this->organization_config->facebook;
435
+		$this->organization_config->twitter = isset($form_data['organization_twitter'])
436
+			? esc_url_raw($form_data['organization_twitter'])
437
+			: $this->organization_config->twitter;
438
+		$this->organization_config->linkedin = isset($form_data['organization_linkedin'])
439
+			? esc_url_raw($form_data['organization_linkedin'])
440
+			: $this->organization_config->linkedin;
441
+		$this->organization_config->pinterest = isset($form_data['organization_pinterest'])
442
+			? esc_url_raw($form_data['organization_pinterest'])
443
+			: $this->organization_config->pinterest;
444
+		$this->organization_config->google = isset($form_data['organization_google'])
445
+			? esc_url_raw($form_data['organization_google'])
446
+			: $this->organization_config->google;
447
+		$this->organization_config->instagram = isset($form_data['organization_instagram'])
448
+			? esc_url_raw($form_data['organization_instagram'])
449
+			: $this->organization_config->instagram;
450
+		$this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
451
+			? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
452
+			: false;
453
+		$this->core_config->ee_ueip_has_notified = true;
454 454
 
455
-        $this->registry->CFG->currency = new EE_Currency_Config(
456
-            $this->organization_config->CNT_ISO
457
-        );
458
-        return true;
459
-    }
455
+		$this->registry->CFG->currency = new EE_Currency_Config(
456
+			$this->organization_config->CNT_ISO
457
+		);
458
+		return true;
459
+	}
460 460
 
461 461
 
462
-    /**
463
-     * @return string
464
-     */
465
-    private function uxipOptinText()
466
-    {
467
-        ob_start();
468
-        Stats::optinText(false);
469
-        return ob_get_clean();
470
-    }
462
+	/**
463
+	 * @return string
464
+	 */
465
+	private function uxipOptinText()
466
+	{
467
+		ob_start();
468
+		Stats::optinText(false);
469
+		return ob_get_clean();
470
+	}
471 471
 
472 472
 
473
-    /**
474
-     * Return whether the site license key has been verified or not.
475
-     * @return bool
476
-     */
477
-    private function licenseKeyVerified()
478
-    {
479
-        if (empty($this->network_core_config->site_license_key)) {
480
-            return false;
481
-        }
482
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
483
-        $verify_fail = get_option($ver_option_key, false);
484
-        return $verify_fail === false
485
-                  || (! empty($this->network_core_config->site_license_key)
486
-                        && $verify_fail === false
487
-                  );
488
-    }
473
+	/**
474
+	 * Return whether the site license key has been verified or not.
475
+	 * @return bool
476
+	 */
477
+	private function licenseKeyVerified()
478
+	{
479
+		if (empty($this->network_core_config->site_license_key)) {
480
+			return false;
481
+		}
482
+		$ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
483
+		$verify_fail = get_option($ver_option_key, false);
484
+		return $verify_fail === false
485
+				  || (! empty($this->network_core_config->site_license_key)
486
+						&& $verify_fail === false
487
+				  );
488
+	}
489 489
 
490 490
 
491
-    /**
492
-     * @return EE_Text_Input
493
-     */
494
-    private function getSiteLicenseKeyField()
495
-    {
496
-        $text_input = new EE_Text_Input(
497
-            array(
498
-                'html_name' => 'site_license_key',
499
-                'html_id' => 'site_license_key',
500
-                'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
501
-                /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
502
-                'html_help_text'  => sprintf(
503
-                    esc_html__(
504
-                        'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
505
-                        'event_espresso'
506
-                    ),
507
-                    '<strong>',
508
-                    '</strong>'
509
-                ),
510
-                /** phpcs:enable */
511
-                'default'         => isset($this->network_core_config->site_license_key)
512
-                    ? $this->network_core_config->site_license_key
513
-                    : '',
514
-                'required'        => false,
515
-                'form_html_filter' => new VsprintfFilter(
516
-                    '%2$s %1$s',
517
-                    array($this->getValidationIndicator())
518
-                )
519
-            )
520
-        );
521
-        return $text_input;
522
-    }
491
+	/**
492
+	 * @return EE_Text_Input
493
+	 */
494
+	private function getSiteLicenseKeyField()
495
+	{
496
+		$text_input = new EE_Text_Input(
497
+			array(
498
+				'html_name' => 'site_license_key',
499
+				'html_id' => 'site_license_key',
500
+				'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
501
+				/** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
502
+				'html_help_text'  => sprintf(
503
+					esc_html__(
504
+						'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
505
+						'event_espresso'
506
+					),
507
+					'<strong>',
508
+					'</strong>'
509
+				),
510
+				/** phpcs:enable */
511
+				'default'         => isset($this->network_core_config->site_license_key)
512
+					? $this->network_core_config->site_license_key
513
+					: '',
514
+				'required'        => false,
515
+				'form_html_filter' => new VsprintfFilter(
516
+					'%2$s %1$s',
517
+					array($this->getValidationIndicator())
518
+				)
519
+			)
520
+		);
521
+		return $text_input;
522
+	}
523 523
 
524 524
 
525
-    /**
526
-     * @return string
527
-     */
528
-    private function getValidationIndicator()
529
-    {
530
-        $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
531
-        return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
532
-    }
525
+	/**
526
+	 * @return string
527
+	 */
528
+	private function getValidationIndicator()
529
+	{
530
+		$verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
531
+		return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
532
+	}
533 533
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -447,8 +447,8 @@  discard block
 block discarded – undo
447 447
         $this->organization_config->instagram = isset($form_data['organization_instagram'])
448 448
             ? esc_url_raw($form_data['organization_instagram'])
449 449
             : $this->organization_config->instagram;
450
-        $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
451
-            ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
450
+        $this->core_config->ee_ueip_optin = isset($form_data[EE_Core_Config::OPTION_NAME_UXIP][0])
451
+            ? filter_var($form_data[EE_Core_Config::OPTION_NAME_UXIP][0], FILTER_VALIDATE_BOOLEAN)
452 452
             : false;
453 453
         $this->core_config->ee_ueip_has_notified = true;
454 454
 
@@ -479,10 +479,10 @@  discard block
 block discarded – undo
479 479
         if (empty($this->network_core_config->site_license_key)) {
480 480
             return false;
481 481
         }
482
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
482
+        $ver_option_key = 'puvererr_'.basename(EE_PLUGIN_BASENAME);
483 483
         $verify_fail = get_option($ver_option_key, false);
484 484
         return $verify_fail === false
485
-                  || (! empty($this->network_core_config->site_license_key)
485
+                  || ( ! empty($this->network_core_config->site_license_key)
486 486
                         && $verify_fail === false
487 487
                   );
488 488
     }
@@ -528,6 +528,6 @@  discard block
 block discarded – undo
528 528
     private function getValidationIndicator()
529 529
     {
530 530
         $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
531
-        return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
531
+        return '<span class="dashicons dashicons-admin-network '.$verified_class.' ee-icon-size-20"></span>';
532 532
     }
533 533
 }
Please login to merge, or discard this patch.
core/domain/services/pue/Stats.php 1 patch
Indentation   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -22,86 +22,86 @@  discard block
 block discarded – undo
22 22
 class Stats
23 23
 {
24 24
 
25
-    const OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS = 'ee_uxip_stats_expiry';
26
-
27
-    /**
28
-     * @var Config
29
-     */
30
-    private $config;
31
-
32
-
33
-    /**
34
-     * @var StatsGatherer
35
-     */
36
-    private $stats_gatherer;
37
-
38
-
39
-    /**
40
-     * @var EE_Maintenance_Mode
41
-     */
42
-    private $maintenance_mode;
43
-
44
-    public function __construct(
45
-        Config $config,
46
-        EE_Maintenance_Mode $maintenance_mode,
47
-        StatsGatherer $stats_gatherer
48
-    ) {
49
-        $this->config = $config;
50
-        $this->maintenance_mode = $maintenance_mode;
51
-        $this->stats_gatherer = $stats_gatherer;
52
-        $this->setUxipNotices();
53
-    }
54
-
55
-
56
-    /**
57
-     * Displays uxip opt-in notice if necessary.
58
-     */
59
-    private function setUxipNotices()
60
-    {
61
-        if ($this->canDisplayNotices()) {
62
-            add_action('admin_notices', array($this, 'optinNotice'));
63
-            add_action('admin_enqueue_scripts', array($this, 'enqueueScripts'));
64
-            add_action('wp_ajax_espresso_data_optin', array($this, 'ajaxHandler'));
65
-        }
66
-    }
67
-
68
-
69
-    /**
70
-     * This returns the callback that PluginUpdateEngineChecker will use for getting any extra stats to send.
71
-     *
72
-     * @return Closure
73
-     */
74
-    public function statsCallback()
75
-    {
76
-        // returns a callback that can is used to retrieve the stats to send along to the pue server.
77
-        return function () {
78
-            // we only send stats one a week, so let's see if our stat timestamp has expired.
79
-            if (! $this->sendStats()) {
80
-                return array();
81
-            }
82
-            return $this->stats_gatherer->stats();
83
-        };
84
-    }
85
-
86
-
87
-    /**
88
-     * Return whether notices can be displayed or not
89
-     *
90
-     * @return bool
91
-     */
92
-    private function canDisplayNotices()
93
-    {
94
-        return ! $this->config->hasNotifiedForUxip()
95
-               && $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
96
-    }
97
-
98
-
99
-    /**
100
-     * Callback for the admin_notices hook that outputs the UXIP optin-in notice.
101
-     */
102
-    public function optinNotice()
103
-    {
104
-        ?>
25
+	const OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS = 'ee_uxip_stats_expiry';
26
+
27
+	/**
28
+	 * @var Config
29
+	 */
30
+	private $config;
31
+
32
+
33
+	/**
34
+	 * @var StatsGatherer
35
+	 */
36
+	private $stats_gatherer;
37
+
38
+
39
+	/**
40
+	 * @var EE_Maintenance_Mode
41
+	 */
42
+	private $maintenance_mode;
43
+
44
+	public function __construct(
45
+		Config $config,
46
+		EE_Maintenance_Mode $maintenance_mode,
47
+		StatsGatherer $stats_gatherer
48
+	) {
49
+		$this->config = $config;
50
+		$this->maintenance_mode = $maintenance_mode;
51
+		$this->stats_gatherer = $stats_gatherer;
52
+		$this->setUxipNotices();
53
+	}
54
+
55
+
56
+	/**
57
+	 * Displays uxip opt-in notice if necessary.
58
+	 */
59
+	private function setUxipNotices()
60
+	{
61
+		if ($this->canDisplayNotices()) {
62
+			add_action('admin_notices', array($this, 'optinNotice'));
63
+			add_action('admin_enqueue_scripts', array($this, 'enqueueScripts'));
64
+			add_action('wp_ajax_espresso_data_optin', array($this, 'ajaxHandler'));
65
+		}
66
+	}
67
+
68
+
69
+	/**
70
+	 * This returns the callback that PluginUpdateEngineChecker will use for getting any extra stats to send.
71
+	 *
72
+	 * @return Closure
73
+	 */
74
+	public function statsCallback()
75
+	{
76
+		// returns a callback that can is used to retrieve the stats to send along to the pue server.
77
+		return function () {
78
+			// we only send stats one a week, so let's see if our stat timestamp has expired.
79
+			if (! $this->sendStats()) {
80
+				return array();
81
+			}
82
+			return $this->stats_gatherer->stats();
83
+		};
84
+	}
85
+
86
+
87
+	/**
88
+	 * Return whether notices can be displayed or not
89
+	 *
90
+	 * @return bool
91
+	 */
92
+	private function canDisplayNotices()
93
+	{
94
+		return ! $this->config->hasNotifiedForUxip()
95
+			   && $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
96
+	}
97
+
98
+
99
+	/**
100
+	 * Callback for the admin_notices hook that outputs the UXIP optin-in notice.
101
+	 */
102
+	public function optinNotice()
103
+	{
104
+		?>
105 105
         <div class="updated data-collect-optin" id="espresso-data-collect-optin-container">
106 106
             <div id="data-collect-optin-options-container">
107 107
                 <span class="dashicons dashicons-admin-site"></span>
@@ -114,125 +114,125 @@  discard block
 block discarded – undo
114 114
             </div>
115 115
         </div>
116 116
         <?php
117
-    }
118
-
119
-
120
-    /**
121
-     * Retrieves the optin text (static so it can be used in multiple places as necessary).
122
-     *
123
-     * @param bool $extra
124
-     */
125
-    public static function optinText($extra = true)
126
-    {
127
-        if (! $extra) {
128
-            echo '<h2 class="ee-admin-settings-hdr" '
129
-                 . (! $extra ? 'id="UXIP_settings"' : '')
130
-                 . '>'
131
-                 . esc_html__('User eXperience Improvement Program (UXIP)', 'event_espresso')
132
-                 . EEH_Template::get_help_tab_link('organization_logo_info')
133
-                 . '</h2>';
134
-            printf(
135
-                esc_html__(
136
-                    '%1$sPlease help us make Event Espresso better and vote for your favorite features.%2$s The %3$sUser eXperience Improvement Program (UXIP)%4$s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary and it is disabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %5$sPlease see our %6$sPrivacy Policy%7$s for more information.',
137
-                    'event_espresso'
138
-                ),
139
-                '<p><em>',
140
-                '</em></p>',
141
-                '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
142
-                '</a>',
143
-                '<br><br>',
144
-                '<a href="https://eventespresso.com/about/privacy-policy/" target="_blank">',
145
-                '</a>'
146
-            );
147
-        } else {
148
-            $settings_url = EE_Admin_Page::add_query_args_and_nonce(
149
-                array('action' => 'default'),
150
-                admin_url('admin.php?page=espresso_general_settings')
151
-            );
152
-            $settings_url .= '#UXIP_settings';
153
-            printf(
154
-                esc_html__(
155
-                    'The Event Espresso UXIP feature is not yet active on your site. For %1$smore info%2$s and to opt-in %3$sclick here%4$s.',
156
-                    'event_espresso'
157
-                ),
158
-                '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
159
-                '</a>',
160
-                '<a href="' . $settings_url . '" target="_blank">',
161
-                '</a>'
162
-            );
163
-        }
164
-    }
165
-
166
-
167
-    /**
168
-     * Callback for admin_enqueue_scripts that sets up the scripts and styles for the uxip notice
169
-     */
170
-    public function enqueueScripts()
171
-    {
172
-        wp_register_script(
173
-            'ee-data-optin-js',
174
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js',
175
-            array('jquery'),
176
-            EVENT_ESPRESSO_VERSION,
177
-            true
178
-        );
179
-        wp_register_style(
180
-            'ee-data-optin-css',
181
-            EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css',
182
-            array(),
183
-            EVENT_ESPRESSO_VERSION
184
-        );
185
-
186
-        wp_enqueue_script('ee-data-optin-js');
187
-        wp_enqueue_style('ee-data-optin-css');
188
-    }
189
-
190
-
191
-    /**
192
-     * Callback for wp_ajax_espresso_data_optin that handles the ajax request
193
-     */
194
-    public function ajaxHandler()
195
-    {
196
-        // verify nonce
197
-        if (isset($_POST['nonce']) && ! wp_verify_nonce($_POST['nonce'], 'ee-data-optin')) {
198
-            exit();
199
-        }
200
-
201
-        // update has notified option
202
-        $this->config->setHasNotifiedAboutUxip();
203
-        exit();
204
-    }
205
-
206
-
207
-    /**
208
-     * Used to determine whether additional stats are sent.
209
-     */
210
-    private function sendStats()
211
-    {
212
-        return $this->config->isOptedInForUxip()
213
-               && $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
214
-               && $this->statSendTimestampExpired();
215
-    }
216
-
217
-
218
-    /**
219
-     * Returns true when the timestamp used to track whether stats get sent (currently a weekly interval) is expired.
220
-     * Returns false otherwise.
221
-     *
222
-     * @return bool
223
-     */
224
-    private function statSendTimestampExpired()
225
-    {
226
-        $current_expiry = get_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, null);
227
-        if ($current_expiry === null) {
228
-            add_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS, '', 'no');
229
-            return true;
230
-        }
231
-
232
-        if (time() > (int) $current_expiry) {
233
-            update_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS);
234
-            return true;
235
-        }
236
-        return false;
237
-    }
117
+	}
118
+
119
+
120
+	/**
121
+	 * Retrieves the optin text (static so it can be used in multiple places as necessary).
122
+	 *
123
+	 * @param bool $extra
124
+	 */
125
+	public static function optinText($extra = true)
126
+	{
127
+		if (! $extra) {
128
+			echo '<h2 class="ee-admin-settings-hdr" '
129
+				 . (! $extra ? 'id="UXIP_settings"' : '')
130
+				 . '>'
131
+				 . esc_html__('User eXperience Improvement Program (UXIP)', 'event_espresso')
132
+				 . EEH_Template::get_help_tab_link('organization_logo_info')
133
+				 . '</h2>';
134
+			printf(
135
+				esc_html__(
136
+					'%1$sPlease help us make Event Espresso better and vote for your favorite features.%2$s The %3$sUser eXperience Improvement Program (UXIP)%4$s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary and it is disabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %5$sPlease see our %6$sPrivacy Policy%7$s for more information.',
137
+					'event_espresso'
138
+				),
139
+				'<p><em>',
140
+				'</em></p>',
141
+				'<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
142
+				'</a>',
143
+				'<br><br>',
144
+				'<a href="https://eventespresso.com/about/privacy-policy/" target="_blank">',
145
+				'</a>'
146
+			);
147
+		} else {
148
+			$settings_url = EE_Admin_Page::add_query_args_and_nonce(
149
+				array('action' => 'default'),
150
+				admin_url('admin.php?page=espresso_general_settings')
151
+			);
152
+			$settings_url .= '#UXIP_settings';
153
+			printf(
154
+				esc_html__(
155
+					'The Event Espresso UXIP feature is not yet active on your site. For %1$smore info%2$s and to opt-in %3$sclick here%4$s.',
156
+					'event_espresso'
157
+				),
158
+				'<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
159
+				'</a>',
160
+				'<a href="' . $settings_url . '" target="_blank">',
161
+				'</a>'
162
+			);
163
+		}
164
+	}
165
+
166
+
167
+	/**
168
+	 * Callback for admin_enqueue_scripts that sets up the scripts and styles for the uxip notice
169
+	 */
170
+	public function enqueueScripts()
171
+	{
172
+		wp_register_script(
173
+			'ee-data-optin-js',
174
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js',
175
+			array('jquery'),
176
+			EVENT_ESPRESSO_VERSION,
177
+			true
178
+		);
179
+		wp_register_style(
180
+			'ee-data-optin-css',
181
+			EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css',
182
+			array(),
183
+			EVENT_ESPRESSO_VERSION
184
+		);
185
+
186
+		wp_enqueue_script('ee-data-optin-js');
187
+		wp_enqueue_style('ee-data-optin-css');
188
+	}
189
+
190
+
191
+	/**
192
+	 * Callback for wp_ajax_espresso_data_optin that handles the ajax request
193
+	 */
194
+	public function ajaxHandler()
195
+	{
196
+		// verify nonce
197
+		if (isset($_POST['nonce']) && ! wp_verify_nonce($_POST['nonce'], 'ee-data-optin')) {
198
+			exit();
199
+		}
200
+
201
+		// update has notified option
202
+		$this->config->setHasNotifiedAboutUxip();
203
+		exit();
204
+	}
205
+
206
+
207
+	/**
208
+	 * Used to determine whether additional stats are sent.
209
+	 */
210
+	private function sendStats()
211
+	{
212
+		return $this->config->isOptedInForUxip()
213
+			   && $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
214
+			   && $this->statSendTimestampExpired();
215
+	}
216
+
217
+
218
+	/**
219
+	 * Returns true when the timestamp used to track whether stats get sent (currently a weekly interval) is expired.
220
+	 * Returns false otherwise.
221
+	 *
222
+	 * @return bool
223
+	 */
224
+	private function statSendTimestampExpired()
225
+	{
226
+		$current_expiry = get_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, null);
227
+		if ($current_expiry === null) {
228
+			add_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS, '', 'no');
229
+			return true;
230
+		}
231
+
232
+		if (time() > (int) $current_expiry) {
233
+			update_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS);
234
+			return true;
235
+		}
236
+		return false;
237
+	}
238 238
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.63.rc.027');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.63.rc.027');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.