PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / Admin / SettingsPages / GeneralSettings.php
wp-user-avatar / src / Admin / SettingsPages Last commit date
DragDropBuilder 1 month ago EmailSettings 1 year ago Membership 1 month ago AbstractSettingsPage.php 2 years ago AddNewForm.php 1 year ago AdminFooter.php 4 years ago ExtensionsSettingsPage.php 1 year ago FormList.php 4 months ago Forms.php 1 year ago FuseWP.php 3 years ago GeneralSettings.php 9 months ago IDUserColumn.php 5 years ago LicenseUpgrader.php 3 years ago MailOptin.php 3 years ago MemberDirectories.php 1 year ago MembersDirectoryList.php 5 years ago ToolsSettingsPage.php 4 years ago index.php 3 years ago
GeneralSettings.php
731 lines
1 <?php
2
3 namespace ProfilePress\Core\Admin\SettingsPages;
4
5 use ProfilePress\Core\Classes\ExtensionManager;
6 use ProfilePress\Core\Classes\FormRepository;
7 use ProfilePress\Core\RegisterActivation\CreateDBTables;
8 use ProfilePress\Core\ShortcodeParser\MyAccount\MyAccountTag;
9 use ProfilePress\Custom_Settings_Page_Api;
10
11 class GeneralSettings extends AbstractSettingsPage
12 {
13 public $settingsPageInstance;
14
15 public function __construct()
16 {
17 // registers the global ProfilePress dashboard menu
18 add_action('admin_menu', array($this, 'register_core_menu'));
19
20 add_action('ppress_register_menu_page_general_general', function () {
21 $this->settingsPageInstance = Custom_Settings_Page_Api::instance([], PPRESS_SETTINGS_DB_OPTION_NAME, esc_html__('General', 'wp-user-avatar'));
22 });
23
24 add_action('ppress_register_menu_page', array($this, 'register_menu_page'));
25
26 add_action('ppress_admin_settings_submenu_page_general_general', [$this, 'settings_admin_page_callback']);
27
28 add_action('admin_footer', [$this, 'js_script']);
29
30 add_action('admin_init', [$this, 'install_missing_db_tables']);
31
32 // flush rewrite rule on save/persistence
33 add_action('wp_cspa_persist_settings', function () {
34 flush_rewrite_rules();
35 });
36
37 $this->custom_sanitize();
38 }
39
40 public function register_menu_page()
41 {
42 $hook = add_submenu_page(
43 PPRESS_DASHBOARD_SETTINGS_SLUG,
44 'ProfilePress ' . apply_filters('ppress_general_settings_admin_page_title', esc_html__('Settings', 'wp-user-avatar')),
45 esc_html__('Settings', 'wp-user-avatar'),
46 'manage_options',
47 PPRESS_SETTINGS_SLUG,
48 array($this, 'admin_page_callback')
49 );
50
51 add_action("load-$hook", [$this, 'screen_option']);
52 }
53
54 public function default_header_menu()
55 {
56 return 'general';
57 }
58
59 public function header_menu_tabs()
60 {
61 $tabs = apply_filters('ppress_settings_page_tabs', [
62 20 => [
63 'id' => 'general',
64 'url' => PPRESS_SETTINGS_SETTING_PAGE,
65 'label' => esc_html__('General', 'wp-user-avatar')
66 ],
67 40 => [
68 'id' => 'email',
69 'url' => add_query_arg('view', 'email', PPRESS_SETTINGS_SETTING_PAGE),
70 'label' => esc_html__('Emails', 'wp-user-avatar')
71 ],
72 ]);
73
74 if ( ! empty($this->integrations_submenu_tabs())) {
75 $tabs[60] = [
76 'id' => 'integrations',
77 'url' => add_query_arg('view', 'integrations', PPRESS_SETTINGS_SETTING_PAGE),
78 'label' => esc_html__('Integrations', 'wp-user-avatar')
79 ];
80 }
81
82 if ( ! ExtensionManager::is_premium()) {
83 $tabs[999] = [
84 'url' => PPRESS_EXTENSIONS_SETTINGS_PAGE,
85 'label' => esc_html__('Premium Addons', 'wp-user-avatar')
86 ];
87 }
88
89 ksort($tabs);
90
91 return $tabs;
92 }
93
94 public function integrations_submenu_tabs()
95 {
96 return apply_filters('ppress_integrations_submenu_tabs', []);
97 }
98
99 public function header_submenu_tabs()
100 {
101 $tabs = apply_filters('ppress_settings_page_submenus_tabs', [
102 0 => ['parent' => 'general', 'id' => 'general', 'label' => esc_html__('General', 'wp-user-avatar')],
103 99999 => ['parent' => 'general', 'id' => 'tools', 'label' => esc_html__('Tools', 'wp-user-avatar')],
104 ]);
105
106 $tabs = $tabs + $this->integrations_submenu_tabs();
107
108 ksort($tabs);
109
110 return $tabs;
111 }
112
113 public function screen_option()
114 {
115 do_action('ppress_settings_page_screen_option');
116 }
117
118 public function settings_admin_page_callback()
119 {
120 $custom_page = apply_filters('ppress_general_settings_admin_page_short_circuit', false);
121
122 if (false !== $custom_page) return $custom_page;
123
124 $edit_profile_forms = array_reduce(FormRepository::get_forms(FormRepository::EDIT_PROFILE_TYPE),
125 function ($carry, $item) {
126 $carry[$item['form_id']] = $item['name'];
127
128 return $carry;
129 }, ['default' => esc_html__('My Account edit profile form (default)', 'wp-user-avatar')]);
130
131 $login_redirect_page_dropdown_args = [
132 ['key' => 'current_page', 'label' => esc_html__('Currently viewed page', 'wp-user-avatar')],
133 [
134 'key' => 'none',
135 'label' => esc_html__('Previous/Referrer page (Pro feature)', 'wp-user-avatar'),
136 'disabled' => true
137 ],
138 ['key' => 'dashboard', 'label' => esc_html__('WordPress Dashboard', 'wp-user-avatar')]
139 ];
140
141 if (ExtensionManager::is_premium()) {
142 $login_redirect_page_dropdown_args[1] = [
143 'key' => 'previous_page',
144 'label' => esc_html__('Previous/Referrer page', 'wp-user-avatar')
145 ];
146 }
147
148 $fix_db_url = wp_nonce_url(
149 add_query_arg('ppress-install-missing-db', 'true', PPRESS_SETTINGS_SETTING_GENERAL_PAGE),
150 'ppress_install_missing_db_tables'
151 );
152
153 $args = [
154 'global_settings' => apply_filters('ppress_global_settings_page', [
155 'tab_title' => esc_html__('Global', 'wp-user-avatar'),
156 'dashicon' => 'dashicons-admin-site-alt',
157 [
158 'section_title' => esc_html__('Global Settings', 'wp-user-avatar'),
159 'disable_ajax_mode' => [
160 'type' => 'checkbox',
161 'label' => esc_html__('Disable Ajax Mode', 'wp-user-avatar'),
162 'value' => 'yes',
163 'checkbox_label' => esc_html__('Disable', 'wp-user-avatar'),
164 'description' => esc_html__('Check this box to disable ajax behaviour(whereby forms do not require page reload when submitted) in forms.', 'wp-user-avatar'),
165 ],
166 'install_missing_db_tables' => [
167 'type' => 'custom_field_block',
168 'label' => __('Install Missing DB Tables', 'mailoptin'),
169 'data' => "<a href='$fix_db_url' class='button action ppress-confirm-delete'>" . __('Fix Database', 'mailoptin') . '</a>',
170 ],
171 'remove_plugin_data' => [
172 'type' => 'checkbox',
173 'value' => 'yes',
174 'label' => esc_html__('Remove Data on Uninstall', 'wp-user-avatar'),
175 'checkbox_label' => esc_html__('Delete', 'wp-user-avatar'),
176 'description' => esc_html__('Check this box if you would like ProfilePress to completely remove all of its data when the plugin is deleted.', 'wp-user-avatar'),
177 ]
178 ],
179 ]),
180 /** Set default values on register activation */
181 'business_info' => apply_filters('ppress_business_info_settings_page', [
182 'tab_title' => esc_html__('Business Info', 'wp-user-avatar'),
183 'dashicon' => 'dashicons-info',
184 [
185 'section_title' => esc_html__('Business Information', 'wp-user-avatar'),
186 'business_name' => [
187 'type' => 'text',
188 'label' => esc_html__('Business Name', 'wp-user-avatar'),
189 'description' => esc_html__('The official (legal) name of your store. Defaults to Site Title if empty.', 'wp-user-avatar'),
190 ],
191 'business_address' => [
192 'type' => 'text',
193 'label' => esc_html__('Address', 'wp-user-avatar'),
194 'description' => esc_html__('The street address where your business is registered and located.', 'wp-user-avatar'),
195 ],
196 'business_city' => [
197 'type' => 'text',
198 'label' => esc_html__('City', 'wp-user-avatar'),
199 'description' => esc_html__('The city in which your business is registered and located.', 'wp-user-avatar'),
200 ],
201 'business_country' => [
202 'type' => 'select',
203 'label' => esc_html__('Country', 'wp-user-avatar'),
204 'description' => esc_html__('The country in which your business is registered and located.', 'wp-user-avatar'),
205 'options' => ['' => '&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;'] + ppress_array_of_world_countries()
206 ],
207 'business_state' => [
208 'type' => 'text',
209 'label' => esc_html__('State / Province / Region', 'wp-user-avatar'),
210 'description' => esc_html__('The state your business is located.', 'wp-user-avatar'),
211 ],
212 'business_postal_code' => [
213 'type' => 'text',
214 'label' => esc_html__('ZIP / Postal Code', 'wp-user-avatar'),
215 'description' => esc_html__('The country in which your business is located.', 'wp-user-avatar'),
216 ],
217 'business_tin' => [
218 'type' => 'text',
219 'label' => esc_html__('Tax Identification Number', 'wp-user-avatar'),
220 'description' => esc_html__('This can be your VAT number, GST/HST or ABN.', 'wp-user-avatar'),
221 ],
222 ],
223 ]),
224 'global_pages' => apply_filters('ppress_global_pages_settings_page', [
225 'tab_title' => esc_html__('Pages', 'wp-user-avatar'),
226 'dashicon' => 'dashicons-admin-page',
227 [
228 'section_title' => esc_html__('Global Pages', 'wp-user-avatar'),
229 'create_required_pages_notice' => [
230 'type' => 'arbitrary',
231 'data' => '',
232 'description' => sprintf(
233 '<div class="ppress-settings-page-notice">' . esc_html__('Assign the WordPress pages for each required ProfilePress page, or %sclick here to let us generate them%s.', 'wp-user-avatar'),
234 '<a href="' . esc_url(add_query_arg([
235 'ppress_create_pages' => 'true',
236 'ppress_nonce' => wp_create_nonce('ppress_create_pages')
237 ])) . '">', '</a>'
238 )
239 ],
240 'set_login_url' => [
241 'type' => 'custom_field_block',
242 'label' => esc_html__('Login Page', 'wp-user-avatar'),
243 'data' => self::page_dropdown('set_login_url'),
244 'description' => sprintf(
245 esc_html__('Select the page you wish to make WordPress default Login page. %3$s This should be the page that contains a %1$slogin form shortcode%2$s.', 'wp-user-avatar'),
246 '<a href="' . add_query_arg('form-type', 'login', PPRESS_FORMS_SETTINGS_PAGE) . '">', '</a>', '<br/>'),
247 ],
248 'set_registration_url' => [
249 'type' => 'custom_field_block',
250 'label' => esc_html__('Registration Page', 'wp-user-avatar'),
251 'data' => self::page_dropdown('set_registration_url'),
252 'description' => sprintf(
253 esc_html__('Select the page you wish to make WordPress default Registration page. %3$s This should be the page that contains a %1$sregistration form shortcode%2$s.', 'wp-user-avatar'),
254 '<a href="' . add_query_arg('form-type', 'registration', PPRESS_FORMS_SETTINGS_PAGE) . '">', '</a>', '<br/>'),
255 ],
256 'set_lost_password_url' => [
257 'type' => 'custom_field_block',
258 'label' => esc_html__('Password Reset Page', 'wp-user-avatar'),
259 'data' => self::page_dropdown('set_lost_password_url'),
260 'description' => sprintf(
261 esc_html__('Select the page you wish to make WordPress default "Lost Password page". %3$s This should be the page that contains a %1$spassword reset form shortcode%2$s.', 'wp-user-avatar'),
262 '<a href="' . add_query_arg('form-type', 'password-reset', PPRESS_FORMS_SETTINGS_PAGE) . '">', '</a>', '<br/>'),
263 ],
264 'edit_user_profile_url' => [
265 'type' => 'custom_field_block',
266 'label' => esc_html__('My Account Page', 'wp-user-avatar'),
267 'data' => self::page_dropdown('edit_user_profile_url'),
268 'description' => sprintf(
269 esc_html__('Select a page that contains %3$s shortcode. You can also use an %1$sedit profile shortcode%2$s on the My Account page in case you want something custom.', 'wp-user-avatar'),
270 '<a href="' . add_query_arg('form-type', 'edit-profile', PPRESS_FORMS_SETTINGS_PAGE) . '">', '</a>', '<code>[profilepress-my-account]</code>'),
271 ],
272 ],
273 [
274 'section_title' => esc_html__('Payment Pages', 'wp-user-avatar'),
275 'checkout_page_id' => [
276 'type' => 'custom_field_block',
277 'label' => esc_html__('Checkout Page', 'wp-user-avatar'),
278 'data' => self::page_dropdown('checkout_page_id'),
279 'description' => sprintf(
280 esc_html__('The checkout page where members will complete their payments. %2$sThe shortcode %1$s must be on this page.', 'wp-user-avatar'),
281 '<code>[profilepress-checkout]</code>', '<br>'
282 ),
283 ],
284 'payment_success_page_id' => [
285 'type' => 'custom_field_block',
286 'label' => esc_html__('Order Success Page', 'wp-user-avatar'),
287 'data' => self::page_dropdown('payment_success_page_id'),
288 'description' => sprintf(
289 esc_html__('The page customers are sent to after completing their orders.%2$sThe shortcode %1$s must be on this page.', 'wp-user-avatar'),
290 '<code>[profilepress-receipt]</code>', '<br>'
291 )
292 ],
293 'payment_failure_page_id' => [
294 'type' => 'custom_field_block',
295 'label' => esc_html__('Order Failure Page', 'wp-user-avatar'),
296 'data' => self::page_dropdown('payment_failure_page_id'),
297 'description' => esc_html__('The page customers are sent to after a failed order.', 'wp-user-avatar')
298 ],
299 'terms_page_id' => [
300 'label' => esc_html__('Terms & Conditions Page', 'wp-user-avatar'),
301 'description' => esc_html__('If you select a "Terms" page, customers will be asked if they accept them when checking out.', 'wp-user-avatar'),
302 'type' => 'custom_field_block',
303 'data' => self::page_dropdown('terms_page_id'),
304 ],
305 ]
306 ]),
307 'registration_settings' => apply_filters('ppress_registration_settings_page', [
308 'tab_title' => esc_html__('Registration', 'wp-user-avatar'),
309 'dashicon' => 'dashicons-welcome-learn-more',
310 [
311 'section_title' => esc_html__('Registration Settings', 'wp-user-avatar'),
312 'set_auto_login_after_reg' => [
313 'type' => 'checkbox',
314 'label' => esc_html__('Auto-login after registration', 'wp-user-avatar'),
315 'checkbox_label' => esc_html__('Enable auto-login', 'wp-user-avatar'),
316 'value' => 'on',
317 'description' => esc_html__('Check this option to automatically login users after successful registration.', 'wp-user-avatar')
318 ]
319 ]
320 ]),
321 'login_settings' => apply_filters('ppress_login_settings_page', [
322 'tab_title' => esc_html__('Login', 'wp-user-avatar'),
323 'dashicon' => 'dashicons-universal-access-alt',
324 [
325 'section_title' => esc_html__('Login Settings', 'wp-user-avatar'),
326 'login_username_email_restrict' => [
327 'type' => 'select',
328 'options' => [
329 'both' => esc_html__('Email Address and Username (default)', 'wp-user-avatar'),
330 'email' => esc_html__('Email Address Only', 'wp-user-avatar'),
331 'username' => esc_html__('Username Only', 'wp-user-avatar')
332 ],
333 'value' => '',
334 'label' => esc_html__('Login with Email or Username', 'wp-user-avatar'),
335 'description' => esc_html__('By default, WordPress allows users to log in using either an email address or username. This setting allows you to restrict logins to only accept email addresses or usernames.', 'wp-user-avatar')
336 ],
337 'disable_concurrent_logins' => [
338 'type' => 'checkbox',
339 'checkbox_label' => esc_html__('Check to Disable', 'wp-user-avatar'),
340 'label' => esc_html__('Disable Concurrent Logins', 'wp-user-avatar'),
341 'description' => esc_html__('Prevent users from being logged into the same account from multiple computers at the same time.', 'wp-user-avatar')
342 ],
343 ]
344 ]),
345 'my_account_settings' => apply_filters('ppress_my_account_settings_page', [
346 'tab_title' => esc_html__('My Account', 'wp-user-avatar'),
347 'section_title' => esc_html__('My Account Settings', 'wp-user-avatar'),
348 'dashicon' => 'dashicons-dashboard',
349 'redirect_default_edit_profile_to_custom' => [
350 'type' => 'checkbox',
351 'label' => esc_html__('Redirect Default Edit Profile', 'wp-user-avatar'),
352 'checkbox_label' => esc_html__('Activate', 'wp-user-avatar'),
353 'value' => 'yes',
354 'description' => sprintf(
355 __('Redirect <a target="_blank" href="%s">default WordPress profile</a> to My Account page.', 'wp-user-avatar'),
356 admin_url('profile.php')
357 )
358 ],
359 'disable_admin_edit_profile_redirect' => [
360 'type' => 'checkbox',
361 'checkbox_label' => esc_html__('Disable Redirect for administrators', 'wp-user-avatar'),
362 'value' => 'yes',
363 'description' => esc_html__('When enabled, administrators will not be redirected from the default profile page.', 'wp-user-avatar'),
364 ],
365 'myac_edit_account_endpoint' => [
366 'type' => 'text',
367 'value' => 'edit-profile',
368 'label' => esc_html__('Edit Account Endpoint', 'wp-user-avatar'),
369 'description' => __('Endpoint for the "My Account → Account Details" page.', 'wp-user-avatar'),
370 ],
371 'myac_change_password_endpoint' => [
372 'type' => 'text',
373 'value' => 'change-password',
374 'label' => esc_html__('Change Password Endpoint', 'wp-user-avatar'),
375 'description' => __('Endpoint for the "My Account → Change Password" page.', 'wp-user-avatar'),
376 ],
377 'myac_account_details_form' => [
378 'type' => 'select',
379 'options' => $edit_profile_forms,
380 'label' => esc_html__('Account Details Form', 'wp-user-avatar'),
381 'description' => esc_html__('Do you want to replace the default form in "My Account → Account Details" page? select an Edit Profile form that will replace it.', 'wp-user-avatar')
382 ],
383 'myac_account_disabled_tabs' => [
384 'type' => 'select2',
385 'label' => esc_html__('Disable My Account Tabs', 'wp-user-avatar'),
386 'options' => (function () {
387 $bucket = [];
388 foreach (MyAccountTag::myaccount_tabs() as $tab_id => $tab) {
389 $bucket[$tab_id] = $tab['title'];
390 }
391
392 return $bucket;
393 })(),
394 'description' => esc_html__('Select the tabs to disable or remove from the My Account page', 'wp-user-avatar')
395 ]
396 ]),
397 'frontend_profile_settings' => apply_filters('ppress_frontend_profile_settings_page', [
398 'tab_title' => esc_html__('Frontend Profile', 'wp-user-avatar'),
399 'section_title' => esc_html__('Frontend Profile Settings', 'wp-user-avatar'),
400 'dashicon' => 'dashicons-admin-users',
401 'set_user_profile_shortcode' => [
402 'type' => 'custom_field_block',
403 'label' => esc_html__('Page with Profile Shortcode', 'wp-user-avatar'),
404 'data' => self::page_dropdown('set_user_profile_shortcode'),
405 'description' => sprintf(__('Select the page that contains your <a href="%s">Frontend user profile shortcode</a>.', 'wp-user-avatar'), PPRESS_USER_PROFILES_SETTINGS_PAGE),
406 ],
407 'set_user_profile_slug' => [
408 'type' => 'text',
409 'value' => 'profile',
410 'label' => esc_html__('Profile Slug', 'wp-user-avatar'),
411 'description' => sprintf(__('Enter your preferred profile URL slug. Default to "profile" if empty. If slug is "profile", URL becomes %s where "john" is a user\'s username.', 'wp-user-avatar'), '<strong>' . home_url() . '/profile/john</strong>'),
412 ],
413 'disable_guests_can_view_profiles' => [
414 'type' => 'checkbox',
415 'label' => esc_html__('Disable Guests from Viewing Profiles', 'wp-user-avatar'),
416 'description' => esc_html__('Enable this option to stop disable guests or non-registered users from viewing users profiles.', 'wp-user-avatar'),
417 'value' => 'on'
418 ],
419 'disable_members_can_view_profiles' => [
420 'type' => 'checkbox',
421 'label' => esc_html__('Disable Members from Viewing Profiles', 'wp-user-avatar'),
422 'description' => esc_html__('Enable this option to stop members from viewing other users profiles. If enabled, users can only see their own profile.', 'wp-user-avatar'),
423 'value' => 'on'
424 ],
425 'comment_author_url_to_profile' => [
426 'type' => 'checkbox',
427 'label' => esc_html__('Comment Author URL to Profile', 'wp-user-avatar'),
428 'checkbox_label' => esc_html__('Enable option', 'wp-user-avatar'),
429 'value' => 'on',
430 'description' => sprintf(__("Change URL of comment authors to their ProfilePress front-end profile.", 'wp-user-avatar'))
431 ],
432 'author_slug_to_profile' => [
433 'type' => 'checkbox',
434 'label' => esc_html__('Authors Page to Profile', 'wp-user-avatar'),
435 'checkbox_label' => esc_html__('Enable option', 'wp-user-avatar'),
436 'value' => 'on',
437 'description' => sprintf(__("Change and redirect authors pages %s to their front-end profiles %s.", 'wp-user-avatar'), '<strong>(' . home_url() . '/author/admin)</strong>', '<strong>(' . home_url() . '/' . ppress_get_profile_slug() . '/admin)</strong>')
438 ],
439 ]
440 ),
441 'redirection_settings' => apply_filters('ppress_redirection_settings_page', [
442 'tab_title' => esc_html__('Redirection', 'wp-user-avatar'),
443 'section_title' => esc_html__('Redirection Settings', 'wp-user-avatar'),
444 'dashicon' => 'dashicons-redo',
445 'set_log_out_url' => [
446 'type' => 'custom_field_block',
447 'label' => esc_html__('Log out', 'wp-user-avatar'),
448 'data' => self::page_dropdown('set_log_out_url',
449 [
450 ['key' => 'default', 'label' => esc_html__('Select...', 'wp-user-avatar')],
451 [
452 'key' => 'current_view_page',
453 'label' => esc_html__('Currently viewed page', 'wp-user-avatar')
454 ]
455 ],
456 ['skip_append_default_select' => true]
457 ) . $this->custom_text_input('custom_url_log_out'),
458 'description' => sprintf(
459 esc_html__('Select the page users will be redirected to after logout. To redirect to a custom URL instead of a selected page, enter the URL in input field directly above this description.', 'wp-user-avatar') . '%s' .
460 esc_html__('Leave the "custom URL" field empty to fallback to the selected page.', 'wp-user-avatar'),
461 '<br/>'
462 )
463 ],
464 'set_login_redirect' => [
465 'type' => 'custom_field_block',
466 'label' => esc_html__('Login', 'wp-user-avatar'),
467 'data' => self::page_dropdown('set_login_redirect', $login_redirect_page_dropdown_args) . $this->custom_text_input('custom_url_login_redirect'),
468 'description' => sprintf(
469 esc_html__('Select the page or custom URL users will be redirected to after login. To redirect to a custom URL instead of a selected page, enter the URL in input field directly above this description', 'wp-user-avatar') . '%s' .
470 esc_html__('Leave the "custom URL" field empty to fallback to the selected page.', 'wp-user-avatar'),
471 '<br/>'
472 )
473 ],
474 'set_password_reset_redirect' => [
475 'type' => 'custom_field_block',
476 'label' => esc_html__('Password Reset', 'wp-user-avatar'),
477 'data' => self::page_dropdown(
478 'set_password_reset_redirect',
479 [],
480 [
481 'show_option_none' => esc_html__('Default..', 'wp-user-avatar'),
482 'option_none_value' => 'no_redirect',
483 ]
484 ) . $this->custom_text_input('custom_url_password_reset_redirect'),
485 'description' => sprintf(
486 esc_html__('Select the page or custom URL users will be redirected to after they successfully reset or change their password. To redirect to a custom URL instead of a selected page, enter the URL in input field directly above this description.', 'wp-user-avatar') . '%s' .
487 esc_html__('Leave the "custom URL" field empty to fallback to the selected page.', 'wp-user-avatar'),
488 '<br/>'
489 )
490 ]
491 ]),
492 'access_settings' => apply_filters('ppress_access_settings_page', [
493 'tab_title' => esc_html__('Access', 'wp-user-avatar'),
494 'section_title' => esc_html__('Access Settings', 'wp-user-avatar'),
495 'dashicon' => 'dashicons-products',
496 'global_site_access_notice' => [
497 'type' => 'arbitrary',
498 'data' => '',
499 'description' => sprintf(
500 '<div class="ppress-settings-page-notice">' . esc_html__('%sNote:%s Access setting takes precedence over %sContent Protection rules%s.', 'wp-user-avatar'),
501 '<strong>', '</strong>', '<a target="_blank" href="' . PPRESS_CONTENT_PROTECTION_SETTINGS_PAGE . '">', '</a>'
502 )
503 ],
504 'global_site_access' => [
505 'type' => 'select',
506 'label' => esc_html__('Global Site Access', 'wp-user-avatar'),
507 'options' => [
508 'everyone' => esc_html__('Accessible to Everyone', 'wp-user-avatar'),
509 'login' => esc_html__('Accessible to Logged-in Users', 'wp-user-avatar')
510 ]
511 ],
512 'global_site_access_redirect_page' => [
513 'type' => 'custom_field_block',
514 'label' => esc_html__('Redirect Page', 'wp-user-avatar'),
515 'data' => self::page_dropdown('global_site_access_redirect_page') . $this->custom_text_input('global_site_access_custom_redirect_page'),
516 'description' => esc_html__('Select the page or custom URL to redirect users that are not logged in to.', 'wp-user-avatar')
517 ],
518 'global_site_access_exclude_pages' => [
519 'type' => 'select2',
520 'label' => esc_html__('Pages to Exclude', 'wp-user-avatar'),
521 'options' => array_reduce(get_pages(), function ($carry, $item) {
522 $carry[$item->ID] = $item->post_title;
523
524 return $carry;
525 }, []),
526 'description' => esc_html__('Select the pages to exclude beside the redirect page that will be accessible by everyone.', 'wp-user-avatar')
527 ],
528 'global_site_access_allow_homepage' => [
529 'type' => 'checkbox',
530 'value' => 'yes',
531 'checkbox_label' => esc_html__('Enable', 'wp-user-avatar'),
532 'label' => esc_html__('Accessible Homepage', 'wp-user-avatar'),
533 'description' => esc_html__('Check to allow homepage to be accessible by everyone.', 'wp-user-avatar')
534 ],
535 'global_restricted_access_message' => [
536 'type' => 'wp_editor',
537 'settings' => ['textarea_rows' => 5, 'wpautop' => false],
538 'value' => esc_html__('You are unauthorized to view this page.', 'wp-user-avatar'),
539 'label' => esc_html__('Global Restricted Access Message', 'wp-user-avatar'),
540 'description' => esc_html__('This is the message shown to users that do not have permission to view the content.', 'wp-user-avatar')
541 ],
542 'blocked_email_addresses' => [
543 'type' => 'textarea',
544 'placeholder' => "hello@example.com" . "\r\n" . '@domain.com' . "\r\n" . '.gov',
545 'label' => esc_html__('Blocked Email Addresses', 'wp-user-avatar'),
546 'description' => sprintf(
547 esc_html__('Block users from registering and checking out with email addresses in this list. You can use full email address (%1$suser@email.com%2$s), domains (%1$s@example.com%2$s), or TLDs (%1$s.gov%2$s). Use a new line for each item.', 'wp-user-avatar'),
548 '<code>', '</code>'
549 )
550 ],
551 'allowed_email_addresses' => [
552 'type' => 'textarea',
553 'placeholder' => "hello@example.com" . "\r\n" . '@domain.com' . "\r\n" . '.gov',
554 'label' => esc_html__('Allowed Email Addresses', 'wp-user-avatar'),
555 'description' => sprintf(
556 esc_html__('Ensures users with email addresses in this list are not blocked from registering and checking out. You can use full email address (%1$suser@email.com%2$s), domains (%1$s@example.com%2$s), or TLDs (%1$s.gov%2$s). Use a new line for each item.', 'wp-user-avatar'),
557 '<code>', '</code>'
558 )
559 ]
560 ])
561 ];
562
563 if ( ! $this->is_core_page_missing()) {
564 unset($args['global_pages'][0]['create_required_pages_notice']);
565 }
566
567 $business_country = ppress_business_country();
568
569 if ( ! empty($business_country) && ! empty(ppress_array_of_world_states($business_country))) {
570 $args['business_info'][0]['business_state']['type'] = 'select';
571 $args['business_info'][0]['business_state']['options'] = ['' => '&mdash;&mdash;&mdash;'] + ppress_array_of_world_states($business_country);
572 }
573
574 if (class_exists('\BuddyPress')) {
575 $args['buddypress_settings'] = apply_filters('ppress_buddypress_settings_page', [
576 'tab_title' => esc_html__('BuddyPress / BuddyBoss', 'wp-user-avatar'),
577 'section_title' => esc_html__('BuddyPress / BuddyBoss Settings', 'wp-user-avatar'),
578 'dashicon' => 'dashicons-buddicons-buddypress-logo',
579 'redirect_bp_registration_page' => [
580 'type' => 'checkbox',
581 'value' => 'yes',
582 'label' => esc_html__('Registration Page', 'wp-user-avatar'),
583 'checkbox_label' => esc_html__('Check to enable', 'wp-user-avatar'),
584 'description' => sprintf(__('Check to redirect BuddyPress or BuddyBoss registration page to your selected %s', 'wp-user-avatar'), '<a href="#global_settings?set_registration_url_row">custom registration page</a>')
585 ],
586 'override_bp_avatar' => [
587 'type' => 'checkbox',
588 'label' => esc_html__('Override Avatar', 'wp-user-avatar'),
589 'value' => 'yes',
590 'checkbox_label' => esc_html__('Check to enable', 'wp-user-avatar'),
591 'description' => esc_html__('Check to override BuddyPress/BuddyBoss users uploaded avatars with that of ProfilePress.', 'wp-user-avatar')
592 ],
593 'override_bp_profile_url' => [
594 'type' => 'checkbox',
595 'value' => 'yes',
596 'label' => esc_html__('Override Profile URL', 'wp-user-avatar'),
597 'checkbox_label' => esc_html__('Check to enable', 'wp-user-avatar'),
598 'description' => esc_html__('Check to change the profile URL of BuddyPress/BuddyBoss users to ProfilePress front-end profile.', 'wp-user-avatar')
599 ]
600 ]
601 );
602 }
603
604 if (class_exists('\bbPress')) {
605 $args['bbpress_settings'] = apply_filters('ppress_bbpress_settings_page', [
606 'tab_title' => esc_html__('bbPress', 'wp-user-avatar'),
607 'section_title' => esc_html__('bbPress Settings', 'wp-user-avatar'),
608 'dashicon' => 'dashicons-buddicons-bbpress-logo',
609 'override_bbp_profile_url' => [
610 'type' => 'checkbox',
611 'value' => 'yes',
612 'label' => esc_html__('Override Profile URL', 'wp-user-avatar'),
613 'checkbox_label' => esc_html__('Check to enable', 'wp-user-avatar'),
614 'description' => esc_html__('Check to change bbPress profile URL to ProfilePress front-end profile.', 'wp-user-avatar')
615 ]
616 ]
617 );
618 }
619
620 $this->settingsPageInstance->main_content(apply_filters('ppress_settings_page_args', $args));
621 $this->settingsPageInstance->build_sidebar_tab_style();
622 }
623
624 private function is_core_page_missing()
625 {
626 $required_pages = [
627 'set_login_url',
628 'set_registration_url',
629 'set_lost_password_url',
630 'edit_user_profile_url',
631 'set_user_profile_shortcode',
632 'checkout_page_id',
633 'payment_success_page_id',
634 'payment_failure_page_id'
635 ];
636
637 $result = false;
638
639 foreach ($required_pages as $required_page) {
640
641 if (empty(ppress_settings_by_key($required_page, ''))) {
642 $result = true;
643 break;
644 }
645 }
646
647 return $result;
648 }
649
650 public function install_missing_db_tables()
651 {
652 if (defined('DOING_AJAX')) return;
653
654 if (ppressGET_var('ppress-install-missing-db') == 'true' && current_user_can('manage_options')) {
655
656 check_admin_referer('ppress_install_missing_db_tables');
657
658 delete_option('ppress_db_ver');
659
660 CreateDBTables::make();
661
662 if (class_exists('\ProfilePress\Libsodium\Libsodium')) {
663 \ProfilePress\Libsodium\Libsodium::create_db_tables();
664 }
665
666 wp_safe_redirect(add_query_arg('settings-updated', 'true', PPRESS_SETTINGS_SETTING_GENERAL_PAGE));
667 exit;
668 }
669 }
670
671 public function custom_sanitize()
672 {
673 $config = apply_filters('ppress_settings_custom_sanitize', [
674 'global_restricted_access_message' => function ($val) {
675 return wp_kses_post($val);
676 },
677 'bank_transfer_account_details' => function ($val) {
678 return wp_kses_post($val);
679 },
680 'uec_unactivated_error' => function ($val) {
681 return wp_kses_post($val);
682 },
683 'uec_invalid_error' => function ($val) {
684 return wp_kses_post($val);
685 },
686 'uec_success_message' => function ($val) {
687 return wp_kses_post($val);
688 },
689 'uec_activation_resent' => function ($val) {
690 return wp_kses_post($val);
691 },
692 'uec_already_confirm_message' => function ($val) {
693 return wp_kses_post($val);
694 }
695 ]);
696
697 foreach ($config as $fieldKey => $callback) {
698 add_filter('wp_cspa_sanitize_skip', function ($return, $key, $value) use ($fieldKey, $callback) {
699 if ($key == $fieldKey) {
700 return call_user_func($callback, $value);
701 }
702
703 return $return;
704 }, 10, 3);
705 }
706 }
707
708 public function js_script()
709 {
710 ?>
711 <script type="text/javascript">
712 (function ($) {
713 $('#business_country').on('change', function () {
714 $('#business_info').find('.button-primary').trigger('click');
715 })
716 })(jQuery)
717 </script>
718 <?php
719 }
720
721 public static function get_instance()
722 {
723 static $instance = null;
724
725 if (is_null($instance)) {
726 $instance = new self();
727 }
728
729 return $instance;
730 }
731 }