bp_admin_setting_callback_page_directory_dropdown( $args )
Pages drop downs callback
Description
Parameters
- $args
-
(Required)
Source
File: bp-core/admin/bp-core-admin-pages.php
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | function bp_admin_setting_callback_page_directory_dropdown( $args ) { extract( $args ); if ( ! bp_is_root_blog() ) { switch_to_blog( bp_get_root_blog_id() ); } // For the button if ( 'button' === $name ) { printf( '<p><a href="%s" class="button">%s</a> </p>' , $args [ 'label' ][ 'link' ], $args [ 'label' ][ 'label' ] ); // For the forums will set the page selected from the custom option `_bbp_root_slug_custom_slug` } elseif ( 'new_forums_page' === $name ) { // Get the page id from the options. $id = (int) bp_get_option( '_bbp_root_slug_custom_slug' ); // Check the status of current set value. $status = get_post_status( $id ); // Set the page id if page exists and in publish otherwise set blank. $id = ( '' !== $status && 'publish' === $status ) ? $id : '' ; echo wp_dropdown_pages( array ( 'name' => 'bp_pages[' . esc_attr( $name ) . ']' , 'echo' => false, 'show_option_none' => __( '- Select a page -' , 'buddyboss' ), 'selected' => ! empty ( $id ) ? $id : false ) ); if ( ! empty ( $id ) ) { printf( '<a href="%s" class="button-secondary" target="_bp">%s</a>' , get_permalink( $id ), __( 'View' , 'buddyboss' ) ); } else { printf( '<a href="%s" class="button-secondary create-background-page" data-name="%s" target="_bp">%s</a>' , 'javascript:void(0);' , esc_attr( $name ), __( 'Create Page' , 'buddyboss' ) ); } if ( '' !== $description ) { printf( '<p class="description">%s</p>' , $description ); } // For the normal directory pages. } else { echo wp_dropdown_pages( array ( 'name' => 'bp_pages[' . esc_attr( $name ) . ']' , 'echo' => false, 'show_option_none' => __( '- Select a page -' , 'buddyboss' ), 'selected' => ! empty ( $existing_pages [ $name ] ) ? $existing_pages [ $name ] : false ) ); if ( ! empty ( $existing_pages [ $name ] ) ) { printf( '<a href="%s" class="button-secondary" target="_bp">%s</a>' , get_permalink( $existing_pages [ $name ] ), __( 'View' , 'buddyboss' ) ); } else { printf( '<a href="%s" class="button-secondary create-background-page" data-name="%s" target="_bp">%s</a>' , 'javascript:void(0);' , esc_attr( $name ), __( 'Create Page' , 'buddyboss' ) ); } if ( '' !== $description ) { printf( '<p class="description">%s</p>' , $description ); } } if ( ! bp_is_root_blog() ) { restore_current_blog(); } } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.