Changeset 1989484
- Timestamp:
- 12/08/2018 07:59:03 PM (7 years ago)
- Location:
- wp-search-category-admin/trunk
- Files:
-
- 2 added
- 3 edited
-
README.md (modified) (3 diffs)
-
css (added)
-
css/style.css (added)
-
js/script.js (modified) (4 diffs)
-
wp-search-cat-admin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-search-category-admin/trunk/README.md
r1925279 r1989484 3 3 Tags: category, admin, post, search, box 4 4 Requires at least: 4.0 5 Tested up to: 4.96 Stable tag: 1. 15 Tested up to: 5.0 6 Stable tag: 1.2 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 12 12 == Description == 13 13 14 Search dynamically a category in the box category in admin14 Search dynamically a category in the box/block category in admin 15 15 16 16 … … 25 25 == Changelog == 26 26 27 = 1.2 = 28 * Compatibility with the new editor in WordPress 5.0+ 29 27 30 = 1.1 = 28 31 * Can search category in quick edit -
wp-search-category-admin/trunk/js/script.js
r1925275 r1989484 1 1 (function( $ ){ 2 $(document).ready(function(){ 2 console.log(wp); 3 $(window).load(function(){ 3 4 adminSearch.init(); 4 5 }); 5 6 var adminSearch = { 7 isGutenberg: false, 6 8 getNameSearchField: function(){ 7 9 return 'wpsca-search-field'; … … 18 20 // Can edit in post edit page or in quick edit 19 21 var isQuickEditPage = $('.quick-edit-row').length > 0; 22 20 23 if (isQuickEditPage === true) { 21 24 this.initQuickEdit(); … … 33 36 initEditPage: function() { 34 37 var globalObject = this; 35 36 38 var search_box = this.getSearchBox(); 37 39 var nameSearchField = this.getNameSearchField(); 40 setTimeout(function() { 41 // WordPress Guttenberg or version sup or equal to 5.0 42 globalObject.isGutenberg = $('.editor-post-taxonomies__hierarchical-terms-list').length > 0; 43 // Add search_box input 44 if (globalObject.isGutenberg) { 45 $('.editor-post-taxonomies__hierarchical-terms-list').before(search_box); 46 } else { 47 $('#category-tabs').before(search_box); 48 } 38 49 39 $('#category-tabs').before(search_box); 40 41 globalObject.initSearch('autocomplete', $('#'+nameSearchField), false); 50 globalObject.initSearch('autocomplete', $('#'+nameSearchField), false); 51 }, 800); 42 52 }, 43 53 … … 90 100 var parentClass = 'categorydiv'; 91 101 var categoryChecklistClass = 'categorychecklist'; 102 var itemSelector = 'li'; 103 104 if (this.isGutenberg) { 105 parentClass = 'components-panel__body'; 106 categoryChecklistClass = 'editor-post-taxonomies__hierarchical-terms-list'; 107 itemSelector = '.editor-post-taxonomies__hierarchical-terms-choice'; 108 } 92 109 if (isQuickEdit) { 93 110 parentClass = 'inline-edit-col'; 94 111 categoryChecklistClass = 'category-checklist'; 95 112 } 113 96 114 if ( $.trim(s) == "" ){ 97 elementEvent.parents('.' + parentClass).first().find('.'+ categoryChecklistClass +' li').show(); 98 } 99 else 100 { 101 var result = elementEvent.parents('.' + parentClass).first().find('.'+categoryChecklistClass+' li:Contains("'+s+'")'); 115 elementEvent.parents('.' + parentClass).first().find('.'+ categoryChecklistClass +' ' + itemSelector).show(); 116 } else { 117 var result = elementEvent.parents('.' + parentClass).first().find('.'+categoryChecklistClass+' ' + itemSelector + ':Contains("'+s+'")'); 102 118 103 elementEvent.parents('.' + parentClass).first().find('.' +categoryChecklistClass+' li').hide();119 elementEvent.parents('.' + parentClass).first().find('.' + categoryChecklistClass + ' ' + itemSelector).hide(); 104 120 result.each(function(){ 105 121 $(this).show(); -
wp-search-category-admin/trunk/wp-search-cat-admin.php
r1925279 r1989484 19 19 wp_register_script('wpsca_debounce', plugin_dir_url( __FILE__ ).'js/script.js'); 20 20 wp_enqueue_script('wpsca_debounce', false, array(), false, true); 21 wp_enqueue_script('wpsca_admin', false, array(), false, true); 21 wp_enqueue_script('wpsca_admin', false, array('wp-blocks'), false, true); 22 wp_enqueue_style('wpsca_style', plugin_dir_url( __FILE__ ).'css/style.css'); 22 23 } 23 24
Note: See TracChangeset
for help on using the changeset viewer.