Plugin Directory

Changeset 3380105


Ignore:
Timestamp:
10/17/2025 12:40:30 PM (3 months ago)
Author:
OllieJones
Message:

Update to version 1.2.0 from GitHub

Location:
fast-woo-order-lookup
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • fast-woo-order-lookup/tags/1.2.0/changelog.txt

    r3299021 r3380105  
     1= 1.1.10 = July 3, 2025 =
     2
     3Less aggressive logging, WooCommerce 9.9.5.
     4
     5= 1.1.8 = May 22, 2025 =
     6
     7Support 9.9.0.
     8
     9= 1.1.7 = April 25, 2025 =
     10
     11Fix memory leak in logging.
     12
     13= 1.1.6 = April 11, 2025 =
     14
     15Fix memory leak in logging.
     16
     17= 1.1.5 April 9, 2025 =
     18
     19Improve Site Health Info.
     20
     21= 1.1.4 April 5, 2025 =
     22
     23Handle a COUNT(*) query in support of pagination.
     24
    125= 1.1.3 October 7, 2024 =
    226
  • fast-woo-order-lookup/tags/1.2.0/fast-woo-order-lookup.php

    r3368869 r3380105  
    1212 * Plugin URI:    https://plumislandmedia.net/wordpress-plugins/fast-woo-order-lookup/
    1313 * Description:   Look up orders faster in large WooCommerce stores with many orders.
    14  * Version:       1.1.11
     14 * Version:       1.2.0
    1515 * Requires PHP: 5.6
    1616 * Requires at least: 5.8
    17  * Tested up to: 6.8
     17 * Tested up to: 6.8.3
    1818 * WC requires at least: 4.0
    1919 * WC tested up to: 9.1.4
     
    3838use WC_Order;
    3939
    40 if ( ! defined( 'ABSPATH' ) ) {
     40if (!defined('ABSPATH')) {
    4141    exit;
    4242}
     
    4444const FAST_WOO_ORDER_LOOKUP_METAKEY_CACHE = 'fast_woo_order_lookup_metakey_cache';
    4545
    46 class FastWooOrderLookup {
     46class FastWooOrderLookup
     47{
    4748
    4849    private static $instance = null;
     
    6061     * @return void
    6162     */
    62     public static function declare_hpos_compatible() {
    63         if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
    64             \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
    65         }
    66     }
    67 
    68     public static function woocommerce_changing_order( $order_id, $order ) {
    69         $instance                                = self::getInstance();
    70         $instance->orders_to_update[ $order_id ] = 1;
    71     }
    72 
    73     public static function woocommerce_deleting_order( $order_id ) {
    74         $instance                                = self::getInstance();
    75         $instance->orders_to_update[ $order_id ] = 1;
    76     }
    77 
    78     public static function woocommerce_order_object_updated_props( $order, $props ) {
    79         $instance                                = self::getInstance();
    80         $order_id                                = $order->get_id();
    81         $instance->orders_to_update[ $order_id ] = 1;
    82     }
    83 
    84     public static function update_post_meta( $meta_id, $object_id, $meta_key, $_meta_value ) {
     63    public static function declare_hpos_compatible()
     64    {
     65        if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
     66            \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
     67        }
     68    }
     69
     70    public static function woocommerce_changing_order($order_id, $order)
     71    {
    8572        $instance = self::getInstance();
    86         if ( $instance->textdex->is_order_meta_key( $meta_key ) ) {
    87             $instance->orders_to_update[ $object_id ] = 1;
    88         }
    89     }
    90 
    91     public static function textdex_batch_action() {
     73        $instance->orders_to_update[$order_id] = 1;
     74    }
     75
     76    public static function woocommerce_deleting_order($order_id)
     77    {
     78        $instance = self::getInstance();
     79        $instance->orders_to_update[$order_id] = 1;
     80    }
     81
     82    public static function woocommerce_order_object_updated_props($order, $props)
     83    {
     84        $instance = self::getInstance();
     85        $order_id = $order->get_id();
     86        $instance->orders_to_update[$order_id] = 1;
     87    }
     88
     89    public static function update_post_meta($meta_id, $object_id, $meta_key, $_meta_value)
     90    {
     91        $instance = self::getInstance();
     92        if ($instance->textdex->is_order_meta_key($meta_key)) {
     93            $instance->orders_to_update[$object_id] = 1;
     94        }
     95    }
     96
     97    public static function textdex_batch_action()
     98    {
    9299        $instance = self::getInstance();
    93100        $instance->textdex->load_batch();
     
    98105     * @return FastWooOrderLookup
    99106     */
    100     public static function getInstance() {
    101         if ( self::$instance == null ) {
     107    public static function getInstance()
     108    {
     109        if (self::$instance == null) {
    102110            self::$instance = new FastWooOrderLookup();
    103111        }
     
    109117     * Configure this plugin to intercept metadata searches for WooCommerce orders.
    110118     */
    111     private function __construct() {
    112         require_once( plugin_dir_path( __FILE__ ) . 'code/class-textdex.php' );
     119    private function __construct()
     120    {
     121        require_once(plugin_dir_path(__FILE__) . 'code/class-textdex.php');
    113122        $this->textdex = new Textdex();
    114123        $this->textdex->activate();
    115124        $this->textdex->load_textdex();
    116125
    117         if ( $this->textdex->is_ready() ) {
     126        if ($this->textdex->is_ready()) {
    118127            /* Query manipulation */
    119             add_filter( 'woocommerce_shop_order_search_fields', array( $this, 'filter_search_fields' ) );
    120             add_filter( 'woocommerce_shop_subscription_search_fields', array( $this, 'filter_search_fields' ) );
    121             add_filter( 'woocommerce_shop_order_search_results', array( $this, 'filter_search_results' ), 10, 3 );
    122             add_filter( 'woocommerce_shop_subscription_search_results', array(
    123                     $this,
    124                     'filter_search_results'
    125             ), 10, 3 );
    126             add_filter( 'woocommerce_order_query_args', array( $this, 'woocommerce_order_query_args' ) );
    127             add_filter( 'woocommerce_order_query', array( $this, 'woocommerce_order_query' ), 10, 2 );
    128         }
    129         add_filter( 'postmeta_form_keys', array( $this, 'postmeta_get_order_custom_field_names' ), 10, 2 );
    130 
    131         require_once( plugin_dir_path( __FILE__ ) . 'code/class-textdex.php' );
     128            add_filter('woocommerce_shop_order_search_fields', array($this, 'filter_search_fields'));
     129            add_filter('woocommerce_shop_subscription_search_fields', array($this, 'filter_search_fields'));
     130            add_filter('woocommerce_shop_order_search_results', array($this, 'filter_search_results'), 10, 3);
     131            add_filter('woocommerce_shop_subscription_search_results', array(
     132                $this,
     133                'filter_search_results'
     134            ), 10, 3);
     135            add_filter('woocommerce_order_query_args', array($this, 'woocommerce_order_query_args'));
     136            add_filter('woocommerce_order_query', array($this, 'woocommerce_order_query'), 10, 2);
     137        }
     138        add_filter('postmeta_form_keys', array($this, 'postmeta_get_order_custom_field_names'), 10, 2);
     139
     140        require_once(plugin_dir_path(__FILE__) . 'code/class-textdex.php');
    132141        $this->textdex = new Textdex();
    133142        $this->textdex->activate();
    134143        $this->textdex->load_textdex();
    135144
    136         add_action( 'admin_notices', array( $this, 'show_status' ), 10, 0 );
    137         add_action( 'shutdown', array( $this, 'update_textdex' ), 1, 0 );
    138         add_filter( 'plugin_row_meta', array( $this, 'filter_plugin_row_meta' ), 10, 2 );
    139     }
    140 
    141     public function show_status() {
     145        add_action('admin_notices', array($this, 'show_status'), 10, 0);
     146        add_action('shutdown', array($this, 'update_textdex'), 1, 0);
     147        add_filter('plugin_row_meta', array($this, 'filter_plugin_row_meta'), 10, 2);
     148    }
     149
     150    public function show_status()
     151    {
    142152
    143153        $error = $this->textdex->get_load_error();
    144         if ( $error ) {
    145             $ms1 = __( 'Fast Woo Order Lookup indexing failed.', 'fast-woo-order-lookup' );
    146             $ms2 = __( 'This happens with some WooCommerce plugins the author did not anticipate.', 'fast-woo-order-lookup' );
    147             $ms3 = __( 'Please create a', 'fast-woo-order-lookup' );
    148             $ms4 = __( 'support topic', 'fast-woo-order-lookup' );
    149             $ms5 = __( 'and paste your', 'fast-woo-order-lookup' );
    150             $ms6 = __( 'Site Health - Info', 'fast-woo-order-lookup' );
    151             $ms7 = __( 'contents into it. Then', 'fast-woo-order-lookup' );
    152             $ms8 = __( 'deactivate', 'fast-woo-order-lookup' );
    153             $ms9 = __( 'the plugin.', 'fast-woo-order-lookup' );
     154        if ($error) {
     155            $ms1 = __('Fast Woo Order Lookup indexing failed.', 'fast-woo-order-lookup');
     156            $ms2 = __('This happens with some WooCommerce plugins the author did not anticipate.', 'fast-woo-order-lookup');
     157            $ms3 = __('Please create a', 'fast-woo-order-lookup');
     158            $ms4 = __('support topic', 'fast-woo-order-lookup');
     159            $ms5 = __('and paste your', 'fast-woo-order-lookup');
     160            $ms6 = __('Site Health - Info', 'fast-woo-order-lookup');
     161            $ms7 = __('contents into it. Then', 'fast-woo-order-lookup');
     162            $ms8 = __('deactivate', 'fast-woo-order-lookup');
     163            $ms9 = __('the plugin.', 'fast-woo-order-lookup');
    154164
    155165
     
    157167            <div class="notice notice-error">
    158168                <p>
    159                     <?php echo esc_html( $ms1 ); ?>
    160                     <?php echo esc_html( $ms2 ); ?>
    161                     <?php echo esc_html( $ms3 ); ?>
     169                    <?php echo esc_html($ms1); ?>
     170                    <?php echo esc_html($ms2); ?>
     171                    <?php echo esc_html($ms3); ?>
    162172                    <a href="https://wordpress.org/support/plugin/fast-woo-order-lookup/"
    163                        target="_blank"><?php echo esc_html( $ms4 ); ?></a>
    164                     <?php echo esc_html( $ms5 ); ?>
    165                     <a href="/wp-admin/site-health.php?tab=debug" target="_blank"><?php echo esc_html( $ms6 ); ?></a>
    166                     <?php echo esc_html( $ms7 ); ?>
    167                     <a href=/wp-admin/plugins.php"><?php echo esc_html( $ms8 ); ?></a>
    168                     <?php echo esc_html( $ms9 ); ?>
     173                       target="_blank"><?php echo esc_html($ms4); ?></a>
     174                    <?php echo esc_html($ms5); ?>
     175                    <a href="/wp-admin/site-health.php?tab=debug" target="_blank"><?php echo esc_html($ms6); ?></a>
     176                    <?php echo esc_html($ms7); ?>
     177                    <a href=/wp-admin/plugins.php"><?php echo esc_html($ms8); ?></a>
     178                    <?php echo esc_html($ms9); ?>
    169179                </p></div>
    170180            <?php
    171         } else if ( ! $this->textdex->is_ready( 10 ) ) {
    172             $sa1  = __( 'See the', 'fast-woo-order-lookup' );
    173             $sa2  = __( 'Scheduled Actions status page', 'fast-woo-order-lookup' );
    174             $sa3  = __( 'for details.', 'fast-woo-order-lookup' );
     181        } else if (!$this->textdex->is_ready(10)) {
     182            $sa1 = __('See the', 'fast-woo-order-lookup');
     183            $sa2 = __('Scheduled Actions status page', 'fast-woo-order-lookup');
     184            $sa3 = __('for details.', 'fast-woo-order-lookup');
    175185            $frac = $this->textdex->fraction_complete();
    176             if ( $frac < 0.01 ) {
    177                 $ms1 = __( 'Fast Woo Order Lookup indexing begins soon.', 'fast-woo-order-lookup' );
     186            if ($frac < 0.01) {
     187                $ms1 = __('Fast Woo Order Lookup indexing begins soon.', 'fast-woo-order-lookup');
    178188                $ms2 = '';
    179189            } else {
    180                 $percent = number_format( 100 * $this->textdex->fraction_complete(), 1 );
    181                 $ms1     = __( 'Fast Woo Order Lookup indexing still in progress.', 'fast-woo-order-lookup' );
     190                $percent = number_format(100 * $this->textdex->fraction_complete(), 1);
     191                $ms1 = __('Fast Woo Order Lookup indexing still in progress.', 'fast-woo-order-lookup');
    182192                /* translators: 1: percent 12.3 */
    183                 $ms2 = __( '%1$s%% complete.', 'fast-woo-order-lookup' );
    184                 $ms2 = sprintf( $ms2, $percent );
     193                $ms2 = __('%1$s%% complete.', 'fast-woo-order-lookup');
     194                $ms2 = sprintf($ms2, $percent);
    185195            }
    186196            ?>
    187197            <div class="notice notice-info">
    188198                <p>
    189                     <?php echo esc_html( $ms1 ); ?>
    190                     <?php echo esc_html( $ms2 ); ?>
    191                     <?php echo esc_html( $sa1 ); ?>
    192                     <a href="admin.php?page=wc-status&tab=action-scheduler&s=fast_woo_order_lookup_textdex_action&status=pending"><?php echo esc_html( $sa2 ); ?></a>
    193                     <?php echo esc_html( $sa3 ); ?>
     199                    <?php echo esc_html($ms1); ?>
     200                    <?php echo esc_html($ms2); ?>
     201                    <?php echo esc_html($sa1); ?>
     202                    <a href="admin.php?page=wc-status&tab=action-scheduler&s=fast_woo_order_lookup_textdex_action&status=pending"><?php echo esc_html($sa2); ?></a>
     203                    <?php echo esc_html($sa3); ?>
    194204                </p></div>
    195205            <?php
     
    202212     * @return void
    203213     */
    204     public function update_textdex() {
    205         if ( count( $this->orders_to_update ) > 0 ) {
    206             $this->update_meta_keys( array_keys( $this->orders_to_update ) );
    207             $this->textdex->update( array_keys( $this->orders_to_update ) );
    208         }
    209     }
    210 
     214    public function update_textdex()
     215    {
     216        if (count($this->orders_to_update) > 0) {
     217            $this->update_meta_keys(array_keys($this->orders_to_update));
     218            $this->textdex->update(array_keys($this->orders_to_update));
     219        }
     220    }
    211221
    212222    /**
     
    219229     * @return array
    220230     */
    221     public function filter_search_fields( $search_fields ) {
    222         if ( ! $this->textdex->is_ready() ) {
     231    public function filter_search_fields($search_fields)
     232    {
     233        if (!$this->textdex->is_ready()) {
    223234            return $search_fields;
    224235        }
    225236        /* Hook to mung the queries. */
    226237        $this->filtering = true;
    227         add_filter( 'query', array( $this, 'standard_query' ), 1 );
     238        add_filter('query', array($this, 'standard_query'), 1);
    228239
    229240        return $search_fields;
     
    241252     * @return array
    242253     */
    243     public function filter_search_results( $order_ids, $term, $search_fields ) {
    244 
    245         if ( $this->filtering ) {
     254    public function filter_search_results($order_ids, $term, $search_fields)
     255    {
     256
     257        if ($this->filtering) {
    246258            /* Discontinue filtering queries after the metadata search */
    247             remove_filter( 'query', array( $this, 'standard_query' ), 1 );
     259            remove_filter('query', array($this, 'standard_query'), 1);
    248260            $this->filtering = false;
    249261        }
     
    261273     * @return string
    262274     */
    263     public function standard_query( $query ) {
    264 
    265         if ( ! $this->term ) {
    266             $splits = explode( 'LIKE \'%', $query, 2 );
    267             if ( 2 !== count( $splits ) ) {
     275    public function standard_query($query)
     276    {
     277
     278        if (!$this->term) {
     279            $splits = explode('LIKE \'%', $query, 2);
     280            if (2 !== count($splits)) {
    268281                return $query;
    269282            }
    270             $splits = explode( '%\'', $splits[1] );
    271             if ( 2 !== count( $splits ) ) {
     283            $splits = explode('%\'', $splits[1]);
     284            if (2 !== count($splits)) {
    272285                return $query;
    273286            }
    274             $this->term           = $splits[0];
    275             $this->trigram_clause = $this->textdex->trigram_clause( $this->term );
     287            $this->term = $splits[0];
     288            $this->trigram_clause = $this->textdex->trigram_clause($this->term);
    276289        }
    277290        $newQuery = $query;
    278         $munged   = false;
    279         if ( str_contains( $newQuery, 'woocommerce_order_items as order_item' ) ) {
    280             $newQuery = str_replace( 'WHERE order_item_name LIKE', 'WHERE order_id IN (' . $this->trigram_clause . ') AND order_item_name LIKE', $newQuery );
    281             $munged   = true;
    282         } else if ( str_contains( $newQuery, 'SELECT DISTINCT os.order_id FROM wp_wc_order_stats os' ) ) {
     291        $munged = false;
     292        if (str_contains($newQuery, 'woocommerce_order_items as order_item')) {
     293            $newQuery = str_replace('WHERE order_item_name LIKE', 'WHERE order_id IN (' . $this->trigram_clause . ') AND order_item_name LIKE', $newQuery);
     294            $munged = true;
     295        } else if (str_contains($newQuery, 'SELECT DISTINCT os.order_id FROM wp_wc_order_stats os')) {
    283296            /* empty, intentionally */
    284297        } else {
    285             $newQuery = str_replace( 'postmeta p1 WHERE ', 'postmeta p1 WHERE post_id IN (' . $this->trigram_clause . ') AND ', $newQuery );
    286             $munged   = true;
    287         }
    288         $munged && $this->textdex->capture_query( $newQuery, 'search', false );
     298            $newQuery = str_replace('postmeta p1 WHERE ', 'postmeta p1 WHERE post_id IN (' . $this->trigram_clause . ') AND ', $newQuery);
     299            $munged = true;
     300        }
     301        $munged && $this->textdex->capture_query($newQuery, 'search', false);
    289302
    290303        return $newQuery;
     
    300313     * @return mixed
    301314     */
    302     public function woocommerce_order_query_args( $args ) {
    303         $its_search          = array_key_exists( 's', $args ) && is_string( $args['s'] ) && strlen( $args['s'] ) > 0;
    304         $its_order_id_search = array_key_exists( 'search_filter', $args ) && 'order_id' === $args ['search_filter'];
    305         if ( $its_search && ! $its_order_id_search && $this->textdex->is_ready() ) {
    306             $this->term           = $args['s'];
    307             $this->trigram_clause = $this->textdex->trigram_clause( $this->term );
     315    public function woocommerce_order_query_args($args)
     316    {
     317        $its_search = array_key_exists('s', $args) && is_string($args['s']) && strlen($args['s']) > 0;
     318        $its_order_id_search = array_key_exists('search_filter', $args) && 'order_id' === $args ['search_filter'];
     319        if ($its_search && !$its_order_id_search && $this->textdex->is_ready()) {
     320            $this->term = $args['s'];
     321            $this->trigram_clause = $this->textdex->trigram_clause($this->term);
    308322
    309323            /* Hook to mung the queries. */
    310324            $this->filtering = true;
    311             add_filter( 'query', array( $this, 'hpos_query' ), 1 );
     325            add_filter('query', array($this, 'hpos_query'), 1);
    312326        }
    313327
     
    325339     * @return mixed
    326340     */
    327     public function woocommerce_order_query( $results, $args ) {
    328         if ( $this->filtering ) {
     341    public function woocommerce_order_query($results, $args)
     342    {
     343        if ($this->filtering) {
    329344            /* Discontinue filtering queries after the search */
    330             remove_filter( 'query', array( $this, 'hpos_query' ), 1 );
     345            remove_filter('query', array($this, 'hpos_query'), 1);
    331346            $this->filtering = false;
    332347        }
     
    348363     * @return string
    349364     */
    350     public function hpos_query( $query ) {
     365    public function hpos_query($query)
     366    {
    351367        global $wpdb;
    352         $orders     = $wpdb->prefix . 'wc_orders';
     368        $orders = $wpdb->prefix . 'wc_orders';
    353369        $orderitems = $wpdb->prefix . 'woocommerce_order_items';
    354370
    355371        /* Skip modifying the FULLTEXT search option choice. */
    356         if ( str_contains( $query, 'IN BOOLEAN MODE' ) ) {
     372        if (str_contains($query, 'IN BOOLEAN MODE')) {
    357373            return $query;
    358374        }
    359         if ( str_contains( $query, "$orderitems AS search_query_items ON search_query_items.order_id = $orders.id WHERE 1=1 AND" ) ||
    360              str_contains( $query, "SELECT $orders.id FROM $orders  WHERE 1=1 AND" ) ||
    361              str_contains( $query, "SELECT COUNT(*) FROM $orders  WHERE 1=1 AND" ) ||
    362              str_contains( $query, "SELECT COUNT(DISTINCT $orders.id) FROM  $orders  WHERE 1=1 AND" )
     375        if (str_contains($query, "$orderitems AS search_query_items ON search_query_items.order_id = $orders.id WHERE 1=1 AND") ||
     376            str_contains($query, "SELECT $orders.id FROM $orders  WHERE 1=1 AND") ||
     377            str_contains($query, "SELECT COUNT(*) FROM $orders  WHERE 1=1 AND") ||
     378            str_contains($query, "SELECT COUNT(DISTINCT $orders.id) FROM  $orders  WHERE 1=1 AND")
    363379        ) {
    364             $query = str_replace( 'WHERE 1=1 AND', "WHERE 1=1 AND  $orders.id IN (" . $this->trigram_clause . ") AND ", $query );
    365             $this->textdex->capture_query( $query, 'search', false );
     380            $query = str_replace('WHERE 1=1 AND', "WHERE 1=1 AND  $orders.id IN (" . $this->trigram_clause . ") AND ", $query);
     381            $this->textdex->capture_query($query, 'search', false);
    366382
    367383        }
     
    382398     * @return array|null
    383399     */
    384     public function postmeta_get_order_custom_field_names( $keys, $order ) {
    385         if ( ! @is_a( $order, WC_Order::class ) ) {
     400    public function postmeta_get_order_custom_field_names($keys, $order)
     401    {
     402        if (!@is_a($order, WC_Order::class)) {
    386403            return $keys;
    387404        }
    388405
    389         require_once( plugin_dir_path( __FILE__ ) . 'code/class-custom-fields.php' );
     406        require_once(plugin_dir_path(__FILE__) . 'code/class-custom-fields.php');
    390407        $cust = new Custom_Fields();
    391408
     
    400417        $changed = false;
    401418        foreach ( $orders as $order_id ) {
    402             $order = wc_get_order( $order_id );
    403             $metas = wc_get_container()->get( OrdersTableDataStoreMeta::class )->read_meta( $order );
    404             foreach ( $metas as $meta ) {
    405                 $meta_key = $meta->meta_key;
    406                 if ( ! str_starts_with( $meta_key, '_' ) ) {
    407                     if ( ! in_array( $meta_key, $cached_keys ) ) {
    408                         $changed        = true;
    409                         $cached_keys [] = $meta_key;
     419            if ( $order_id ) {
     420                $order = wc_get_order( $order_id );
     421                if ( $order instanceof WC_Order ) {
     422                    $metas = wc_get_container()->get( OrdersTableDataStoreMeta::class )->read_meta( $order );
     423                    foreach ( $metas as $meta ) {
     424                        $meta_key = $meta->meta_key;
     425                        if ( ! str_starts_with( $meta_key, '_' ) ) {
     426                            if ( ! in_array( $meta_key, $cached_keys ) ) {
     427                                $changed        = true;
     428                                $cached_keys [] = $meta_key;
     429                            }
     430                        }
    410431                    }
    411432                }
     
    425446     * @return array<int, string> Updated array of the plugin's metadata.
    426447     */
    427     public function filter_plugin_row_meta( array $plugin_meta, $plugin_file ) {
    428         if ( FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE !== $plugin_file ) {
     448    public function filter_plugin_row_meta(array $plugin_meta, $plugin_file)
     449    {
     450        if (FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE !== $plugin_file) {
    429451            return $plugin_meta;
    430452        }
    431453
    432454        $plugin_meta[] = sprintf(
    433                 '<a href="%1$s"><span class="dashicons dashicons-star-filled" aria-hidden="true" style="font-size:14px;line-height:1.3"></span>%2$s</a>',
    434                 'https://github.com/sponsors/OllieJones',
    435                 esc_html_x( 'Sponsor', 'verb', 'index-wp-users-for-speed' )
     455            '<a href="%1$s"><span class="dashicons dashicons-star-filled" aria-hidden="true" style="font-size:14px;line-height:1.3"></span>%2$s</a>',
     456            'https://github.com/sponsors/OllieJones',
     457            esc_html_x('Sponsor', 'verb', 'index-wp-users-for-speed')
    436458        );
    437459
     
    443465
    444466// Plugin name
    445 const FAST_WOO_ORDER_LOOKUP_NAME          = 'Fast Woo Order Lookup';
     467const FAST_WOO_ORDER_LOOKUP_NAME = 'Fast Woo Order Lookup';
    446468
    447469// Plugin version
    448 const FAST_WOO_ORDER_LOOKUP_VERSION       = '1.1.11';
     470const FAST_WOO_ORDER_LOOKUP_VERSION = '1.2.0';
    449471
    450472// Plugin Root File
    451 const FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE   = __FILE__;
     473const FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE = __FILE__;
    452474
    453475// Plugin base
    454 define( 'FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE', plugin_basename( FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE ) );
     476define('FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE', plugin_basename(FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE));
    455477
    456478// Plugin slug
    457 define( 'FAST_WOO_ORDER_LOOKUP_SLUG', explode( DIRECTORY_SEPARATOR, FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE )[0] );
     479define('FAST_WOO_ORDER_LOOKUP_SLUG', explode(DIRECTORY_SEPARATOR, FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE)[0]);
    458480
    459481// Plugin Folder Path
    460 define( 'FAST_WOO_ORDER_LOOKUP_PLUGIN_DIR', plugin_dir_path( FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE ) );
     482define('FAST_WOO_ORDER_LOOKUP_PLUGIN_DIR', plugin_dir_path(FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE));
    461483
    462484// Plugin Folder URL
    463 define( 'FAST_WOO_ORDER_LOOKUP_PLUGIN_URL', plugin_dir_url( FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE ) );
    464 
    465 
    466 register_activation_hook( __FILE__, 'Fast_Woo_Order_Lookup\activate' );
    467 register_deactivation_hook( __FILE__, 'Fast_Woo_Order_Lookup\deactivate' );
    468 
    469 add_action( 'before_woocommerce_init', array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'declare_hpos_compatible' ) );
    470 
    471 add_action( 'admin_init', function() {
     485define('FAST_WOO_ORDER_LOOKUP_PLUGIN_URL', plugin_dir_url(FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE));
     486
     487
     488register_activation_hook(__FILE__, 'Fast_Woo_Order_Lookup\activate');
     489register_deactivation_hook(__FILE__, 'Fast_Woo_Order_Lookup\deactivate');
     490
     491add_action('before_woocommerce_init', array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'declare_hpos_compatible'));
     492
     493add_action('admin_init', function () {
    472494    FastWooOrderLookup::getInstance();
    473 }, 10, 0 );
     495}, 10, 0);
    474496
    475497/* Hook anything that changes an order object */
    476 add_action( 'woocommerce_new_order',
    477         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_changing_order' ), 10, 2 );
    478 add_action( 'woocommerce_update_order',
    479         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_changing_order' ), 10, 2 );
    480 add_action( 'woocommerce_order_object_updated_props',
    481         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_order_object_updated_props' ), 10, 2 );
     498add_action('woocommerce_new_order',
     499    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_changing_order'), 10, 2);
     500add_action('woocommerce_update_order',
     501    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_changing_order'), 10, 2);
     502add_action('woocommerce_order_object_updated_props',
     503    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_order_object_updated_props'), 10, 2);
    482504/* Hook changes to order status. */
    483 add_action( 'woocommerce_delete_order',
    484         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order' ) );
    485 add_action( 'woocommerce_trash_order',
    486         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order' ) );
    487 add_action( 'woocommerce_untrash_order',
    488         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order' ) );
    489 add_action( 'woocommerce_cancelled_order',
    490         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order' ) );
    491 add_action( 'update_post_meta',
    492         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'update_post_meta' ), 10, 4 );
     505add_action('woocommerce_delete_order',
     506    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order'));
     507add_action('woocommerce_trash_order',
     508    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order'));
     509add_action('woocommerce_untrash_order',
     510    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order'));
     511add_action('woocommerce_cancelled_order',
     512    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order'));
     513add_action('update_post_meta',
     514    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'update_post_meta'), 10, 4);
    493515
    494516/* ActionScheduler action for loading textdex. */
    495 add_action( 'fast_woo_order_lookup_textdex_action',
    496         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'textdex_batch_action' ) );
    497 
    498 function activate() {
    499     register_uninstall_hook( __FILE__, 'Fast_Woo_Order_Lookup\uninstall' );
    500     require_once( plugin_dir_path( __FILE__ ) . 'code/class-textdex.php' );
     517add_action('fast_woo_order_lookup_textdex_action',
     518    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'textdex_batch_action'));
     519
     520function activate()
     521{
     522    register_uninstall_hook(__FILE__, 'Fast_Woo_Order_Lookup\uninstall');
     523    require_once(plugin_dir_path(__FILE__) . 'code/class-textdex.php');
    501524    $textdex = new Textdex();
    502525    $textdex->activate();
     
    506529}
    507530
    508 function deactivate() {
    509 
    510     require_once( plugin_dir_path( __FILE__ ) . 'code/class-textdex.php' );
     531function deactivate()
     532{
     533
     534    require_once(plugin_dir_path(__FILE__) . 'code/class-textdex.php');
    511535    $textdex = new Textdex();
    512536    $textdex->deactivate();
    513     delete_transient( FAST_WOO_ORDER_LOOKUP_METAKEY_CACHE );
     537    delete_transient(FAST_WOO_ORDER_LOOKUP_METAKEY_CACHE);
    514538}
    515539
    516 function uninstall() {
     540function uninstall()
     541{
    517542
    518543}
  • fast-woo-order-lookup/tags/1.2.0/languages/fast-woo-order-lookup.pot

    r3368869 r3380105  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Fast Woo Order Lookup 1.1.11\n"
     5"Project-Id-Version: Fast Woo Order Lookup 1.2.0\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/fast-woo-order-lookup\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2025-09-25T18:53:53-04:00\n"
     12"POT-Creation-Date: 2025-10-17T08:33:40-04:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.9.0\n"
     
    1616
    1717#. Plugin Name of the plugin
    18 #: code/class-textdex.php:681
     18#: code/class-textdex.php:693
    1919msgid "Fast Woo Order Lookup"
    2020msgstr ""
     
    3636msgstr ""
    3737
    38 #: code/class-textdex.php:601
     38#: code/class-textdex.php:613
    3939msgid "Operation"
    4040msgstr ""
    4141
    42 #: code/class-textdex.php:657
     42#: code/class-textdex.php:669
    4343msgid "Explanation"
    4444msgstr ""
    4545
    46 #: code/class-textdex.php:658
     46#: code/class-textdex.php:670
    4747msgid "Errors sometimes occur while the plugin is creating its index table. Variations in database server make and version, and your WordPress version when you created it cause these. The plugin author will add suppot for your variation if you open a support topic."
    4848msgstr ""
    4949
    50 #: code/class-textdex.php:659
     50#: code/class-textdex.php:671
    5151msgid "And sometimes some types of orders cannot be found. Search for the failing orders and return here to capture useful troubleshooting information."
    5252msgstr ""
    5353
    54 #: code/class-textdex.php:664
     54#: code/class-textdex.php:676
    5555msgid "Request"
    5656msgstr ""
    5757
    58 #: code/class-textdex.php:665
    59 #: code/class-textdex.php:667
     58#: code/class-textdex.php:677
     59#: code/class-textdex.php:679
    6060msgid "Please create a support topic at"
    6161msgstr ""
    6262
    63 #: code/class-textdex.php:666
     63#: code/class-textdex.php:678
    6464msgid "Click [Copy Site Info To Clipboard] then paste your site info into the topic."
    6565msgstr ""
    6666
    67 #: code/class-textdex.php:668
     67#: code/class-textdex.php:680
    6868msgid "and paste this site info (all of it please) into the topic. We will take a look."
    6969msgstr ""
    7070
    71 #: code/class-textdex.php:672
     71#: code/class-textdex.php:684
    7272msgid "WooCommerce Features"
    7373msgstr ""
    7474
    75 #: code/class-textdex.php:676
     75#: code/class-textdex.php:688
    7676msgid "Trigram Table"
    7777msgstr ""
    7878
    79 #: fast-woo-order-lookup.php:145
     79#: fast-woo-order-lookup.php:155
    8080msgid "Fast Woo Order Lookup indexing failed."
    8181msgstr ""
    8282
    83 #: fast-woo-order-lookup.php:146
     83#: fast-woo-order-lookup.php:156
    8484msgid "This happens with some WooCommerce plugins the author did not anticipate."
    8585msgstr ""
    8686
    87 #: fast-woo-order-lookup.php:147
     87#: fast-woo-order-lookup.php:157
    8888msgid "Please create a"
    8989msgstr ""
    9090
    91 #: fast-woo-order-lookup.php:148
     91#: fast-woo-order-lookup.php:158
    9292msgid "support topic"
    9393msgstr ""
    9494
    95 #: fast-woo-order-lookup.php:149
     95#: fast-woo-order-lookup.php:159
    9696msgid "and paste your"
    9797msgstr ""
    9898
    99 #: fast-woo-order-lookup.php:150
     99#: fast-woo-order-lookup.php:160
    100100msgid "Site Health - Info"
    101101msgstr ""
    102102
    103 #: fast-woo-order-lookup.php:151
     103#: fast-woo-order-lookup.php:161
    104104msgid "contents into it. Then"
    105105msgstr ""
    106106
    107 #: fast-woo-order-lookup.php:152
     107#: fast-woo-order-lookup.php:162
    108108msgid "deactivate"
    109109msgstr ""
    110110
    111 #: fast-woo-order-lookup.php:153
     111#: fast-woo-order-lookup.php:163
    112112msgid "the plugin."
    113113msgstr ""
    114114
    115 #: fast-woo-order-lookup.php:172
     115#: fast-woo-order-lookup.php:182
    116116msgid "See the"
    117117msgstr ""
    118118
    119 #: fast-woo-order-lookup.php:173
     119#: fast-woo-order-lookup.php:183
    120120msgid "Scheduled Actions status page"
    121121msgstr ""
    122122
    123 #: fast-woo-order-lookup.php:174
     123#: fast-woo-order-lookup.php:184
    124124msgid "for details."
    125125msgstr ""
    126126
    127 #: fast-woo-order-lookup.php:177
     127#: fast-woo-order-lookup.php:187
    128128msgid "Fast Woo Order Lookup indexing begins soon."
    129129msgstr ""
    130130
    131 #: fast-woo-order-lookup.php:181
     131#: fast-woo-order-lookup.php:191
    132132msgid "Fast Woo Order Lookup indexing still in progress."
    133133msgstr ""
    134134
    135135#. translators: 1: percent 12.3
    136 #: fast-woo-order-lookup.php:183
     136#: fast-woo-order-lookup.php:193
    137137msgid "%1$s%% complete."
    138138msgstr ""
  • fast-woo-order-lookup/tags/1.2.0/readme.txt

    r3368869 r3380105  
    55Tags: woocommerce, search, orders, database, performance
    66Requires at least: 5.9
    7 Tested up to: 6.8.1
     7Tested up to: 6.8.3
    88Requires PHP: 5.6
    99WC requires at least: 8.0
    1010WC tested up to: 10.2.1
    11 Stable tag: 1.1.11
     11Stable tag: 1.2.0
    1212Requires Plugins: woocommerce
    1313License: GPLv2
     
    2727The downside: the trigram table takes database space and takes time to generate.
    2828
    29 The orders page itself contains a slow query to look up meta_keys. This fixes that query's performance too.
     29The orders page itself contains a slow query to look up meta_keys. This fixes that query's performance too, using a cache of available values.
    3030
    3131<h4>If you have problems</h4>
     
    5858    Build a [trigram lookup table](https://www.plumislandmedia.net/wordpress-plugins/fast-woo-order-lookup/#how-does-it-work-trigrams), maintain it, and use it for the queries.
    5959
    60 = How much space does the trigram lookup table take? =
     60= How much space does the lookup table -- `wp_fwol` -- take? =
    6161
    62 It takes about 5-10KiB per order, as MariaDB / MySQL database storage, counting both data and indexes. So, if your site has a million orders, the table will take something like 5-10 GiB.
     62It takes about 5-10KiB per order, as MariaDB / MySQL database storage, counting both data and indexes. So, if your site has a million orders, the table will take something like 5-10 GiB. The rows of the table are each quite small, just three letters and an order ID. And there are many of those rows for each order.
     63
     64The table, named with an abbreviation for "Fast Woo Order Lookup", contains the trigram lookups. It has a terse name to keep queries short. It is dropped automatically if you deactivate the plugin.
     65
     66= Can it get so large this plugin becomes useless or counterproductive? =
     67
     68**No, unless your database tablespace is too small for it.**
     69
     70This answer uses the [Big **O**](https://en.wikipedia.org/wiki/Big_O_notation) conceptual way of understanding program performance.
     71
     72The table is organized by its primary key so this plugin can search for orders with **O**(log n) computational complexity.  That means if searching 100 orders takes two seconds, then searching 1000 takes about three seconds and 10,000 about four. So it will work at large scale.  And without this plugin the complexity of the order search in WooCommerce is a quite unpleasant **O**(n).   Ten times as many orders take ten times as long to search. So, 100 times as many take 100 times as long. Used at large scale that gets nasty. It burns server electricity. Just as importantly, it wastes users' time.
     73
     74That's true even if you use a nice search plugin like [Relevanssi](https://wordpress.org/plugins/relevanssi/) to help your customers search for products. The author does that. It works. But not on orders.
     75
     76This plugin improves order search performance by using a better algorithm. It's the InnoDB team we have to thank for this in MariaDB and MySQL. Legendary.  (See, Dr. Knuth? Somebody read your book!)
     77
     78If your hosting service is such a cheapskate you don't have the tablespace for the table, that might be a reason to avoid this plugin.
    6379
    6480= How long does it take to generate trigram lookup table? =
     
    81972. Deactivate, then activate the plugin. This rebuilds the lookup table.
    8298
    83 = What is this wp_fwol table created by the plugin? =
    84 
    85 This table, named with an abbreviation for "Fast Woo Order Lookup", contains the trigram lookups. It has a terse name to keep queries short. It is dropped automatically if you deactivate the plugin.
    86 
    8799= My store only has a few hundred orders. Do I need this plugin ? =
    88100
    89 This plugin addresses database performance problems that only show themselves on stores with many tens of thousands of orders. If your store is smaller than that you probably don't need it.
     101This plugin addresses database performance problems that only show themselves on stores with many thousands of orders. If your store is smaller than that you probably don't need it.
    90102
    91103Wise owners of rapidly growing stores return regularly to examine their site performance. If your site is still small, it's better to wait until you actually need performance-enhancing plugins and other features. Installing them "just in case" is ineffective.
     
    109121* It improves indexing performance by skipping gaps in order numbers.
    110122
    111 ## Changelog
     123== Upgrade Notice ==
     124
     125Recent versions correct intermittent problems generating the index and maintaining the postmeta key cache.
     126
     127Thanks to my loyal users for bringing these problems to my attention!
     128
     129== Changelog ==
     130
     131= 1.2.0 = October 17, 2025
     132
     133Correct an intermittent problem maintaining the postmeta key cache. Props tp slservice33 on w.org.
    112134
    113135= 1.1.11 = September 24, 2025 =
     
    115137WooCommerce 10.2.1, indexing defect fixed, gap skipping when indexing. Props to StefT1 on GitHub.
    116138
    117 = 1.1.10 = July 3, 2025 =
    118 
    119 Less aggressive logging, WooCommerce 9.9.5.
    120 
    121 = 1.1.8 = May 22, 2025 =
    122 
    123 Support 9.9.0.
    124 
    125 = 1.1.7 = April 25, 2025 =
    126 
    127 Fix memory leak in logging.
    128 
    129 = 1.1.6 = April 11, 2025 =
    130 
    131 Fix memory leak in logging.
    132 
    133 = 1.1.5 April 9, 2025 =
    134 
    135 Improve Site Health Info.
    136 
    137 = 1.1.4 April 5, 2025 =
    138 
    139 Handle a COUNT(*) query in support of pagination.
    140 
  • fast-woo-order-lookup/trunk/changelog.txt

    r3299021 r3380105  
     1= 1.1.10 = July 3, 2025 =
     2
     3Less aggressive logging, WooCommerce 9.9.5.
     4
     5= 1.1.8 = May 22, 2025 =
     6
     7Support 9.9.0.
     8
     9= 1.1.7 = April 25, 2025 =
     10
     11Fix memory leak in logging.
     12
     13= 1.1.6 = April 11, 2025 =
     14
     15Fix memory leak in logging.
     16
     17= 1.1.5 April 9, 2025 =
     18
     19Improve Site Health Info.
     20
     21= 1.1.4 April 5, 2025 =
     22
     23Handle a COUNT(*) query in support of pagination.
     24
    125= 1.1.3 October 7, 2024 =
    226
  • fast-woo-order-lookup/trunk/fast-woo-order-lookup.php

    r3368869 r3380105  
    1212 * Plugin URI:    https://plumislandmedia.net/wordpress-plugins/fast-woo-order-lookup/
    1313 * Description:   Look up orders faster in large WooCommerce stores with many orders.
    14  * Version:       1.1.11
     14 * Version:       1.2.0
    1515 * Requires PHP: 5.6
    1616 * Requires at least: 5.8
    17  * Tested up to: 6.8
     17 * Tested up to: 6.8.3
    1818 * WC requires at least: 4.0
    1919 * WC tested up to: 9.1.4
     
    3838use WC_Order;
    3939
    40 if ( ! defined( 'ABSPATH' ) ) {
     40if (!defined('ABSPATH')) {
    4141    exit;
    4242}
     
    4444const FAST_WOO_ORDER_LOOKUP_METAKEY_CACHE = 'fast_woo_order_lookup_metakey_cache';
    4545
    46 class FastWooOrderLookup {
     46class FastWooOrderLookup
     47{
    4748
    4849    private static $instance = null;
     
    6061     * @return void
    6162     */
    62     public static function declare_hpos_compatible() {
    63         if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
    64             \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
    65         }
    66     }
    67 
    68     public static function woocommerce_changing_order( $order_id, $order ) {
    69         $instance                                = self::getInstance();
    70         $instance->orders_to_update[ $order_id ] = 1;
    71     }
    72 
    73     public static function woocommerce_deleting_order( $order_id ) {
    74         $instance                                = self::getInstance();
    75         $instance->orders_to_update[ $order_id ] = 1;
    76     }
    77 
    78     public static function woocommerce_order_object_updated_props( $order, $props ) {
    79         $instance                                = self::getInstance();
    80         $order_id                                = $order->get_id();
    81         $instance->orders_to_update[ $order_id ] = 1;
    82     }
    83 
    84     public static function update_post_meta( $meta_id, $object_id, $meta_key, $_meta_value ) {
     63    public static function declare_hpos_compatible()
     64    {
     65        if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
     66            \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
     67        }
     68    }
     69
     70    public static function woocommerce_changing_order($order_id, $order)
     71    {
    8572        $instance = self::getInstance();
    86         if ( $instance->textdex->is_order_meta_key( $meta_key ) ) {
    87             $instance->orders_to_update[ $object_id ] = 1;
    88         }
    89     }
    90 
    91     public static function textdex_batch_action() {
     73        $instance->orders_to_update[$order_id] = 1;
     74    }
     75
     76    public static function woocommerce_deleting_order($order_id)
     77    {
     78        $instance = self::getInstance();
     79        $instance->orders_to_update[$order_id] = 1;
     80    }
     81
     82    public static function woocommerce_order_object_updated_props($order, $props)
     83    {
     84        $instance = self::getInstance();
     85        $order_id = $order->get_id();
     86        $instance->orders_to_update[$order_id] = 1;
     87    }
     88
     89    public static function update_post_meta($meta_id, $object_id, $meta_key, $_meta_value)
     90    {
     91        $instance = self::getInstance();
     92        if ($instance->textdex->is_order_meta_key($meta_key)) {
     93            $instance->orders_to_update[$object_id] = 1;
     94        }
     95    }
     96
     97    public static function textdex_batch_action()
     98    {
    9299        $instance = self::getInstance();
    93100        $instance->textdex->load_batch();
     
    98105     * @return FastWooOrderLookup
    99106     */
    100     public static function getInstance() {
    101         if ( self::$instance == null ) {
     107    public static function getInstance()
     108    {
     109        if (self::$instance == null) {
    102110            self::$instance = new FastWooOrderLookup();
    103111        }
     
    109117     * Configure this plugin to intercept metadata searches for WooCommerce orders.
    110118     */
    111     private function __construct() {
    112         require_once( plugin_dir_path( __FILE__ ) . 'code/class-textdex.php' );
     119    private function __construct()
     120    {
     121        require_once(plugin_dir_path(__FILE__) . 'code/class-textdex.php');
    113122        $this->textdex = new Textdex();
    114123        $this->textdex->activate();
    115124        $this->textdex->load_textdex();
    116125
    117         if ( $this->textdex->is_ready() ) {
     126        if ($this->textdex->is_ready()) {
    118127            /* Query manipulation */
    119             add_filter( 'woocommerce_shop_order_search_fields', array( $this, 'filter_search_fields' ) );
    120             add_filter( 'woocommerce_shop_subscription_search_fields', array( $this, 'filter_search_fields' ) );
    121             add_filter( 'woocommerce_shop_order_search_results', array( $this, 'filter_search_results' ), 10, 3 );
    122             add_filter( 'woocommerce_shop_subscription_search_results', array(
    123                     $this,
    124                     'filter_search_results'
    125             ), 10, 3 );
    126             add_filter( 'woocommerce_order_query_args', array( $this, 'woocommerce_order_query_args' ) );
    127             add_filter( 'woocommerce_order_query', array( $this, 'woocommerce_order_query' ), 10, 2 );
    128         }
    129         add_filter( 'postmeta_form_keys', array( $this, 'postmeta_get_order_custom_field_names' ), 10, 2 );
    130 
    131         require_once( plugin_dir_path( __FILE__ ) . 'code/class-textdex.php' );
     128            add_filter('woocommerce_shop_order_search_fields', array($this, 'filter_search_fields'));
     129            add_filter('woocommerce_shop_subscription_search_fields', array($this, 'filter_search_fields'));
     130            add_filter('woocommerce_shop_order_search_results', array($this, 'filter_search_results'), 10, 3);
     131            add_filter('woocommerce_shop_subscription_search_results', array(
     132                $this,
     133                'filter_search_results'
     134            ), 10, 3);
     135            add_filter('woocommerce_order_query_args', array($this, 'woocommerce_order_query_args'));
     136            add_filter('woocommerce_order_query', array($this, 'woocommerce_order_query'), 10, 2);
     137        }
     138        add_filter('postmeta_form_keys', array($this, 'postmeta_get_order_custom_field_names'), 10, 2);
     139
     140        require_once(plugin_dir_path(__FILE__) . 'code/class-textdex.php');
    132141        $this->textdex = new Textdex();
    133142        $this->textdex->activate();
    134143        $this->textdex->load_textdex();
    135144
    136         add_action( 'admin_notices', array( $this, 'show_status' ), 10, 0 );
    137         add_action( 'shutdown', array( $this, 'update_textdex' ), 1, 0 );
    138         add_filter( 'plugin_row_meta', array( $this, 'filter_plugin_row_meta' ), 10, 2 );
    139     }
    140 
    141     public function show_status() {
     145        add_action('admin_notices', array($this, 'show_status'), 10, 0);
     146        add_action('shutdown', array($this, 'update_textdex'), 1, 0);
     147        add_filter('plugin_row_meta', array($this, 'filter_plugin_row_meta'), 10, 2);
     148    }
     149
     150    public function show_status()
     151    {
    142152
    143153        $error = $this->textdex->get_load_error();
    144         if ( $error ) {
    145             $ms1 = __( 'Fast Woo Order Lookup indexing failed.', 'fast-woo-order-lookup' );
    146             $ms2 = __( 'This happens with some WooCommerce plugins the author did not anticipate.', 'fast-woo-order-lookup' );
    147             $ms3 = __( 'Please create a', 'fast-woo-order-lookup' );
    148             $ms4 = __( 'support topic', 'fast-woo-order-lookup' );
    149             $ms5 = __( 'and paste your', 'fast-woo-order-lookup' );
    150             $ms6 = __( 'Site Health - Info', 'fast-woo-order-lookup' );
    151             $ms7 = __( 'contents into it. Then', 'fast-woo-order-lookup' );
    152             $ms8 = __( 'deactivate', 'fast-woo-order-lookup' );
    153             $ms9 = __( 'the plugin.', 'fast-woo-order-lookup' );
     154        if ($error) {
     155            $ms1 = __('Fast Woo Order Lookup indexing failed.', 'fast-woo-order-lookup');
     156            $ms2 = __('This happens with some WooCommerce plugins the author did not anticipate.', 'fast-woo-order-lookup');
     157            $ms3 = __('Please create a', 'fast-woo-order-lookup');
     158            $ms4 = __('support topic', 'fast-woo-order-lookup');
     159            $ms5 = __('and paste your', 'fast-woo-order-lookup');
     160            $ms6 = __('Site Health - Info', 'fast-woo-order-lookup');
     161            $ms7 = __('contents into it. Then', 'fast-woo-order-lookup');
     162            $ms8 = __('deactivate', 'fast-woo-order-lookup');
     163            $ms9 = __('the plugin.', 'fast-woo-order-lookup');
    154164
    155165
     
    157167            <div class="notice notice-error">
    158168                <p>
    159                     <?php echo esc_html( $ms1 ); ?>
    160                     <?php echo esc_html( $ms2 ); ?>
    161                     <?php echo esc_html( $ms3 ); ?>
     169                    <?php echo esc_html($ms1); ?>
     170                    <?php echo esc_html($ms2); ?>
     171                    <?php echo esc_html($ms3); ?>
    162172                    <a href="https://wordpress.org/support/plugin/fast-woo-order-lookup/"
    163                        target="_blank"><?php echo esc_html( $ms4 ); ?></a>
    164                     <?php echo esc_html( $ms5 ); ?>
    165                     <a href="/wp-admin/site-health.php?tab=debug" target="_blank"><?php echo esc_html( $ms6 ); ?></a>
    166                     <?php echo esc_html( $ms7 ); ?>
    167                     <a href=/wp-admin/plugins.php"><?php echo esc_html( $ms8 ); ?></a>
    168                     <?php echo esc_html( $ms9 ); ?>
     173                       target="_blank"><?php echo esc_html($ms4); ?></a>
     174                    <?php echo esc_html($ms5); ?>
     175                    <a href="/wp-admin/site-health.php?tab=debug" target="_blank"><?php echo esc_html($ms6); ?></a>
     176                    <?php echo esc_html($ms7); ?>
     177                    <a href=/wp-admin/plugins.php"><?php echo esc_html($ms8); ?></a>
     178                    <?php echo esc_html($ms9); ?>
    169179                </p></div>
    170180            <?php
    171         } else if ( ! $this->textdex->is_ready( 10 ) ) {
    172             $sa1  = __( 'See the', 'fast-woo-order-lookup' );
    173             $sa2  = __( 'Scheduled Actions status page', 'fast-woo-order-lookup' );
    174             $sa3  = __( 'for details.', 'fast-woo-order-lookup' );
     181        } else if (!$this->textdex->is_ready(10)) {
     182            $sa1 = __('See the', 'fast-woo-order-lookup');
     183            $sa2 = __('Scheduled Actions status page', 'fast-woo-order-lookup');
     184            $sa3 = __('for details.', 'fast-woo-order-lookup');
    175185            $frac = $this->textdex->fraction_complete();
    176             if ( $frac < 0.01 ) {
    177                 $ms1 = __( 'Fast Woo Order Lookup indexing begins soon.', 'fast-woo-order-lookup' );
     186            if ($frac < 0.01) {
     187                $ms1 = __('Fast Woo Order Lookup indexing begins soon.', 'fast-woo-order-lookup');
    178188                $ms2 = '';
    179189            } else {
    180                 $percent = number_format( 100 * $this->textdex->fraction_complete(), 1 );
    181                 $ms1     = __( 'Fast Woo Order Lookup indexing still in progress.', 'fast-woo-order-lookup' );
     190                $percent = number_format(100 * $this->textdex->fraction_complete(), 1);
     191                $ms1 = __('Fast Woo Order Lookup indexing still in progress.', 'fast-woo-order-lookup');
    182192                /* translators: 1: percent 12.3 */
    183                 $ms2 = __( '%1$s%% complete.', 'fast-woo-order-lookup' );
    184                 $ms2 = sprintf( $ms2, $percent );
     193                $ms2 = __('%1$s%% complete.', 'fast-woo-order-lookup');
     194                $ms2 = sprintf($ms2, $percent);
    185195            }
    186196            ?>
    187197            <div class="notice notice-info">
    188198                <p>
    189                     <?php echo esc_html( $ms1 ); ?>
    190                     <?php echo esc_html( $ms2 ); ?>
    191                     <?php echo esc_html( $sa1 ); ?>
    192                     <a href="admin.php?page=wc-status&tab=action-scheduler&s=fast_woo_order_lookup_textdex_action&status=pending"><?php echo esc_html( $sa2 ); ?></a>
    193                     <?php echo esc_html( $sa3 ); ?>
     199                    <?php echo esc_html($ms1); ?>
     200                    <?php echo esc_html($ms2); ?>
     201                    <?php echo esc_html($sa1); ?>
     202                    <a href="admin.php?page=wc-status&tab=action-scheduler&s=fast_woo_order_lookup_textdex_action&status=pending"><?php echo esc_html($sa2); ?></a>
     203                    <?php echo esc_html($sa3); ?>
    194204                </p></div>
    195205            <?php
     
    202212     * @return void
    203213     */
    204     public function update_textdex() {
    205         if ( count( $this->orders_to_update ) > 0 ) {
    206             $this->update_meta_keys( array_keys( $this->orders_to_update ) );
    207             $this->textdex->update( array_keys( $this->orders_to_update ) );
    208         }
    209     }
    210 
     214    public function update_textdex()
     215    {
     216        if (count($this->orders_to_update) > 0) {
     217            $this->update_meta_keys(array_keys($this->orders_to_update));
     218            $this->textdex->update(array_keys($this->orders_to_update));
     219        }
     220    }
    211221
    212222    /**
     
    219229     * @return array
    220230     */
    221     public function filter_search_fields( $search_fields ) {
    222         if ( ! $this->textdex->is_ready() ) {
     231    public function filter_search_fields($search_fields)
     232    {
     233        if (!$this->textdex->is_ready()) {
    223234            return $search_fields;
    224235        }
    225236        /* Hook to mung the queries. */
    226237        $this->filtering = true;
    227         add_filter( 'query', array( $this, 'standard_query' ), 1 );
     238        add_filter('query', array($this, 'standard_query'), 1);
    228239
    229240        return $search_fields;
     
    241252     * @return array
    242253     */
    243     public function filter_search_results( $order_ids, $term, $search_fields ) {
    244 
    245         if ( $this->filtering ) {
     254    public function filter_search_results($order_ids, $term, $search_fields)
     255    {
     256
     257        if ($this->filtering) {
    246258            /* Discontinue filtering queries after the metadata search */
    247             remove_filter( 'query', array( $this, 'standard_query' ), 1 );
     259            remove_filter('query', array($this, 'standard_query'), 1);
    248260            $this->filtering = false;
    249261        }
     
    261273     * @return string
    262274     */
    263     public function standard_query( $query ) {
    264 
    265         if ( ! $this->term ) {
    266             $splits = explode( 'LIKE \'%', $query, 2 );
    267             if ( 2 !== count( $splits ) ) {
     275    public function standard_query($query)
     276    {
     277
     278        if (!$this->term) {
     279            $splits = explode('LIKE \'%', $query, 2);
     280            if (2 !== count($splits)) {
    268281                return $query;
    269282            }
    270             $splits = explode( '%\'', $splits[1] );
    271             if ( 2 !== count( $splits ) ) {
     283            $splits = explode('%\'', $splits[1]);
     284            if (2 !== count($splits)) {
    272285                return $query;
    273286            }
    274             $this->term           = $splits[0];
    275             $this->trigram_clause = $this->textdex->trigram_clause( $this->term );
     287            $this->term = $splits[0];
     288            $this->trigram_clause = $this->textdex->trigram_clause($this->term);
    276289        }
    277290        $newQuery = $query;
    278         $munged   = false;
    279         if ( str_contains( $newQuery, 'woocommerce_order_items as order_item' ) ) {
    280             $newQuery = str_replace( 'WHERE order_item_name LIKE', 'WHERE order_id IN (' . $this->trigram_clause . ') AND order_item_name LIKE', $newQuery );
    281             $munged   = true;
    282         } else if ( str_contains( $newQuery, 'SELECT DISTINCT os.order_id FROM wp_wc_order_stats os' ) ) {
     291        $munged = false;
     292        if (str_contains($newQuery, 'woocommerce_order_items as order_item')) {
     293            $newQuery = str_replace('WHERE order_item_name LIKE', 'WHERE order_id IN (' . $this->trigram_clause . ') AND order_item_name LIKE', $newQuery);
     294            $munged = true;
     295        } else if (str_contains($newQuery, 'SELECT DISTINCT os.order_id FROM wp_wc_order_stats os')) {
    283296            /* empty, intentionally */
    284297        } else {
    285             $newQuery = str_replace( 'postmeta p1 WHERE ', 'postmeta p1 WHERE post_id IN (' . $this->trigram_clause . ') AND ', $newQuery );
    286             $munged   = true;
    287         }
    288         $munged && $this->textdex->capture_query( $newQuery, 'search', false );
     298            $newQuery = str_replace('postmeta p1 WHERE ', 'postmeta p1 WHERE post_id IN (' . $this->trigram_clause . ') AND ', $newQuery);
     299            $munged = true;
     300        }
     301        $munged && $this->textdex->capture_query($newQuery, 'search', false);
    289302
    290303        return $newQuery;
     
    300313     * @return mixed
    301314     */
    302     public function woocommerce_order_query_args( $args ) {
    303         $its_search          = array_key_exists( 's', $args ) && is_string( $args['s'] ) && strlen( $args['s'] ) > 0;
    304         $its_order_id_search = array_key_exists( 'search_filter', $args ) && 'order_id' === $args ['search_filter'];
    305         if ( $its_search && ! $its_order_id_search && $this->textdex->is_ready() ) {
    306             $this->term           = $args['s'];
    307             $this->trigram_clause = $this->textdex->trigram_clause( $this->term );
     315    public function woocommerce_order_query_args($args)
     316    {
     317        $its_search = array_key_exists('s', $args) && is_string($args['s']) && strlen($args['s']) > 0;
     318        $its_order_id_search = array_key_exists('search_filter', $args) && 'order_id' === $args ['search_filter'];
     319        if ($its_search && !$its_order_id_search && $this->textdex->is_ready()) {
     320            $this->term = $args['s'];
     321            $this->trigram_clause = $this->textdex->trigram_clause($this->term);
    308322
    309323            /* Hook to mung the queries. */
    310324            $this->filtering = true;
    311             add_filter( 'query', array( $this, 'hpos_query' ), 1 );
     325            add_filter('query', array($this, 'hpos_query'), 1);
    312326        }
    313327
     
    325339     * @return mixed
    326340     */
    327     public function woocommerce_order_query( $results, $args ) {
    328         if ( $this->filtering ) {
     341    public function woocommerce_order_query($results, $args)
     342    {
     343        if ($this->filtering) {
    329344            /* Discontinue filtering queries after the search */
    330             remove_filter( 'query', array( $this, 'hpos_query' ), 1 );
     345            remove_filter('query', array($this, 'hpos_query'), 1);
    331346            $this->filtering = false;
    332347        }
     
    348363     * @return string
    349364     */
    350     public function hpos_query( $query ) {
     365    public function hpos_query($query)
     366    {
    351367        global $wpdb;
    352         $orders     = $wpdb->prefix . 'wc_orders';
     368        $orders = $wpdb->prefix . 'wc_orders';
    353369        $orderitems = $wpdb->prefix . 'woocommerce_order_items';
    354370
    355371        /* Skip modifying the FULLTEXT search option choice. */
    356         if ( str_contains( $query, 'IN BOOLEAN MODE' ) ) {
     372        if (str_contains($query, 'IN BOOLEAN MODE')) {
    357373            return $query;
    358374        }
    359         if ( str_contains( $query, "$orderitems AS search_query_items ON search_query_items.order_id = $orders.id WHERE 1=1 AND" ) ||
    360              str_contains( $query, "SELECT $orders.id FROM $orders  WHERE 1=1 AND" ) ||
    361              str_contains( $query, "SELECT COUNT(*) FROM $orders  WHERE 1=1 AND" ) ||
    362              str_contains( $query, "SELECT COUNT(DISTINCT $orders.id) FROM  $orders  WHERE 1=1 AND" )
     375        if (str_contains($query, "$orderitems AS search_query_items ON search_query_items.order_id = $orders.id WHERE 1=1 AND") ||
     376            str_contains($query, "SELECT $orders.id FROM $orders  WHERE 1=1 AND") ||
     377            str_contains($query, "SELECT COUNT(*) FROM $orders  WHERE 1=1 AND") ||
     378            str_contains($query, "SELECT COUNT(DISTINCT $orders.id) FROM  $orders  WHERE 1=1 AND")
    363379        ) {
    364             $query = str_replace( 'WHERE 1=1 AND', "WHERE 1=1 AND  $orders.id IN (" . $this->trigram_clause . ") AND ", $query );
    365             $this->textdex->capture_query( $query, 'search', false );
     380            $query = str_replace('WHERE 1=1 AND', "WHERE 1=1 AND  $orders.id IN (" . $this->trigram_clause . ") AND ", $query);
     381            $this->textdex->capture_query($query, 'search', false);
    366382
    367383        }
     
    382398     * @return array|null
    383399     */
    384     public function postmeta_get_order_custom_field_names( $keys, $order ) {
    385         if ( ! @is_a( $order, WC_Order::class ) ) {
     400    public function postmeta_get_order_custom_field_names($keys, $order)
     401    {
     402        if (!@is_a($order, WC_Order::class)) {
    386403            return $keys;
    387404        }
    388405
    389         require_once( plugin_dir_path( __FILE__ ) . 'code/class-custom-fields.php' );
     406        require_once(plugin_dir_path(__FILE__) . 'code/class-custom-fields.php');
    390407        $cust = new Custom_Fields();
    391408
     
    400417        $changed = false;
    401418        foreach ( $orders as $order_id ) {
    402             $order = wc_get_order( $order_id );
    403             $metas = wc_get_container()->get( OrdersTableDataStoreMeta::class )->read_meta( $order );
    404             foreach ( $metas as $meta ) {
    405                 $meta_key = $meta->meta_key;
    406                 if ( ! str_starts_with( $meta_key, '_' ) ) {
    407                     if ( ! in_array( $meta_key, $cached_keys ) ) {
    408                         $changed        = true;
    409                         $cached_keys [] = $meta_key;
     419            if ( $order_id ) {
     420                $order = wc_get_order( $order_id );
     421                if ( $order instanceof WC_Order ) {
     422                    $metas = wc_get_container()->get( OrdersTableDataStoreMeta::class )->read_meta( $order );
     423                    foreach ( $metas as $meta ) {
     424                        $meta_key = $meta->meta_key;
     425                        if ( ! str_starts_with( $meta_key, '_' ) ) {
     426                            if ( ! in_array( $meta_key, $cached_keys ) ) {
     427                                $changed        = true;
     428                                $cached_keys [] = $meta_key;
     429                            }
     430                        }
    410431                    }
    411432                }
     
    425446     * @return array<int, string> Updated array of the plugin's metadata.
    426447     */
    427     public function filter_plugin_row_meta( array $plugin_meta, $plugin_file ) {
    428         if ( FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE !== $plugin_file ) {
     448    public function filter_plugin_row_meta(array $plugin_meta, $plugin_file)
     449    {
     450        if (FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE !== $plugin_file) {
    429451            return $plugin_meta;
    430452        }
    431453
    432454        $plugin_meta[] = sprintf(
    433                 '<a href="%1$s"><span class="dashicons dashicons-star-filled" aria-hidden="true" style="font-size:14px;line-height:1.3"></span>%2$s</a>',
    434                 'https://github.com/sponsors/OllieJones',
    435                 esc_html_x( 'Sponsor', 'verb', 'index-wp-users-for-speed' )
     455            '<a href="%1$s"><span class="dashicons dashicons-star-filled" aria-hidden="true" style="font-size:14px;line-height:1.3"></span>%2$s</a>',
     456            'https://github.com/sponsors/OllieJones',
     457            esc_html_x('Sponsor', 'verb', 'index-wp-users-for-speed')
    436458        );
    437459
     
    443465
    444466// Plugin name
    445 const FAST_WOO_ORDER_LOOKUP_NAME          = 'Fast Woo Order Lookup';
     467const FAST_WOO_ORDER_LOOKUP_NAME = 'Fast Woo Order Lookup';
    446468
    447469// Plugin version
    448 const FAST_WOO_ORDER_LOOKUP_VERSION       = '1.1.11';
     470const FAST_WOO_ORDER_LOOKUP_VERSION = '1.2.0';
    449471
    450472// Plugin Root File
    451 const FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE   = __FILE__;
     473const FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE = __FILE__;
    452474
    453475// Plugin base
    454 define( 'FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE', plugin_basename( FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE ) );
     476define('FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE', plugin_basename(FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE));
    455477
    456478// Plugin slug
    457 define( 'FAST_WOO_ORDER_LOOKUP_SLUG', explode( DIRECTORY_SEPARATOR, FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE )[0] );
     479define('FAST_WOO_ORDER_LOOKUP_SLUG', explode(DIRECTORY_SEPARATOR, FAST_WOO_ORDER_LOOKUP_PLUGIN_BASE)[0]);
    458480
    459481// Plugin Folder Path
    460 define( 'FAST_WOO_ORDER_LOOKUP_PLUGIN_DIR', plugin_dir_path( FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE ) );
     482define('FAST_WOO_ORDER_LOOKUP_PLUGIN_DIR', plugin_dir_path(FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE));
    461483
    462484// Plugin Folder URL
    463 define( 'FAST_WOO_ORDER_LOOKUP_PLUGIN_URL', plugin_dir_url( FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE ) );
    464 
    465 
    466 register_activation_hook( __FILE__, 'Fast_Woo_Order_Lookup\activate' );
    467 register_deactivation_hook( __FILE__, 'Fast_Woo_Order_Lookup\deactivate' );
    468 
    469 add_action( 'before_woocommerce_init', array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'declare_hpos_compatible' ) );
    470 
    471 add_action( 'admin_init', function() {
     485define('FAST_WOO_ORDER_LOOKUP_PLUGIN_URL', plugin_dir_url(FAST_WOO_ORDER_LOOKUP_PLUGIN_FILE));
     486
     487
     488register_activation_hook(__FILE__, 'Fast_Woo_Order_Lookup\activate');
     489register_deactivation_hook(__FILE__, 'Fast_Woo_Order_Lookup\deactivate');
     490
     491add_action('before_woocommerce_init', array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'declare_hpos_compatible'));
     492
     493add_action('admin_init', function () {
    472494    FastWooOrderLookup::getInstance();
    473 }, 10, 0 );
     495}, 10, 0);
    474496
    475497/* Hook anything that changes an order object */
    476 add_action( 'woocommerce_new_order',
    477         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_changing_order' ), 10, 2 );
    478 add_action( 'woocommerce_update_order',
    479         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_changing_order' ), 10, 2 );
    480 add_action( 'woocommerce_order_object_updated_props',
    481         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_order_object_updated_props' ), 10, 2 );
     498add_action('woocommerce_new_order',
     499    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_changing_order'), 10, 2);
     500add_action('woocommerce_update_order',
     501    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_changing_order'), 10, 2);
     502add_action('woocommerce_order_object_updated_props',
     503    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_order_object_updated_props'), 10, 2);
    482504/* Hook changes to order status. */
    483 add_action( 'woocommerce_delete_order',
    484         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order' ) );
    485 add_action( 'woocommerce_trash_order',
    486         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order' ) );
    487 add_action( 'woocommerce_untrash_order',
    488         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order' ) );
    489 add_action( 'woocommerce_cancelled_order',
    490         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order' ) );
    491 add_action( 'update_post_meta',
    492         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'update_post_meta' ), 10, 4 );
     505add_action('woocommerce_delete_order',
     506    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order'));
     507add_action('woocommerce_trash_order',
     508    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order'));
     509add_action('woocommerce_untrash_order',
     510    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order'));
     511add_action('woocommerce_cancelled_order',
     512    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'woocommerce_deleting_order'));
     513add_action('update_post_meta',
     514    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'update_post_meta'), 10, 4);
    493515
    494516/* ActionScheduler action for loading textdex. */
    495 add_action( 'fast_woo_order_lookup_textdex_action',
    496         array( 'Fast_Woo_Order_Lookup\FastWooOrderLookup', 'textdex_batch_action' ) );
    497 
    498 function activate() {
    499     register_uninstall_hook( __FILE__, 'Fast_Woo_Order_Lookup\uninstall' );
    500     require_once( plugin_dir_path( __FILE__ ) . 'code/class-textdex.php' );
     517add_action('fast_woo_order_lookup_textdex_action',
     518    array('Fast_Woo_Order_Lookup\FastWooOrderLookup', 'textdex_batch_action'));
     519
     520function activate()
     521{
     522    register_uninstall_hook(__FILE__, 'Fast_Woo_Order_Lookup\uninstall');
     523    require_once(plugin_dir_path(__FILE__) . 'code/class-textdex.php');
    501524    $textdex = new Textdex();
    502525    $textdex->activate();
     
    506529}
    507530
    508 function deactivate() {
    509 
    510     require_once( plugin_dir_path( __FILE__ ) . 'code/class-textdex.php' );
     531function deactivate()
     532{
     533
     534    require_once(plugin_dir_path(__FILE__) . 'code/class-textdex.php');
    511535    $textdex = new Textdex();
    512536    $textdex->deactivate();
    513     delete_transient( FAST_WOO_ORDER_LOOKUP_METAKEY_CACHE );
     537    delete_transient(FAST_WOO_ORDER_LOOKUP_METAKEY_CACHE);
    514538}
    515539
    516 function uninstall() {
     540function uninstall()
     541{
    517542
    518543}
  • fast-woo-order-lookup/trunk/languages/fast-woo-order-lookup.pot

    r3368869 r3380105  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Fast Woo Order Lookup 1.1.11\n"
     5"Project-Id-Version: Fast Woo Order Lookup 1.2.0\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/fast-woo-order-lookup\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2025-09-25T18:53:53-04:00\n"
     12"POT-Creation-Date: 2025-10-17T08:33:40-04:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.9.0\n"
     
    1616
    1717#. Plugin Name of the plugin
    18 #: code/class-textdex.php:681
     18#: code/class-textdex.php:693
    1919msgid "Fast Woo Order Lookup"
    2020msgstr ""
     
    3636msgstr ""
    3737
    38 #: code/class-textdex.php:601
     38#: code/class-textdex.php:613
    3939msgid "Operation"
    4040msgstr ""
    4141
    42 #: code/class-textdex.php:657
     42#: code/class-textdex.php:669
    4343msgid "Explanation"
    4444msgstr ""
    4545
    46 #: code/class-textdex.php:658
     46#: code/class-textdex.php:670
    4747msgid "Errors sometimes occur while the plugin is creating its index table. Variations in database server make and version, and your WordPress version when you created it cause these. The plugin author will add suppot for your variation if you open a support topic."
    4848msgstr ""
    4949
    50 #: code/class-textdex.php:659
     50#: code/class-textdex.php:671
    5151msgid "And sometimes some types of orders cannot be found. Search for the failing orders and return here to capture useful troubleshooting information."
    5252msgstr ""
    5353
    54 #: code/class-textdex.php:664
     54#: code/class-textdex.php:676
    5555msgid "Request"
    5656msgstr ""
    5757
    58 #: code/class-textdex.php:665
    59 #: code/class-textdex.php:667
     58#: code/class-textdex.php:677
     59#: code/class-textdex.php:679
    6060msgid "Please create a support topic at"
    6161msgstr ""
    6262
    63 #: code/class-textdex.php:666
     63#: code/class-textdex.php:678
    6464msgid "Click [Copy Site Info To Clipboard] then paste your site info into the topic."
    6565msgstr ""
    6666
    67 #: code/class-textdex.php:668
     67#: code/class-textdex.php:680
    6868msgid "and paste this site info (all of it please) into the topic. We will take a look."
    6969msgstr ""
    7070
    71 #: code/class-textdex.php:672
     71#: code/class-textdex.php:684
    7272msgid "WooCommerce Features"
    7373msgstr ""
    7474
    75 #: code/class-textdex.php:676
     75#: code/class-textdex.php:688
    7676msgid "Trigram Table"
    7777msgstr ""
    7878
    79 #: fast-woo-order-lookup.php:145
     79#: fast-woo-order-lookup.php:155
    8080msgid "Fast Woo Order Lookup indexing failed."
    8181msgstr ""
    8282
    83 #: fast-woo-order-lookup.php:146
     83#: fast-woo-order-lookup.php:156
    8484msgid "This happens with some WooCommerce plugins the author did not anticipate."
    8585msgstr ""
    8686
    87 #: fast-woo-order-lookup.php:147
     87#: fast-woo-order-lookup.php:157
    8888msgid "Please create a"
    8989msgstr ""
    9090
    91 #: fast-woo-order-lookup.php:148
     91#: fast-woo-order-lookup.php:158
    9292msgid "support topic"
    9393msgstr ""
    9494
    95 #: fast-woo-order-lookup.php:149
     95#: fast-woo-order-lookup.php:159
    9696msgid "and paste your"
    9797msgstr ""
    9898
    99 #: fast-woo-order-lookup.php:150
     99#: fast-woo-order-lookup.php:160
    100100msgid "Site Health - Info"
    101101msgstr ""
    102102
    103 #: fast-woo-order-lookup.php:151
     103#: fast-woo-order-lookup.php:161
    104104msgid "contents into it. Then"
    105105msgstr ""
    106106
    107 #: fast-woo-order-lookup.php:152
     107#: fast-woo-order-lookup.php:162
    108108msgid "deactivate"
    109109msgstr ""
    110110
    111 #: fast-woo-order-lookup.php:153
     111#: fast-woo-order-lookup.php:163
    112112msgid "the plugin."
    113113msgstr ""
    114114
    115 #: fast-woo-order-lookup.php:172
     115#: fast-woo-order-lookup.php:182
    116116msgid "See the"
    117117msgstr ""
    118118
    119 #: fast-woo-order-lookup.php:173
     119#: fast-woo-order-lookup.php:183
    120120msgid "Scheduled Actions status page"
    121121msgstr ""
    122122
    123 #: fast-woo-order-lookup.php:174
     123#: fast-woo-order-lookup.php:184
    124124msgid "for details."
    125125msgstr ""
    126126
    127 #: fast-woo-order-lookup.php:177
     127#: fast-woo-order-lookup.php:187
    128128msgid "Fast Woo Order Lookup indexing begins soon."
    129129msgstr ""
    130130
    131 #: fast-woo-order-lookup.php:181
     131#: fast-woo-order-lookup.php:191
    132132msgid "Fast Woo Order Lookup indexing still in progress."
    133133msgstr ""
    134134
    135135#. translators: 1: percent 12.3
    136 #: fast-woo-order-lookup.php:183
     136#: fast-woo-order-lookup.php:193
    137137msgid "%1$s%% complete."
    138138msgstr ""
  • fast-woo-order-lookup/trunk/readme.txt

    r3368869 r3380105  
    55Tags: woocommerce, search, orders, database, performance
    66Requires at least: 5.9
    7 Tested up to: 6.8.1
     7Tested up to: 6.8.3
    88Requires PHP: 5.6
    99WC requires at least: 8.0
    1010WC tested up to: 10.2.1
    11 Stable tag: 1.1.11
     11Stable tag: 1.2.0
    1212Requires Plugins: woocommerce
    1313License: GPLv2
     
    2727The downside: the trigram table takes database space and takes time to generate.
    2828
    29 The orders page itself contains a slow query to look up meta_keys. This fixes that query's performance too.
     29The orders page itself contains a slow query to look up meta_keys. This fixes that query's performance too, using a cache of available values.
    3030
    3131<h4>If you have problems</h4>
     
    5858    Build a [trigram lookup table](https://www.plumislandmedia.net/wordpress-plugins/fast-woo-order-lookup/#how-does-it-work-trigrams), maintain it, and use it for the queries.
    5959
    60 = How much space does the trigram lookup table take? =
     60= How much space does the lookup table -- `wp_fwol` -- take? =
    6161
    62 It takes about 5-10KiB per order, as MariaDB / MySQL database storage, counting both data and indexes. So, if your site has a million orders, the table will take something like 5-10 GiB.
     62It takes about 5-10KiB per order, as MariaDB / MySQL database storage, counting both data and indexes. So, if your site has a million orders, the table will take something like 5-10 GiB. The rows of the table are each quite small, just three letters and an order ID. And there are many of those rows for each order.
     63
     64The table, named with an abbreviation for "Fast Woo Order Lookup", contains the trigram lookups. It has a terse name to keep queries short. It is dropped automatically if you deactivate the plugin.
     65
     66= Can it get so large this plugin becomes useless or counterproductive? =
     67
     68**No, unless your database tablespace is too small for it.**
     69
     70This answer uses the [Big **O**](https://en.wikipedia.org/wiki/Big_O_notation) conceptual way of understanding program performance.
     71
     72The table is organized by its primary key so this plugin can search for orders with **O**(log n) computational complexity.  That means if searching 100 orders takes two seconds, then searching 1000 takes about three seconds and 10,000 about four. So it will work at large scale.  And without this plugin the complexity of the order search in WooCommerce is a quite unpleasant **O**(n).   Ten times as many orders take ten times as long to search. So, 100 times as many take 100 times as long. Used at large scale that gets nasty. It burns server electricity. Just as importantly, it wastes users' time.
     73
     74That's true even if you use a nice search plugin like [Relevanssi](https://wordpress.org/plugins/relevanssi/) to help your customers search for products. The author does that. It works. But not on orders.
     75
     76This plugin improves order search performance by using a better algorithm. It's the InnoDB team we have to thank for this in MariaDB and MySQL. Legendary.  (See, Dr. Knuth? Somebody read your book!)
     77
     78If your hosting service is such a cheapskate you don't have the tablespace for the table, that might be a reason to avoid this plugin.
    6379
    6480= How long does it take to generate trigram lookup table? =
     
    81972. Deactivate, then activate the plugin. This rebuilds the lookup table.
    8298
    83 = What is this wp_fwol table created by the plugin? =
    84 
    85 This table, named with an abbreviation for "Fast Woo Order Lookup", contains the trigram lookups. It has a terse name to keep queries short. It is dropped automatically if you deactivate the plugin.
    86 
    8799= My store only has a few hundred orders. Do I need this plugin ? =
    88100
    89 This plugin addresses database performance problems that only show themselves on stores with many tens of thousands of orders. If your store is smaller than that you probably don't need it.
     101This plugin addresses database performance problems that only show themselves on stores with many thousands of orders. If your store is smaller than that you probably don't need it.
    90102
    91103Wise owners of rapidly growing stores return regularly to examine their site performance. If your site is still small, it's better to wait until you actually need performance-enhancing plugins and other features. Installing them "just in case" is ineffective.
     
    109121* It improves indexing performance by skipping gaps in order numbers.
    110122
    111 ## Changelog
     123== Upgrade Notice ==
     124
     125Recent versions correct intermittent problems generating the index and maintaining the postmeta key cache.
     126
     127Thanks to my loyal users for bringing these problems to my attention!
     128
     129== Changelog ==
     130
     131= 1.2.0 = October 17, 2025
     132
     133Correct an intermittent problem maintaining the postmeta key cache. Props tp slservice33 on w.org.
    112134
    113135= 1.1.11 = September 24, 2025 =
     
    115137WooCommerce 10.2.1, indexing defect fixed, gap skipping when indexing. Props to StefT1 on GitHub.
    116138
    117 = 1.1.10 = July 3, 2025 =
    118 
    119 Less aggressive logging, WooCommerce 9.9.5.
    120 
    121 = 1.1.8 = May 22, 2025 =
    122 
    123 Support 9.9.0.
    124 
    125 = 1.1.7 = April 25, 2025 =
    126 
    127 Fix memory leak in logging.
    128 
    129 = 1.1.6 = April 11, 2025 =
    130 
    131 Fix memory leak in logging.
    132 
    133 = 1.1.5 April 9, 2025 =
    134 
    135 Improve Site Health Info.
    136 
    137 = 1.1.4 April 5, 2025 =
    138 
    139 Handle a COUNT(*) query in support of pagination.
    140 
Note: See TracChangeset for help on using the changeset viewer.