Plugin Directory

Changeset 2865566


Ignore:
Timestamp:
02/15/2023 10:02:28 AM (3 years ago)
Author:
setaryapp
Message:

Update to version 1.3.0 from GitHub

Location:
setary
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • setary/tags/1.3.0/README.md

    r2864952 r2865566  
    55Tested up to: 6.1.1
    66Requires PHP: 7.1
    7 Stable tag: 1.2.0
     7Stable tag: 1.3.0
    88License: MIT
    99License URI: https://opensource.org/licenses/MIT
     
    6262== Changelog ==
    6363
     64= v1.3.0 (2023-02-15) =
     65* [update] Performance improvements so only visible columns are fetched. This can dramatically reduce the request size.
     66
    6467= v1.2.0 (2023-02-14) =
    6568* [new] Enabled the "menu_order" field
  • setary/tags/1.3.0/inc/class-products-with-variations.php

    r2864952 r2865566  
    9898
    9999        // Enable fields in response to increase speed of request and reduce response size.
     100        $params = $this->get_core_fields_from_request();
     101
     102        $request->set_param( '_fields', $params );
     103
     104        $this->filter_variation_data();
     105
     106        /**
     107         * Prevent shuffling of related products.
     108         */
     109        add_filter( 'woocommerce_product_related_posts_shuffle', '__return_false' );
     110
     111        return parent::get_product_data( $product, $context, $request );
     112    }
     113
     114    /**
     115     * Get core fields from the API request.
     116     *
     117     * @return string[]
     118     */
     119    protected function get_core_fields_from_request() {
    100120        $params = [
    101121            0  => 'id',
     
    167187        ];
    168188
    169         $request->set_param( '_fields', $params );
    170 
    171         $this->filter_variation_data();
    172 
    173         /**
    174          * Prevent shuffling of related products.
    175          */
    176         add_filter( 'woocommerce_product_related_posts_shuffle', '__return_false' );
    177 
    178         return parent::get_product_data( $product, $context, $request );
     189        // Get the requested fields.
     190        $requested_fields = isset( $_GET['fields'] ) ? wp_unslash( $_GET['fields'] ) : array();
     191
     192        if ( empty( $requested_fields ) ) {
     193            return $params;
     194        }
     195
     196        $cache_key             = 'setary_product_fields_' . md5( wp_json_encode( $requested_fields ) );
     197        $cached_matched_fields = wp_cache_get( $cache_key );
     198
     199        if ( $cached_matched_fields ) {
     200            return $cached_matched_fields;
     201        }
     202
     203        // Map requested fields to the correct WooCommerce field.
     204        $field_map = [
     205            'length' => 'dimensions',
     206            'width'  => 'dimensions',
     207            'height' => 'dimensions',
     208            'formatted_upsell_ids' => 'upsell_ids',
     209            'formatted_cross_sell_ids' => 'cross_sell_ids',
     210            'formatted_categories' => 'categories',
     211            'formatted_tags' => 'tags',
     212            'attribute_*' => 'attributes',
     213        ];
     214
     215        // Always get attributes so they show in the columns list.
     216        // @todo: See if we can get the attributes without this.
     217        $matched_fields = [
     218            60 => 'attributes',
     219        ];
     220
     221        // Create an array of fields that match the requested fields.
     222        foreach ( $requested_fields as $value ) {
     223            $value = isset( $field_map[ $value ] ) ? $field_map[ $value ] : $value;
     224
     225            if ( in_array( $value, $params, true ) ) {
     226                $array_key                    = array_search( $value, $params, true );
     227                $matched_fields[ $array_key ] = $value;
     228            } else {
     229                // If it's not a core field, it must be meta data.
     230                $matched_fields[ 65 ] = 'meta_data';
     231            }
     232        }
     233
     234        ksort( $matched_fields );
     235
     236        wp_cache_set( $cache_key, $matched_fields );
     237
     238        return ! empty( $matched_fields ) ? $matched_fields : $params;
    179239    }
    180240
     
    219279        unset( $item['variations'] );
    220280
    221         $item['formatted_categories']     = $this->format_categories( $item );
    222         $item['formatted_tags']           = $this->format_tags( $item );
    223         $item['formatted_images']         = $this->format_images( $item );
    224         $item['date_on_sale_from']        = $this->format_date( $item['date_on_sale_from'] );
    225         $item['date_on_sale_to']          = $this->format_date( $item['date_on_sale_to'] );
    226         $item['formatted_upsell_ids']     = $this->format_ids( $item['upsell_ids'] );
    227         $item['formatted_cross_sell_ids'] = $this->format_ids( $item['cross_sell_ids'] );
    228         $item['width']                    = $this->get_dimension( $item, 'width');
    229         $item['height']                   = $this->get_dimension( $item, 'height');
    230         $item['length']                   = $this->get_dimension( $item, 'length');
    231         $item['tax_class']                = empty( $item['tax_class'] ) ? 'standard' : $item['tax_class'];
    232 
    233         // If manage stock is "parent", then really it means "No".
    234         $item['manage_stock'] = $item['manage_stock'] && 'parent' !== $item['manage_stock'];
     281        if ( isset( $item['categories'] ) ) {
     282            $item['formatted_categories'] = $this->format_categories( $item );
     283        }
     284
     285        if ( isset( $item['tags'] ) ) {
     286            $item['formatted_tags'] = $this->format_tags( $item );
     287        }
     288
     289        if ( isset( $item['images'] ) ) {
     290            $item['formatted_images'] = $this->format_images( $item );
     291        }
     292
     293        if ( isset( $item['date_on_sale_from'] ) ) {
     294            $item['date_on_sale_from'] = $this->format_date( $item['date_on_sale_from'] );
     295        }
     296
     297        if ( isset( $item['date_on_sale_to'] ) ) {
     298            $item['date_on_sale_to'] = $this->format_date( $item['date_on_sale_to'] );
     299        }
     300
     301        if ( isset( $item['upsell_ids'] ) ) {
     302            $item['formatted_upsell_ids'] = $this->format_ids( $item['upsell_ids'] );
     303        }
     304
     305        if ( isset( $item['cross_sell_ids'] ) ) {
     306            $item['formatted_cross_sell_ids'] = $this->format_ids( $item['cross_sell_ids'] );
     307        }
     308
     309        if ( isset( $item['dimensions'] ) ) {
     310            $item['width']  = $this->get_dimension( $item, 'width' );
     311            $item['height'] = $this->get_dimension( $item, 'height' );
     312            $item['length'] = $this->get_dimension( $item, 'length' );
     313        }
     314
     315        $item['tax_class'] = empty( $item['tax_class'] ) ? 'standard' : $item['tax_class'];
     316
     317        if ( isset( $item['manage_stock'] ) ) {
     318            // If manage stock is "parent", then really it means "No".
     319            $item['manage_stock'] = $item['manage_stock'] && 'parent' !== $item['manage_stock'];
     320        }
    235321
    236322        return $item;
  • setary/tags/1.3.0/setary.php

    r2864952 r2865566  
    1111 * Author URI:           https://setary.com/
    1212 *
    13  * Version:              1.2.0
     13 * Version:              1.3.0
    1414 * WC requires at least: 6.0.0
    1515 * WC tested up to:      7.3.0
     
    2323define( 'SETARY_PATH', \plugin_dir_path( __FILE__ ) );
    2424define( 'SETARY_URL', \plugins_url( '/', __FILE__ ) );
    25 define( 'SETARY_VERSION', '1.2.0' );
     25define( 'SETARY_VERSION', '1.3.0' );
    2626define( 'SETARY_SITE_URL', 'https://setary.com/' );
    2727define( 'SETARY_APP_URL', 'https://setary.com/app/' );
  • setary/trunk/README.md

    r2864952 r2865566  
    55Tested up to: 6.1.1
    66Requires PHP: 7.1
    7 Stable tag: 1.2.0
     7Stable tag: 1.3.0
    88License: MIT
    99License URI: https://opensource.org/licenses/MIT
     
    6262== Changelog ==
    6363
     64= v1.3.0 (2023-02-15) =
     65* [update] Performance improvements so only visible columns are fetched. This can dramatically reduce the request size.
     66
    6467= v1.2.0 (2023-02-14) =
    6568* [new] Enabled the "menu_order" field
  • setary/trunk/inc/class-products-with-variations.php

    r2864952 r2865566  
    9898
    9999        // Enable fields in response to increase speed of request and reduce response size.
     100        $params = $this->get_core_fields_from_request();
     101
     102        $request->set_param( '_fields', $params );
     103
     104        $this->filter_variation_data();
     105
     106        /**
     107         * Prevent shuffling of related products.
     108         */
     109        add_filter( 'woocommerce_product_related_posts_shuffle', '__return_false' );
     110
     111        return parent::get_product_data( $product, $context, $request );
     112    }
     113
     114    /**
     115     * Get core fields from the API request.
     116     *
     117     * @return string[]
     118     */
     119    protected function get_core_fields_from_request() {
    100120        $params = [
    101121            0  => 'id',
     
    167187        ];
    168188
    169         $request->set_param( '_fields', $params );
    170 
    171         $this->filter_variation_data();
    172 
    173         /**
    174          * Prevent shuffling of related products.
    175          */
    176         add_filter( 'woocommerce_product_related_posts_shuffle', '__return_false' );
    177 
    178         return parent::get_product_data( $product, $context, $request );
     189        // Get the requested fields.
     190        $requested_fields = isset( $_GET['fields'] ) ? wp_unslash( $_GET['fields'] ) : array();
     191
     192        if ( empty( $requested_fields ) ) {
     193            return $params;
     194        }
     195
     196        $cache_key             = 'setary_product_fields_' . md5( wp_json_encode( $requested_fields ) );
     197        $cached_matched_fields = wp_cache_get( $cache_key );
     198
     199        if ( $cached_matched_fields ) {
     200            return $cached_matched_fields;
     201        }
     202
     203        // Map requested fields to the correct WooCommerce field.
     204        $field_map = [
     205            'length' => 'dimensions',
     206            'width'  => 'dimensions',
     207            'height' => 'dimensions',
     208            'formatted_upsell_ids' => 'upsell_ids',
     209            'formatted_cross_sell_ids' => 'cross_sell_ids',
     210            'formatted_categories' => 'categories',
     211            'formatted_tags' => 'tags',
     212            'attribute_*' => 'attributes',
     213        ];
     214
     215        // Always get attributes so they show in the columns list.
     216        // @todo: See if we can get the attributes without this.
     217        $matched_fields = [
     218            60 => 'attributes',
     219        ];
     220
     221        // Create an array of fields that match the requested fields.
     222        foreach ( $requested_fields as $value ) {
     223            $value = isset( $field_map[ $value ] ) ? $field_map[ $value ] : $value;
     224
     225            if ( in_array( $value, $params, true ) ) {
     226                $array_key                    = array_search( $value, $params, true );
     227                $matched_fields[ $array_key ] = $value;
     228            } else {
     229                // If it's not a core field, it must be meta data.
     230                $matched_fields[ 65 ] = 'meta_data';
     231            }
     232        }
     233
     234        ksort( $matched_fields );
     235
     236        wp_cache_set( $cache_key, $matched_fields );
     237
     238        return ! empty( $matched_fields ) ? $matched_fields : $params;
    179239    }
    180240
     
    219279        unset( $item['variations'] );
    220280
    221         $item['formatted_categories']     = $this->format_categories( $item );
    222         $item['formatted_tags']           = $this->format_tags( $item );
    223         $item['formatted_images']         = $this->format_images( $item );
    224         $item['date_on_sale_from']        = $this->format_date( $item['date_on_sale_from'] );
    225         $item['date_on_sale_to']          = $this->format_date( $item['date_on_sale_to'] );
    226         $item['formatted_upsell_ids']     = $this->format_ids( $item['upsell_ids'] );
    227         $item['formatted_cross_sell_ids'] = $this->format_ids( $item['cross_sell_ids'] );
    228         $item['width']                    = $this->get_dimension( $item, 'width');
    229         $item['height']                   = $this->get_dimension( $item, 'height');
    230         $item['length']                   = $this->get_dimension( $item, 'length');
    231         $item['tax_class']                = empty( $item['tax_class'] ) ? 'standard' : $item['tax_class'];
    232 
    233         // If manage stock is "parent", then really it means "No".
    234         $item['manage_stock'] = $item['manage_stock'] && 'parent' !== $item['manage_stock'];
     281        if ( isset( $item['categories'] ) ) {
     282            $item['formatted_categories'] = $this->format_categories( $item );
     283        }
     284
     285        if ( isset( $item['tags'] ) ) {
     286            $item['formatted_tags'] = $this->format_tags( $item );
     287        }
     288
     289        if ( isset( $item['images'] ) ) {
     290            $item['formatted_images'] = $this->format_images( $item );
     291        }
     292
     293        if ( isset( $item['date_on_sale_from'] ) ) {
     294            $item['date_on_sale_from'] = $this->format_date( $item['date_on_sale_from'] );
     295        }
     296
     297        if ( isset( $item['date_on_sale_to'] ) ) {
     298            $item['date_on_sale_to'] = $this->format_date( $item['date_on_sale_to'] );
     299        }
     300
     301        if ( isset( $item['upsell_ids'] ) ) {
     302            $item['formatted_upsell_ids'] = $this->format_ids( $item['upsell_ids'] );
     303        }
     304
     305        if ( isset( $item['cross_sell_ids'] ) ) {
     306            $item['formatted_cross_sell_ids'] = $this->format_ids( $item['cross_sell_ids'] );
     307        }
     308
     309        if ( isset( $item['dimensions'] ) ) {
     310            $item['width']  = $this->get_dimension( $item, 'width' );
     311            $item['height'] = $this->get_dimension( $item, 'height' );
     312            $item['length'] = $this->get_dimension( $item, 'length' );
     313        }
     314
     315        $item['tax_class'] = empty( $item['tax_class'] ) ? 'standard' : $item['tax_class'];
     316
     317        if ( isset( $item['manage_stock'] ) ) {
     318            // If manage stock is "parent", then really it means "No".
     319            $item['manage_stock'] = $item['manage_stock'] && 'parent' !== $item['manage_stock'];
     320        }
    235321
    236322        return $item;
  • setary/trunk/setary.php

    r2864952 r2865566  
    1111 * Author URI:           https://setary.com/
    1212 *
    13  * Version:              1.2.0
     13 * Version:              1.3.0
    1414 * WC requires at least: 6.0.0
    1515 * WC tested up to:      7.3.0
     
    2323define( 'SETARY_PATH', \plugin_dir_path( __FILE__ ) );
    2424define( 'SETARY_URL', \plugins_url( '/', __FILE__ ) );
    25 define( 'SETARY_VERSION', '1.2.0' );
     25define( 'SETARY_VERSION', '1.3.0' );
    2626define( 'SETARY_SITE_URL', 'https://setary.com/' );
    2727define( 'SETARY_APP_URL', 'https://setary.com/app/' );
Note: See TracChangeset for help on using the changeset viewer.