Make WordPress Core

Ticket #27417: 27417.2.patch

File 27417.2.patch, 4.6 KB (added by westonruter, 11 years ago)

Use DEFAULT_NUMBER class constant; prevent customizer default input styles from applying to widget control forms; use input number type for integer widget fields and ensure proper number styles. Commits also pushed to GitHub branch: https://github.com/x-team/wordpress-develop/compare/trac-27417

  • src/wp-admin/css/customize-controls.css

    diff --git src/wp-admin/css/customize-controls.css src/wp-admin/css/customize-controls.css
    index 448f1b5..4ffe269 100644
    body { 
    157157        line-height: 28px;
    158158}
    159159
    160 .customize-control input[type="text"] {
     160.customize-control:not(.customize-control-widget_form) input[type="text"] {
    161161        width: 98%;
    162162        line-height: 18px;
    163163        margin: 0;
    164164}
    165165
    166 .customize-control select {
     166.customize-control:not(.customize-control-widget_form) select {
    167167        min-width: 50%;
    168168        max-width: 100%;
    169169        height: 28px;
  • src/wp-admin/css/widgets.css

    diff --git src/wp-admin/css/widgets.css src/wp-admin/css/widgets.css
    index 75014f6..49a1561 100644
    div#widgets-right .widget-top:hover, 
    501501        cursor: pointer;
    502502}
    503503
     504/* Specific widgets */
     505
     506.widget input[type="number"][size="3"] {
     507        width: 3em;
     508}
     509
    504510/* =Media Queries
    505511-------------------------------------------------------------- */
    506512
  • src/wp-includes/default-widgets.php

    diff --git src/wp-includes/default-widgets.php src/wp-includes/default-widgets.php
    index 851e94c..7a1017e 100644
    class WP_Widget_Links extends WP_Widget { 
    175175                <label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>
    176176                </p>
    177177                <p>
    178                 <label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e( 'Number of links to show:' ); ?></label>
    179                 <input id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" />
     178                <label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e( 'Number of links to show:' ); ?></label>
     179                <input id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo $limit == -1 ? '' : intval( $limit ); ?>" size="3" />
    180180                </p>
    181181<?php
    182182        }
    class WP_Widget_Categories extends WP_Widget { 
    531531 * @since 2.8.0
    532532 */
    533533class WP_Widget_Recent_Posts extends WP_Widget {
     534        const DEFAULT_NUMBER = 5;
    534535
    535536        function __construct() {
    536537                $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "Your site&#8217;s most recent Posts.") );
    class WP_Widget_Recent_Posts extends WP_Widget { 
    561562
    562563                $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );
    563564                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    564                 $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 10;
    565                 if ( ! $number )
    566                         $number = 10;
     565                $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : self::DEFAULT_NUMBER;
     566                if ( ! $number ) {
     567                        $number = self::DEFAULT_NUMBER;
     568                }
    567569                $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
    568570
    569571                $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) );
    class WP_Widget_Recent_Posts extends WP_Widget { 
    612614
    613615        function form( $instance ) {
    614616                $title     = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
    615                 $number    = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
     617                $number    = isset( $instance['number'] ) ? absint( $instance['number'] ) : self::DEFAULT_NUMBER;
    616618                $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false;
    617619?>
    618620                <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
    619621                <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></p>
    620622
    621623                <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to show:' ); ?></label>
    622                 <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
     624                <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="number" min="1" value="<?php echo $number; ?>" size="3" /></p>
    623625
    624626                <p><input class="checkbox" type="checkbox" <?php checked( $show_date ); ?> id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" />
    625627                <label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Display post date?' ); ?></label></p>