Make WordPress Core

Ticket #64278: 64278.diff

File 64278.diff, 26.0 KB (added by iflairwebtechnologies, 6 months ago)

Remove Legacy Internet Explorer-Specific Code and Clean Up Outdated Scripts in WordPress

  • src/js/_enqueues/vendor/imgareaselect/jquery.imgareaselect.js

     
    347347            .add($area).width(w = selection.width).height(h = selection.height);
    348348
    349349        /*
    350          * Reset the position of selection area, borders, and handles (IE6/IE7
    351          * position them incorrectly if we don't do this)
     350         * Reset the position of selection area, borders, and handles.
    352351         */
    353352        $area.add($border).add($handles).css({ left: 0, top: 0 });
    354353
     
    401400                });
    402401        }
    403402
    404         /*
    405          * Internet Explorer displays 1px-wide dashed borders incorrectly by
    406          * filling the spaces between dashes with white. Toggling the margin
    407          * property between 0 and "auto" fixes this in IE6 and IE7 (IE8 is still
    408          * broken). This workaround is not perfect, as it requires setTimeout()
    409          * and thus causes the border to flicker a bit, but I haven't found a
    410          * better solution.
    411          *
    412          * Note: This only happens with CSS borders, set with the borderWidth,
    413          * borderOpacity, borderColor1, and borderColor2 options (which are now
    414          * deprecated). Borders created with GIF background images are fine.
    415          */
    416         if (msie && $border.outerWidth() - $border.innerWidth() == 2) {
    417             $border.css('margin', 0);
    418             setTimeout(function () { $border.css('margin', 'auto'); }, 0);
    419         }
    420403    }
    421404
    422405    /**
     
    1008991        /* Append all the selection area elements to the container box */
    1009992        $box.append($area.add($border).add($areaOpera)).append($handles);
    1010993
    1011         if (msie) {
    1012             if (o = ($outer.css('filter')||'').match(/opacity=(\d+)/))
    1013                 $outer.css('opacity', o[1]/100);
    1014             if (o = ($border.css('filter')||'').match(/opacity=(\d+)/))
    1015                 $border.css('opacity', o[1]/100);
    1016         }
    1017 
    1018994        if (newOptions.hide)
    1019995            hide($box.add($outer));
    1020996        else if (newOptions.show && imgLoaded) {
     
    11231099    this.update = doUpdate;
    11241100
    11251101    /* Do the dreaded browser detection */
    1126     var msie = (/msie ([\w.]+)/i.exec(ua)||[])[1],
    1127         opera = /opera/i.test(ua),
     1102    var opera = /opera/i.test(ua),
    11281103        safari = /webkit/i.test(ua) && !/chrome/i.test(ua);
    11291104
    11301105    /*
     
    11491124     */
    11501125    zIndex = options.zIndex || zIndex;
    11511126
    1152     if (msie)
    1153         $img.attr('unselectable', 'on');
    1154 
    11551127    /*
    1156      * In MSIE and WebKit, we need to use the keydown event instead of keypress
     1128     * In WebKit, we need to use the keydown event instead of keypress.
    11571129     */
    1158     $.imgAreaSelect.keyPress = msie || safari ? 'keydown' : 'keypress';
     1130    $.imgAreaSelect.keyPress = safari ? 'keydown' : 'keypress';
    11591131
    11601132    /*
    11611133     * There is a bug affecting the CSS cursor property in Opera (observed in
     
    11881160    img.complete || img.readyState == 'complete' || !$img.is('img') ?
    11891161        imgLoad() : $img.one('load', imgLoad);
    11901162
    1191     /*
    1192      * MSIE 9.0 doesn't always fire the image load event -- resetting the src
    1193      * attribute seems to trigger it. The check is for version 7 and above to
    1194      * accommodate for MSIE 9 running in compatibility mode.
    1195      */
    1196     if (!imgLoaded && msie && msie >= 7)
    1197         img.src = img.src;
    11981163};
    11991164
    12001165/**
  • src/js/_enqueues/vendor/farbtastic.js

     
    3535  fb.square = 100;
    3636  fb.width = 194;
    3737
    38   // Fix background PNGs in IE6
    39   if (navigator.appVersion.match(/MSIE [0-6]\./)) {
    40     $('*', e).each(function () {
    41       if (this.currentStyle.backgroundImage != 'none') {
    42         var image = this.currentStyle.backgroundImage;
    43         image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
    44         $(this).css({
    45           'backgroundImage': 'none',
    46           'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
    47         });
    48       }
    49     });
    50   }
    51 
    5238  /**
    5339   * Link to the given element(s) or callback.
    5440   */
  • src/js/_enqueues/vendor/thickbox/thickbox.js

     
    4444        var $closeBtn;
    4545
    4646        try {
    47                 if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
    48                         jQuery("body","html").css({height: "100%", width: "100%"});
    49                         jQuery("html").css("overflow","hidden");
    50                         if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
    51                                 jQuery("body").append("<iframe id='TB_HideSelect'>"+thickboxL10n.noiframes+"</iframe><div id='TB_overlay'></div><div id='TB_window' class='thickbox-loading'></div>");
    52                                 jQuery("#TB_overlay").on( 'click', tb_remove );
    53                         }
    54                 }else{//all others
    55                         if(document.getElementById("TB_overlay") === null){
    56                                 jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window' class='thickbox-loading'></div>");
    57                                 jQuery("#TB_overlay").on( 'click', tb_remove );
    58                                 jQuery( 'body' ).addClass( 'modal-open' );
    59                         }
     47                if(document.getElementById("TB_overlay") === null){
     48                        jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window' class='thickbox-loading'></div>");
     49                        jQuery("#TB_overlay").on( 'click', tb_remove );
     50                        jQuery( 'body' ).addClass( 'modal-open' );
    6051                }
    6152
    6253                if(tb_detectMacXFF()){
     
    292283function tb_remove() {
    293284        jQuery("#TB_imageOff").off("click");
    294285        jQuery("#TB_closeWindowButton").off("click");
    295         jQuery( '#TB_window' ).fadeOut( 'fast', function() {
    296                 jQuery( '#TB_window, #TB_overlay, #TB_HideSelect' ).trigger( 'tb_unload' ).off().remove();
     286                jQuery( '#TB_window' ).fadeOut( 'fast', function() {
     287                jQuery( '#TB_window, #TB_overlay' ).trigger( 'tb_unload' ).off().remove();
    297288                jQuery( 'body' ).trigger( 'thickbox:removed' );
    298289        });
    299290        jQuery( 'body' ).removeClass( 'modal-open' );
    300291        jQuery("#TB_load").remove();
    301         if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
    302                 jQuery("body","html").css({height: "auto", width: "auto"});
    303                 jQuery("html").css("overflow","");
    304         }
    305292        jQuery(document).off('.thickbox');
    306293        return false;
    307294}
    308295
    309296function tb_position() {
    310 var isIE6 = typeof document.body.style.maxHeight === "undefined";
    311297jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
    312         if ( ! isIE6 ) { // take away IE6
    313                 jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
    314         }
     298        jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
    315299}
    316300
    317301function tb_parseQuery ( query ) {
  • src/js/_enqueues/vendor/tinymce/skins/wordpress/wp-content.css

     
    395395        overflow-x: hidden;
    396396}
    397397
    398 .ie7 .gallery,
    399 .ie8 .gallery {
    400         margin: auto;
    401 }
    402 
    403398.gallery .gallery-item {
    404399        float: left;
    405400        margin: 0;
     
    410405        box-sizing: border-box;
    411406}
    412407
    413 .ie7 .gallery .gallery-item,
    414 .ie8 .gallery .gallery-item {
    415         padding: 6px 0;
    416 }
    417 
    418408.gallery .gallery-caption,
    419409.gallery .gallery-icon {
    420410        margin: 0;
     
    437427        width: 33.333%;
    438428}
    439429
    440 .ie8 .gallery-columns-3 .gallery-item,
    441 .ie7 .gallery-columns-3 .gallery-item {
    442         width: 33%;
    443 }
    444 
    445430.gallery-columns-4 .gallery-item {
    446431        width: 25%;
    447432}
  • src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js

     
    512512
    513513                dom.setAttrib( doc.documentElement, 'lang', editor.getParam( 'wp_lang_attr' ) );
    514514
    515                 if ( env.ie ) {
    516                         if ( parseInt( env.ie, 10 ) === 9 ) {
    517                                 bodyClass.push('ie9');
    518                         } else if ( parseInt( env.ie, 10 ) === 8 ) {
    519                                 bodyClass.push('ie8');
    520                         } else if ( env.ie < 8 ) {
    521                                 bodyClass.push('ie7');
    522                         }
    523                 } else if ( env.webkit ) {
     515                if ( env.webkit ) {
    524516                        bodyClass.push('webkit');
    525517                }
    526518
  • src/js/_enqueues/wp/heartbeat.js

     
    181181                                settings.minimalInterval = settings.minimalInterval * 1000;
    182182                        }
    183183
    184                         /*
    185                         * Switch the interval to 120 seconds by using the Page Visibility API.
    186                          * If the browser doesn't support it (Safari < 7, Android < 4.4, IE < 10), the
    187                         * interval will be increased to 120 seconds after 5 minutes of mouse and keyboard
    188                         * inactivity.
    189                         */
     184        /*
     185        * Switch the interval to 120 seconds by using the Page Visibility API.
     186         * If the browser doesn't support it (Safari < 7, Android < 4.4), the
     187        * interval will be increased to 120 seconds after 5 minutes of mouse and keyboard
     188        * inactivity.
     189        */
    190190                        if ( typeof document.hidden !== 'undefined' ) {
    191191                                hidden = 'hidden';
    192192                                visibilitychange = 'visibilitychange';
    193193                                visibilityState = 'visibilityState';
    194                         } else if ( typeof document.msHidden !== 'undefined' ) { // IE10.
    195                                 hidden = 'msHidden';
    196                                 visibilitychange = 'msvisibilitychange';
    197                                 visibilityState = 'msVisibilityState';
    198194                        } else if ( typeof document.webkitHidden !== 'undefined' ) { // Android.
    199195                                hidden = 'webkitHidden';
    200196                                visibilitychange = 'webkitvisibilitychange';
  • src/js/_enqueues/wp/emoji.js

     
    2828                // Private.
    2929                twemoji, timer,
    3030                loaded = false,
    31                 count = 0,
    32                 ie11 = window.navigator.userAgent.indexOf( 'Trident/7.0' ) > 0;
     31                count = 0;
    3332
    3433                /**
    3534                 * Detect if the browser supports SVG.
     
    126125                                                                if ( ! node.parentNode ) {
    127126                                                                        continue;
    128127                                                                }
    129 
    130                                                                 if ( ie11 ) {
    131                                                                         /*
    132                                                                          * IE 11's implementation of MutationObserver is buggy.
    133                                                                          * It unnecessarily splits text nodes when it encounters a HTML
    134                                                                          * template interpolation symbol ( "{{", for example ). So, we
    135                                                                          * join the text nodes back together as a work-around.
    136                                                                          *
    137                                                                          * Node type 3 is a TEXT_NODE.
    138                                                                          */
    139                                                                         while( node.nextSibling && 3 === node.nextSibling.nodeType ) {
    140                                                                                 node.nodeValue = node.nodeValue + node.nextSibling.nodeValue;
    141                                                                                 node.parentNode.removeChild( node.nextSibling );
    142                                                                         }
    143                                                                 }
    144 
    145128                                                                node = node.parentNode;
    146129                                                        }
    147130
  • src/js/_enqueues/wp/dashboard.js

     
    199199         * @return {void}
    200200         */
    201201        function autoResizeTextarea() {
    202                 // When IE8 or older is used to render this document, exit.
    203                 if ( document.documentMode && document.documentMode < 9 ) {
    204                         return;
    205                 }
    206 
    207202                // Add a hidden div. We'll copy over the text from the textarea to measure its height.
    208203                $('body').append( '<div class="quick-draft-textarea-clone" style="display: none;"></div>' );
    209204
     
    233228                        'display': 'none'
    234229                });
    235230
    236                 // The 'propertychange' is used in IE < 9.
    237                 editor.on('focus input propertychange', function() {
     231                editor.on('focus input', function() {
    238232                        var $this = $(this),
    239233                                // Add a non-breaking space to ensure that the height of a trailing newline is
    240234                                // included.
     
    422416
    423417                        requestParams          = requestParams || {};
    424418                        requestParams._wpnonce = communityEventsData.nonce;
    425                         requestParams.timezone = window.Intl ? window.Intl.DateTimeFormat().resolvedOptions().timeZone : '';
     419                        requestParams.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
    426420
    427421                        initiatedBy = requestParams.location ? 'user' : 'app';
    428422
     
    675669                         * Prefer a name like `Europe/Helsinki`, since that automatically tracks daylight savings. This
    676670                         * doesn't need to take `startTimestamp` into account for that reason.
    677671                         */
    678                         var timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
    679 
    680                         /*
    681                          * Fall back to an offset for IE11, which declares the property but doesn't assign a value.
    682                          */
    683                         if ( 'undefined' === typeof timeZone ) {
    684                                 /*
    685                                  * It's important to use the _event_ time, not the _current_
    686                                  * time, so that daylight savings time is accounted for.
    687                                  */
    688                                 timeZone = app.getFlippedTimeZoneOffset( startTimestamp );
    689                         }
    690 
    691                         return timeZone;
     672                        return Intl.DateTimeFormat().resolvedOptions().timeZone;
    692673                },
    693674
    694675                /**
    695                  * Get intuitive time zone offset.
    696                  *
    697                  * `Data.prototype.getTimezoneOffset()` returns a positive value for time zones
    698                  * that are _behind_ UTC, and a _negative_ value for ones that are ahead.
    699                  *
    700                  * See https://stackoverflow.com/questions/21102435/why-does-javascript-date-gettimezoneoffset-consider-0500-as-a-positive-off.
    701                  *
    702                  * @since 5.5.2
    703                  *
    704                  * @param {number} startTimestamp
    705                  *
    706                  * @returns {number}
    707                  */
    708                 getFlippedTimeZoneOffset: function( startTimestamp ) {
    709                         return new Date( startTimestamp ).getTimezoneOffset() * -1;
    710                 },
    711 
    712                 /**
    713676                 * Get a short time zone name, like `PST`.
    714677                 *
    715678                 * @since 5.5.2
     
    736699                                timeZoneAbbreviation = shortTimeStringParts[2];
    737700                        }
    738701
    739                         if ( 'undefined' === typeof timeZoneAbbreviation ) {
    740                                 /*
    741                                  * It's important to use the _event_ time, not the _current_
    742                                  * time, so that daylight savings time is accounted for.
    743                                  */
    744                                 var timeZoneOffset = app.getFlippedTimeZoneOffset( startTimestamp ),
    745                                         sign = -1 === Math.sign( timeZoneOffset ) ? '' : '+';
    746 
    747                                 // translators: Used as part of a string like `GMT+5` in the Events Widget.
    748                                 timeZoneAbbreviation = _x( 'GMT', 'Events widget offset prefix' ) + sign + ( timeZoneOffset / 60 );
    749                         }
    750 
    751702                        return timeZoneAbbreviation;
    752703                },
    753704
  • src/js/_enqueues/wp/customize/controls.js

     
    81158115                        populateChangesetUuidParam = function( isIncluded ) {
    81168116                                var urlParser, queryParams;
    81178117
    8118                                 // Abort on IE9 which doesn't support history management.
    8119                                 if ( ! history.replaceState ) {
    8120                                         return;
    8121                                 }
    8122 
    81238118                                urlParser = document.createElement( 'a' );
    81248119                                urlParser.href = location.href;
    81258120                                queryParams = api.utils.parseQueryString( urlParser.search.substr( 1 ) );
  • src/wp-admin/css/forms.css

     
    362362        text-shadow: 0 0 0 #0a4b78;
    363363}
    364364
    365 /* Remove background focus style from IE11 while keeping focus style available on option elements. */
    366 .wp-core-ui select::-ms-value {
    367         background: transparent;
    368         color: #50575e;
    369 }
    370365
    371 .wp-core-ui select:hover::-ms-value {
    372         color: #2271b1;
    373 }
    374 
    375 .wp-core-ui select:focus::-ms-value {
    376         color: #0a4b78;
    377 }
    378 
    379 .wp-core-ui select.disabled::-ms-value,
    380 .wp-core-ui select:disabled::-ms-value {
    381         color: #a7aaad;
    382 }
    383 
    384 /* Hide the native down arrow for select element on IE. */
    385 .wp-core-ui select::-ms-expand {
    386         display: none;
    387 }
    388 
    389366.wp-admin .button-cancel {
    390367        display: inline-block;
    391368        min-height: 28px;
     
    695672        min-height: 30px;
    696673}
    697674
    698 /* Hide the Edge "reveal password" native button */
    699 .wp-pwd input::-ms-reveal {
    700         display: none;
    701 }
    702 
    703675#pass1-text,
    704676.show-password #pass1 {
    705677        display: none;
    706678}
    707679
    708 #pass1-text::-ms-clear {
    709         display: none;
    710 }
    711 
    712680.show-password #pass1-text {
    713681        display: inline-block;
    714682}
  • src/wp-content/themes/twentynineteen/js/touch-keyboard-navigation.js

     
    4343        }
    4444
    4545        /**
    46          * Adds class to an element.
    47          *
    48          * @param {Object} el
    49          * @param {string} cls
    50          */
    51         function addClass(el, cls) {
    52                 if ( ! el.className.match( '(?:^|\\s)' + cls + '(?!\\S)') ) {
    53                         el.className += ' ' + cls;
    54                 }
    55         }
    56 
    57         /**
    58          * Deletes class from an element.
    59          *
    60          * @param {Object} el
    61          * @param {string} cls
    62          */
    63         function deleteClass(el, cls) {
    64                 el.className = el.className.replace( new RegExp( '(?:^|\\s)' + cls + '(?!\\S)' ),'' );
    65         }
    66 
    67         /**
    68          * Determines whether an element has the given class.
    69          *
    70          * @param {Object} el
    71          * @param {string} cls
    72          *
    73          * @returns {boolean} Has class
    74          */
    75         function hasClass(el, cls) {
    76 
    77                 if ( el.className.match( '(?:^|\\s)' + cls + '(?!\\S)' ) ) {
    78                         return true;
    79                 }
    80         }
    81 
    82         /**
    8346         * Toggles Aria Expanded state for screenreaders.
    8447         *
    8548         * @param {Object} ariaItem
     
    10770                'use strict';
    10871
    10972                // Update classes.
    110                 // classList.add is not supported in IE11.
    111                 currentSubMenu.parentElement.className += ' off-canvas';
    112                 currentSubMenu.parentElement.lastElementChild.className += ' expanded-true';
     73                currentSubMenu.parentElement.classList.add( 'off-canvas' );
     74                if ( currentSubMenu.parentElement.lastElementChild ) {
     75                        currentSubMenu.parentElement.lastElementChild.classList.add( 'expanded-true' );
     76                }
    11377
    11478                // Update aria-expanded state.
    11579                toggleAriaExpandedState( currentSubMenu );
     
    13195                if ( getCurrentParent( currentSubMenu, 'ul' ).classList.contains( 'sub-menu' ) ) {
    13296
    13397                        // Update classes.
    134                         // classList.remove is not supported in IE11.
    135                         menuItem.className = menuItem.className.replace( 'off-canvas', '' );
    136                         subMenu.className  = subMenu.className.replace( 'expanded-true', '' );
     98                        menuItem.classList.remove( 'off-canvas' );
     99                        if ( subMenu ) {
     100                                subMenu.classList.remove( 'expanded-true' );
     101                        }
    137102
    138103                        // Update aria-expanded and :focus states.
    139104                        toggleAriaExpandedState( menuItemAria );
     
    142107                } else {
    143108
    144109                        // Update classes.
    145                         // classList.remove is not supported in IE11.
    146                         menuItem.className = menuItem.className.replace( 'off-canvas', '' );
    147                         menuItem.lastElementChild.className = menuItem.lastElementChild.className.replace( 'expanded-true', '' );
     110                        menuItem.classList.remove( 'off-canvas' );
     111                        if ( menuItem.lastElementChild ) {
     112                                menuItem.lastElementChild.classList.remove( 'expanded-true' );
     113                        }
    148114
    149115                        // Update aria-expanded and :focus states.
    150116                        toggleAriaExpandedState( menuItemAria );
     
    197163                }
    198164
    199165                for ( o = 0; o < getFocusedClassElements.length; o++) {
    200                         deleteClass( getFocusedClassElements[o], 'is-focused' );
     166                        getFocusedClassElements[o].classList.remove( 'is-focused' );
    201167                }
    202168        }
    203169
    204170        /**
    205          * Matches polyfill for IE11.
    206          */
    207         if (!Element.prototype.matches) {
    208                 Element.prototype.matches = Element.prototype.msMatchesSelector;
    209         }
    210 
    211         /**
    212171         * Toggles `focus` class to allow sub-menu access on touch screens.
    213172         */
    214173        function toggleSubmenuDisplay() {
     
    252211
    253212                        var mainNav = getCurrentParent( event.target, '.main-navigation' );
    254213
    255                         if ( null != mainNav && hasClass( mainNav, '.main-navigation' ) ) {
     214                        if ( null != mainNav ) {
    256215                                // Prevent default mouse events.
    257216                                event.preventDefault();
    258217
     
    284243                                var prevLi            = getCurrentParent( event.target, '.main-navigation > div > ul > li', '.main-navigation' ).previousElementSibling;
    285244                                var nextLi            = getCurrentParent( event.target, '.main-navigation > div > ul > li', '.main-navigation' ).nextElementSibling;
    286245
    287                                 if ( null !== focusedElement && null !== hasClass( focusedElement, focusedClass ) ) {
    288                                         deleteClass( focusedElement, focusedClass );
     246                                if ( null !== focusedElement && focusedElement.classList.contains( focusedClass ) ) {
     247                                        focusedElement.classList.remove( focusedClass );
    289248                                }
    290249
    291250                                // Add .is-focused class to top-level li.
    292251                                if ( getCurrentParent( event.target, '.main-navigation > div > ul > li', '.main-navigation' ) ) {
    293                                         addClass( getCurrentParent( event.target, '.main-navigation > div > ul > li', '.main-navigation' ), focusedClass );
     252                                        getCurrentParent( event.target, '.main-navigation > div > ul > li', '.main-navigation' ).classList.add( focusedClass );
    294253                                }
    295254
    296255                                // Check for previous li.
    297                                 if ( prevLi && hasClass( prevLi, focusedClass ) ) {
    298                                         deleteClass( prevLi, focusedClass );
     256                                if ( prevLi && prevLi.classList.contains( focusedClass ) ) {
     257                                        prevLi.classList.remove( focusedClass );
    299258                                }
    300259
    301260                                // Check for next li.
    302                                 if ( nextLi && hasClass( nextLi, focusedClass ) ) {
    303                                         deleteClass( nextLi, focusedClass );
     261                                if ( nextLi && nextLi.classList.contains( focusedClass ) ) {
     262                                        nextLi.classList.remove( focusedClass );
    304263                                }
    305264                        }
    306265
  • src/wp-content/themes/twentynineteen/js/priority-menu.js

     
    5656         * @param {Element} element
    5757         */
    5858        function showButton(element) {
    59                 // classList.remove is not supported in IE11.
    60                 element.className = element.className.replace('is-empty', '');
     59                element.classList.remove( 'is-empty' );
    6160        }
    6261
    6362        /**
     
    6665         * @param {Element} element
    6766         */
    6867        function hideButton(element) {
    69                 // classList.add is not supported in IE11.
    70                 if (!element.classList.contains('is-empty')) {
    71                         element.className += ' is-empty';
    72                 }
     68                element.classList.add( 'is-empty' );
    7369        }
    7470
    7571        /**
  • src/wp-content/themes/twentytwentyone/functions.php

     
    391391 *
    392392 * @since Twenty Twenty-One 1.0
    393393 *
    394  * @global bool       $is_IE
    395  * @global WP_Scripts $wp_scripts
    396  *
    397394 * @return void
    398395 */
    399396function twenty_twenty_one_scripts() {
    400         // Note, the is_IE global variable is defined by WordPress and is used
    401         // to detect if the current browser is internet explorer.
    402         global $is_IE, $wp_scripts;
    403         if ( $is_IE ) {
    404                 // If IE 11 or below, use a flattened stylesheet with static values replacing CSS Variables.
    405                 wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/assets/css/ie.css', array(), wp_get_theme()->get( 'Version' ) );
    406         } else {
    407                 // If not IE, use the standard stylesheet.
    408                 wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) );
    409         }
     397        wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) );
    410398
    411399        // RTL styles.
    412400        wp_style_add_data( 'twenty-twenty-one-style', 'rtl', 'replace' );
     
    419407                wp_enqueue_script( 'comment-reply' );
    420408        }
    421409
    422         // Register the IE11 polyfill file.
    423         wp_register_script(
    424                 'twenty-twenty-one-ie11-polyfills-asset',
    425                 get_template_directory_uri() . '/assets/js/polyfills.js',
    426                 array(),
    427                 wp_get_theme()->get( 'Version' ),
    428                 array( 'in_footer' => true )
    429         );
    430 
    431         // Register the IE11 polyfill loader.
    432         wp_register_script(
    433                 'twenty-twenty-one-ie11-polyfills',
    434                 null,
    435                 array(),
    436                 wp_get_theme()->get( 'Version' ),
    437                 array( 'in_footer' => true )
    438         );
    439         wp_add_inline_script(
    440                 'twenty-twenty-one-ie11-polyfills',
    441                 wp_get_script_polyfill(
    442                         $wp_scripts,
    443                         array(
    444                                 'Element.prototype.matches && Element.prototype.closest && window.NodeList && NodeList.prototype.forEach' => 'twenty-twenty-one-ie11-polyfills-asset',
    445                         )
    446                 )
    447         );
    448 
    449410        // Main navigation scripts.
    450411        if ( has_nav_menu( 'primary' ) ) {
    451412                wp_enqueue_script(
    452413                        'twenty-twenty-one-primary-navigation-script',
    453414                        get_template_directory_uri() . '/assets/js/primary-navigation.js',
    454                         array( 'twenty-twenty-one-ie11-polyfills' ),
     415                        array(),
    455416                        wp_get_theme()->get( 'Version' ),
    456417                        array(
    457418                                'in_footer' => false, // Because involves header.
     
    464425        wp_enqueue_script(
    465426                'twenty-twenty-one-responsive-embeds-script',
    466427                get_template_directory_uri() . '/assets/js/responsive-embeds.js',
    467                 array( 'twenty-twenty-one-ie11-polyfills' ),
     428                array(),
    468429                wp_get_theme()->get( 'Version' ),
    469430                array( 'in_footer' => true )
    470431        );
  • src/wp-content/themes/twentytwentyone/assets/js/polyfills.js

     
    1 /**
    2  * File polyfills.js.
    3  *
    4  * Polyfills for IE11.
    5  */
    6 
    7 /**
    8  * Polyfill for Element.closest() because we need to support IE11.
    9  *
    10  * @since Twenty Twenty-One 1.0
    11  *
    12  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
    13  */
    14 if ( ! Element.prototype.matches ) {
    15         Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
    16 }
    17 
    18 if ( ! Element.prototype.closest ) {
    19         Element.prototype.closest = function( s ) {
    20                 var el = this;
    21                 do {
    22                         if ( Element.prototype.matches.call( el, s ) ) {
    23                                 return el;
    24                         }
    25                         el = el.parentElement || el.parentNode;
    26                 } while ( el !== null && el.nodeType === 1 );
    27                 return null;
    28         };
    29 }
    30 
    31 /**
    32  * Polyfill for NodeList.foreach() because we need to support IE11.
    33  *
    34  * @since Twenty Twenty-One 1.0
    35  *
    36  * @see https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach
    37  */
    38 if ( window.NodeList && ! NodeList.prototype.forEach ) {
    39         NodeList.prototype.forEach = function( callback, thisArg ) {
    40                 var i;
    41                 thisArg = thisArg || window;
    42                 for ( i = 0; i < this.length; i++ ) {
    43                         callback.call( thisArg, this[i], i, this );
    44                 }
    45         };
    46 }