Changeset 2927964
- Timestamp:
- 06/19/2023 01:16:05 PM (21 months ago)
- Location:
- fcp-posts-by-search-query/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
fcp-posts-by-search-query/trunk/assets/advisor.js
r2907638 r2927964 4 4 const $ = jQuery, 5 5 css_prefix = 'fcp-advisor-', 6 css_class = css_prefix+'holder' ,7 css_status_class = css_prefix+'holder-status';8 let init_val = '';6 css_class = css_prefix+'holder'; 7 let init_val = '', 8 input_delay = setTimeout( ()=>{} ); 9 9 10 10 if ( !$input || !$input instanceof $ || !arr ) { return } … … 18 18 }); 19 19 $input.on( 'input', function() { 20 list_holder_fill(); 20 clearTimeout( input_delay ); 21 input_delay = setTimeout( list_holder_fill, 500 ); // ++ make abort immediately, but request delay 21 22 }); 22 23 $input.on( 'keydown', function(e) { … … 218 219 // ++ abort all if the field got cleared 219 220 // ++? appear the loading after 0.3s 221 // ++ the option to prevent the bar from closing, just remove the <li> -
fcp-posts-by-search-query/trunk/inc/config.php
r2907638 r2927964 58 58 } 59 59 60 function get_default_values() { // apply on install && only planned to be usef in fields, which must not be empty // ++ turn to the constant 60 function get_default_values() { // apply on install && only planned to be usef in fields, which must not be empty // ++ turn to the constant ++!! set up them all by the structure 61 61 return [ 62 62 'main-color' => '#007cba', -
fcp-posts-by-search-query/trunk/inc/meta-boxes.php
r2927416 r2927964 64 64 65 65 // api to fetch the posts by search query or by id-s 66 // ++ show correct unfilled behavior!!! 66 67 add_action( 'rest_api_init', function () { 67 68 … … 96 97 } 97 98 98 if ( FCPPBK_DEV ) { usleep( rand(0, 1000000) ); } // simulate server responce delay99 100 99 return [ 101 100 'methods' => 'GET', 102 101 'callback' => function( \WP_REST_Request $request ) use ( $wp_query_args, $format_output ) { 102 103 if ( FCPPBK_DEV ) { usleep( rand(0, 1000000) ); } // simulate server responce delay 103 104 104 105 $wp_query_args['s'] = $request['search']; -
fcp-posts-by-search-query/trunk/inc/settings-page.php
r2907638 r2927964 20 20 ['Additional CSS', 'textarea', [ 'filter' => 'css' ]], 21 21 ['Limit the list', 'number', [ 'placeholder' => '10', 'step' => 1, 'comment' => 'If the Layout Setting contains the List option, this number will limit the amount of posts in it', 'filter' => 'integer' ]], 22 ['Minimum posts', 'number', [ 'placeholder' => '0', 'step' => 1, 'comment' => 'Minimum number of posts found to be printed. Doesn\'t refer to the List of particular posts', 'filter' => 'integer' ]], 22 23 ['Default thumbnail', 'image', [ 'comment' => 'This image is shown, if a post doesn\'t have the featured image', 'className' => 'image' ]], 23 24 ['Thumbnail size', 'select', [ 'options' => '%thumbnail_sizes' ]], … … 36 37 ['Select from', 'checkboxes', [ 'options' => '%get_public_post_types', 'comment' => 'Pick the post types in which the search is performed' ]], 37 38 ['Apply to', 'checkboxes', [ 'options' => '%get_public_post_types', 'comment' => 'This plugin will be applied to posts of these post types' ]], 39 ['Unfilled behavior', 'select', [ 'options' => [ '' => 'Hide', 'search-by-title' => 'Search by Title' ] ]], 38 40 ], 39 41 ]; -
fcp-posts-by-search-query/trunk/inc/shortcode.php
r2927416 r2927964 14 14 15 15 $settings = get_settings(); 16 $queried_id = get_queried_object_id(); 16 17 17 18 // styles … … 45 46 } 46 47 47 // wp_reset_query(); // ++ investigate when to apply48 49 48 $metas = array_map( function( $value ) { // get the meta values 50 49 return $value[0]; 51 }, array_filter( get_post_ custom(), function($key) { // get only meta for the plugin50 }, array_filter( get_post_meta( $queried_id ), function($key) { // get only meta for the plugin 52 51 return strpos( $key, FCPPBK_PREF ) === 0; 53 52 }, ARRAY_FILTER_USE_KEY ) ); … … 59 58 }, 0 ); 60 59 61 $current_id = empty( get_queried_object() ) ? 0 : get_queried_object()->ID;62 63 60 $wp_query_args = [ 64 61 'post_type' => get_types_to_search_among(), 65 62 'post_status' => 'publish', 66 63 'posts_per_page' => $limit, 67 'post__not_in' => [ $ current_id ], // exclude self64 'post__not_in' => [ $queried_id ], // exclude self 68 65 'lang' => 'all', 69 66 ]; … … 78 75 break; 79 76 case ( 'query' ): 80 $query = $metas[ FCPPBK_PREF.'query' ]; 81 if ( trim( $query ) === '' ) { return; } 77 $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; } 82 82 $wp_query_args += [ 'orderby' => 'date', 'order' => 'DESC', 's' => $query ]; 83 83 break; … … 88 88 $search = new \WP_Query( $wp_query_args ); 89 89 90 if ( !$search->have_posts() ) { return; }90 if ( !$search->have_posts() || !( $search->found_posts >= ( $settings['minimum-posts'] ?: 0 ) ) ) { return; } 91 91 92 92 $get_template = function($name, $is_part = true) { -
fcp-posts-by-search-query/trunk/posts-by-query.php
r2927418 r2927964 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. 25 Version: 1.0.3 6 6 Requires at least: 5.8 7 7 Tested up to: 6.2 -
fcp-posts-by-search-query/trunk/readme.txt
r2927418 r2927964 5 5 Tested up to: 6.2 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 27 Stable tag: 1.0.3 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.