Plugin Directory

Changeset 3032910


Ignore:
Timestamp:
02/07/2024 09:54:25 PM (13 months ago)
Author:
firmcatalyst
Message:

excerpt cut out shortcodes

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  
    4444    // inline the additional CSS
    4545    $handle = FCPPBK_PREF.'additional';
    46     if ( $settings['additional-css'] ?? trim( $settings['additional-css'] ) ) {
     46    if ( isset($settings['additional-css']) && (trim($settings['additional-css']) !== '') ) {
    4747        wp_register_style( $handle, false );
    4848        wp_enqueue_style( $handle );
     
    7575    switch ( $search_by ) {
    7676        case ( 'list' ):
    77             $ids = unserialize( $metas[ FCPPBK_PREF.'posts' ] );
     77            $ids = unserialize( $metas[ FCPPBK_PREF.'posts' ] ?? 'a:0:{}' );
    7878            if ( empty( $ids ) ) { $unfilled = true; break; }
    7979            $wp_query_args += [ 'post__in' => $ids, 'orderby' => 'post__in' ];
    8080        break;
    8181        case ( 'query' ):
    82             $query = trim( $metas[ FCPPBK_PREF.'query' ] );
     82            $query = trim( $metas[ FCPPBK_PREF.'query' ] ?? '' );
    8383            if ( $query === '' ) { $unfilled = true; break; }
    8484            $wp_query_args += [ 'orderby' => 'date', 'order' => 'DESC', 's' => $query ];
     
    8888    }
    8989   
    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
     90    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
    9393        $query = trim( get_the_title( $queried_id ) );
    9494        $wp_query_args += [ 'orderby' => 'date', 'order' => 'DESC', 's' => $query ];
     
    133133        return $text;
    134134    };
     135    $content_to_excerpt_format = function($content) {
     136        $content = \wp_strip_all_tags( $content, true );
     137        $content = preg_replace( '/\[[^\]]+\]/', '', $content );
     138        return $content;
     139    };
    135140
    136141    $posts = [];
     
    140145
    141146        // 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 );
    143148        $categories = isset( $settings['hide-category'] ) ? [] : get_the_category( $p );
    144149
    145150        $thumbnail = $settings['thumbnail-size'] ? (
    146151            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 )
    148153            ?: '<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">'
    149154        ) : '';
  • fcp-posts-by-search-query/trunk/posts-by-query.php

    r3006495 r3032910  
    33Plugin Name: Posts by Search Query
    44Description: 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.8
     5Version: 1.0.9
    66Requires at least: 5.8
    77Tested up to: 6.4
  • fcp-posts-by-search-query/trunk/readme.txt

    r3006495 r3032910  
    55Tested up to: 6.4
    66Requires PHP: 7.4
    7 Stable tag: 1.0.8
     7Stable tag: 1.0.9
    88Author: Firmcatalyst, Vadim Volkov, Aude Jamier
    99Author URI: https://firmcatalyst.com/about/
Note: See TracChangeset for help on using the changeset viewer.