Changeset 2944709
- Timestamp:
- 07/28/2023 03:45:01 PM (20 months ago)
- Location:
- fcp-posts-by-search-query/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fcp-posts-by-search-query/trunk/inc/shortcode.php
r2934823 r2944709 9 9 10 10 if ( is_admin() ) { return; } 11 if ( empty( get_types_to_search_among() ) ) { return; } 11 12 12 if ( empty( get_types_to_search_among() ) ) { return; } 13 if ( !in_array( get_post_type(), get_types_to_apply_to() ) ) { return; } 13 $queried_id = get_queried_object_id(); 14 $post_type = get_post_type( $queried_id ); 15 16 if ( !in_array( $post_type, get_types_to_apply_to() ) ) { return; } 17 18 if( !is_singular($post_type) ) { return; } 14 19 15 20 $settings = get_settings(); 16 $queried_id = get_queried_object_id();17 21 18 22 // styles … … 67 71 68 72 $search_by = $metas[ FCPPBK_PREF.'variants' ] ?? 'list'; 73 $unfilled = false; 69 74 70 75 switch ( $search_by ) { 71 76 case ( 'list' ): 72 77 $ids = unserialize( $metas[ FCPPBK_PREF.'posts' ] ); 73 if ( empty( $ids ) ) { return; }78 if ( empty( $ids ) ) { $unfilled = true; break; } 74 79 $wp_query_args += [ 'post__in' => $ids, 'orderby' => 'post__in' ]; 75 80 break; 76 81 case ( 'query' ): 77 82 $query = trim( $metas[ FCPPBK_PREF.'query' ] ); 78 if ( $query === '' && $settings['unfilled-behavior'] === 'search-by-title' ) { // ++-- && is_single( $queried_id ) doesn't work somehow 79 $query = trim( get_the_title( $queried_id ) ); 80 } 81 if ( $query === '' ) { return; } 83 if ( $query === '' ) { $unfilled = true; break; } 82 84 $wp_query_args += [ 'orderby' => 'date', 'order' => 'DESC', 's' => $query ]; 83 85 break; 84 86 default: 85 return;87 $unfilled = true; 86 88 } 89 90 if ( $unfilled && $settings['unfilled-behavior'] !== 'search-by-title' ) { return; } // ++ improve the logic 91 92 if ( $unfilled && $settings['unfilled-behavior'] === 'search-by-title' ) { // ++-- && is_single( $queried_id ) doesn't work somehow 93 $query = trim( get_the_title( $queried_id ) ); 94 $wp_query_args += [ 'orderby' => 'date', 'order' => 'DESC', 's' => $query ]; 95 } 87 96 88 97 $search = new \WP_Query( $wp_query_args ); 89 98 90 if ( !$search->have_posts() || !( $search->found_posts >= ( $settings['minimum-posts'] ? : 0 ) ) ) { return; }99 if ( !$search->have_posts() || !( $search->found_posts >= ( $settings['minimum-posts'] ?? 0 ?: 0 ) ) ) { return; } 91 100 92 101 $get_template = function($name, $is_part = true) { -
fcp-posts-by-search-query/trunk/posts-by-query.php
r2934823 r2944709 3 3 Plugin Name: FCP Posts by Search Query 4 4 Description: Implement a list of relevant posts to particular pages with a search query or exact list of posts. Easy pick and add. 5 Version: 1.0. 45 Version: 1.0.5 6 6 Requires at least: 5.8 7 7 Tested up to: 6.2 … … 47 47 // !!title and description must be more like for printing to understans blah blah check out the competitors 48 48 // after publishing add thumbnails and the preview page 49 49 // test for errors and warnings on empty values in settings 50 50 // ++ if Posts by Search Query & Date become empty, the old query still prints what was found 51 51 // ++ turn posts-by-query into a constant and avoid conflict with FCPPBK_SETT -
fcp-posts-by-search-query/trunk/readme.txt
r2934823 r2944709 5 5 Tested up to: 6.2 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 47 Stable tag: 1.0.5 8 8 Author: Firmcatalyst, Vadim Volkov, Aude Jamier 9 9 Author URI: https://firmcatalyst.com
Note: See TracChangeset
for help on using the changeset viewer.