Changeset 2651363
- Timestamp:
- 12/31/2021 11:47:01 AM (4 years ago)
- Location:
- ts-search-slug
- Files:
-
- 6 added
- 2 edited
-
tags/1.0.2 (added)
-
tags/1.0.2/index.php (added)
-
tags/1.0.2/languages (added)
-
tags/1.0.2/license.txt (added)
-
tags/1.0.2/plugin.php (added)
-
tags/1.0.2/readme.txt (added)
-
trunk/plugin.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ts-search-slug/trunk/plugin.php
r1899137 r2651363 7 7 Author: Tobias Spiess 8 8 Author URI: https://www.spiess-informatik.de 9 Version: 1.0. 19 Version: 1.0.2 10 10 Text-Domain: tsinf_search_plugin_textdomain 11 11 Domain Path: /languages … … 54 54 } 55 55 56 add_filter('posts_where' , array('TS_Search_Slug', 'posts_where') );56 add_filter('posts_where' , array('TS_Search_Slug', 'posts_where'), 10, 2); 57 57 } 58 58 … … 196 196 * @return string 197 197 */ 198 public static function posts_where($where ) {198 public static function posts_where($where, &$wp_query) { 199 199 global $pagenow; 200 200 … … 212 212 } 213 213 214 if(is_admin() && 'edit.php' === $pagenow && isset($_GET['s']) && ($post_type === 'post' || $post_type === 'page' || in_array($post_type, $activated_cpts)))214 if(is_admin() && 'edit.php' === $pagenow && isset($_GET['s']) && is_string($_GET['s']) && strlen($_GET['s']) && ($post_type === 'post' || $post_type === 'page' || in_array($post_type, $activated_cpts))) 215 215 { 216 216 global $wpdb; 217 217 218 $search_term = sanitize_text_field($_GET['s']); 219 $search_term_slug = sanitize_title($_GET['s']); 220 221 $where = " 222 AND ( 223 ( 224 (" . $wpdb->posts . ".post_title LIKE '%" . $search_term . "%') OR 225 (" . $wpdb->posts . ".post_excerpt LIKE '%" . $search_term . "%') OR 226 (" . $wpdb->posts . ".post_content LIKE '%" . $search_term . "%') OR 227 (" . $wpdb->posts . ".post_name LIKE '%" . $search_term_slug . "%') 228 ) 229 ) 230 AND " . $wpdb->posts . ".post_type = '" . $post_type . "' 231 AND (" . $wpdb->posts . ".post_status = 'publish' OR " . $wpdb->posts . ".post_status = 'future' OR " . $wpdb->posts . ".post_status = 'draft' OR " . $wpdb->posts . ".post_status = 'pending' OR " . $wpdb->posts . ".post_status = 'private') 232 "; 218 $like = '%' . $wpdb->esc_like($_GET['s']) . '%'; 219 $like_term = $wpdb->prepare("({$wpdb->posts}.post_name LIKE %s)", $like); 220 221 $like_search_pattern = $wpdb->prepare("({$wpdb->posts}.post_title LIKE %s)", $like); 222 $like_search_replace = " " . $like_search_pattern . " OR " . $like_term . " "; 223 224 $where = str_replace($like_search_pattern, $like_search_replace, $where); 233 225 } 234 226 -
ts-search-slug/trunk/readme.txt
r2497640 r2651363 1 1 === TS Search Slug === 2 2 Contributors: tsinf 3 Tags: post, slug , order, admin3 Tags: post, slug 4 4 Requires at least: 4.8 5 Tested up to: 5. 75 Tested up to: 5.8 6 6 Stable Tag: 4.9 7 7 Creation time: 01.05.2018 8 Last updated time: 2 6.06.20188 Last updated time: 29.12.2021 9 9 10 10 Search for Slug in Admin Post/Page Overview and add Slug Column to Post/Page Overview. 11 11 12 12 == Description == 13 With this plugin you can search posts and for their slug, see the slug in admin post overview in an additional column and sort by it. 14 You can search for the slug in admin post ovierview. 13 With this plugin you can search posts and for their slug, see the slug in admin post overview in an additional column and sort by it 15 14 16 15 == Installation == … … 21 20 22 21 == Changelog == 22 * 1.0.2 23 Fix bug, that other search parameters in admin area are ignored when slug search is activated 23 24 24 25 * 1.0.1
Note: See TracChangeset
for help on using the changeset viewer.