Changeset 13886 for trunk/src/bp-core/admin/bp-core-admin-settings.php
- Timestamp:
- 06/01/2024 07:41:30 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-settings.php
r13878 r13886 14 14 * Main settings section description for the settings page. 15 15 * 16 * @since 1.6.0 17 */ 18 function bp_admin_setting_callback_main_section() { } 16 * @internal This function is used as a callback for the 'bp_main_section' settings section. 17 * 18 * @since 1.6.0 19 */ 20 function bp_admin_setting_callback_main_section() {} 19 21 20 22 /** … … 22 24 * 23 25 * @since 1.6.0 24 *25 26 */ 26 27 function bp_admin_setting_callback_admin_bar() { 27 ?>28 29 <input id="hide-loggedout-adminbar" name="hide-loggedout-adminbar" type="checkbox" value="1" <?php checked( ! bp_hide_loggedout_adminbar( false ) ); ?> />28 ?> 29 30 <input id="hide-loggedout-adminbar" name="hide-loggedout-adminbar" type="checkbox" value="1" <?php checked( ! bp_hide_loggedout_adminbar( false ) ); ?> /> 30 31 <label for="hide-loggedout-adminbar"><?php esc_html_e( 'Show the Toolbar for logged out users', 'buddypress' ); ?></label> 31 32 32 <?php33 <?php 33 34 } 34 35 … … 40 41 function bp_admin_setting_callback_community_visibility() { 41 42 $visibility = bp_get_community_visibility( 'all' ); 42 ?>43 ?> 43 44 <select name="_bp_community_visibility[global]" id="_bp_community_visibility-global" aria-describedby="_bp_community_visibility_description" autocomplete="off"> 44 45 <option value="anyone" <?php echo selected( $visibility['global'], 'anyone' ); ?>><?php esc_html_e( 'Anyone', 'buddypress' ); ?></option> … … 47 48 48 49 <p id="_bp_community_visibility_description" class="description"><?php esc_html_e( 'Choose "Anyone" to allow any visitor access to your community area. Choose "Members Only" to restrict access to your community area to logged-in members only.', 'buddypress' ); ?></p> 49 <?php50 <?php 50 51 } 51 52 … … 56 57 * 57 58 * @param mixed $saved_value The value passed to the save function. 59 * @return array 58 60 */ 59 61 function bp_admin_sanitize_callback_community_visibility( $saved_value ) { … … 91 93 */ 92 94 function bp_admin_setting_callback_theme_package_id() { 93 $options = ''; 95 $options = ''; 96 $package_id = bp_get_theme_package_id(); 94 97 95 98 /* … … 104 107 '<option value="%1$s" %2$s>%3$s</option>', 105 108 esc_attr( $id ), 106 selected( $theme->id, bp_get_theme_package_id(), false ),109 selected( $theme->id, $package_id, false ), 107 110 esc_html( $theme->name ) 108 111 ); … … 110 113 111 114 // phpcs:disable WordPress.Security.EscapeOutput 112 if ( $options ) : ?> 115 if ( $options ) : 116 ?> 113 117 <select name="_bp_theme_package_id" id="_bp_theme_package_id" aria-describedby="_bp_theme_package_description"><?php echo $options; ?></select> 114 118 <p id="_bp_theme_package_description" class="description"><?php esc_html_e( 'The selected Template Pack will serve all BuddyPress templates.', 'buddypress' ); ?></p> … … 117 121 <p><?php esc_html_e( 'No template packages available.', 'buddypress' ); ?></p> 118 122 119 <?php endif; 123 <?php 124 endif; 120 125 // phpcs:enable 121 126 } … … 126 131 * Groups settings section description for the settings page. 127 132 * 128 * @since 1.6.0 129 */ 130 function bp_admin_setting_callback_activity_section() { } 133 * @internal This function is used as a callback for the 'bp_activity_section' settings section. 134 * 135 * @since 1.6.0 136 */ 137 function bp_admin_setting_callback_activity_section() {} 131 138 132 139 /** … … 134 141 * 135 142 * @since 1.6.0 136 *137 143 */ 138 144 function bp_admin_setting_callback_activity_akismet() { 139 ?> 140 145 ?> 141 146 <input id="_bp_enable_akismet" name="_bp_enable_akismet" type="checkbox" value="1" <?php checked( bp_is_akismet_active( true ) ); ?> /> 142 147 <label for="_bp_enable_akismet"><?php esc_html_e( 'Allow Akismet to scan for activity stream spam', 'buddypress' ); ?></label> 143 144 <?php 148 <?php 145 149 } 146 150 … … 152 156 function bp_admin_setting_callback_blogforum_comments() { 153 157 $support = post_type_supports( 'post', 'buddypress-activity' ); 154 ?>158 ?> 155 159 156 160 <input id="bp-disable-blogforum-comments" name="bp-disable-blogforum-comments" type="checkbox" value="1" <?php checked( ! bp_disable_blogforum_comments( false ) ); ?> <?php disabled( ! $support ); ?> /> … … 160 164 <?php endif; ?> 161 165 162 <?php166 <?php 163 167 } 164 168 … … 169 173 */ 170 174 function bp_admin_setting_callback_heartbeat() { 171 ?> 172 175 ?> 173 176 <input id="_bp_enable_heartbeat_refresh" name="_bp_enable_heartbeat_refresh" type="checkbox" value="1" <?php checked( bp_is_activity_heartbeat_active( true ) ); ?> /> 174 177 <label for="_bp_enable_heartbeat_refresh"><?php esc_html_e( 'Automatically check for new items while viewing the activity stream', 'buddypress' ); ?></label> 175 176 <?php 178 <?php 177 179 } 178 180 … … 187 189 * 188 190 * @param bool $value Whether or not to sanitize. 189 * @return bool191 * @return int 190 192 */ 191 193 function bp_admin_sanitize_callback_blogforum_comments( $value = false ) { … … 198 200 * Profile settings section description for the settings page. 199 201 * 200 * @since 1.6.0 201 */ 202 function bp_admin_setting_callback_members_section() { } 202 * @internal This function is used as a callback for the 'bp_members_section' settings section. 203 * 204 * @since 1.6.0 205 */ 206 function bp_admin_setting_callback_members_section() {} 203 207 204 208 /** … … 209 213 */ 210 214 function bp_admin_setting_callback_avatar_uploads() { 211 ?>215 ?> 212 216 <input id="bp-disable-avatar-uploads" name="bp-disable-avatar-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_avatar_uploads( false ) ); ?> /> 213 217 <label for="bp-disable-avatar-uploads"><?php esc_html_e( 'Allow registered members to upload avatars', 'buddypress' ); ?></label> 214 <?php218 <?php 215 219 } 216 220 … … 222 226 */ 223 227 function bp_admin_setting_callback_cover_image_uploads() { 224 ?>228 ?> 225 229 <input id="bp-disable-cover-image-uploads" name="bp-disable-cover-image-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_cover_image_uploads() ); ?> /> 226 230 <label for="bp-disable-cover-image-uploads"><?php esc_html_e( 'Allow registered members to upload cover images', 'buddypress' ); ?></label> 227 <?php231 <?php 228 232 } 229 233 … … 234 238 */ 235 239 function bp_admin_setting_callback_members_invitations() { 236 ?>240 ?> 237 241 <input id="bp-enable-members-invitations" name="bp-enable-members-invitations" type="checkbox" value="1" <?php checked( bp_get_members_invitations_allowed() ); ?> /> 238 242 <label for="bp-enable-members-invitations"><?php esc_html_e( 'Allow registered members to invite people to join this network', 'buddypress' ); ?></label> … … 255 259 */ 256 260 function bp_admin_setting_callback_membership_requests() { 257 ?>261 ?> 258 262 <input id="bp-enable-membership-requests" name="bp-enable-membership-requests" type="checkbox" value="1" <?php checked( bp_get_membership_requests_required( 'raw' ) ); ?> <?php disabled( bp_get_signup_allowed() ); ?> /> 259 263 <label for="bp-enable-membership-requests"><?php esc_html_e( 'Allow visitors to request site membership. If enabled, an administrator must approve each new site membership request.', 'buddypress' ); ?></label> … … 262 266 <p class="description"><?php esc_html_e( 'With a WP multisite setup, to require membership requests for new signups, choose one of the following two options from the Network Settings > Registration Settings pane:', 'buddypress' ); ?><p> 263 267 <ul> 264 <li><p class="description"><?php esc_html_e( 'To allow the submission of membership requests but not allow site creation requests, select "Registration is disabled".', 'buddypress' ) ?></p></li>265 <li><p class="description"><?php esc_html_e( 'To allow the submission of membership requests and to allow new sites to be created by your users, choose "Logged in users may register new sites".', 'buddypress' ) ?></p></li>268 <li><p class="description"><?php esc_html_e( 'To allow the submission of membership requests but not allow site creation requests, select "Registration is disabled".', 'buddypress' ); ?></p></li> 269 <li><p class="description"><?php esc_html_e( 'To allow the submission of membership requests and to allow new sites to be created by your users, choose "Logged in users may register new sites".', 'buddypress' ); ?></p></li> 266 270 </ul> 267 271 <p class="description"><?php esc_html_e( 'The other two options, "User accounts may be registered" and "Both sites and user accounts can be registered," are open in nature and membership requests will not be enabled if one of those options is selected.', 'buddypress' ); ?><p> … … 284 288 * Profile settings section description for the settings page. 285 289 * 286 * @since 1.6.0 287 */ 288 function bp_admin_setting_callback_xprofile_section() { } 290 * @internal This function is used as a callback for the 'bp_xprofile_section' settings section. 291 * 292 * @since 1.6.0 293 */ 294 function bp_admin_setting_callback_xprofile_section() {} 289 295 290 296 /** … … 292 298 * 293 299 * @since 1.6.0 294 *295 300 */ 296 301 function bp_admin_setting_callback_profile_sync() { 297 ?> 298 299 <input id="bp-disable-profile-sync" name="bp-disable-profile-sync" type="checkbox" value="1" <?php checked( !bp_disable_profile_sync( false ) ); ?> /> 302 ?> 303 <input id="bp-disable-profile-sync" name="bp-disable-profile-sync" type="checkbox" value="1" <?php checked( ! bp_disable_profile_sync( false ) ); ?> /> 300 304 <label for="bp-disable-profile-sync"><?php esc_html_e( 'Enable BuddyPress to WordPress profile syncing', 'buddypress' ); ?></label> 301 302 <?php 305 <?php 303 306 } 304 307 … … 308 311 * Groups settings section description for the settings page. 309 312 * 310 * @since 1.6.0 311 */ 312 function bp_admin_setting_callback_groups_section() { } 313 * @internal This function is used as a callback for the 'bp_groups_section' settings section. 314 * 315 * @since 1.6.0 316 */ 317 function bp_admin_setting_callback_groups_section() {} 313 318 314 319 /** … … 316 321 * 317 322 * @since 1.6.0 318 *319 323 */ 320 324 function bp_admin_setting_callback_group_creation() { 321 ?> 322 323 <input id="bp_restrict_group_creation" name="bp_restrict_group_creation" type="checkbox" aria-describedby="bp_group_creation_description" value="1" <?php checked( !bp_restrict_group_creation( false ) ); ?> /> 325 ?> 326 <input id="bp_restrict_group_creation" name="bp_restrict_group_creation" type="checkbox" aria-describedby="bp_group_creation_description" value="1" <?php checked( ! bp_restrict_group_creation( false ) ); ?> /> 324 327 <label for="bp_restrict_group_creation"><?php esc_html_e( 'Enable group creation for all users', 'buddypress' ); ?></label> 325 328 <p class="description" id="bp_group_creation_description"><?php esc_html_e( 'Administrators can always create groups, regardless of this setting.', 'buddypress' ); ?></p> 326 327 <?php 329 <?php 328 330 } 329 331 … … 334 336 */ 335 337 function bp_admin_setting_callback_group_avatar_uploads() { 336 ?>338 ?> 337 339 <input id="bp-disable-group-avatar-uploads" name="bp-disable-group-avatar-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_group_avatar_uploads() ); ?> /> 338 340 <label for="bp-disable-group-avatar-uploads"><?php esc_html_e( 'Allow customizable avatars for groups', 'buddypress' ); ?></label> 339 <?php341 <?php 340 342 } 341 343 … … 346 348 */ 347 349 function bp_admin_setting_callback_group_cover_image_uploads() { 348 ?>350 ?> 349 351 <input id="bp-disable-group-cover-image-uploads" name="bp-disable-group-cover-image-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_group_cover_image_uploads() ); ?> /> 350 352 <label for="bp-disable-group-cover-image-uploads"><?php esc_html_e( 'Allow customizable cover images for groups', 'buddypress' ); ?></label> 351 <?php353 <?php 352 354 } 353 355 … … 358 360 */ 359 361 function bp_admin_setting_callback_group_activity_deletions() { 360 ?>362 ?> 361 363 <input id="bp-disable-group-activity-deletions" name="bp-disable-group-activity-deletions" type="checkbox" value="1" <?php checked( ! bp_disable_group_activity_deletions() ); ?> /> 362 364 <label for="bp-disable-group-activity-deletions"><?php esc_html_e( "Allow group administrators and moderators to delete activity items from their group's activity stream", 'buddypress' ); ?></label> 363 <?php365 <?php 364 366 } 365 367 … … 369 371 * Account settings section description for the settings page. 370 372 * 373 * @internal This function is used as a callback for the 'bp_account_section' settings section. 374 * 371 375 * @since 12.0.0 372 376 */ 373 function bp_admin_setting_callback_settings_section() { 377 function bp_admin_setting_callback_settings_section() {} 374 378 375 379 /** … … 379 383 */ 380 384 function bp_admin_setting_callback_account_deletion() { 381 ?> 382 385 ?> 383 386 <input id="bp-disable-account-deletion" name="bp-disable-account-deletion" type="checkbox" value="1" <?php checked( ! bp_disable_account_deletion( false ) ); ?> /> 384 387 <label for="bp-disable-account-deletion"><?php esc_html_e( 'Allow registered members to delete their own accounts', 'buddypress' ); ?></label> 385 386 <?php 388 <?php 387 389 } 388 390 … … 393 395 * 394 396 * @since 1.6.0 395 *396 397 */ 397 398 function bp_core_admin_settings() { … … 403 404 404 405 <div class="buddypress-body"> 405 <form action="<?php echo esc_url( $form_action ) ?>" method="post">406 <form action="<?php echo esc_url( $form_action ); ?>" method="post"> 406 407 407 408 <?php settings_fields( 'buddypress' ); ?> … … 415 416 </div> 416 417 417 <?php418 <?php 418 419 } 419 420 … … 426 427 global $wp_settings_fields; 427 428 428 if ( isset( $_GET['page'] ) && 'bp-settings' == $_GET['page'] && !empty( $_POST['submit'] ) ) {429 if ( isset( $_GET['page'] ) && 'bp-settings' === $_GET['page'] && ! empty( $_POST['submit'] ) ) { 429 430 check_admin_referer( 'buddypress-options' ); 430 431 … … 434 435 foreach ( (array) $wp_settings_fields['buddypress'] as $section => $settings ) { 435 436 foreach ( $settings as $setting_name => $setting ) { 436 $value = isset( $_POST[ $setting_name] ) ? $_POST[$setting_name] : '';437 $value = isset( $_POST[ $setting_name ] ) ? $_POST[ $setting_name ] : ''; 437 438 438 439 bp_update_option( $setting_name, $value ); … … 459 460 // Ie, the Profile Syncing option reads "Enable Sync", so when it's checked, 460 461 // the corresponding option should be unset. 461 $value = isset( $_POST[ $legacy_option] ) ? '' : 1;462 $value = isset( $_POST[ $legacy_option ] ) ? '' : 1; 462 463 bp_update_option( $legacy_option, $value ); 463 464 } 464 465 465 bp_core_redirect( add_query_arg( array( 'page' => 'bp-settings', 'updated' => 'true' ), bp_get_admin_url( 'admin.php' ) ) ); 466 bp_core_redirect( 467 add_query_arg( 468 array( 469 'page' => 'bp-settings', 470 'updated' => 'true', 471 ), 472 bp_get_admin_url( 'admin.php' ) 473 ) 474 ); 466 475 } 467 476 } … … 473 482 * @since 1.6.0 474 483 * 475 * @param string $option Form option to echo.476 * @param string $default Form option default.477 * @param bool $slug Form option slug.478 */ 479 function bp_form_option( $option, $default = '', $slug = false ) {484 * @param string $option Form option to echo. 485 * @param string $default_option Form option default. 486 * @param bool $slug Form option slug. 487 */ 488 function bp_form_option( $option, $default_option = '', $slug = false ) { 480 489 // phpcs:ignore WordPress.Security.EscapeOutput 481 echo bp_get_form_option( $option, $default, $slug ); 482 } 483 484 /** 485 * Return settings API option 486 * 487 * @since 1.6.0 488 * 489 * 490 * @param string $option Form option to return. 491 * @param string $default Form option default. 492 * @param bool $slug Form option slug. 490 echo bp_get_form_option( $option, $default_option, $slug ); 491 } 492 493 /** 494 * Return settings API option. 495 * 496 * @since 1.6.0 497 * 498 * @param string $option Form option to return. 499 * @param string $default_option Optional. Form option default. Default is empty string. 500 * @param bool $slug Optional. Form option slug. Default is false. 493 501 * @return string 494 502 */ 495 function bp_get_form_option( $option, $default = '', $slug = false ) {503 function bp_get_form_option( $option, $default_option = '', $slug = false ) { 496 504 497 505 // Get the option and sanitize it. 498 $value = bp_get_option( $option, $default );506 $value = bp_get_option( $option, $default_option ); 499 507 500 508 // Slug? 501 509 if ( true === $slug ) { 502 503 510 /** 504 511 * Filters the slug value in the form field. … … 507 514 * 508 515 * @param string $value Value being returned for the requested option. 516 * @param string $option Option whose value is being requested. 509 517 */ 510 $value = esc_attr( apply_filters( 'editable_slug', $value ) ); 511 } else { // Not a slug. 512 $value = esc_attr( $value ); 518 $value = apply_filters( 'editable_slug', $value, $option ); 513 519 } 514 520 515 521 // Fallback to default. 516 522 if ( empty( $value ) ) { 517 $value = $default ;523 $value = $default_option; 518 524 } 525 526 $value = esc_attr( $value ); 519 527 520 528 /**
Note: See TracChangeset
for help on using the changeset viewer.