Make WordPress Core


Ignore:
Timestamp:
11/23/2017 04:08:42 AM (7 years ago)
Author:
pento
Message:

General: Reformat inline if () statements inside HTML tags.

This pattern occurs a handful of times across the codebase:

<div class="foo<?php if ( $bar ) { echo ' baz'; } ?>">

Unfortunately, it doesn't really play nicely with phpcbf, so all instances need to be removed in preperation for auto code formatting.

See #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/nav-menus.php

    r41868 r42217  
    590590        );
    591591    endif;
     592
     593    $nav_tab_active_class = '';
     594    if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) {
     595        $nav_tab_active_class = ' nav-tab-active';
     596    }
    592597    ?>
    593598
     
    595600
    596601    <h2 class="nav-tab-wrapper wp-clearfix">
    597         <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Edit Menus' ); ?></a>
     602        <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php echo $nav_tab_active_class; ?>"><?php esc_html_e( 'Edit Menus' ); ?></a>
    598603        <?php if ( $num_locations && $menu_count ) : ?>
    599604            <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( $locations_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Manage Locations' ); ?></a>
     
    631636                            <select name="menu-locations[<?php echo $_location; ?>]" id="locations-<?php echo $_location; ?>">
    632637                                <option value="0"><?php printf( '&mdash; %s &mdash;', esc_html__( 'Select a Menu' ) ); ?></option>
    633                                 <?php foreach ( $nav_menus as $menu ) : ?>
    634                                     <?php $selected = isset( $menu_locations[$_location] ) && $menu_locations[$_location] == $menu->term_id; ?>
    635                                     <option <?php if ( $selected ) echo 'data-orig="true"'; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>">
     638                                <?php
     639                                    foreach ( $nav_menus as $menu ) :
     640                                        $data_orig = '';
     641                                        $selected = isset( $menu_locations[$_location] ) && $menu_locations[$_location] == $menu->term_id;
     642                                        if ( $selected ) {
     643                                            $data_orig = 'data-orig="true"';
     644                                        }
     645                                        ?>
     646                                    <option <?php echo $data_orig; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>">
    636647                                        <?php echo wp_html_excerpt( $menu->name, 40, '&hellip;' ); ?>
    637648                                    </option>
     
    722733            </span><!-- /add-new-menu-action -->
    723734        </form>
    724     <?php endif; ?>
     735    <?php
     736        endif;
     737
     738        $metabox_holder_disabled_class = '';
     739        if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] ) {
     740            $metabox_holder_disabled_class = ' metabox-holder-disabled';
     741        }
     742    ?>
    725743    </div><!-- /manage-menus -->
    726744    <div id="nav-menus-frame" class="wp-clearfix">
    727     <div id="menu-settings-column" class="metabox-holder<?php if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] ) { echo ' metabox-holder-disabled'; } ?>">
     745    <div id="menu-settings-column" class="metabox-holder<?php echo $metabox_holder_disabled_class; ?>">
    728746
    729747        <div class="clear"></div>
     
    740758        <div id="menu-management">
    741759            <form id="update-nav-menu" method="post" enctype="multipart/form-data">
    742                 <div class="menu-edit <?php if ( $add_new_screen ) echo 'blank-slate'; ?>">
     760            <?php
     761                $new_screen_class = '';
     762                if ( $add_new_screen ) {
     763                    $new_screen_class = 'blank-slate';
     764                }
     765            ?>
     766                <div class="menu-edit <?php echo $new_screen_class; ?>">
    743767                    <input type="hidden" name="nav-menu-data">
    744768                    <?php
     
    771795                            <?php if ( ! $add_new_screen ) : ?>
    772796                            <h3><?php _e( 'Menu Structure' ); ?></h3>
    773                             <?php $starter_copy = ( $one_theme_location_no_menus ) ? __( 'Edit your default menu by adding or removing items. Drag each item into the order you prefer. Click Create Menu to save your changes.' ) : __( 'Drag each item into the order you prefer. Click the arrow on the right of the item to reveal additional configuration options.' ); ?>
    774                             <div class="drag-instructions post-body-plain" <?php if ( isset( $menu_items ) && 0 == count( $menu_items ) ) { ?>style="display: none;"<?php } ?>>
     797                            <?php
     798                                $hide_style = '';
     799                                if ( isset( $menu_items ) && 0 == count( $menu_items ) ) {
     800                                    $hide_style = 'style="display: none;"';
     801                                }
     802                                $starter_copy = ( $one_theme_location_no_menus ) ? __( 'Edit your default menu by adding or removing items. Drag each item into the order you prefer. Click Create Menu to save your changes.' ) : __( 'Drag each item into the order you prefer. Click the arrow on the right of the item to reveal additional configuration options.' );
     803                            ?>
     804                            <div class="drag-instructions post-body-plain" <?php echo $hide_style; ?>>
    775805                                <p><?php echo $starter_copy; ?></p>
    776806                            </div>
     
    788818                                    <input type="hidden" name="use-location" value="<?php echo esc_attr( $_GET['use-location'] ); ?>" />
    789819                                <?php endif; ?>
    790                             <?php endif; ?>
    791                             <div class="menu-settings" <?php if ( $one_theme_location_no_menus ) { ?>style="display: none;"<?php } ?>>
     820                            <?php
     821                                endif;
     822
     823                                $no_menus_style = '';
     824                                if ( $one_theme_location_no_menus ) {
     825                                    $no_menus_style = 'style="display: none;"';
     826                                }
     827                            ?>
     828                            <div class="menu-settings" <?php echo $no_menus_style; ?>>
    792829                                <h3><?php _e( 'Menu Settings' ); ?></h3>
    793830                                <?php
Note: See TracChangeset for help on using the changeset viewer.