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/includes/widgets.php

    r41621 r42217  
    182182    $widget_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
    183183    $id_base = isset($control['id_base']) ? $control['id_base'] : $widget_id;
     184    $width = isset($control['width']) ? $control['width'] : '';
     185    $height = isset($control['height']) ? $control['height'] : '';
    184186    $multi_number = isset($sidebar_args['_multi_num']) ? $sidebar_args['_multi_num'] : '';
    185187    $add_new = isset($sidebar_args['_add']) ? $sidebar_args['_add'] : '';
     
    245247        echo "\t\t<p>" . __('There are no options for this widget.') . "</p>\n";
    246248    }
     249
     250    $noform_class = '';
     251    if ( 'noform' === $has_form ) {
     252        $noform_class = ' widget-control-noform';
     253    }
    247254    ?>
    248255    <?php echo $after_widget_content; ?>
    249256    <input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($id_format); ?>" />
    250257    <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" />
    251     <input type="hidden" name="widget-width" class="widget-width" value="<?php if (isset( $control['width'] )) echo esc_attr($control['width']); ?>" />
    252     <input type="hidden" name="widget-height" class="widget-height" value="<?php if (isset( $control['height'] )) echo esc_attr($control['height']); ?>" />
     258    <input type="hidden" name="widget-width" class="widget-width" value="<?php echo esc_attr($width); ?>" />
     259    <input type="hidden" name="widget-height" class="widget-height" value="<?php echo esc_attr($height); ?>" />
    253260    <input type="hidden" name="widget_number" class="widget_number" value="<?php echo esc_attr($widget_number); ?>" />
    254261    <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" />
     
    263270            </span>
    264271        </div>
    265         <div class="alignright<?php if ( 'noform' === $has_form ) echo ' widget-control-noform'; ?>">
     272        <div class="alignright<?php echo $noform_class; ?>">
    266273            <?php submit_button( __( 'Save' ), 'primary widget-control-save right', 'savewidget', false, array( 'id' => 'widget-' . esc_attr( $id_format ) . '-savewidget' ) ); ?>
    267274            <span class="spinner"></span>
Note: See TracChangeset for help on using the changeset viewer.