Make WordPress Core

Ticket #28829: 28829.diff

File 28829.diff, 9.4 KB (added by welcher, 12 years ago)

admin-bar.php with if statement braces added

  • admin-bar.php

     
    1818function _wp_admin_bar_init() {
    1919        global $wp_admin_bar;
    2020
    21         if ( ! is_admin_bar_showing() )
     21        if ( ! is_admin_bar_showing() ) {
    2222                return false;
     23        }
    2324
    2425        /* Load the admin bar class code ready for instantiation */
    2526        require( ABSPATH . WPINC . '/class-wp-admin-bar.php' );
     
    3435         * @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'.
    3536         */
    3637        $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
    37         if ( class_exists( $admin_bar_class ) )
     38        if ( class_exists( $admin_bar_class ) ) {
    3839                $wp_admin_bar = new $admin_bar_class;
    39         else
     40        } else {
    4041                return false;
     42        }
    4143
    4244        $wp_admin_bar->initialize();
    4345        $wp_admin_bar->add_menus();
     
    6264function wp_admin_bar_render() {
    6365        global $wp_admin_bar;
    6466
    65         if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) )
     67        if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) {
    6668                return false;
     69        }
    6770
    6871        /**
    6972         * Load all necessary admin bar items.
     
    184187        $current_user = wp_get_current_user();
    185188        $profile_url  = get_edit_profile_url( $user_id );
    186189
    187         if ( ! $user_id )
     190        if ( ! $user_id ) {
    188191                return;
     192        }
    189193
    190194        $avatar = get_avatar( $user_id, 26 );
    191195        $howdy  = sprintf( __('Howdy, %1$s'), $current_user->display_name );
     
    215219        $current_user = wp_get_current_user();
    216220        $profile_url  = get_edit_profile_url( $user_id );
    217221
    218         if ( ! $user_id )
     222        if ( ! $user_id ) {
    219223                return;
     224        }
    220225
    221226        $wp_admin_bar->add_group( array(
    222227                'parent' => 'my-account',
     
    261266 */
    262267function wp_admin_bar_site_menu( $wp_admin_bar ) {
    263268        // Don't show for logged out users.
    264         if ( ! is_user_logged_in() )
     269        if ( ! is_user_logged_in() ) {
    265270                return;
     271        }
    266272
    267273        // Show only when the user is a member of this site, or they're a super admin.
    268         if ( ! is_user_member_of_blog() && ! is_super_admin() )
     274        if ( ! is_user_member_of_blog() && ! is_super_admin() ) {
    269275                return;
     276        }
    270277
    271278        $blogname = get_bloginfo('name');
    272279
    273         if ( empty( $blogname ) )
     280        if ( empty( $blogname ) ) {
    274281                $blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() );
     282        }
    275283
    276284        if ( is_network_admin() ) {
    277285                $blogname = sprintf( __('Network Admin: %s'), esc_html( get_current_site()->site_name ) );
     
    330338 */
    331339function wp_admin_bar_my_sites_menu( $wp_admin_bar ) {
    332340        // Don't show for logged out users or single site mode.
    333         if ( ! is_user_logged_in() || ! is_multisite() )
     341        if ( ! is_user_logged_in() || ! is_multisite() ) {
    334342                return;
     343        }
    335344
    336345        // Show only when the user has at least one site, or they're a super admin.
    337         if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() )
     346        if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() ) {
    338347                return;
     348        }
    339349
    340350        $wp_admin_bar->add_menu( array(
    341351                'id'    => 'my-sites',
     
    459469        $short = wp_get_shortlink( 0, 'query' );
    460470        $id = 'get-shortlink';
    461471
    462         if ( empty( $short ) )
     472        if ( empty( $short ) ) {
    463473                return;
     474        }
    464475
    465476        $html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />';
    466477
     
    524535        } else {
    525536                $current_object = $wp_the_query->get_queried_object();
    526537
    527                 if ( empty( $current_object ) )
     538                if ( empty( $current_object ) ) {
    528539                        return;
     540                }
    529541
    530542                if ( ! empty( $current_object->post_type )
    531543                        && ( $post_type_object = get_post_type_object( $current_object->post_type ) )
     
    563575
    564576        $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' );
    565577
    566         if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) )
     578        if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) ) {
    567579                $actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' );
     580        }
    568581
    569         if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) )
     582        if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) ) {
    570583                $actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' );
     584        }
    571585
    572         if ( current_user_can( 'manage_links' ) )
     586        if ( current_user_can( 'manage_links' ) ) {
    573587                $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' );
     588        }
    574589
    575         if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) )
     590        if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) ) {
    576591                $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' );
     592        }
    577593
    578594        unset( $cpts['post'], $cpts['page'], $cpts['attachment'] );
    579595
    580596        // Add any additional custom post types.
    581597        foreach ( $cpts as $cpt ) {
    582                 if ( ! current_user_can( $cpt->cap->create_posts ) )
     598                if ( ! current_user_can( $cpt->cap->create_posts ) ) {
    583599                        continue;
     600                }
    584601
    585602                $key = 'post-new.php?post_type=' . $cpt->name;
    586603                $actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name );
    587604        }
    588605        // Avoid clash with parent node and a 'content' post type.
    589         if ( isset( $actions['post-new.php?post_type=content'] ) )
     606        if ( isset( $actions['post-new.php?post_type=content'] ) ) {
    590607                $actions['post-new.php?post_type=content'][1] = 'add-new-content';
     608        }
    591609
    592         if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) )
     610        if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) {
    593611                $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' );
     612        }
    594613
    595         if ( ! $actions )
     614        if ( ! $actions ) {
    596615                return;
     616        }
    597617
    598618        $title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>';
    599619
     
    626646 * @param WP_Admin_Bar $wp_admin_bar
    627647 */
    628648function wp_admin_bar_comments_menu( $wp_admin_bar ) {
    629         if ( !current_user_can('edit_posts') )
     649        if ( !current_user_can('edit_posts') ) {
    630650                return;
     651        }
    631652
    632653        $awaiting_mod = wp_count_comments();
    633654        $awaiting_mod = $awaiting_mod->moderated;
     
    654675function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
    655676        $wp_admin_bar->add_group( array( 'parent' => 'site-name', 'id' => 'appearance' ) );
    656677
    657         if ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
     678        if ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) {
    658679                $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'themes', 'title' => __('Themes'), 'href' => admin_url('themes.php') ) );
     680        }
    659681
    660         if ( ! current_user_can( 'edit_theme_options' ) )
     682        if ( ! current_user_can( 'edit_theme_options' ) ) {
    661683                return;
     684        }
    662685
    663686        $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    664687        $wp_admin_bar->add_menu( array(
     
    672695        ) );
    673696        add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
    674697
    675         if ( current_theme_supports( 'widgets' )  )
     698        if ( current_theme_supports( 'widgets' )  ) {
    676699                $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'widgets', 'title' => __('Widgets'), 'href' => admin_url('widgets.php') ) );
     700        }
    677701
    678         if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
     702        if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) {
    679703                $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) );
     704        }
    680705
    681         if ( current_theme_supports( 'custom-background' ) )
     706        if ( current_theme_supports( 'custom-background' ) ) {
    682707                $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'background', 'title' => __('Background'), 'href' => admin_url('themes.php?page=custom-background') ) );
     708        }
    683709
    684         if ( current_theme_supports( 'custom-header' ) )
     710        if ( current_theme_supports( 'custom-header' ) ) {
    685711                $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'header', 'title' => __('Header'), 'href' => admin_url('themes.php?page=custom-header') ) );
     712        }
    686713}
    687714
    688715/**
     
    696723
    697724        $update_data = wp_get_update_data();
    698725
    699         if ( !$update_data['counts']['total'] )
     726        if ( !$update_data['counts']['total'] ) {
    700727                return;
     728        }
    701729
    702730        $title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
    703731        $title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>';
     
    720748 * @param WP_Admin_Bar $wp_admin_bar
    721749 */
    722750function wp_admin_bar_search_menu( $wp_admin_bar ) {
    723         if ( is_admin() )
     751        if ( is_admin() ) {
    724752                return;
     753        }
    725754
    726755        $form  = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">';
    727756        $form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />';
     
    816845        global $show_admin_bar, $pagenow;
    817846
    818847        // For all these types of requests, we never want an admin bar.
    819         if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') )
     848        if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') ) {
    820849                return false;
     850        }
    821851
    822852        // Integrated into the admin.
    823         if ( is_admin() )
     853        if ( is_admin() ) {
    824854                return true;
     855        }
    825856
    826857        if ( ! isset( $show_admin_bar ) ) {
    827858                if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow ) {
     
    859890 */
    860891function _get_admin_bar_pref( $context = 'front', $user = 0 ) {
    861892        $pref = get_user_option( "show_admin_bar_{$context}", $user );
    862         if ( false === $pref )
     893        if ( false === $pref ) {
    863894                return true;
     895        }
    864896
    865897        return 'true' === $pref;
    866898}