Plugin Directory

Changeset 3482456


Ignore:
Timestamp:
03/14/2026 09:55:02 AM (3 weeks ago)
Author:
nakedcatplugins
Message:

Update to version 5.2 from GitHub

Location:
feed-kuantokusta-for-woocommerce
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • feed-kuantokusta-for-woocommerce/tags/5.2/feed-kuantokusta-for-woocommerce.php

    r3444190 r3482456  
    44 * Plugin URI:           https://www.webdados.pt/wordpress/plugins/feed-kuantokusta-para-woocommerce/
    55 * Description:          This plugin allows you to generate a WooCommerce product feed to submit to KuantoKusta, a portuguese price comparison website and marketplace.
    6  * Version:              5.1
     6 * Version:              5.2
    77 * Author:               Naked Cat Plugins (by Webdados)
    88 * Author URI:           https://nakedcatplugins.com
     
    1010 * Domain Path:          /languages
    1111 * Requires at least:    6.2
    12  * Tested up to:         6.9
     12 * Tested up to:         7.0
    1313 * Requires PHP:         7.2
    1414 * WC requires at least: 8.0
    15  * WC tested up to:      10.5
     15 * WC tested up to:      10.6
    1616 * Requires Plugins:     woocommerce
    1717 **/
     
    9191}
    9292
    93 
     93/**
     94 * Incompatible version of KuantoKusta PRO notice
     95 *
     96 * @return void
     97 */
    9498function fkkwc_admin_notices_pro_incompatible() {
    9599    ?>
  • feed-kuantokusta-for-woocommerce/tags/5.2/includes/class-wc-feed-kuantokusta.php

    r3394301 r3482456  
    9797        $this->out_link_utm = '?utm_source=' . rawurlencode( esc_url( home_url( '/' ) ) ) . '&utm_medium=link&utm_campaign=kk_woocommerce_plugin';
    9898        // Mode
    99         $this->mode = get_option( $this->id . '_plugin_mode' ) != '' ? get_option( $this->id . '_plugin_mode' ) : 'comparison';
     99        $this->mode = get_option( $this->id . '_plugin_mode' ) !== '' ? get_option( $this->id . '_plugin_mode' ) : 'comparison';
    100100        // Settings
    101101        $temp = $this->get_settings();
    102102        foreach ( $temp as $key => $value ) {
    103             if ( isset( $value['id_'] ) && $value['id_'] != '' ) {
     103            if ( isset( $value['id_'] ) && $value['id_'] !== '' ) {
    104104                $this->settings[ $value['id_'] ] = get_option( $value['id'] );
    105105            }
     
    234234        );
    235235
    236         if ( $this->mode == 'marketplace' ) {
     236        if ( $this->mode === 'marketplace' ) {
    237237            // Product stock
    238238            $settings = array_merge(
     
    280280            )
    281281        );
    282         if ( $this->mode == 'marketplace' ) {
     282        if ( $this->mode === 'marketplace' ) {
    283283            $settings = array_merge(
    284284                $settings,
     
    318318
    319319        foreach ( $settings as $key => $value ) {
    320             if ( isset( $value['id_'] ) && $value['id_'] != '' ) {
     320            if ( isset( $value['id_'] ) && $value['id_'] !== '' ) {
    321321                $settings[ $key ]['id'] = $this->id . '_' . $value['id_'];
    322322            }
     
    467467                    )
    468468                );
    469                 if ( $this->mode == 'marketplace' ) {
    470                     // Preparation days
    471                     woocommerce_wp_text_input(
    472                         array(
    473                             'id'                => '_kuantokusta_preparation_days_max',
    474                             'label'             => __( 'Maximum preparation time', 'feed-kuantokusta-for-woocommerce' ) . ' (' . __( 'days', 'feed-kuantokusta-for-woocommerce' ) . ')',
    475                             'placeholder'       => sprintf(
    476                                 /* translators: 1: default preparation days. */
    477                                 __( 'Blank for default (%s)', 'feed-kuantokusta-for-woocommerce' ),
    478                                 $this->get_setting( 'preparation_days_max_default' )
    479                             ),
    480                             'type'              => 'number',
    481                             'custom_attributes' => array(
    482                                 'min' => 0,
    483                             ),
    484                         )
    485                     );
    486                     // Delivery days
    487                     woocommerce_wp_text_input(
    488                         array(
    489                             'id'                => '_kuantokusta_delivery_days_max',
    490                             'label'             => __( 'Maximum delivery time', 'feed-kuantokusta-for-woocommerce' ) . ' (' . __( 'days', 'feed-kuantokusta-for-woocommerce' ) . ')',
    491                             'placeholder'       => sprintf(
    492                                 /* translators: 1: default delivery days. */
    493                                 __( 'Blank for default (%s)', 'feed-kuantokusta-for-woocommerce' ),
    494                                 $this->get_setting( 'delivery_days_max_default' )
    495                             ),
    496                             'type'              => 'number',
    497                             'custom_attributes' => array(
    498                                 'min' => 0,
    499                             ),
    500                         )
    501                     );
    502                 }
     469        if ( $this->mode === 'marketplace' ) {
     470            // Preparation days
     471            woocommerce_wp_text_input(
     472                array(
     473                    'id'                => '_kuantokusta_preparation_days_max',
     474                    'label'             => __( 'Maximum preparation time', 'feed-kuantokusta-for-woocommerce' ) . ' (' . __( 'days', 'feed-kuantokusta-for-woocommerce' ) . ')',
     475                    'placeholder'       => sprintf(
     476                        /* translators: 1: default preparation days. */
     477                        __( 'Blank for default (%s)', 'feed-kuantokusta-for-woocommerce' ),
     478                        $this->get_setting( 'preparation_days_max_default' )
     479                    ),
     480                    'type'              => 'number',
     481                    'custom_attributes' => array(
     482                        'min' => 0,
     483                    ),
     484                )
     485            );
     486            // Delivery days
     487            woocommerce_wp_text_input(
     488                array(
     489                    'id'                => '_kuantokusta_delivery_days_max',
     490                    'label'             => __( 'Maximum delivery time', 'feed-kuantokusta-for-woocommerce' ) . ' (' . __( 'days', 'feed-kuantokusta-for-woocommerce' ) . ')',
     491                    'placeholder'       => sprintf(
     492                        /* translators: 1: default delivery days. */
     493                        __( 'Blank for default (%s)', 'feed-kuantokusta-for-woocommerce' ),
     494                        $this->get_setting( 'delivery_days_max_default' )
     495                    ),
     496                    'type'              => 'number',
     497                    'custom_attributes' => array(
     498                        'min' => 0,
     499                    ),
     500                )
     501            );
     502        }
    503503                // Action for integration...
    504504                do_action( 'kuantokusta_product_data_panel_end' );
    505             ?>
     505        ?>
    506506            </div>
    507507            <script type="text/javascript">
    508508                jQuery( function( $ ) {
    509509                    function kk_hide_fields() {
    510                         if ( $( '#_kuantokusta_hide' ).is(":checked") ) {
     510                        if ( $( '#_kuantokusta_hide' ).is( ':checked' ) ) {
    511511                            $( '#kuantokusta p.form-field' ).hide();
    512512                            $( '#kuantokusta p.kuantokusta-title' ).hide();
     
    542542     */
    543543    public function woocommerce_process_product_meta( $post_id ) {
     544        // WooCommerce took care of nonces
     545        // phpcs:disable WordPress.Security.NonceVerification.Missing
    544546        $meta    = array();
    545547        $product = wc_get_product( $post_id );
    546548        // Hide
    547         $meta['_kuantokusta_hide'] = ! empty( $_POST['_kuantokusta_hide'] ) ? wc_clean( $_POST['_kuantokusta_hide'] ) : '';
     549        $meta['_kuantokusta_hide'] = ! empty( $_POST['_kuantokusta_hide'] ) ? sanitize_text_field( wp_unslash( $_POST['_kuantokusta_hide'] ) ) : '';
    548550        // EAN
    549         $meta['_kuantokusta_ean'] = isset( $_POST['_kuantokusta_ean'] ) && ! empty( $_POST['_kuantokusta_ean'] ) ? wc_clean( $_POST['_kuantokusta_ean'] ) : '';
     551        $meta['_kuantokusta_ean'] = ! empty( $_POST['_kuantokusta_ean'] ) ? sanitize_text_field( wp_unslash( $_POST['_kuantokusta_ean'] ) ) : '';
    550552        if ( version_compare( WC_VERSION, '9.2', '>=' ) && ! empty( $_POST['_global_unique_id'] ) ) {
    551553            // If the core field is filled in, remove ours from the database
     
    554556        }
    555557        // Shipping
    556         $meta['_kuantokusta_shipping'] = trim( $_POST['_kuantokusta_shipping'] ) != '' ? wc_clean( $_POST['_kuantokusta_shipping'] ) : '';
     558        $meta['_kuantokusta_shipping'] = ! empty( $_POST['_kuantokusta_shipping'] ) ? sanitize_text_field( wp_unslash( $_POST['_kuantokusta_shipping'] ) ) : '';
    557559        // Shipping
    558         $meta['_kuantokusta_preparation_days_max'] = ! empty( $_POST['_kuantokusta_preparation_days_max'] ) ? wc_clean( $_POST['_kuantokusta_preparation_days_max'] ) : '';
     560        $meta['_kuantokusta_preparation_days_max'] = ! empty( $_POST['_kuantokusta_preparation_days_max'] ) ? sanitize_text_field( wp_unslash( $_POST['_kuantokusta_preparation_days_max'] ) ) : '';
    559561        // Shipping
    560         $meta['_kuantokusta_delivery_days_max'] = ! empty( $_POST['_kuantokusta_delivery_days_max'] ) ? wc_clean( $_POST['_kuantokusta_delivery_days_max'] ) : '';
     562        $meta['_kuantokusta_delivery_days_max'] = ! empty( $_POST['_kuantokusta_delivery_days_max'] ) ? sanitize_text_field( wp_unslash( $_POST['_kuantokusta_delivery_days_max'] ) ) : '';
    561563        // Filter for integration ( Use this filter to add to $meta the keys/values of the fields added by the `kuantokusta_product_data_panel_end` action )
    562564        $meta = apply_filters( 'kuantokusta_process_product_meta', $meta );
     
    568570        // Action for integration - ONLY if the filter above was not used
    569571        do_action( 'kuantokusta_process_product_meta_end', $post_id );
     572        // phpcs:enable
    570573    }
    571574
     
    583586    public function render_products_feed() {
    584587        define( 'KK_IS_FEED', true );
    585         @define( 'DONOTCACHEPAGE', true ); // Cache plugins
     588        if ( ! defined( 'DONOTCACHEPAGE' ) ) {
     589            define( 'DONOTCACHEPAGE', true ); // Cache plugins
     590        }
    586591        header( 'Content-Type: application/rss+xml; charset=utf-8' );
    587592        header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() - 86400 ) . ' GMT' ); // Yesterday
     
    589594        header( 'Cache-Control: post-check=0, pre-check=0', false );
    590595        header( 'Pragma: no-cache' );
    591         $offset         = intval( isset( $_GET['LIMIT'] ) ? $_GET['LIMIT'] : 0 );
    592         $posts_per_page = intval( isset( $_GET['TOTAL_PRODUTOS'] ) ? $_GET['TOTAL_PRODUTOS'] : -1 );
     596        // phpcs:disable WordPress.Security.NonceVerification.Recommended
     597        $offset         = isset( $_GET['LIMIT'] ) ? intval( $_GET['LIMIT'] ) : 0;
     598        $posts_per_page = isset( $_GET['TOTAL_PRODUTOS'] ) ? intval( $_GET['TOTAL_PRODUTOS'] ) : -1;
     599        // phpcs:enable
     600        ob_start();
    593601        do_action( 'kuantokusta_render_products_feed_start' );
    594         echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>
     602        echo '<?xml version="1.0" encoding="' . esc_attr( get_option( 'blog_charset' ) ) . '"?' . '>
    595603';
    596604        ?>
     
    602610        $sql_exclude = "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE ( meta_key = '_kuantokusta_hide' AND meta_value = 'yes' )";
    603611        // Debug and only include specific SKU
    604         if ( isset( $_GET['sku'] ) && trim( $_GET['sku'] ) != '' ) {
    605             $sql_exclude .= " || ( meta_key = '_sku' AND meta_value NOT LIKE '%" . sanitize_text_field( trim( $_GET['sku'] ) ) . "%' )";
    606         }
    607         $results = $wpdb->get_results( $sql_exclude, ARRAY_A );
     612        // phpcs:disable WordPress.Security.NonceVerification.Recommended
     613        if ( isset( $_GET['sku'] ) && trim( sanitize_text_field( wp_unslash( $_GET['sku'] ) ) ) !== '' ) {
     614            $sql_exclude .= " || ( meta_key = '_sku' AND meta_value NOT LIKE '%" . trim( sanitize_text_field( wp_unslash( $_GET['sku'] ) ) ) . "%' )";
     615        }
     616        // phpcs:enable
     617        $results = $wpdb->get_results( $sql_exclude, ARRAY_A ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
    608618        if ( ! empty( $results ) ) {
    609619            if ( count( $results ) > 0 ) {
     
    639649                                        if ( apply_filters( 'kuantokusta_variation_node_show', true, $product, $variation ) ) {
    640650                                            $product_node = $this->render_product_feed_variation( $product, $variation );
    641                                             echo apply_filters( 'kuantokusta_product_node_variation', $product_node, $product, $variation );
     651                                            // This is XML, so we cannot escape it
     652                                            echo apply_filters( 'kuantokusta_product_node_variation', $product_node, $product, $variation ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    642653                                        }
    643654                                    }
     
    647658                                    // Just like simple products
    648659                                    $product_node = $this->render_product_feed_default( $product, $product_type );
    649                                     echo apply_filters( 'kuantokusta_product_node_default', $product_node, $product, $product_type );
     660                                    // This is XML, so we cannot escape it
     661                                    echo apply_filters( 'kuantokusta_product_node_default', $product_node, $product, $product_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    650662                                    break;
    651663                            }
     
    653665                        default: // Including 'simple'
    654666                            $product_node = $this->render_product_feed_default( $product, $product_type );
    655                             echo apply_filters( 'kuantokusta_product_node_default', $product_node, $product, $product_type );
     667                            // This is XML, so we cannot escape it
     668                            echo apply_filters( 'kuantokusta_product_node_default', $product_node, $product, $product_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    656669                            break;
    657670                    }
     
    663676</products>
    664677        <?php
     678        // This is XML, so we cannot escape it
     679        // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
     680        $xml_string = ob_get_clean();
     681        if ( apply_filters( 'kuantokusta_prettify_xml', true ) && class_exists( 'DOMDocument' ) ) {
     682            libxml_use_internal_errors( true );
     683            $dom                     = new DOMDocument( '1.0', 'UTF-8' );
     684            $dom->preserveWhiteSpace = false; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     685            $dom->formatOutput       = true; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     686            $ok                      = $dom->loadXML( $xml_string, LIBXML_NOBLANKS | LIBXML_NOERROR | LIBXML_NOWARNING );
     687            if ( ! $ok ) {
     688                // If it fails, output the non-formatted XML and log the error
     689                error_log( 'KuantoKusta feed XML parsing errors:' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     690                foreach ( libxml_get_errors() as $error ) {
     691                    error_log( $error->message ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     692                    error_log( 'Line: ' . $error->line . ' Column: ' . $error->column ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     693                }
     694                libxml_clear_errors();
     695                echo $xml_string;
     696            }
     697            libxml_clear_errors();
     698            // Keep empty tags instead of self-closing tags, as we don't know if KuantoKusta accepts self-closing tags
     699            echo preg_replace( '/<(\w+)\/>/', '<$1></$1>', $dom->saveXML() );
     700        } else {
     701            echo $xml_string;
     702        }
     703        // phpcs:enable
    665704    }
    666705
     
    685724        $image         = apply_filters( 'kuantokusta_product_node_default_image', $this->get_product_image( $product ), $product, $product_type );
    686725        $description   = apply_filters( 'kuantokusta_product_node_default_description', $this->get_product_description( $product ), $product, $product_type );
    687 //      $brand         = apply_filters( 'kuantokusta_product_node_default_brand', $this->get_product_brand( $product ), $product, $product_type );
    688726        $ean           = apply_filters( 'kuantokusta_product_node_default_ean', $this->get_product_ean( $product ), $product, $product_type );
    689727        $reference     = apply_filters( 'kuantokusta_product_node_default_reference', $product->get_sku(), $product, $product_type );
     
    743781                'cdata' => true,
    744782            ),
    745 //          'brand'                    => array(
    746 //              'value' => trim( $brand ),
    747 //              'cdata' => true,
    748 //          ),
    749783            'upc_ean'                  => array(
    750784                'value'     => trim( $ean ),
     
    761795            ),
    762796            'shipping_cost'            => array(
    763                 'value'     => ( trim( $shipping_cost ) != '' && floatval( $shipping_cost ) >= 0 ) ? round( floatval( $shipping_cost ), wc_get_price_decimals() ) : '',
     797                'value'     => ( trim( $shipping_cost ) !== '' && floatval( $shipping_cost ) >= 0 ) ? round( floatval( $shipping_cost ), wc_get_price_decimals() ) : '',
    764798                'cdata'     => false,
    765799                'alias_key' => 'shipping',
    766800            ),
    767801        );
    768         if ( $this->mode == 'marketplace' ) {
     802        if ( $this->mode === 'marketplace' ) {
    769803            // Marketplace
    770804            unset( $xml_fields['stock'] );
     
    805839        foreach ( $xml_fields as $key => $value ) {
    806840            ?>
    807         <<?php echo $key; ?>><?php echo $value['cdata'] ? '<![CDATA[' . $value['value'] . ']]>' : $value['value']; ?></<?php echo $key; ?>>
     841        <<?php echo esc_attr( $key ); ?>><?php echo $value['cdata'] ? '<![CDATA[' . wp_kses_post( $value['value'] ) . ']]>' : esc_html( $value['value'] ); ?></<?php echo esc_attr( $key ); ?>>
    808842            <?php
    809843        }
     
    827861        $url          = $variation->get_permalink();
    828862        $title        = trim( apply_filters( 'kuantokusta_product_node_pre_variation_title', $variation->get_name(), $product, $variation ) );
    829         if ( trim( $title ) == '' ) {
     863        if ( trim( $title ) === '' ) {
    830864            $title = trim( $product->get_title() );
    831865        }
    832866        $reference = $variation->get_sku();
    833867        if ( apply_filters( 'kuantokusta_product_node_variation_title_append_description', true, $product, $variation ) ) {
    834             if ( trim( $variation->get_description() ) != '' ) {
     868            if ( trim( $variation->get_description() ) !== '' ) {
    835869                // Variation description
    836870                $title .= apply_filters( 'woocommerce_product_variation_title_attributes_separator', ' - ', $variation ) . trim( $variation->get_description() );
    837871            } elseif ( apply_filters( 'kuantokusta_product_node_variation_title_append_sku_or_id', true, $product, $variation ) ) {
    838                 if ( trim( $reference ) != '' ) {
     872                if ( trim( $reference ) !== '' ) {
    839873                    // Variation sku
    840874                    $title .= ' (' . trim( $reference ) . ')';
     
    855889        $image       = apply_filters( 'kuantokusta_product_node_variation_image', $this->get_product_variation_image( $product, $variation ), $product, $variation );
    856890        $description = apply_filters( 'kuantokusta_product_node_variation_description', $this->get_product_variation_description( $product, $variation ), $product, $variation );
    857 //      $brand       = apply_filters( 'kuantokusta_product_node_variation_brand', $this->get_product_brand( $product ), $product, $variation );
    858891        $ean         = apply_filters( 'kuantokusta_product_node_variation_ean', $this->get_product_ean( $product ), $product, $variation ); // On the free version we only read EAN from the main product
    859         if ( trim( $reference ) == '' ) {
     892        if ( trim( $reference ) === '' ) {
    860893            $reference = $product->get_sku();
    861894        }
    862895        $reference = apply_filters( 'kuantokusta_product_node_variation_reference', $reference, $product, $variation );
    863896        $weight    = $variation->get_weight();
    864         if ( floatval( $weight ) == 0 ) {
     897        if ( floatval( $weight ) === 0 ) {
    865898            $weight = $product->get_weight();
    866899        }
     
    920953                'cdata' => true,
    921954            ),
    922 //          'brand'                    => array(
    923 //              'value' => trim( $brand ),
    924 //              'cdata' => true,
    925 //          ),
    926955            'upc_ean'                  => array(
    927956                'value'     => trim( $ean ),
     
    938967            ),
    939968            'shipping_cost'            => array(
    940                 'value'     => ( trim( $shipping_cost ) != '' && floatval( $shipping_cost ) >= 0 ) ? round( floatval( $shipping_cost ), wc_get_price_decimals() ) : '',
     969                'value'     => ( trim( $shipping_cost ) !== '' && floatval( $shipping_cost ) >= 0 ) ? round( floatval( $shipping_cost ), wc_get_price_decimals() ) : '',
    941970                'cdata'     => false,
    942971                'alias_key' => 'shipping',
     
    9821011        foreach ( $xml_fields as $key => $value ) {
    9831012            ?>
    984         <<?php echo $key; ?>><?php echo $value['cdata'] ? '<![CDATA[' . $value['value'] . ']]>' : $value['value']; ?></<?php echo $key; ?>>
     1013        <<?php echo esc_attr( $key ); ?>><?php echo $value['cdata'] ? '<![CDATA[' . wp_kses_post( $value['value'] ) . ']]>' : esc_html( $value['value'] ); ?></<?php echo esc_attr( $key ); ?>>
    9851014            <?php
    9861015        }
     
    10301059     */
    10311060    public function get_product_description( $product ) {
    1032         if ( $this->get_setting( 'description_type' ) == 'full' ) {
     1061        if ( $this->get_setting( 'description_type' ) === 'full' ) {
    10331062            $description = trim( $product->get_description() );
    1034             if ( trim( $description ) == '' ) {
     1063            if ( trim( $description ) === '' ) {
    10351064                $description = trim( $product->get_short_description() );
    10361065            }
     
    10381067            $description = trim( $product->get_short_description() );
    10391068        }
    1040         if ( trim( $description ) == '' ) {
     1069        if ( trim( $description ) === '' ) {
    10411070            $description = trim( $product->get_title() );
    10421071        }
     
    10441073        return wpautop( $description );
    10451074    }
     1075
     1076    /**
     1077     * Get the product variation description
     1078     *
     1079     * @param WC_Product           $product   The product object.
     1080     * @param WC_Product_Variation $variation The variation object.
     1081     * @return string The product variation description.
     1082     */
    10461083    public function get_product_variation_description( $product, $variation ) {
    10471084        $product_description   = $this->get_product_description( $product );
     
    11311168                case 'parent':
    11321169                    return $this->get_comparison_product_stock( $product );
    1133                     break;
    11341170                default: // ???
    11351171                    return '';
    1136                     break;
    11371172            }
    11381173        }
     
    11631198                case 'parent':
    11641199                    return $this->get_marketplace_product_stock( $product );
    1165                     break;
    11661200                default: // ???
    11671201                    return '';
    1168                     break;
    11691202            }
    11701203        }
     
    11811214        $shipping_cost = $product->get_meta( '_kuantokusta_shipping' );
    11821215        // We do not use empty() because the shop owner might want to offer free shipping
    1183         if ( trim( $shipping_cost ) == '' ) {
     1216        if ( trim( $shipping_cost ) === '' ) {
    11841217            $shipping_cost = $this->get_setting( 'shipping_cost_default' );
    11851218        }
  • feed-kuantokusta-for-woocommerce/tags/5.2/readme.txt

    r3444190 r3482456  
    33Tags: marketplace, feed, comparison, e-commerce, Portugal
    44Requires at least: 6.2
    5 Tested up to: 6.8
     5Tested up to: 7.0
    66Requires PHP: 7.2
    7 Stable tag: 5.1
     7Stable tag: 5.2
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    121121== Changelog ==
    122122
     123= 5.2 - 2026-03-14 =
     124
     125* [TWEAK] XML output is now prettified (can be disabled by returning `false` to the `kuantokusta_prettify_xml` filter)
     126* [DEV] New updater v13.1I [Pro add-on](https://nakedcatplugins.com/product/feed-kuantokusta-for-woocommerce-pro/?utm_source=wordpress.org&utm_medium=link&utm_campaign=kk_woocommerce_plugin)
     127* [DEV] Enforce hooks to be initialized only if the license is activeI [Pro add-on](https://nakedcatplugins.com/product/feed-kuantokusta-for-woocommerce-pro/?utm_source=wordpress.org&utm_medium=link&utm_campaign=kk_woocommerce_plugin)
     128* [DEV] Enforce WordPress Coding Standards on all the codebase
     129* [DEV] Update GitHub actions
     130* [DEV] Tested with WordPress 7.0-beta5-61992 and WooCommerce 10.6.1
     131
    123132= 5.1 - 2026-01-21 =
    124133* [FIX] Plugin license validation when running in WP CLI [Pro add-on](https://nakedcatplugins.com/product/feed-kuantokusta-for-woocommerce-pro/?utm_source=wordpress.org&utm_medium=link&utm_campaign=kk_woocommerce_plugin)
  • feed-kuantokusta-for-woocommerce/trunk/feed-kuantokusta-for-woocommerce.php

    r3444190 r3482456  
    44 * Plugin URI:           https://www.webdados.pt/wordpress/plugins/feed-kuantokusta-para-woocommerce/
    55 * Description:          This plugin allows you to generate a WooCommerce product feed to submit to KuantoKusta, a portuguese price comparison website and marketplace.
    6  * Version:              5.1
     6 * Version:              5.2
    77 * Author:               Naked Cat Plugins (by Webdados)
    88 * Author URI:           https://nakedcatplugins.com
     
    1010 * Domain Path:          /languages
    1111 * Requires at least:    6.2
    12  * Tested up to:         6.9
     12 * Tested up to:         7.0
    1313 * Requires PHP:         7.2
    1414 * WC requires at least: 8.0
    15  * WC tested up to:      10.5
     15 * WC tested up to:      10.6
    1616 * Requires Plugins:     woocommerce
    1717 **/
     
    9191}
    9292
    93 
     93/**
     94 * Incompatible version of KuantoKusta PRO notice
     95 *
     96 * @return void
     97 */
    9498function fkkwc_admin_notices_pro_incompatible() {
    9599    ?>
  • feed-kuantokusta-for-woocommerce/trunk/includes/class-wc-feed-kuantokusta.php

    r3394301 r3482456  
    9797        $this->out_link_utm = '?utm_source=' . rawurlencode( esc_url( home_url( '/' ) ) ) . '&amp;utm_medium=link&amp;utm_campaign=kk_woocommerce_plugin';
    9898        // Mode
    99         $this->mode = get_option( $this->id . '_plugin_mode' ) != '' ? get_option( $this->id . '_plugin_mode' ) : 'comparison';
     99        $this->mode = get_option( $this->id . '_plugin_mode' ) !== '' ? get_option( $this->id . '_plugin_mode' ) : 'comparison';
    100100        // Settings
    101101        $temp = $this->get_settings();
    102102        foreach ( $temp as $key => $value ) {
    103             if ( isset( $value['id_'] ) && $value['id_'] != '' ) {
     103            if ( isset( $value['id_'] ) && $value['id_'] !== '' ) {
    104104                $this->settings[ $value['id_'] ] = get_option( $value['id'] );
    105105            }
     
    234234        );
    235235
    236         if ( $this->mode == 'marketplace' ) {
     236        if ( $this->mode === 'marketplace' ) {
    237237            // Product stock
    238238            $settings = array_merge(
     
    280280            )
    281281        );
    282         if ( $this->mode == 'marketplace' ) {
     282        if ( $this->mode === 'marketplace' ) {
    283283            $settings = array_merge(
    284284                $settings,
     
    318318
    319319        foreach ( $settings as $key => $value ) {
    320             if ( isset( $value['id_'] ) && $value['id_'] != '' ) {
     320            if ( isset( $value['id_'] ) && $value['id_'] !== '' ) {
    321321                $settings[ $key ]['id'] = $this->id . '_' . $value['id_'];
    322322            }
     
    467467                    )
    468468                );
    469                 if ( $this->mode == 'marketplace' ) {
    470                     // Preparation days
    471                     woocommerce_wp_text_input(
    472                         array(
    473                             'id'                => '_kuantokusta_preparation_days_max',
    474                             'label'             => __( 'Maximum preparation time', 'feed-kuantokusta-for-woocommerce' ) . ' (' . __( 'days', 'feed-kuantokusta-for-woocommerce' ) . ')',
    475                             'placeholder'       => sprintf(
    476                                 /* translators: 1: default preparation days. */
    477                                 __( 'Blank for default (%s)', 'feed-kuantokusta-for-woocommerce' ),
    478                                 $this->get_setting( 'preparation_days_max_default' )
    479                             ),
    480                             'type'              => 'number',
    481                             'custom_attributes' => array(
    482                                 'min' => 0,
    483                             ),
    484                         )
    485                     );
    486                     // Delivery days
    487                     woocommerce_wp_text_input(
    488                         array(
    489                             'id'                => '_kuantokusta_delivery_days_max',
    490                             'label'             => __( 'Maximum delivery time', 'feed-kuantokusta-for-woocommerce' ) . ' (' . __( 'days', 'feed-kuantokusta-for-woocommerce' ) . ')',
    491                             'placeholder'       => sprintf(
    492                                 /* translators: 1: default delivery days. */
    493                                 __( 'Blank for default (%s)', 'feed-kuantokusta-for-woocommerce' ),
    494                                 $this->get_setting( 'delivery_days_max_default' )
    495                             ),
    496                             'type'              => 'number',
    497                             'custom_attributes' => array(
    498                                 'min' => 0,
    499                             ),
    500                         )
    501                     );
    502                 }
     469        if ( $this->mode === 'marketplace' ) {
     470            // Preparation days
     471            woocommerce_wp_text_input(
     472                array(
     473                    'id'                => '_kuantokusta_preparation_days_max',
     474                    'label'             => __( 'Maximum preparation time', 'feed-kuantokusta-for-woocommerce' ) . ' (' . __( 'days', 'feed-kuantokusta-for-woocommerce' ) . ')',
     475                    'placeholder'       => sprintf(
     476                        /* translators: 1: default preparation days. */
     477                        __( 'Blank for default (%s)', 'feed-kuantokusta-for-woocommerce' ),
     478                        $this->get_setting( 'preparation_days_max_default' )
     479                    ),
     480                    'type'              => 'number',
     481                    'custom_attributes' => array(
     482                        'min' => 0,
     483                    ),
     484                )
     485            );
     486            // Delivery days
     487            woocommerce_wp_text_input(
     488                array(
     489                    'id'                => '_kuantokusta_delivery_days_max',
     490                    'label'             => __( 'Maximum delivery time', 'feed-kuantokusta-for-woocommerce' ) . ' (' . __( 'days', 'feed-kuantokusta-for-woocommerce' ) . ')',
     491                    'placeholder'       => sprintf(
     492                        /* translators: 1: default delivery days. */
     493                        __( 'Blank for default (%s)', 'feed-kuantokusta-for-woocommerce' ),
     494                        $this->get_setting( 'delivery_days_max_default' )
     495                    ),
     496                    'type'              => 'number',
     497                    'custom_attributes' => array(
     498                        'min' => 0,
     499                    ),
     500                )
     501            );
     502        }
    503503                // Action for integration...
    504504                do_action( 'kuantokusta_product_data_panel_end' );
    505             ?>
     505        ?>
    506506            </div>
    507507            <script type="text/javascript">
    508508                jQuery( function( $ ) {
    509509                    function kk_hide_fields() {
    510                         if ( $( '#_kuantokusta_hide' ).is(":checked") ) {
     510                        if ( $( '#_kuantokusta_hide' ).is( ':checked' ) ) {
    511511                            $( '#kuantokusta p.form-field' ).hide();
    512512                            $( '#kuantokusta p.kuantokusta-title' ).hide();
     
    542542     */
    543543    public function woocommerce_process_product_meta( $post_id ) {
     544        // WooCommerce took care of nonces
     545        // phpcs:disable WordPress.Security.NonceVerification.Missing
    544546        $meta    = array();
    545547        $product = wc_get_product( $post_id );
    546548        // Hide
    547         $meta['_kuantokusta_hide'] = ! empty( $_POST['_kuantokusta_hide'] ) ? wc_clean( $_POST['_kuantokusta_hide'] ) : '';
     549        $meta['_kuantokusta_hide'] = ! empty( $_POST['_kuantokusta_hide'] ) ? sanitize_text_field( wp_unslash( $_POST['_kuantokusta_hide'] ) ) : '';
    548550        // EAN
    549         $meta['_kuantokusta_ean'] = isset( $_POST['_kuantokusta_ean'] ) && ! empty( $_POST['_kuantokusta_ean'] ) ? wc_clean( $_POST['_kuantokusta_ean'] ) : '';
     551        $meta['_kuantokusta_ean'] = ! empty( $_POST['_kuantokusta_ean'] ) ? sanitize_text_field( wp_unslash( $_POST['_kuantokusta_ean'] ) ) : '';
    550552        if ( version_compare( WC_VERSION, '9.2', '>=' ) && ! empty( $_POST['_global_unique_id'] ) ) {
    551553            // If the core field is filled in, remove ours from the database
     
    554556        }
    555557        // Shipping
    556         $meta['_kuantokusta_shipping'] = trim( $_POST['_kuantokusta_shipping'] ) != '' ? wc_clean( $_POST['_kuantokusta_shipping'] ) : '';
     558        $meta['_kuantokusta_shipping'] = ! empty( $_POST['_kuantokusta_shipping'] ) ? sanitize_text_field( wp_unslash( $_POST['_kuantokusta_shipping'] ) ) : '';
    557559        // Shipping
    558         $meta['_kuantokusta_preparation_days_max'] = ! empty( $_POST['_kuantokusta_preparation_days_max'] ) ? wc_clean( $_POST['_kuantokusta_preparation_days_max'] ) : '';
     560        $meta['_kuantokusta_preparation_days_max'] = ! empty( $_POST['_kuantokusta_preparation_days_max'] ) ? sanitize_text_field( wp_unslash( $_POST['_kuantokusta_preparation_days_max'] ) ) : '';
    559561        // Shipping
    560         $meta['_kuantokusta_delivery_days_max'] = ! empty( $_POST['_kuantokusta_delivery_days_max'] ) ? wc_clean( $_POST['_kuantokusta_delivery_days_max'] ) : '';
     562        $meta['_kuantokusta_delivery_days_max'] = ! empty( $_POST['_kuantokusta_delivery_days_max'] ) ? sanitize_text_field( wp_unslash( $_POST['_kuantokusta_delivery_days_max'] ) ) : '';
    561563        // Filter for integration ( Use this filter to add to $meta the keys/values of the fields added by the `kuantokusta_product_data_panel_end` action )
    562564        $meta = apply_filters( 'kuantokusta_process_product_meta', $meta );
     
    568570        // Action for integration - ONLY if the filter above was not used
    569571        do_action( 'kuantokusta_process_product_meta_end', $post_id );
     572        // phpcs:enable
    570573    }
    571574
     
    583586    public function render_products_feed() {
    584587        define( 'KK_IS_FEED', true );
    585         @define( 'DONOTCACHEPAGE', true ); // Cache plugins
     588        if ( ! defined( 'DONOTCACHEPAGE' ) ) {
     589            define( 'DONOTCACHEPAGE', true ); // Cache plugins
     590        }
    586591        header( 'Content-Type: application/rss+xml; charset=utf-8' );
    587592        header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() - 86400 ) . ' GMT' ); // Yesterday
     
    589594        header( 'Cache-Control: post-check=0, pre-check=0', false );
    590595        header( 'Pragma: no-cache' );
    591         $offset         = intval( isset( $_GET['LIMIT'] ) ? $_GET['LIMIT'] : 0 );
    592         $posts_per_page = intval( isset( $_GET['TOTAL_PRODUTOS'] ) ? $_GET['TOTAL_PRODUTOS'] : -1 );
     596        // phpcs:disable WordPress.Security.NonceVerification.Recommended
     597        $offset         = isset( $_GET['LIMIT'] ) ? intval( $_GET['LIMIT'] ) : 0;
     598        $posts_per_page = isset( $_GET['TOTAL_PRODUTOS'] ) ? intval( $_GET['TOTAL_PRODUTOS'] ) : -1;
     599        // phpcs:enable
     600        ob_start();
    593601        do_action( 'kuantokusta_render_products_feed_start' );
    594         echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>
     602        echo '<?xml version="1.0" encoding="' . esc_attr( get_option( 'blog_charset' ) ) . '"?' . '>
    595603';
    596604        ?>
     
    602610        $sql_exclude = "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE ( meta_key = '_kuantokusta_hide' AND meta_value = 'yes' )";
    603611        // Debug and only include specific SKU
    604         if ( isset( $_GET['sku'] ) && trim( $_GET['sku'] ) != '' ) {
    605             $sql_exclude .= " || ( meta_key = '_sku' AND meta_value NOT LIKE '%" . sanitize_text_field( trim( $_GET['sku'] ) ) . "%' )";
    606         }
    607         $results = $wpdb->get_results( $sql_exclude, ARRAY_A );
     612        // phpcs:disable WordPress.Security.NonceVerification.Recommended
     613        if ( isset( $_GET['sku'] ) && trim( sanitize_text_field( wp_unslash( $_GET['sku'] ) ) ) !== '' ) {
     614            $sql_exclude .= " || ( meta_key = '_sku' AND meta_value NOT LIKE '%" . trim( sanitize_text_field( wp_unslash( $_GET['sku'] ) ) ) . "%' )";
     615        }
     616        // phpcs:enable
     617        $results = $wpdb->get_results( $sql_exclude, ARRAY_A ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
    608618        if ( ! empty( $results ) ) {
    609619            if ( count( $results ) > 0 ) {
     
    639649                                        if ( apply_filters( 'kuantokusta_variation_node_show', true, $product, $variation ) ) {
    640650                                            $product_node = $this->render_product_feed_variation( $product, $variation );
    641                                             echo apply_filters( 'kuantokusta_product_node_variation', $product_node, $product, $variation );
     651                                            // This is XML, so we cannot escape it
     652                                            echo apply_filters( 'kuantokusta_product_node_variation', $product_node, $product, $variation ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    642653                                        }
    643654                                    }
     
    647658                                    // Just like simple products
    648659                                    $product_node = $this->render_product_feed_default( $product, $product_type );
    649                                     echo apply_filters( 'kuantokusta_product_node_default', $product_node, $product, $product_type );
     660                                    // This is XML, so we cannot escape it
     661                                    echo apply_filters( 'kuantokusta_product_node_default', $product_node, $product, $product_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    650662                                    break;
    651663                            }
     
    653665                        default: // Including 'simple'
    654666                            $product_node = $this->render_product_feed_default( $product, $product_type );
    655                             echo apply_filters( 'kuantokusta_product_node_default', $product_node, $product, $product_type );
     667                            // This is XML, so we cannot escape it
     668                            echo apply_filters( 'kuantokusta_product_node_default', $product_node, $product, $product_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    656669                            break;
    657670                    }
     
    663676</products>
    664677        <?php
     678        // This is XML, so we cannot escape it
     679        // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
     680        $xml_string = ob_get_clean();
     681        if ( apply_filters( 'kuantokusta_prettify_xml', true ) && class_exists( 'DOMDocument' ) ) {
     682            libxml_use_internal_errors( true );
     683            $dom                     = new DOMDocument( '1.0', 'UTF-8' );
     684            $dom->preserveWhiteSpace = false; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     685            $dom->formatOutput       = true; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     686            $ok                      = $dom->loadXML( $xml_string, LIBXML_NOBLANKS | LIBXML_NOERROR | LIBXML_NOWARNING );
     687            if ( ! $ok ) {
     688                // If it fails, output the non-formatted XML and log the error
     689                error_log( 'KuantoKusta feed XML parsing errors:' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     690                foreach ( libxml_get_errors() as $error ) {
     691                    error_log( $error->message ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     692                    error_log( 'Line: ' . $error->line . ' Column: ' . $error->column ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     693                }
     694                libxml_clear_errors();
     695                echo $xml_string;
     696            }
     697            libxml_clear_errors();
     698            // Keep empty tags instead of self-closing tags, as we don't know if KuantoKusta accepts self-closing tags
     699            echo preg_replace( '/<(\w+)\/>/', '<$1></$1>', $dom->saveXML() );
     700        } else {
     701            echo $xml_string;
     702        }
     703        // phpcs:enable
    665704    }
    666705
     
    685724        $image         = apply_filters( 'kuantokusta_product_node_default_image', $this->get_product_image( $product ), $product, $product_type );
    686725        $description   = apply_filters( 'kuantokusta_product_node_default_description', $this->get_product_description( $product ), $product, $product_type );
    687 //      $brand         = apply_filters( 'kuantokusta_product_node_default_brand', $this->get_product_brand( $product ), $product, $product_type );
    688726        $ean           = apply_filters( 'kuantokusta_product_node_default_ean', $this->get_product_ean( $product ), $product, $product_type );
    689727        $reference     = apply_filters( 'kuantokusta_product_node_default_reference', $product->get_sku(), $product, $product_type );
     
    743781                'cdata' => true,
    744782            ),
    745 //          'brand'                    => array(
    746 //              'value' => trim( $brand ),
    747 //              'cdata' => true,
    748 //          ),
    749783            'upc_ean'                  => array(
    750784                'value'     => trim( $ean ),
     
    761795            ),
    762796            'shipping_cost'            => array(
    763                 'value'     => ( trim( $shipping_cost ) != '' && floatval( $shipping_cost ) >= 0 ) ? round( floatval( $shipping_cost ), wc_get_price_decimals() ) : '',
     797                'value'     => ( trim( $shipping_cost ) !== '' && floatval( $shipping_cost ) >= 0 ) ? round( floatval( $shipping_cost ), wc_get_price_decimals() ) : '',
    764798                'cdata'     => false,
    765799                'alias_key' => 'shipping',
    766800            ),
    767801        );
    768         if ( $this->mode == 'marketplace' ) {
     802        if ( $this->mode === 'marketplace' ) {
    769803            // Marketplace
    770804            unset( $xml_fields['stock'] );
     
    805839        foreach ( $xml_fields as $key => $value ) {
    806840            ?>
    807         <<?php echo $key; ?>><?php echo $value['cdata'] ? '<![CDATA[' . $value['value'] . ']]>' : $value['value']; ?></<?php echo $key; ?>>
     841        <<?php echo esc_attr( $key ); ?>><?php echo $value['cdata'] ? '<![CDATA[' . wp_kses_post( $value['value'] ) . ']]>' : esc_html( $value['value'] ); ?></<?php echo esc_attr( $key ); ?>>
    808842            <?php
    809843        }
     
    827861        $url          = $variation->get_permalink();
    828862        $title        = trim( apply_filters( 'kuantokusta_product_node_pre_variation_title', $variation->get_name(), $product, $variation ) );
    829         if ( trim( $title ) == '' ) {
     863        if ( trim( $title ) === '' ) {
    830864            $title = trim( $product->get_title() );
    831865        }
    832866        $reference = $variation->get_sku();
    833867        if ( apply_filters( 'kuantokusta_product_node_variation_title_append_description', true, $product, $variation ) ) {
    834             if ( trim( $variation->get_description() ) != '' ) {
     868            if ( trim( $variation->get_description() ) !== '' ) {
    835869                // Variation description
    836870                $title .= apply_filters( 'woocommerce_product_variation_title_attributes_separator', ' - ', $variation ) . trim( $variation->get_description() );
    837871            } elseif ( apply_filters( 'kuantokusta_product_node_variation_title_append_sku_or_id', true, $product, $variation ) ) {
    838                 if ( trim( $reference ) != '' ) {
     872                if ( trim( $reference ) !== '' ) {
    839873                    // Variation sku
    840874                    $title .= ' (' . trim( $reference ) . ')';
     
    855889        $image       = apply_filters( 'kuantokusta_product_node_variation_image', $this->get_product_variation_image( $product, $variation ), $product, $variation );
    856890        $description = apply_filters( 'kuantokusta_product_node_variation_description', $this->get_product_variation_description( $product, $variation ), $product, $variation );
    857 //      $brand       = apply_filters( 'kuantokusta_product_node_variation_brand', $this->get_product_brand( $product ), $product, $variation );
    858891        $ean         = apply_filters( 'kuantokusta_product_node_variation_ean', $this->get_product_ean( $product ), $product, $variation ); // On the free version we only read EAN from the main product
    859         if ( trim( $reference ) == '' ) {
     892        if ( trim( $reference ) === '' ) {
    860893            $reference = $product->get_sku();
    861894        }
    862895        $reference = apply_filters( 'kuantokusta_product_node_variation_reference', $reference, $product, $variation );
    863896        $weight    = $variation->get_weight();
    864         if ( floatval( $weight ) == 0 ) {
     897        if ( floatval( $weight ) === 0 ) {
    865898            $weight = $product->get_weight();
    866899        }
     
    920953                'cdata' => true,
    921954            ),
    922 //          'brand'                    => array(
    923 //              'value' => trim( $brand ),
    924 //              'cdata' => true,
    925 //          ),
    926955            'upc_ean'                  => array(
    927956                'value'     => trim( $ean ),
     
    938967            ),
    939968            'shipping_cost'            => array(
    940                 'value'     => ( trim( $shipping_cost ) != '' && floatval( $shipping_cost ) >= 0 ) ? round( floatval( $shipping_cost ), wc_get_price_decimals() ) : '',
     969                'value'     => ( trim( $shipping_cost ) !== '' && floatval( $shipping_cost ) >= 0 ) ? round( floatval( $shipping_cost ), wc_get_price_decimals() ) : '',
    941970                'cdata'     => false,
    942971                'alias_key' => 'shipping',
     
    9821011        foreach ( $xml_fields as $key => $value ) {
    9831012            ?>
    984         <<?php echo $key; ?>><?php echo $value['cdata'] ? '<![CDATA[' . $value['value'] . ']]>' : $value['value']; ?></<?php echo $key; ?>>
     1013        <<?php echo esc_attr( $key ); ?>><?php echo $value['cdata'] ? '<![CDATA[' . wp_kses_post( $value['value'] ) . ']]>' : esc_html( $value['value'] ); ?></<?php echo esc_attr( $key ); ?>>
    9851014            <?php
    9861015        }
     
    10301059     */
    10311060    public function get_product_description( $product ) {
    1032         if ( $this->get_setting( 'description_type' ) == 'full' ) {
     1061        if ( $this->get_setting( 'description_type' ) === 'full' ) {
    10331062            $description = trim( $product->get_description() );
    1034             if ( trim( $description ) == '' ) {
     1063            if ( trim( $description ) === '' ) {
    10351064                $description = trim( $product->get_short_description() );
    10361065            }
     
    10381067            $description = trim( $product->get_short_description() );
    10391068        }
    1040         if ( trim( $description ) == '' ) {
     1069        if ( trim( $description ) === '' ) {
    10411070            $description = trim( $product->get_title() );
    10421071        }
     
    10441073        return wpautop( $description );
    10451074    }
     1075
     1076    /**
     1077     * Get the product variation description
     1078     *
     1079     * @param WC_Product           $product   The product object.
     1080     * @param WC_Product_Variation $variation The variation object.
     1081     * @return string The product variation description.
     1082     */
    10461083    public function get_product_variation_description( $product, $variation ) {
    10471084        $product_description   = $this->get_product_description( $product );
     
    11311168                case 'parent':
    11321169                    return $this->get_comparison_product_stock( $product );
    1133                     break;
    11341170                default: // ???
    11351171                    return '';
    1136                     break;
    11371172            }
    11381173        }
     
    11631198                case 'parent':
    11641199                    return $this->get_marketplace_product_stock( $product );
    1165                     break;
    11661200                default: // ???
    11671201                    return '';
    1168                     break;
    11691202            }
    11701203        }
     
    11811214        $shipping_cost = $product->get_meta( '_kuantokusta_shipping' );
    11821215        // We do not use empty() because the shop owner might want to offer free shipping
    1183         if ( trim( $shipping_cost ) == '' ) {
     1216        if ( trim( $shipping_cost ) === '' ) {
    11841217            $shipping_cost = $this->get_setting( 'shipping_cost_default' );
    11851218        }
  • feed-kuantokusta-for-woocommerce/trunk/readme.txt

    r3444190 r3482456  
    33Tags: marketplace, feed, comparison, e-commerce, Portugal
    44Requires at least: 6.2
    5 Tested up to: 6.8
     5Tested up to: 7.0
    66Requires PHP: 7.2
    7 Stable tag: 5.1
     7Stable tag: 5.2
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    121121== Changelog ==
    122122
     123= 5.2 - 2026-03-14 =
     124
     125* [TWEAK] XML output is now prettified (can be disabled by returning `false` to the `kuantokusta_prettify_xml` filter)
     126* [DEV] New updater v13.1I [Pro add-on](https://nakedcatplugins.com/product/feed-kuantokusta-for-woocommerce-pro/?utm_source=wordpress.org&utm_medium=link&utm_campaign=kk_woocommerce_plugin)
     127* [DEV] Enforce hooks to be initialized only if the license is activeI [Pro add-on](https://nakedcatplugins.com/product/feed-kuantokusta-for-woocommerce-pro/?utm_source=wordpress.org&utm_medium=link&utm_campaign=kk_woocommerce_plugin)
     128* [DEV] Enforce WordPress Coding Standards on all the codebase
     129* [DEV] Update GitHub actions
     130* [DEV] Tested with WordPress 7.0-beta5-61992 and WooCommerce 10.6.1
     131
    123132= 5.1 - 2026-01-21 =
    124133* [FIX] Plugin license validation when running in WP CLI [Pro add-on](https://nakedcatplugins.com/product/feed-kuantokusta-for-woocommerce-pro/?utm_source=wordpress.org&utm_medium=link&utm_campaign=kk_woocommerce_plugin)
Note: See TracChangeset for help on using the changeset viewer.