WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/23/2017 04:08:42 AM (2 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-includes/widgets/class-wp-nav-menu-widget.php

    r41868 r42217  
    121121        $menus = wp_get_nav_menus();
    122122
     123        $empty_menus_style = $not_empty_menus_style = '';
     124        if ( empty( $menus ) ) {
     125            $empty_menus_style = ' style="display:none" ';
     126        } else {
     127            $not_empty_menus_style = ' style="display:none" ';
     128        }
     129
     130        $nav_menu_style = '';
     131        if ( ! $nav_menu ) {
     132            $nav_menu_style = 'display: none;';
     133        }
     134
    123135        // If no menus exists, direct the user to go and create some.
    124136        ?>
    125         <p class="nav-menu-widget-no-menus-message" <?php if ( ! empty( $menus ) ) { echo ' style="display:none" '; } ?>>
     137        <p class="nav-menu-widget-no-menus-message" <?php echo $not_empty_menus_style; ?>>
    126138            <?php
    127139            if ( $wp_customize instanceof WP_Customize_Manager ) {
     
    133145            <?php echo sprintf( __( 'No menus have been created yet. <a href="%s">Create some</a>.' ), esc_attr( $url ) ); ?>
    134146        </p>
    135         <div class="nav-menu-widget-form-controls" <?php if ( empty( $menus ) ) { echo ' style="display:none" '; } ?>>
     147        <div class="nav-menu-widget-form-controls" <?php echo $empty_menus_style; ?>>
    136148            <p>
    137149                <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ) ?></label>
     
    150162            </p>
    151163            <?php if ( $wp_customize instanceof WP_Customize_Manager ) : ?>
    152                 <p class="edit-selected-nav-menu" style="<?php if ( ! $nav_menu ) { echo 'display: none;'; } ?>">
     164                <p class="edit-selected-nav-menu" style="<?php echo $nav_menu_style; ?>">
    153165                    <button type="button" class="button"><?php _e( 'Edit Menu' ) ?></button>
    154166                </p>
Note: See TracChangeset for help on using the changeset viewer.