Plugin Directory

Changeset 3333728


Ignore:
Timestamp:
07/24/2025 02:38:13 PM (8 months ago)
Author:
david.kane
Message:

Releasing v2.26.4

Location:
supapress/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • supapress/trunk/composer.json

    r3280659 r3333728  
    33  "description": "Quickly and easily connect your book metadata (ONIX) to your WordPress site.",
    44  "type": "wordpress-plugin",
    5   "version": "2.26.2",
     5  "version": "2.26.4",
    66  "authors": [
    77    {
  • supapress/trunk/includes/functions.php

    r3268984 r3333728  
    978978
    979979    // check that the ISBN is set
    980     if( preg_match( '/\d{13}$/', get_query_var( 'supapress_isbn' ) ) === '' ) {
     980    $isbn = get_query_var('supapress_isbn');
     981    if (!preg_match('/\d{13}$/', $isbn)) {
    981982        return;
    982983    }
     
    10231024        return $str;
    10241025    }
    1025 
    10261026    // grab the matching tag
    10271027    $tag = $matches[0];
  • supapress/trunk/includes/typesense-functions.php

    r3280659 r3333728  
    6262        $salesDate = $this->get_sales_date();
    6363
    64         if ( isset( $this->properties['show_sales_date'] ) && $this->properties['show_sales_date'] !== 'on' && empty( $salesDate ) ) {
     64        if ( isset( $this->properties['show_sales_date'] ) && $this->properties['show_sales_date'] !== 'on' ) {
    6565            return '';
    6666        }
     
    9292        $bookPrices = $this->get_price();
    9393
    94         if( isset( $this->properties['show_price'] ) && $this->properties['show_price'] !== 'on' && !isset( $this->properties['price'] ) && empty( $bookPrices ) ) {
    95             return '';
    96         }
    97 
    98         foreach ( $this->properties['price'] as $p ) {
    99             $currency = $this->get_currency_symbol($p);
    100             if ( isset( $bookPrices[ $p ] ) ) {
    101                 $price .= "{$before}{$currency}{$bookPrices[$p]}{$after}";
    102             }
    103         }
     94        if( isset( $this->properties['show_price'] ) && $this->properties['show_price'] !== 'on' && !isset( $this->properties['price'] ) ) {
     95            return '';
     96        }
     97
     98        if( !empty( $bookPrices ) ) {
     99            foreach ( $this->properties['price'] as $p ) {
     100                $currency = $this->get_currency_symbol($p);
     101                if ( isset( $bookPrices[ $p ] ) ) {
     102                    $price .= "{$before}{$currency}{$bookPrices[$p]}{$after}";
     103                }
     104            }
     105        }
     106
     107        if( empty( $price ) ) {
     108            return '';
     109        }
    104110
    105111        if ( $echo ) {
     
    114120        $contributors = $this->get_author();
    115121
    116         if ( isset( $this->properties['show_author'] ) && $this->properties['show_author'] !== 'on' && empty( $contributors ) ) {
     122        if ( isset( $this->properties['show_author'] ) && $this->properties['show_author'] !== 'on' ) {
    117123            return '';
    118124        }
    119125           
    120         foreach ( $contributors as $i => $contributor ) {
    121             if ( is_int( $index ) && $index !== $i ) {
    122                 continue;
    123             }
    124             if ( !empty( $contributor['name'] ) ) {
    125                 $authors[] = $contributor['name'];
    126             }
    127         }
     126        if( !empty( $contributors ) ) {
     127            foreach ( $contributors as $i => $contributor ) {
     128                if ( is_int( $index ) && $index !== $i ) {
     129                    continue;
     130                }
     131                if ( !empty( $contributor['name'] ) ) {
     132                    $authors[] = $contributor['name'];
     133                }
     134            }
     135        }
    128136
    129137        $authors = $before . implode( $separator, $authors ) . $after;
     
    132140            return '';
    133141        }
    134 
     142       
    135143        if ( $echo ) {
    136144            echo $authors;
     
    187195
    188196    return $client;
    189    
    190197}
    191198
     
    216223}
    217224
     225function supapress_ts_search_args($params, $properties, $args = []) {
     226    $priceProp = $properties['price'][0] ?? '';
     227    $order = $params['order'] ?? '';
     228
     229    $sortByOptions = [
     230        'as-entered'        => '',
     231        'publishdate-desc'  => 'publicationDate:desc',
     232        'publishdate-asc'   => 'publicationDate:asc',
     233        'title-az'          => 'title:asc',
     234        'title-za'          => 'title:desc',
     235    ] + (!empty($priceProp) ? [
     236        'price-asc'  => "prices.{$priceProp}:asc",
     237        'price-desc' => "prices.{$priceProp}:desc"
     238    ] : []);
     239
     240    if (!empty($sortByOptions[$order])) {
     241        $args['sort_by'] = $sortByOptions[$order];
     242    }
     243
     244    foreach (['isbns' => 'isbn13:[%s]', 'collection' => "collections.list.name:='%s'", 'publisher' => "publisher:='%s'", 'imprint' => "imprint:='%s'"] as $key => $format) {
     245        if (!empty($params[$key])) {
     246            $args['filter_by'] = sprintf($format, $params[$key]);
     247            break;
     248        }
     249    }
     250   
     251
     252    if (!empty($args['filter_by'])) {
     253        $args += ['q' => '*', 'per_page' => $params['amount'] ?? "250"];
     254    }
     255
     256    return $args;
     257}
     258
     259
    218260function supapress_call_typesense_search( $params, $properties ) {
    219     $args = array();
    220     $priceProp = $properties['price'][0] ?? "";
    221     $order = $params['order'] ?? '';
    222 
    223     //Map dropdown sort by options
    224     $sortByOptions = [
    225         'as-entered'        => '',
    226         'publishdate-desc'  => 'publicationDate:desc', // Newest to Oldest
    227         'publishdate-asc'   => 'publicationDate:asc',  // Oldest to Newest
    228         'title-az'          => 'title:asc',            // Title - A to Z
    229         'title-za'          => 'title:desc',           // Title - Z to A
    230     ];
    231 
    232     if( !empty( $priceProp ) ) {
    233         $sortByOptions += [
    234             'price-asc' => "prices.{$priceProp}:asc", // Price - Low to High
    235             'price-desc' => "prices.{$priceProp}:desc" // Price - High to Low
    236         ];
    237     }
    238 
    239     if( !empty( $sortByOptions[$order] ) )  {
    240         $args['sort_by'] = $sortByOptions[$order];
    241     }
    242 
    243     $args['filter_by'] = !empty($params['isbns']) ? "isbn13:[" . $params['isbns'] . "]" : (!empty($params['collection']) ? "collections.list.name:='{$params['collection']}'" : '');
    244 
    245     if( !empty( $args['filter_by'] ) ) {
    246         $args += ['q' => '*', 'per_page' => '250'];
    247     }
    248 
     261   
     262    $args = supapress_ts_search_args( $params, $properties );
    249263    $results = supapress_call_typesense( $args );
    250264
  • supapress/trunk/readme.txt

    r3280659 r3333728  
    44Requires at least: 6.0
    55Tested up to: 6.7.2
    6 Stable tag: 2.26.2
     6Stable tag: 2.26.4
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3838
    3939== Changelog ==
     40
     41= 2.26.4 =
     42Release Date: Jul 2025
     43* Change: supapress_ts_search_args function created
     44* Bug: preg_match check fixed
    4045
    4146= 2.26.2 =
  • supapress/trunk/supapress.php

    r3280659 r3333728  
    77 * Plugin URI: https://www.supadu.com
    88 * Description: Quickly and easily connect your book metadata (ONIX) to your WordPress site.
    9  * Version: 2.26.2
     9 * Version: 2.26.4
    1010 * Author: Supadü
    1111 * Author URI: https://www.supadu.com
     
    3737defined( 'ABSPATH' ) or die( 'Illegal Access!' );
    3838
    39 define( 'SUPAPRESS_VERSION', '2.26.2' );
     39define( 'SUPAPRESS_VERSION', '2.26.4' );
    4040
    4141define( 'SUPAPRESS_SITE_URL', get_site_url() );
Note: See TracChangeset for help on using the changeset viewer.