DragDropBuilder
4 years ago
EmailSettings
4 years ago
AbstractSettingsPage.php
4 years ago
AddNewForm.php
4 years ago
AdminFooter.php
5 years ago
ExtensionsSettingsPage.php
4 years ago
FormList.php
5 years ago
Forms.php
4 years ago
GeneralSettings.php
4 years ago
IDUserColumn.php
5 years ago
MailOptin.php
4 years ago
MemberDirectories.php
4 years ago
MembersDirectoryList.php
5 years ago
ToolsSettingsPage.php
4 years ago
index.php
5 years ago
GeneralSettings.php
478 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePress\Core\Admin\SettingsPages; |
| 4 | |
| 5 | use ProfilePress\Core\Admin\SettingsPages\EmailSettings\EmailSettingsPage; |
| 6 | use ProfilePress\Core\Classes\ExtensionManager; |
| 7 | use ProfilePress\Core\Classes\FormRepository; |
| 8 | use ProfilePress\Custom_Settings_Page_Api; |
| 9 | |
| 10 | class GeneralSettings extends AbstractSettingsPage |
| 11 | { |
| 12 | public $settingsPageInstance; |
| 13 | |
| 14 | public function __construct() |
| 15 | { |
| 16 | // registers the global ProfilePress dashboard menu |
| 17 | add_action('admin_menu', array($this, 'register_core_menu')); |
| 18 | |
| 19 | add_action('ppress_register_menu_page_general_general', function () { |
| 20 | $this->settingsPageInstance = Custom_Settings_Page_Api::instance([], PPRESS_SETTINGS_DB_OPTION_NAME, esc_html__('General', 'wp-user-avatar')); |
| 21 | }); |
| 22 | |
| 23 | add_action('ppress_register_menu_page', array($this, 'register_menu_page')); |
| 24 | |
| 25 | add_action('ppress_admin_settings_submenu_page_general_general', [$this, 'settings_admin_page_callback']); |
| 26 | |
| 27 | // flush rewrite rule on save/persistence |
| 28 | add_action('wp_cspa_persist_settings', function () { |
| 29 | flush_rewrite_rules(); |
| 30 | }); |
| 31 | |
| 32 | $this->custom_sanitize(); |
| 33 | } |
| 34 | |
| 35 | public function register_menu_page() |
| 36 | { |
| 37 | $hook = add_submenu_page( |
| 38 | PPRESS_SETTINGS_SLUG, |
| 39 | apply_filters('ppress_general_settings_admin_page_title', esc_html__('Settings', 'wp-user-avatar')) . ' - ProfilePress', |
| 40 | esc_html__('Settings', 'wp-user-avatar'), |
| 41 | 'manage_options', |
| 42 | PPRESS_SETTINGS_SLUG, |
| 43 | array($this, 'admin_page_callback') |
| 44 | ); |
| 45 | |
| 46 | add_action("load-$hook", [$this, 'screen_option']); |
| 47 | } |
| 48 | |
| 49 | public function default_header_menu() |
| 50 | { |
| 51 | return 'general'; |
| 52 | } |
| 53 | |
| 54 | public function header_menu_tabs() |
| 55 | { |
| 56 | $tabs = apply_filters('ppress_settings_page_tabs', [ |
| 57 | 20 => ['id' => 'general', 'url' => PPRESS_SETTINGS_SETTING_PAGE, 'label' => esc_html__('General', 'wp-user-avatar')], |
| 58 | 40 => ['id' => 'email', 'url' => add_query_arg('view', 'email', PPRESS_SETTINGS_SETTING_PAGE), 'label' => esc_html__('Emails', 'wp-user-avatar')], |
| 59 | ]); |
| 60 | |
| 61 | if ( ! empty($this->integrations_submenu_tabs())) { |
| 62 | $tabs[60] = ['id' => 'integrations', 'url' => add_query_arg('view', 'integrations', PPRESS_SETTINGS_SETTING_PAGE), 'label' => esc_html__('Integrations', 'wp-user-avatar')]; |
| 63 | } |
| 64 | |
| 65 | if ( ! ExtensionManager::is_premium()) { |
| 66 | $tabs[999] = ['url' => PPRESS_EXTENSIONS_SETTINGS_PAGE, 'label' => esc_html__('Premium Addons', 'wp-user-avatar')]; |
| 67 | } |
| 68 | |
| 69 | ksort($tabs); |
| 70 | |
| 71 | return $tabs; |
| 72 | } |
| 73 | |
| 74 | public function integrations_submenu_tabs() |
| 75 | { |
| 76 | return apply_filters('ppress_integrations_submenu_tabs', []); |
| 77 | } |
| 78 | |
| 79 | public function header_submenu_tabs() |
| 80 | { |
| 81 | $tabs = apply_filters('ppress_settings_page_submenus_tabs', [ |
| 82 | 0 => ['parent' => 'general', 'id' => 'general', 'label' => esc_html__('General', 'wp-user-avatar')], |
| 83 | 99999 => ['parent' => 'general', 'id' => 'tools', 'label' => esc_html__('Tools', 'wp-user-avatar')], |
| 84 | ]); |
| 85 | |
| 86 | $tabs = $tabs + $this->integrations_submenu_tabs(); |
| 87 | |
| 88 | ksort($tabs); |
| 89 | |
| 90 | return $tabs; |
| 91 | } |
| 92 | |
| 93 | public function screen_option() |
| 94 | { |
| 95 | do_action('ppress_settings_page_screen_option'); |
| 96 | } |
| 97 | |
| 98 | public function settings_admin_page_callback() |
| 99 | { |
| 100 | $custom_page = apply_filters('ppress_general_settings_admin_page_short_circuit', false); |
| 101 | |
| 102 | if (false !== $custom_page) return $custom_page; |
| 103 | |
| 104 | $edit_profile_forms = array_reduce(FormRepository::get_forms(FormRepository::EDIT_PROFILE_TYPE), |
| 105 | function ($carry, $item) { |
| 106 | $carry[$item['form_id']] = $item['name']; |
| 107 | |
| 108 | return $carry; |
| 109 | }, ['default' => esc_html__('My Account edit profile form (default)', 'wp-user-avatar')]); |
| 110 | |
| 111 | $login_redirect_page_dropdown_args = [ |
| 112 | ['key' => 'current_page', 'label' => esc_html__('Currently viewed page', 'wp-user-avatar')], |
| 113 | ['key' => '', 'label' => esc_html__('Previous/Referrer page (Pro feature)', 'wp-user-avatar'), 'disabled' => true], |
| 114 | ['key' => 'dashboard', 'label' => esc_html__('WordPress Dashboard', 'wp-user-avatar')] |
| 115 | ]; |
| 116 | |
| 117 | if (ExtensionManager::is_premium()) { |
| 118 | $login_redirect_page_dropdown_args[1] = ['key' => 'previous_page', 'label' => esc_html__('Previous/Referrer page', 'wp-user-avatar')]; |
| 119 | } |
| 120 | |
| 121 | $args = [ |
| 122 | 'global_settings' => apply_filters('ppress_global_settings_page', [ |
| 123 | 'tab_title' => esc_html__('Global', 'wp-user-avatar'), |
| 124 | 'dashicon' => 'dashicons-admin-site-alt', |
| 125 | [ |
| 126 | 'section_title' => esc_html__('Global Settings', 'wp-user-avatar'), |
| 127 | 'set_lost_password_url' => [ |
| 128 | 'type' => 'custom_field_block', |
| 129 | 'label' => esc_html__('Password-reset Page', 'wp-user-avatar'), |
| 130 | 'data' => $this->page_dropdown('set_lost_password_url'), |
| 131 | 'description' => sprintf( |
| 132 | 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'), |
| 133 | '<a href="' . add_query_arg('form-type', 'password-reset', PPRESS_FORMS_SETTINGS_PAGE) . '"><strong>', '</strong></a>', '<br/>'), |
| 134 | ], |
| 135 | 'set_login_url' => [ |
| 136 | 'type' => 'custom_field_block', |
| 137 | 'label' => esc_html__('Login Page', 'wp-user-avatar'), |
| 138 | 'data' => $this->page_dropdown('set_login_url'), |
| 139 | 'description' => sprintf( |
| 140 | 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'), |
| 141 | '<a href="' . add_query_arg('form-type', 'login', PPRESS_FORMS_SETTINGS_PAGE) . '"><strong>', '</strong></a>', '<br/>'), |
| 142 | ], |
| 143 | 'set_registration_url' => [ |
| 144 | 'type' => 'custom_field_block', |
| 145 | 'label' => esc_html__('Registration Page', 'wp-user-avatar'), |
| 146 | 'data' => $this->page_dropdown('set_registration_url'), |
| 147 | 'description' => sprintf( |
| 148 | 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'), |
| 149 | '<a href="' . add_query_arg('form-type', 'registration', PPRESS_FORMS_SETTINGS_PAGE) . '"><strong>', '</strong></a>', '<br/>'), |
| 150 | ], |
| 151 | 'edit_user_profile_url' => [ |
| 152 | 'type' => 'custom_field_block', |
| 153 | 'label' => esc_html__('My Account Page', 'wp-user-avatar'), |
| 154 | 'data' => $this->page_dropdown('edit_user_profile_url'), |
| 155 | 'description' => sprintf( |
| 156 | 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'), |
| 157 | '<a href="' . add_query_arg('form-type', 'edit-profile', PPRESS_FORMS_SETTINGS_PAGE) . '"><strong>', '</strong></a>', '<code>[profilepress-my-account]</code>'), |
| 158 | ], |
| 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 | 'remove_plugin_data' => [ |
| 167 | 'type' => 'checkbox', |
| 168 | 'value' => 'yes', |
| 169 | 'label' => esc_html__('Remove Data on Uninstall', 'wp-user-avatar'), |
| 170 | 'checkbox_label' => esc_html__('Delete', 'wp-user-avatar'), |
| 171 | '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'), |
| 172 | ] |
| 173 | ] |
| 174 | ]), |
| 175 | 'registration_settings' => apply_filters('ppress_registration_settings_page', [ |
| 176 | 'tab_title' => esc_html__('Registration', 'wp-user-avatar'), |
| 177 | 'dashicon' => 'dashicons-welcome-learn-more', |
| 178 | [ |
| 179 | 'section_title' => esc_html__('Registration Settings', 'wp-user-avatar'), |
| 180 | 'set_auto_login_after_reg' => [ |
| 181 | 'type' => 'checkbox', |
| 182 | 'label' => esc_html__('Auto-login after registration', 'wp-user-avatar'), |
| 183 | 'checkbox_label' => esc_html__('Enable auto-login', 'wp-user-avatar'), |
| 184 | 'value' => 'on', |
| 185 | 'description' => esc_html__('Check this option to automatically login users after successful registration.', 'wp-user-avatar') |
| 186 | ] |
| 187 | ] |
| 188 | ]), |
| 189 | 'login_settings' => apply_filters('ppress_login_settings_page', [ |
| 190 | 'tab_title' => esc_html__('Login', 'wp-user-avatar'), |
| 191 | 'dashicon' => 'dashicons-universal-access-alt', |
| 192 | [ |
| 193 | 'section_title' => esc_html__('Login Settings', 'wp-user-avatar'), |
| 194 | 'login_username_email_restrict' => [ |
| 195 | 'type' => 'select', |
| 196 | 'options' => [ |
| 197 | 'both' => esc_html__('Email Address and Username (default)', 'wp-user-avatar'), |
| 198 | 'email' => esc_html__('Email Address Only', 'wp-user-avatar'), |
| 199 | 'username' => esc_html__('Username Only', 'wp-user-avatar') |
| 200 | ], |
| 201 | 'value' => '', |
| 202 | 'label' => esc_html__('Login with Email or Username', 'wp-user-avatar'), |
| 203 | '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') |
| 204 | ], |
| 205 | ] |
| 206 | ]), |
| 207 | 'my_account_settings' => apply_filters('ppress_my_account_settings_page', [ |
| 208 | 'tab_title' => esc_html__('My Account', 'wp-user-avatar'), |
| 209 | 'section_title' => esc_html__('My Account Settings', 'wp-user-avatar'), |
| 210 | 'dashicon' => 'dashicons-dashboard', |
| 211 | 'redirect_default_edit_profile_to_custom' => [ |
| 212 | 'type' => 'checkbox', |
| 213 | 'label' => esc_html__('Redirect Default Edit Profile', 'wp-user-avatar'), |
| 214 | 'checkbox_label' => esc_html__('Activate', 'wp-user-avatar'), |
| 215 | 'value' => 'yes', |
| 216 | 'description' => sprintf( |
| 217 | __('Redirect <a target="_blank" href="%s">default WordPress profile</a> to My Account page.', 'wp-user-avatar'), |
| 218 | admin_url('profile.php') |
| 219 | ) |
| 220 | ], |
| 221 | 'myac_edit_account_endpoint' => [ |
| 222 | 'type' => 'text', |
| 223 | 'value' => 'edit-profile', |
| 224 | 'label' => esc_html__('Edit Account Endpoint', 'wp-user-avatar'), |
| 225 | 'description' => __('Endpoint for the "My Account → Account Details" page.', 'wp-user-avatar'), |
| 226 | ], |
| 227 | 'myac_change_password_endpoint' => [ |
| 228 | 'type' => 'text', |
| 229 | 'value' => 'change-password', |
| 230 | 'label' => esc_html__('Change Password Endpoint', 'wp-user-avatar'), |
| 231 | 'description' => __('Endpoint for the "My Account → Change Password" page.', 'wp-user-avatar'), |
| 232 | ], |
| 233 | 'myac_account_details_form' => [ |
| 234 | 'type' => 'select', |
| 235 | 'options' => $edit_profile_forms, |
| 236 | 'label' => esc_html__('Account Details Form', 'wp-user-avatar'), |
| 237 | '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') |
| 238 | ], |
| 239 | ]), |
| 240 | 'frontend_profile_settings' => apply_filters('ppress_frontend_profile_settings_page', [ |
| 241 | 'tab_title' => esc_html__('Frontend Profile', 'wp-user-avatar'), |
| 242 | 'section_title' => esc_html__('Frontend Profile Settings', 'wp-user-avatar'), |
| 243 | 'dashicon' => 'dashicons-admin-users', |
| 244 | 'set_user_profile_shortcode' => [ |
| 245 | 'type' => 'custom_field_block', |
| 246 | 'label' => esc_html__('Page with Profile Shortcode', 'wp-user-avatar'), |
| 247 | 'data' => $this->page_dropdown('set_user_profile_shortcode'), |
| 248 | 'description' => sprintf(__('Select the page that contains your <a href="%s">Frontend user profile shortcode</a>.', 'wp-user-avatar'), PPRESS_USER_PROFILES_SETTINGS_PAGE), |
| 249 | ], |
| 250 | 'set_user_profile_slug' => [ |
| 251 | 'type' => 'text', |
| 252 | 'value' => 'profile', |
| 253 | 'label' => esc_html__('Profile Slug', 'wp-user-avatar'), |
| 254 | '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>'), |
| 255 | ], |
| 256 | 'disable_guests_can_view_profiles' => [ |
| 257 | 'type' => 'checkbox', |
| 258 | 'label' => esc_html__('Disable Guests from Viewing Profiles', 'wp-user-avatar'), |
| 259 | 'description' => esc_html__('Enable this option to stop disable guests or non-registered users from viewing users profiles.', 'wp-user-avatar'), |
| 260 | 'value' => 'on' |
| 261 | ], |
| 262 | 'disable_members_can_view_profiles' => [ |
| 263 | 'type' => 'checkbox', |
| 264 | 'label' => esc_html__('Disable Members from Viewing Profiles', 'wp-user-avatar'), |
| 265 | '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'), |
| 266 | 'value' => 'on' |
| 267 | ], |
| 268 | 'comment_author_url_to_profile' => [ |
| 269 | 'type' => 'checkbox', |
| 270 | 'label' => esc_html__('Comment Author URL to Profile', 'wp-user-avatar'), |
| 271 | 'checkbox_label' => esc_html__('Enable option', 'wp-user-avatar'), |
| 272 | 'value' => 'on', |
| 273 | 'description' => sprintf(__("Change URL of comment authors to their ProfilePress front-end profile.", 'wp-user-avatar')) |
| 274 | ], |
| 275 | 'author_slug_to_profile' => [ |
| 276 | 'type' => 'checkbox', |
| 277 | 'label' => esc_html__('Authors Page to Profile', 'wp-user-avatar'), |
| 278 | 'checkbox_label' => esc_html__('Enable option', 'wp-user-avatar'), |
| 279 | 'value' => 'on', |
| 280 | '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>') |
| 281 | ], |
| 282 | ] |
| 283 | ), |
| 284 | 'redirection_settings' => apply_filters('ppress_redirection_settings_page', [ |
| 285 | 'tab_title' => esc_html__('Redirection', 'wp-user-avatar'), |
| 286 | 'section_title' => esc_html__('Redirection Settings', 'wp-user-avatar'), |
| 287 | 'dashicon' => 'dashicons-redo', |
| 288 | 'set_log_out_url' => [ |
| 289 | 'type' => 'custom_field_block', |
| 290 | 'label' => esc_html__('Log out', 'wp-user-avatar'), |
| 291 | 'data' => $this->page_dropdown('set_log_out_url', |
| 292 | [ |
| 293 | ['key' => 'default', 'label' => esc_html__('Select...', 'wp-user-avatar')], |
| 294 | ['key' => 'current_view_page', 'label' => esc_html__('Currently viewed page', 'wp-user-avatar')] |
| 295 | ], |
| 296 | ['skip_append_default_select' => true] |
| 297 | ) . $this->custom_text_input('custom_url_log_out'), |
| 298 | 'description' => sprintf( |
| 299 | 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' . |
| 300 | esc_html__('Leave the "custom URL" field empty to fallback to the selected page.', 'wp-user-avatar'), |
| 301 | '<br/>' |
| 302 | ) |
| 303 | ], |
| 304 | 'set_login_redirect' => [ |
| 305 | 'type' => 'custom_field_block', |
| 306 | 'label' => esc_html__('Login', 'wp-user-avatar'), |
| 307 | 'data' => $this->page_dropdown('set_login_redirect', $login_redirect_page_dropdown_args) . $this->custom_text_input('custom_url_login_redirect'), |
| 308 | 'description' => sprintf( |
| 309 | 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' . |
| 310 | esc_html__('Leave the "custom URL" field empty to fallback to the selected page.', 'wp-user-avatar'), |
| 311 | '<br/>' |
| 312 | ) |
| 313 | ], |
| 314 | 'set_password_reset_redirect' => [ |
| 315 | 'type' => 'custom_field_block', |
| 316 | 'label' => esc_html__('Password Reset', 'wp-user-avatar'), |
| 317 | 'data' => $this->page_dropdown( |
| 318 | 'set_password_reset_redirect', |
| 319 | [], |
| 320 | [ |
| 321 | 'show_option_none' => esc_html__('Default..', 'wp-user-avatar'), |
| 322 | 'option_none_value' => 'no_redirect', |
| 323 | ] |
| 324 | ) . $this->custom_text_input('custom_url_password_reset_redirect'), |
| 325 | 'description' => sprintf( |
| 326 | 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' . |
| 327 | esc_html__('Leave the "custom URL" field empty to fallback to the selected page.', 'wp-user-avatar'), |
| 328 | '<br/>' |
| 329 | ) |
| 330 | ] |
| 331 | ]), |
| 332 | 'access_settings' => apply_filters('ppress_access_settings_page', [ |
| 333 | 'tab_title' => esc_html__('Access', 'wp-user-avatar'), |
| 334 | 'section_title' => esc_html__('Access Settings', 'wp-user-avatar'), |
| 335 | 'dashicon' => 'dashicons-products', |
| 336 | 'global_site_access_notice' => [ |
| 337 | 'type' => 'arbitrary', |
| 338 | 'data' => '', |
| 339 | 'description' => sprintf( |
| 340 | '<div class="ppress-settings-page-notice">' . esc_html__('%sNote:%s Access setting takes precedence over %sContent Protection rules%s.', 'wp-user-avatar'), |
| 341 | '<strong>', '</strong>', '<a target="_blank" href="' . PPRESS_CONTENT_PROTECTION_SETTINGS_PAGE . '">', '</a>' |
| 342 | ) |
| 343 | ], |
| 344 | 'global_site_access' => [ |
| 345 | 'type' => 'select', |
| 346 | 'label' => esc_html__('Global Site Access', 'wp-user-avatar'), |
| 347 | 'options' => [ |
| 348 | 'everyone' => esc_html__('Accessible to Everyone', 'wp-user-avatar'), |
| 349 | 'login' => esc_html__('Accessible to Logged-in Users', 'wp-user-avatar') |
| 350 | ] |
| 351 | ], |
| 352 | 'global_site_access_redirect_page' => [ |
| 353 | 'type' => 'custom_field_block', |
| 354 | 'label' => esc_html__('Redirect Page', 'wp-user-avatar'), |
| 355 | 'data' => $this->page_dropdown('global_site_access_redirect_page') . $this->custom_text_input('global_site_access_custom_redirect_page'), |
| 356 | 'description' => esc_html__('Select the page or custom URL to redirect users that are not logged in to.', 'wp-user-avatar') |
| 357 | ], |
| 358 | 'global_site_access_exclude_pages' => [ |
| 359 | 'type' => 'select2', |
| 360 | 'label' => esc_html__('Pages to Exclude', 'wp-user-avatar'), |
| 361 | 'options' => array_reduce(get_pages(), function ($carry, $item) { |
| 362 | $carry[$item->ID] = $item->post_title; |
| 363 | |
| 364 | return $carry; |
| 365 | }, []), |
| 366 | 'description' => esc_html__('Select the pages to exclude beside the redirect page that will be accessible by everyone.', 'wp-user-avatar') |
| 367 | ], |
| 368 | 'global_site_access_allow_homepage' => [ |
| 369 | 'type' => 'checkbox', |
| 370 | 'value' => 'yes', |
| 371 | 'checkbox_label' => esc_html__('Enable', 'wp-user-avatar'), |
| 372 | 'label' => esc_html__('Accessible Homepage', 'wp-user-avatar'), |
| 373 | 'description' => esc_html__('Check to allow homepage to be accessible by everyone.', 'wp-user-avatar') |
| 374 | ], |
| 375 | 'global_restricted_access_message' => [ |
| 376 | 'type' => 'wp_editor', |
| 377 | 'value' => esc_html__('You are unauthorized to view this page.', 'wp-user-avatar'), |
| 378 | 'label' => esc_html__('Global Restricted Access Message', 'wp-user-avatar'), |
| 379 | 'description' => esc_html__('This is the message shown to users that do not have permission to view the content.', 'wp-user-avatar') |
| 380 | ], |
| 381 | ]) |
| 382 | ]; |
| 383 | |
| 384 | if (class_exists('\BuddyPress')) { |
| 385 | $args['buddypress_settings'] = apply_filters('ppress_buddypress_settings_page', [ |
| 386 | 'tab_title' => esc_html__('BuddyPress', 'wp-user-avatar'), |
| 387 | 'section_title' => esc_html__('BuddyPress Settings', 'wp-user-avatar'), |
| 388 | 'dashicon' => 'dashicons-buddicons-buddypress-logo', |
| 389 | 'redirect_bp_registration_page' => [ |
| 390 | 'type' => 'checkbox', |
| 391 | 'value' => 'yes', |
| 392 | 'label' => esc_html__('Registration Page', 'wp-user-avatar'), |
| 393 | 'checkbox_label' => esc_html__('Check to enable', 'wp-user-avatar'), |
| 394 | 'description' => sprintf(__('Check to redirect BuddyPress registration page to your selected %s', 'wp-user-avatar'), '<a href="#global_settings?set_registration_url_row">custom registration page</a>') |
| 395 | ], |
| 396 | 'override_bp_avatar' => [ |
| 397 | 'type' => 'checkbox', |
| 398 | 'label' => esc_html__('Override Avatar', 'wp-user-avatar'), |
| 399 | 'value' => 'yes', |
| 400 | 'checkbox_label' => esc_html__('Check to enable', 'wp-user-avatar'), |
| 401 | 'description' => esc_html__('Check to override BuddyPress users uploaded avatars with that of ProfilePress.', 'wp-user-avatar') |
| 402 | ], |
| 403 | 'override_bp_profile_url' => [ |
| 404 | 'type' => 'checkbox', |
| 405 | 'value' => 'yes', |
| 406 | 'label' => esc_html__('Override Profile URL', 'wp-user-avatar'), |
| 407 | 'checkbox_label' => esc_html__('Check to enable', 'wp-user-avatar'), |
| 408 | 'description' => esc_html__('Check to change the profile URL of BuddyPress users to ProfilePress front-end profile.', 'wp-user-avatar') |
| 409 | ] |
| 410 | ] |
| 411 | ); |
| 412 | } |
| 413 | |
| 414 | if (class_exists('\bbPress')) { |
| 415 | $args['bbpress_settings'] = apply_filters('ppress_bbpress_settings_page', [ |
| 416 | 'tab_title' => esc_html__('bbPress', 'wp-user-avatar'), |
| 417 | 'section_title' => esc_html__('bbPress Settings', 'wp-user-avatar'), |
| 418 | 'dashicon' => 'dashicons-buddicons-bbpress-logo', |
| 419 | 'override_bbp_profile_url' => [ |
| 420 | 'type' => 'checkbox', |
| 421 | 'value' => 'yes', |
| 422 | 'label' => esc_html__('Override Profile URL', 'wp-user-avatar'), |
| 423 | 'checkbox_label' => esc_html__('Check to enable', 'wp-user-avatar'), |
| 424 | 'description' => esc_html__('Check to change bbPress profile URL to ProfilePress front-end profile.', 'wp-user-avatar') |
| 425 | ] |
| 426 | ] |
| 427 | ); |
| 428 | } |
| 429 | |
| 430 | $this->settingsPageInstance->main_content(apply_filters('ppress_settings_page_args', $args)); |
| 431 | $this->settingsPageInstance->build_sidebar_tab_style(); |
| 432 | } |
| 433 | |
| 434 | public function custom_sanitize() |
| 435 | { |
| 436 | $config = apply_filters('ppress_settings_custom_sanitize', [ |
| 437 | 'global_restricted_access_message' => function ($val) { |
| 438 | return wp_kses_post($val); |
| 439 | }, |
| 440 | 'uec_unactivated_error' => function ($val) { |
| 441 | return wp_kses_post($val); |
| 442 | }, |
| 443 | 'uec_invalid_error' => function ($val) { |
| 444 | return wp_kses_post($val); |
| 445 | }, |
| 446 | 'uec_success_message' => function ($val) { |
| 447 | return wp_kses_post($val); |
| 448 | }, |
| 449 | 'uec_activation_resent' => function ($val) { |
| 450 | return wp_kses_post($val); |
| 451 | }, |
| 452 | 'uec_already_confirm_message' => function ($val) { |
| 453 | return wp_kses_post($val); |
| 454 | } |
| 455 | ]); |
| 456 | |
| 457 | foreach ($config as $fieldKey => $callback) { |
| 458 | add_filter('wp_cspa_sanitize_skip', function ($return, $key, $value) use ($fieldKey, $callback) { |
| 459 | if ($key == $fieldKey) { |
| 460 | return call_user_func($callback, $value); |
| 461 | } |
| 462 | |
| 463 | return $return; |
| 464 | }, 10, 3); |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | public static function get_instance() |
| 469 | { |
| 470 | static $instance = null; |
| 471 | |
| 472 | if (is_null($instance)) { |
| 473 | $instance = new self(); |
| 474 | } |
| 475 | |
| 476 | return $instance; |
| 477 | } |
| 478 | } |