Make WordPress Core

Ticket #43058: 43058.patch

File 43058.patch, 2.2 KB (added by Mahesh901122, 8 years ago)

File search patch

  • wp-admin/js/theme-plugin-editor.js

     
    7373                        }
    7474                        return undefined;
    7575                } );
     76
     77                $( document ).on('keyup', '#plugin-files-search, #theme-files-search',  component._searchFile);
    7678        };
    7779
    7880        /**
     81         * Search file.
     82         *
     83         * @since 4.9.2
     84         * @returns {void}
     85         */
     86        component._searchFile = function() {
     87                var parent      = $('#templateside');
     88                var directories = parent.find('ul ul li');
     89                var files       = parent.find('ul ul li a');
     90
     91                // Expand all directories.
     92                directories.attr('aria-expanded', true);
     93
     94                // Hide Directories. Becuase, Below we show those directories
     95                // which have search term in the file name.
     96        directories.hide();
     97
     98                // Search file and ONLY show these directories which "contain" the file name.
     99                var rex = new RegExp( $(this).val(), 'i');
     100        files.filter(function () {
     101                        var file_name = $.trim( $(this).text() ) || '';
     102                return rex.test( file_name );
     103        }).parents('li').show();
     104        };
     105
     106        /**
    79107         * Set up and display the warning modal.
    80108         *
    81109         * @since 4.9.0
  • wp-admin/plugin-editor.php

     
    232232
    233233<div id="templateside">
    234234        <h2 id="plugin-files-label"><?php _e( 'Plugin Files' ); ?></h2>
     235        <input id="plugin-files-search" type="text" placeholder="<?php _e( 'Search file..' ); ?>">
    235236
    236237        <?php
    237238        $plugin_editable_files = array();
  • wp-admin/theme-editor.php

     
    229229?>
    230230<div id="templateside">
    231231        <h2 id="theme-files-label"><?php _e( 'Theme Files' ); ?></h2>
     232        <input id="theme-files-search" type="text" placeholder="<?php _e( 'Search file..' ); ?>">
    232233        <ul role="tree" aria-labelledby="theme-files-label">
    233234                <?php if ( ( $has_templates || $theme->parent() ) && $theme->parent() ) : ?>
    234235                        <li class="howto">