Changeset 3086600
- Timestamp:
- 05/14/2024 03:18:05 PM (2 months ago)
- 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 1 1 jQuery(document).ready(function($) { 2 // Verify that clearSearchData is defined correctly3 if (typeof clearSearchData === 'undefined' || typeof clearSearchData.buttonText === 'undefined') {4 console.error('clearSearchData is not defined correctly.');5 return;6 }7 8 2 // Define a list of selectors for the search fields 9 3 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']; … … 13 7 const $searchField = $(selector); 14 8 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); 19 17 20 18 // 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 4 4 Plugin URI: https://wordpress.org/plugins/clear-internal-search-button/ 5 5 Description: 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. 56 Version: 1. 7 7 Requires at least: 6.0 8 8 Tested up to: 6.5 … … 19 19 function cisb_admin_enqueue_scripts() { 20 20 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 strings23 24 wp_localize_script('clear-internal-search-button-js', 'clearSearchData', array(25 'buttonText' => esc_html__('Clear', 'clear-internal-search-button'),26 ));27 28 21 wp_enqueue_style('clear-internal-search-button-css', plugin_dir_url(__FILE__) . 'styles.css', array(), '1.0'); 29 22 } -
clear-internal-search-button/trunk/readme.txt
r3086301 r3086600 6 6 Requires PHP: 7.0 7 7 Tested PHP: 8.3 8 Stable tag: 1. 58 Stable tag: 1. 9 9 License: GNU General Public License v2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 26 26 == Changelog == 27 27 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 = 29 33 30 34 * 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; 4 3 } 5 4 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; 8 8 } 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.