Plugin Directory

Changeset 3086600

Timestamp:
05/14/2024 03:18:05 PM (2 months ago)
Author:
Marc4
Message:

v1.6

Location:
clear-internal-search-button
Files:
1 added
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • clear-internal-search-button/trunk/clear-internal-search-button.js

    r3086120 r3086600  
    11jQuery(document).ready(function($) {
    2     // Verify that clearSearchData is defined correctly
    3     if (typeof clearSearchData === 'undefined' || typeof clearSearchData.buttonText === 'undefined') {
    4         console.error('clearSearchData is not defined correctly.');
    5         return;
    6     }
    7 
    82    // Define a list of selectors for the search fields
    93    const searchFieldsSelectors = ['#post-search-input', '#comment-search-input', '#user-search-input', '#media-search-input', '#plugin-search-input', '#wp-filter-search-input', '#search-plugins', '#tag-search-input'];
     
    137        const $searchField = $(selector);
    148
    15         if($searchField.length) {
    16             // Creates the button but initially hidden
    17             const buttonText = $('<div>').text(clearSearchData.buttonText).html();
    18             const $button = $('<button type="button" class="button clear-search-button">' + buttonText + '</button>').insertAfter($searchField);
     9        if ($searchField.length) {
     10            // Wraps each search field in a div that will position the clear button
     11            $searchField.wrap('<div class="search-field-wrapper"></div>');
     12            const $wrapper = $searchField.parent();
     13
     14            // Creates the button inside the search field, initially hidden
     15            const $button = $('<button type="button" class="button clear-search-button" style="display: none;" aria-label="Clear search field">X</button>');
     16            $wrapper.append($button);
    1917
    2018            // Function to control the visibility of the button based on the content of the search field
  • clear-internal-search-button/trunk/clear-internal-search-button.php

    r3086301 r3086600  
    44Plugin URI: https://wordpress.org/plugins/clear-internal-search-button/
    55Description: Clear Internal Search Button adds a button to clear the text of the internal search field for posts, pages, comments, users, media library, categories, tags, plugins and themes sections in the WordPress admin area.
    6 Version: 1.5
     6Version: 1.
    77Requires at least: 6.0
    88Tested up to: 6.5
     
    1919function cisb_admin_enqueue_scripts() {
    2020    wp_enqueue_script('clear-internal-search-button-js', plugin_dir_url(__FILE__) . 'clear-internal-search-button.js', array('jquery'), '1.0', true);
    21 
    22     // Localize the script to pass translatable strings
    23 
    24     wp_localize_script('clear-internal-search-button-js', 'clearSearchData', array(
    25         'buttonText' => esc_html__('Clear', 'clear-internal-search-button'),
    26     ));
    27 
    2821    wp_enqueue_style('clear-internal-search-button-css', plugin_dir_url(__FILE__) . 'styles.css', array(), '1.0');
    2922}
  • clear-internal-search-button/trunk/readme.txt

    r3086301 r3086600  
    66Requires PHP: 7.0
    77Tested PHP: 8.3
    8 Stable tag: 1.5
     8Stable tag: 1.
    99License: GNU General Public License v2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2626== Changelog ==
    2727
    28 = [1.5] - 2024-14-05 =
     28= [1.6] - 2024-14-05 =
     29
     30* Added "X" button inside the search field.
     31
     32= [1.5] - 2024-13-05 =
    2933
    3034* Added version to `wp_enqueue_style`.
  • clear-internal-search-button/trunk/styles.css

    r3078075 r3086600  
    1 .button.clear-search-button {
    2     display: none;
    3     margin: 0 3px;
     1.wp-core-ui p .button {
     2    vertical-align: top !important;
    43}
    54
    6 .wp-filter .search-plugins .button.clear-search-button {
    7     margin: 10px 0px 0px 3px;
     5.search-field-wrapper {
     6    position: relative;
     7    display: inline-block;
    88}
     9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
Note: See TracChangeset for help on using the changeset viewer.