Plugin Directory

Changeset 3068367


Ignore:
Timestamp:
04/10/2024 10:31:42 AM (2 years ago)
Author:
simonefontana
Message:

Update plugin version 1.6

Location:
sf-autosuggest-product-search
Files:
40 added
5 edited

Legend:

Unmodified
Added
Removed
  • sf-autosuggest-product-search/trunk/README.txt

    r3027301 r3068367  
    44Requires at least: 3.8.8
    55Requires PHP: 7.0
    6 Tested up to: 6.4
    7 Stable tag: 1.5
     6Tested up to: 6.5
     7Stable tag: 1.6
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.txt
     
    5858
    5959== Changelog ==
     60= 1.6 =
     61* Add the ability to include stop words
     62* Fix product thumbnails without sizes
     63
    6064= 1.5 =
    6165* Add price in search results
  • sf-autosuggest-product-search/trunk/classes/AdminClass.php

    r3027301 r3068367  
    136136                                'input' => 'taxonomies',
    137137                                'instruction' => __('Select wich taxonomy want search.', 'sf_products_autosuggest')
    138                             )
     138                            ),
     139                            array(
     140                                'title' => __('Stop Words', 'sf_products_autosuggest'),
     141                                'section' => 'sf_pa_apparance',
     142                                'key' => 'stop_words',
     143                                'input' => 'textarea',
     144                                'instruction' => __('Words that should be ignored by the search. Write them divided by "|".', 'sf_products_autosuggest')
     145                            ),
     146
    139147                        );
    140148   
     
    155163       
    156164        echo "<input id='".$params['section']."_".$params['key']."' name='sf_pa_autosuggest_plugin_options[".$params['key']."]' type='text' value='" .$value. "' />";
     165       
     166        if(isset($params['instruction']) && !empty($params['instruction'])){
     167            echo '<p class="sf_pa-instruction">'.esc_html($params['instruction']).'</p>';
     168        }
     169    }
     170
     171    public function textarea($params){
     172        $options = get_option( 'sf_pa_autosuggest_plugin_options' );
     173        $value = '';
     174        if (isset($options[$params['key']]))
     175            $value = esc_attr( $options[$params['key']]);
     176       
     177        echo "<textarea id='".$params['section']."_".$params['key']."' name='sf_pa_autosuggest_plugin_options[".$params['key']."]' type='text' />".$value."</textarea>";
    157178       
    158179        if(isset($params['instruction']) && !empty($params['instruction'])){
     
    218239        $newinput['all_color'] =  $validator->hexadecimal($input['all_color'], '#fff');
    219240        $newinput['not_found'] =  $validator->plaintext($input['not_found']);
     241        $newinput['stop_words'] =  $validator->plaintext($input['stop_words']);
    220242        if(isset($input['show_thumbnail']) && !empty($input['show_thumbnail'])){
    221243            $newinput['show_thumbnail'] = $validator->checkbox($input['show_thumbnail']);
  • sf-autosuggest-product-search/trunk/classes/FeedbackClass.php

    r3027301 r3068367  
    387387        );
    388388
    389         error_log(print_r(json_encode($data), true));
    390 
    391389        wp_send_json_success();
    392390    }
  • sf-autosuggest-product-search/trunk/classes/SearchClass.php

    r3027301 r3068367  
    3131        /* IF NOT CACHED */
    3232        if(!$results){
     33
     34            //Remove Stop words
     35            if(isset($this->options['stop_words']) && !empty($this->options['stop_words'])){
     36                $sf_pa_search = $this->remove_stop_words($sf_pa_search);
     37            }
    3338
    3439            $prepare =  array($this->options['show_cat'], $this->options['show_thumbnail'], $this->options['show_price'], '%' . $wpdb->esc_like($sf_pa_search) .'%');
     
    135140                }
    136141            }
     142            elseif(!empty( $data['file'] )){
     143                $file = $data['file'];
     144                $file = "$this->content_url/$file";
     145                return esc_url($file);
     146            }
    137147        }
    138148        return '';
     
    158168        }
    159169    }
     170
     171    private function remove_stop_words($search_words){
     172        $stop_words = explode('|', $this->options['stop_words']);
     173       
     174
     175        foreach($stop_words as $stop_word){
     176            //If space is before and after
     177            $search_words = str_ireplace(' '.trim($stop_word).' ',' ',$search_words);
     178            //If space is after
     179            $search_words = str_ireplace(trim($stop_word).' ',' ',$search_words);
     180            //If space is before
     181            $search_words = str_ireplace(' '.trim($stop_word),' ',$search_words);
     182        }
     183
     184        return $search_words;
     185       
     186    }
    160187}
  • sf-autosuggest-product-search/trunk/sf_products_autosuggest.php

    r3027301 r3068367  
    33* Plugin Name: SF Autosuggest Product Search
    44* Description: Autosuggest Product Search for Woocommerce
    5 * Version: 1.5
     5* Version: 1.6
    66* Author: Simone Fontana
    77* Author URI: https://www.simonefontana.net/
    88* WC requires at least: 3.0.0
    9 * WC tested up to: 8.5
     9* WC tested up to: 8.7
    1010**/
    1111
     
    1414}
    1515
    16 const SF_VERSION = "1.5";
     16const SF_VERSION = "1.6";
    1717
    1818/* Add style and script to plugin*/
Note: See TracChangeset for help on using the changeset viewer.