Changeset 6283
- Timestamp:
- 02/03/2017 08:30:28 PM (9 years ago)
- Location:
- trunk/src/includes/admin
- Files:
-
- 2 edited
-
functions.php (modified) (1 diff)
-
tools.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/functions.php
r6279 r6283 251 251 } 252 252 } 253 254 /**255 * Output the tabs in the admin area256 *257 * @since 2.1.0 bbPress (r3872)258 *259 * @param string $active_tab Name of the tab that is active260 */261 function bbp_tools_admin_tabs( $active_tab = '' ) {262 echo bbp_get_tools_admin_tabs( $active_tab );263 }264 265 /**266 * Output the tabs in the admin area267 *268 * @since 2.1.0 bbPress (r3872)269 *270 * @param string $active_tab Name of the tab that is active271 */272 function bbp_get_tools_admin_tabs( $active_tab = '' ) {273 274 // Declare local variables275 $tabs_html = '';276 $idle_class = 'nav-tab';277 $active_class = 'nav-tab nav-tab-active';278 279 // Setup core admin tabs280 $tabs = bbp_get_tools_admin_pages();281 282 // Loop through tabs and build navigation283 foreach ( $tabs as $tab ) {284 285 // Skip if user cannot visit page286 if ( ! current_user_can( $tab['cap'] ) ) {287 continue;288 }289 290 // Setup tab HTML291 $is_current = (bool) ( $tab['name'] == $active_tab );292 $tab_class = $is_current ? $active_class : $idle_class;293 $tab_url = get_admin_url( '', add_query_arg( array( 'page' => $tab['page'] ), 'tools.php' ) );294 $tabs_html .= '<a href="' . esc_url( $tab_url ) . '" class="' . esc_attr( $tab_class ) . '">' . esc_html( $tab['name'] ) . '</a>';295 }296 297 // Output the tabs298 return $tabs_html;299 }300 301 /**302 * Return possible tools pages303 *304 * @since 2.6.0 (r6273)305 *306 * @return array307 */308 function bbp_get_tools_admin_pages() {309 return apply_filters( 'bbp_tools_admin_tabs', array(310 array(311 'page' => 'bbp-repair',312 'func' => 'bbp_admin_repair_page',313 'cap' => 'bbp_tools_repair_page',314 'name' => esc_html__( 'Repair Forums', 'bbpress' ),315 316 // Deprecated 2.6.0317 'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-repair' ), 'tools.php' ) )318 ),319 array(320 'page' => 'bbp-upgrade',321 'func' => 'bbp_admin_upgrade_page',322 'cap' => 'bbp_tools_upgrade_page',323 'name' => esc_html__( 'Upgrade Forums', 'bbpress' ),324 325 // Deprecated 2.6.0326 'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-upgrade' ), 'tools.php' ) )327 ),328 array(329 'page' => 'bbp-converter',330 'func' => 'bbp_converter_settings_page',331 'cap' => 'bbp_tools_import_page',332 'name' => esc_html__( 'Import Forums', 'bbpress' ),333 334 // Deprecated 2.6.0335 'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-converter' ), 'tools.php' ) )336 ),337 array(338 'page' => 'bbp-reset',339 'func' => 'bbp_admin_reset_page',340 'cap' => 'bbp_tools_reset_page',341 'name' => esc_html__( 'Reset Forums', 'bbpress' ),342 343 // Deprecated 2.6.0344 'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-reset' ), 'tools.php' ) )345 )346 ) );347 } -
trunk/src/includes/admin/tools.php
r6282 r6283 391 391 ) ); 392 392 } 393 394 /** 395 * Output the tabs in the admin area 396 * 397 * @since 2.1.0 bbPress (r3872) 398 * 399 * @param string $active_tab Name of the tab that is active 400 */ 401 function bbp_tools_admin_tabs( $active_tab = '' ) { 402 echo bbp_get_tools_admin_tabs( $active_tab ); 403 } 404 405 /** 406 * Output the tabs in the admin area 407 * 408 * @since 2.1.0 bbPress (r3872) 409 * 410 * @param string $active_tab Name of the tab that is active 411 */ 412 function bbp_get_tools_admin_tabs( $active_tab = '' ) { 413 414 // Declare local variables 415 $tabs_html = ''; 416 $idle_class = 'nav-tab'; 417 $active_class = 'nav-tab nav-tab-active'; 418 419 // Setup core admin tabs 420 $tabs = bbp_get_tools_admin_pages(); 421 422 // Loop through tabs and build navigation 423 foreach ( $tabs as $tab ) { 424 425 // Skip if user cannot visit page 426 if ( ! current_user_can( $tab['cap'] ) ) { 427 continue; 428 } 429 430 // Setup tab HTML 431 $is_current = (bool) ( $tab['name'] == $active_tab ); 432 $tab_class = $is_current ? $active_class : $idle_class; 433 $tab_url = get_admin_url( '', add_query_arg( array( 'page' => $tab['page'] ), 'tools.php' ) ); 434 $tabs_html .= '<a href="' . esc_url( $tab_url ) . '" class="' . esc_attr( $tab_class ) . '">' . esc_html( $tab['name'] ) . '</a>'; 435 } 436 437 // Output the tabs 438 return $tabs_html; 439 } 440 441 /** 442 * Return possible tools pages 443 * 444 * @since 2.6.0 (r6273) 445 * 446 * @return array 447 */ 448 function bbp_get_tools_admin_pages() { 449 return apply_filters( 'bbp_tools_admin_tabs', array( 450 array( 451 'page' => 'bbp-repair', 452 'func' => 'bbp_admin_repair_page', 453 'cap' => 'bbp_tools_repair_page', 454 'name' => esc_html__( 'Repair Forums', 'bbpress' ), 455 456 // Deprecated 2.6.0 457 'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-repair' ), 'tools.php' ) ) 458 ), 459 array( 460 'page' => 'bbp-upgrade', 461 'func' => 'bbp_admin_upgrade_page', 462 'cap' => 'bbp_tools_upgrade_page', 463 'name' => esc_html__( 'Upgrade Forums', 'bbpress' ), 464 465 // Deprecated 2.6.0 466 'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-upgrade' ), 'tools.php' ) ) 467 ), 468 array( 469 'page' => 'bbp-converter', 470 'func' => 'bbp_converter_settings_page', 471 'cap' => 'bbp_tools_import_page', 472 'name' => esc_html__( 'Import Forums', 'bbpress' ), 473 474 // Deprecated 2.6.0 475 'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-converter' ), 'tools.php' ) ) 476 ), 477 array( 478 'page' => 'bbp-reset', 479 'func' => 'bbp_admin_reset_page', 480 'cap' => 'bbp_tools_reset_page', 481 'name' => esc_html__( 'Reset Forums', 'bbpress' ), 482 483 // Deprecated 2.6.0 484 'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-reset' ), 'tools.php' ) ) 485 ) 486 ) ); 487 }
Note: See TracChangeset
for help on using the changeset viewer.