Make WordPress Core

Ticket #31233: 31233.2.diff

File 31233.2.diff, 3.5 KB (added by valendesigns, 10 years ago)
  • src/wp-admin/css/common.css

    diff --git src/wp-admin/css/common.css src/wp-admin/css/common.css
    index 054ef23..d153f8d 100644
    div.error { 
    12631263        -webkit-box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
    12641264        box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
    12651265        margin: 5px 15px 2px;
     1266        overflow: hidden;
    12661267        padding: 1px 12px;
    12671268}
    12681269
    div.error p, 
    12761277
    12771278.notice-success,
    12781279div.updated {
    1279      border-color: #7ad03a;
     1280        border-color: #7ad03a;
    12801281}
    12811282
    12821283.notice-warning {
    1283     border-color: #ffba00;
     1284        border-color: #ffba00;
    12841285}
    12851286
    12861287.notice-error,
    12871288div.error {
    1288     border-color: #dd3d36;
     1289        border-color: #dd3d36;
    12891290}
    12901291
    12911292.notice-info {
    1292     border-color: #00a0d2;
     1293        border-color: #00a0d2;
     1294}
     1295
     1296.notice .dismiss,
     1297div.updated .dismiss,
     1298div.error .dismiss {
     1299        cursor: pointer;
     1300        float: right;
     1301        margin: 0.5em 0;
     1302        padding: 2px;
    12931303}
    12941304
    12951305.wrap .notice,
  • src/wp-admin/js/common.js

    diff --git src/wp-admin/js/common.js src/wp-admin/js/common.js
    index dda9247..83175e9 100644
    $(document).ready( function() { 
    373373        $firstHeading.nextAll( 'div.updated, div.error, div.notice' ).addClass( 'below-h2' );
    374374        $( 'div.updated, div.error, div.notice' ).not( '.below-h2, .inline' ).insertAfter( $firstHeading );
    375375
     376        // Hide and make notices dismissible with cookie support.
     377        $( 'div.updated, div.error, div.notice' ).each(function(){
     378                var $this = $(this),
     379                        $anchor = $( '<a href="#" class="dismiss"></a>' ),
     380                        hide = commonL10n.hide || '',
     381                        dismiss = commonL10n.dismiss || '',
     382                        id = 0;
     383
     384                // Bail, we're not allowed to hide this notice.
     385                if ( $this.data( 'hide' ) === false ) {
     386                        return;
     387                }
     388
     389                // This notice is dismissible, so use cookies to hide it for a period of time.
     390                if ( $this.data( 'dismiss' ) === true ) {
     391
     392                        // Create the notice ID by converting the text to a 32bit integer.
     393                        if ( $this.text().length !== 0 ) {
     394                                var i, len, chr;
     395                                for ( i = 0, len = $this.text().length; i < len; i++ ) {
     396                                        chr = $this.text().charCodeAt(i);
     397                                        id = ( ( id << 5 ) - id ) + chr;
     398                                        id |= 0;
     399                                }
     400                        }
     401
     402                        // Cookie check, remove element & bail if set.
     403                        if ( id !== 0 && wpCookies.get( 'wp-dismiss-notice-' + id ) === 'dismissed' ) {
     404                                $this.remove();
     405                                return;
     406                        }
     407                }
     408
     409                // Ensure plain text
     410                $anchor.text( id !== 0 ? dismiss : hide );
     411
     412                $this.prepend( $anchor );
     413
     414                $anchor.on( 'click.wp-dismiss-notice', function( event ) {
     415                        event.preventDefault();
     416                        $this.remove();
     417
     418                        // Set a session cookie, or use the expires data.
     419                        if ( id !== 0 ) {
     420                                wpCookies.set( 'wp-dismiss-notice-' + id, 'dismissed', $this.data( 'expires' ) || '' );
     421                        }
     422                });
     423        });
     424
    376425        // Init screen meta
    377426        screenMeta.init();
    378427
  • src/wp-includes/script-loader.php

    diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
    index c1bd357..bebdd59 100644
    function wp_default_scripts( &$scripts ) { 
    7979
    8080        $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 );
    8181        did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array(
    82                 'warnDelete' => __("You are about to permanently delete the selected items.\n  'Cancel' to stop, 'OK' to delete.")
     82                'warnDelete' => __( "You are about to permanently delete the selected items.\n  'Cancel' to stop, 'OK' to delete." ),
     83                'hide'       => __( 'Hide' ),
     84                'dismiss'    => __( 'Dismiss' )
    8385        ) );
    8486
    8587        $scripts->add( 'wp-a11y', "/wp-includes/js/wp-a11y$suffix.js", array( 'jquery' ), false, 1 );