Skip to:
Content

BuddyPress.org

Changeset 1619


Ignore:
Timestamp:
07/20/2009 05:08:39 PM (15 years ago)
Author:
apeatling
Message:

Re-positioned the "BuddyPress" admin area menu and added a proper icon.

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core.php

    r1608 r1619  
    297297 */
    298298function bp_core_add_admin_menu() {
    299     global $wpdb, $bp;
     299    global $wpdb, $bp, $menu;
    300300   
    301301    if ( !is_site_admin() )
     
    303303       
    304304    /* Add the administration tab under the "Site Admin" tab for site administrators */
    305     add_menu_page( __("BuddyPress", 'buddypress'), __("BuddyPress", 'buddypress'), 2, 'bp-core.php', "bp_core_admin_settings" );
    306     add_submenu_page( 'bp-core.php', __("General Settings", 'buddypress'), __("General Settings", 'buddypress'), 1, 'bp-core.php', "bp_core_admin_settings" );
    307     add_submenu_page( 'bp-core.php', __("Component Setup", 'buddypress'), __("Component Setup", 'buddypress'), 2, __FILE__, "bp_core_admin_component_setup" );
     305    bp_core_add_admin_menu_page( array( 'menu_title' => __( 'BuddyPress', 'buddypress' ), 'page_title' => __( 'BuddyPress', 'buddypress' ), 'access_level' => 10, 'file' => 'bp-core.php', 'function' => 'bp_core_admin_settings', 'position' => 2 ) );
     306    add_submenu_page( 'bp-core.php', __( 'General Settings', 'buddypress'), __( 'General Settings', 'buddypress' ), 1, 'bp-core.php', 'bp_core_admin_settings' );
     307    add_submenu_page( 'bp-core.php', __( 'Component Setup', 'buddypress'), __( 'Component Setup', 'buddypress' ), 2, __FILE__, 'bp_core_admin_component_setup' );
    308308}
    309309add_action( 'admin_menu', 'bp_core_add_admin_menu' );
     
    11011101   
    11021102    if ( 0 > $since )
    1103         return __( '[Adjust Time Zone]', 'buddypress' );
     1103        return __( '[Use GMT Timezone]', 'buddypress' );
    11041104
    11051105    /**
     
    15451545add_action( 'wp_footer', 'bp_core_print_generation_time' );
    15461546
     1547/**
     1548 * bp_core_add_admin_menu_page()
     1549 *
     1550 * A better version of add_admin_menu_page() that allows positioning of menus.
     1551 *
     1552 * @package BuddyPress Core
     1553 */
     1554function bp_core_add_admin_menu_page( $args = '' ) {
     1555    global $menu, $admin_page_hooks, $_registered_pages;
     1556
     1557    $defaults = array(
     1558        'page_title' => '',
     1559        'menu_title' => '',
     1560        'access_level' => 2,
     1561        'file' => false,
     1562        'function' => false,
     1563        'icon_url' => false,
     1564        'position' => 100
     1565    );
     1566
     1567    $r = wp_parse_args( $args, $defaults );
     1568    extract( $r, EXTR_SKIP );
     1569   
     1570    $file = plugin_basename( $file );
     1571
     1572    $admin_page_hooks[$file] = sanitize_title( $menu_title );
     1573
     1574    $hookname = get_plugin_page_hookname( $file, '' );
     1575    if (!empty ( $function ) && !empty ( $hookname ))
     1576        add_action( $hookname, $function );
     1577
     1578    if ( empty($icon_url) )
     1579        $icon_url = 'images/generic.png';
     1580    elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') )
     1581        $icon_url = 'https://' . substr($icon_url, 7);
     1582
     1583    do {
     1584        $position++;
     1585    } while ( !empty( $menu[$position] ) );
     1586   
     1587    $menu[$position] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
     1588
     1589    $_registered_pages[$hookname] = true;
     1590
     1591    return $hookname;
     1592}
     1593
    15471594
    15481595/**
  • trunk/bp-core/bp-core-cssjs.php

    r1544 r1619  
    121121}
    122122add_action( 'admin_menu', 'bp_core_add_admin_css' );
     123
     124/**
     125 * bp_core_admin_menu_icon_css()
     126 *
     127 * Add a hover-able icon to the "BuddyPress" wp-admin area menu.
     128 *
     129 * @package BuddyPress Core
     130 */
     131function bp_core_admin_menu_icon_css() {
     132    global $bp;
     133?>
     134    <style type="text/css">
     135        ul#adminmenu li.toplevel_page_bp-core .wp-menu-image a { background-image: url( <?php echo $bp->core->image_base . '/admin_menu_icon.png' ?> ) !important; background-position: -1px -32px; }
     136        ul#adminmenu li.toplevel_page_bp-core:hover .wp-menu-image a { background-position: -1px 0; }
     137        ul#adminmenu li.toplevel_page_bp-core .wp-menu-image a img { display: none; }
     138    </style>
     139<?php
     140}
     141add_action( 'admin_head', 'bp_core_admin_menu_icon_css' );
    123142
    124143/**
Note: See TracChangeset for help on using the changeset viewer.