Plugin Directory

Changeset 2934823


Ignore:
Timestamp:
07/05/2023 09:24:00 PM (21 months ago)
Author:
firmcatalyst
Message:

Minor improvements and update to 1.0.4

Location:
fcp-posts-by-search-query/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • fcp-posts-by-search-query/trunk/inc/functions.php

    r2907638 r2934823  
    3535
    3636function get_types_to_apply_to() {
    37     return filter_by_public_types( get_settings()['apply-to'] );
     37    return filter_by_public_types( get_settings()['apply-to'] ?? [] );
    3838}
    3939function get_types_to_search_among() {
    40     return filter_by_public_types( get_settings()['select-from'] );
     40    return filter_by_public_types( get_settings()['select-from'] ?? [] );
    4141}
    4242
    4343function css_minify($css) {
    44     $css = preg_replace( '/\/\*(?:.*?)*\*\//', '', $css ); // remove comments
    45     $css = preg_replace( '/\s+/', ' ', $css ); // one-line & only single speces
    46     $css = preg_replace( '/ ?([\{\};:\>\~\+]) ?/', '$1', $css ); // remove spaces
    47     $css = preg_replace( '/\+(\d)/', ' + $1', $css ); // restore spaces in functions
    48     $css = preg_replace( '/(?:[^\}]*)\{\}/', '', $css ); // remove empty properties
     44    $preg_replace = function($regexp, $replace, $string) { // avoid null result so that css still works even though not fully minified
     45        return preg_replace( $regexp, $replace, $string ) ?: $string . '/* --- failed '.$regexp.', '.$replace.' */';
     46    };
     47    $css = $preg_replace( '/\s+/', ' ', $css ); // one-line & only single speces
     48    $css = $preg_replace( '/ ?\/\*(?:.*?)\*\/ ?/', '', $css ); // remove comments
     49    $css = $preg_replace( '/ ?([\{\};:\>\~\+]) ?/', '$1', $css ); // remove spaces
     50    $css = $preg_replace( '/\+(\d)/', ' + $1', $css ); // restore spaces in functions
     51    $css = $preg_replace( '/(?:[^\}]*)\{\}/', '', $css ); // remove empty properties
    4952    $css = str_replace( [';}', '( ', ' )'], ['}', '(', ')'], $css ); // remove last ; and spaces
     53    // ++ should also remove 0 from 0.5, but not from svg-s?
     54    // ++ try replacing ', ' with ','
     55    // ++ remove space between %3E %3C and before %3E and /%3E
    5056    return trim( $css );
    5157};
  • fcp-posts-by-search-query/trunk/inc/meta-boxes.php

    r2927964 r2934823  
    2929    ];
    3030
    31 
    3231    $screen = get_current_screen();
    3332    if ( !isset( $screen ) || !is_object( $screen ) || !isset( $files[ $screen->base ] ) ) { return; }
     33
     34    if ( $screen->base === 'post' && !in_array( $screen->post_type, get_types_to_apply_to() ) ) { return; }
    3435
    3536    $assets_path = FCPPBK_DIR.'assets';
     
    5051    }
    5152
     53    if ( $screen->base !== 'settings_page_posts-by-query' ) { return; }
     54
    5255    // wp color picker
    5356    wp_enqueue_script( 'wp-color-picker' );
     
    6871
    6972    $route_args = function($search_by) {
    70 
    71         if ( empty( get_types_to_search_among() ) ) {
    72             return new \WP_Error( 'post_type_not_selected', 'Post type not selected', [ 'status' => 404 ] );
    73         }
    7473
    7574        $wp_query_args = [
     
    10099            'methods'  => 'GET',
    101100            'callback' => function( \WP_REST_Request $request ) use ( $wp_query_args, $format_output ) {
     101
     102                if ( empty( get_types_to_search_among() ) ) {
     103                    return new \WP_Error( 'post_type_not_selected', 'Post type not selected', [ 'status' => 404 ] );
     104                }
    102105
    103106                if ( FCPPBK_DEV ) { usleep( rand(0, 1000000) ); } // simulate server responce delay
  • fcp-posts-by-search-query/trunk/inc/shortcode.php

    r2927964 r2934823  
    6666    ];
    6767
    68     $search_by = $metas[ FCPPBK_PREF.'variants' ];
     68    $search_by = $metas[ FCPPBK_PREF.'variants' ] ?? 'list';
    6969
    7070    switch ( $search_by ) {
  • fcp-posts-by-search-query/trunk/posts-by-query.php

    r2927964 r2934823  
    33Plugin Name: FCP 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.
    5 Version: 1.0.3
     5Version: 1.0.4
    66Requires at least: 5.8
    77Tested up to: 6.2
  • fcp-posts-by-search-query/trunk/readme.txt

    r2927964 r2934823  
    55Tested up to: 6.2
    66Requires PHP: 7.4
    7 Stable tag: 1.0.3
     7Stable tag: 1.0.4
    88Author: Firmcatalyst, Vadim Volkov, Aude Jamier
    99Author URI: https://firmcatalyst.com
Note: See TracChangeset for help on using the changeset viewer.