Changeset 3333728
- Timestamp:
- 07/24/2025 02:38:13 PM (8 months ago)
- Location:
- supapress/trunk
- Files:
-
- 5 edited
-
composer.json (modified) (1 diff)
-
includes/functions.php (modified) (2 diffs)
-
includes/typesense-functions.php (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
-
supapress.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
supapress/trunk/composer.json
r3280659 r3333728 3 3 "description": "Quickly and easily connect your book metadata (ONIX) to your WordPress site.", 4 4 "type": "wordpress-plugin", 5 "version": "2.26. 2",5 "version": "2.26.4", 6 6 "authors": [ 7 7 { -
supapress/trunk/includes/functions.php
r3268984 r3333728 978 978 979 979 // 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)) { 981 982 return; 982 983 } … … 1023 1024 return $str; 1024 1025 } 1025 1026 1026 // grab the matching tag 1027 1027 $tag = $matches[0]; -
supapress/trunk/includes/typesense-functions.php
r3280659 r3333728 62 62 $salesDate = $this->get_sales_date(); 63 63 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' ) { 65 65 return ''; 66 66 } … … 92 92 $bookPrices = $this->get_price(); 93 93 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 } 104 110 105 111 if ( $echo ) { … … 114 120 $contributors = $this->get_author(); 115 121 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' ) { 117 123 return ''; 118 124 } 119 125 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 } 128 136 129 137 $authors = $before . implode( $separator, $authors ) . $after; … … 132 140 return ''; 133 141 } 134 142 135 143 if ( $echo ) { 136 144 echo $authors; … … 187 195 188 196 return $client; 189 190 197 } 191 198 … … 216 223 } 217 224 225 function 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 218 260 function 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 ); 249 263 $results = supapress_call_typesense( $args ); 250 264 -
supapress/trunk/readme.txt
r3280659 r3333728 4 4 Requires at least: 6.0 5 5 Tested up to: 6.7.2 6 Stable tag: 2.26. 26 Stable tag: 2.26.4 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 38 38 39 39 == Changelog == 40 41 = 2.26.4 = 42 Release Date: Jul 2025 43 * Change: supapress_ts_search_args function created 44 * Bug: preg_match check fixed 40 45 41 46 = 2.26.2 = -
supapress/trunk/supapress.php
r3280659 r3333728 7 7 * Plugin URI: https://www.supadu.com 8 8 * Description: Quickly and easily connect your book metadata (ONIX) to your WordPress site. 9 * Version: 2.26. 29 * Version: 2.26.4 10 10 * Author: Supadü 11 11 * Author URI: https://www.supadu.com … … 37 37 defined( 'ABSPATH' ) or die( 'Illegal Access!' ); 38 38 39 define( 'SUPAPRESS_VERSION', '2.26. 2' );39 define( 'SUPAPRESS_VERSION', '2.26.4' ); 40 40 41 41 define( 'SUPAPRESS_SITE_URL', get_site_url() );
Note: See TracChangeset
for help on using the changeset viewer.