Changeset 3032910
- Timestamp:
- 02/07/2024 09:54:25 PM (13 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
r3006495 r3032910 44 44 // inline the additional CSS 45 45 $handle = FCPPBK_PREF.'additional'; 46 if ( $settings['additional-css'] ?? trim( $settings['additional-css']) ) {46 if ( isset($settings['additional-css']) && (trim($settings['additional-css']) !== '') ) { 47 47 wp_register_style( $handle, false ); 48 48 wp_enqueue_style( $handle ); … … 75 75 switch ( $search_by ) { 76 76 case ( 'list' ): 77 $ids = unserialize( $metas[ FCPPBK_PREF.'posts' ] );77 $ids = unserialize( $metas[ FCPPBK_PREF.'posts' ] ?? 'a:0:{}' ); 78 78 if ( empty( $ids ) ) { $unfilled = true; break; } 79 79 $wp_query_args += [ 'post__in' => $ids, 'orderby' => 'post__in' ]; 80 80 break; 81 81 case ( 'query' ): 82 $query = trim( $metas[ FCPPBK_PREF.'query' ] );82 $query = trim( $metas[ FCPPBK_PREF.'query' ] ?? '' ); 83 83 if ( $query === '' ) { $unfilled = true; break; } 84 84 $wp_query_args += [ 'orderby' => 'date', 'order' => 'DESC', 's' => $query ]; … … 88 88 } 89 89 90 if ( $unfilled && $settings['unfilled-behavior'] !== 'search-by-title') { return; } // ++ improve the logic91 92 if ( $unfilled && $settings['unfilled-behavior'] === 'search-by-title' ) { // ++-- && is_single( $queried_id ) doesn't work somehow90 if ( $unfilled && (!isset($settings['unfilled-behavior']) || $settings['unfilled-behavior'] !== 'search-by-title') ) { return; } // ++ improve the logic 91 92 if ( $unfilled && isset($settings['unfilled-behavior']) && $settings['unfilled-behavior'] === 'search-by-title' ) { // ++-- && is_single( $queried_id ) doesn't work somehow 93 93 $query = trim( get_the_title( $queried_id ) ); 94 94 $wp_query_args += [ 'orderby' => 'date', 'order' => 'DESC', 's' => $query ]; … … 133 133 return $text; 134 134 }; 135 $content_to_excerpt_format = function($content) { 136 $content = \wp_strip_all_tags( $content, true ); 137 $content = preg_replace( '/\[[^\]]+\]/', '', $content ); 138 return $content; 139 }; 135 140 136 141 $posts = []; … … 140 145 141 146 // prepare the values to fill in the template 142 $excerpt = $crop_excerpt( ( has_excerpt( $p ) ? get_the_excerpt( $p ) : wp_strip_all_tags( get_the_content( null, false, $p ), true) ), $settings['excerpt-length'] ?: 200 );147 $excerpt = $crop_excerpt( ( has_excerpt( $p ) ? get_the_excerpt( $p ) : $content_to_excerpt_format( get_the_content( null, false, $p ) ) ), $settings['excerpt-length'] ?: 200 ); 143 148 $categories = isset( $settings['hide-category'] ) ? [] : get_the_category( $p ); 144 149 145 150 $thumbnail = $settings['thumbnail-size'] ? ( 146 151 get_the_post_thumbnail( $p, $settings['thumbnail-size'] ) 147 ?: wp_get_attachment_image( $settings['default-thumbnail'], $settings['thumbnail-size'])152 ?: ( isset($settings['default-thumbnail']) ? wp_get_attachment_image( $settings['default-thumbnail'], $settings['thumbnail-size'] ) : null ) 148 153 ?: '<img src="data:image/svg+xml,%3Csvg width=\'16\' height=\'16\' version=\'1.1\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3C/svg%3E" class="blank">' 149 154 ) : ''; -
fcp-posts-by-search-query/trunk/posts-by-query.php
r3006495 r3032910 3 3 Plugin Name: 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. Print with the shortcode <code>[fcppbk]</code> 5 Version: 1.0. 85 Version: 1.0.9 6 6 Requires at least: 5.8 7 7 Tested up to: 6.4 -
fcp-posts-by-search-query/trunk/readme.txt
r3006495 r3032910 5 5 Tested up to: 6.4 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 87 Stable tag: 1.0.9 8 8 Author: Firmcatalyst, Vadim Volkov, Aude Jamier 9 9 Author URI: https://firmcatalyst.com/about/
Note: See TracChangeset
for help on using the changeset viewer.