Plugin Directory

Changeset 3831643


Ignore:
Timestamp:
11/28/2026 02:54:27 PM (less than one hour ago)
Author:
spyrosvl
Message:

Release 1.7.4: wishlist button on out-of-stock product pages and in Product Collection blocks; block context and editor preview; readme video

Location:
nitroweb-amazing-wishlist-for-woocommerce
Files:
2 added
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • nitroweb-amazing-wishlist-for-woocommerce/tags/1.7.4/assets/css/nawfw-frontend.css

    r3829857 r3831643  
    110110}
    111111
     112/* Product pages without an Add to Cart button (out of stock, not purchasable). */
     113.nawfw-product-page-button {
     114        margin: 0 0 1em;
     115}
     116
     117.nawfw-product-page-button .nawfw-add-button,
     118.nawfw-block-loop-button .nawfw-add-button {
     119        margin-left: 0;
     120}
     121
     122/* Product Collection blocks (related products, grids on pages). */
     123.nawfw-block-loop-button {
     124        margin-top: 8px;
     125}
     126
     127.wc-block-components-product-image:has(> .nawfw-on-image-wrap) {
     128        position: relative;
     129}
     130
    112131/* --------------------------------------------------------------------------
    113132   "Icon Only in Loop"
  • nitroweb-amazing-wishlist-for-woocommerce/tags/1.7.4/assets/js/nawfw-blocks.js

    r3829857 r3831643  
    4242                        variationId: { type: 'number', default: 0 }
    4343                },
     44                usesContext: [ 'postId', 'postType' ],
    4445                edit: function ( props ) {
    4546                        var attributes = props.attributes;
    … …  
    7576                                el( ServerSideRender, {
    7677                                        block: 'nawfw/add-to-wishlist-button',
    77                                         attributes: attributes
     78                                        attributes: attributes,
     79                                        // Product of the block context (e.g. a product card in a Product Collection).
     80                                        urlQueryArgs: props.context && props.context.postId ? { post_id: props.context.postId } : {}
    7881                                } )
    7982                        );
  • nitroweb-amazing-wishlist-for-woocommerce/tags/1.7.4/includes/class-nawfw-blocks.php

    r3829857 r3831643  
    5050                                        ),
    5151                                ),
     52                                'uses_context'    => array( 'postId', 'postType' ),
    5253                                'render_callback' => array( __CLASS__, 'render_button_block' ),
    5354                        )
    … …  
    8384         * Render button block.
    8485         *
    85          * @param array $attributes Attributes.
     86         * The product is the one set in the block settings, else the product of the
     87         * block context (product card in a Product Collection, product template),
     88         * else the current post.
     89         *
     90         * @param array         $attributes Attributes.
     91         * @param string        $content    Inner content (unused).
     92         * @param WP_Block|null $block      Block instance.
    8693         * @return string
    8794         */
    88         public static function render_button_block( array $attributes = array() ): string {
    89                 $product_id   = ! empty( $attributes['productId'] ) ? (int) $attributes['productId'] : (int) get_the_ID();
     95        public static function render_button_block( array $attributes = array(), $content = '', $block = null ): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found -- Block render callback signature.
    9096                $variation_id = ! empty( $attributes['variationId'] ) ? (int) $attributes['variationId'] : 0;
     97                $product_id   = ! empty( $attributes['productId'] ) ? (int) $attributes['productId'] : 0;
     98
     99                if ( ! $product_id && $block instanceof WP_Block && ! empty( $block->context['postId'] ) ) {
     100                        $product_id = (int) $block->context['postId'];
     101                }
     102                if ( ! $product_id ) {
     103                        $product_id = (int) get_the_ID();
     104                }
     105                if ( $product_id && 'product' !== get_post_type( $product_id ) && 'product_variation' !== get_post_type( $product_id ) ) {
     106                        $product_id = 0;
     107                }
     108
     109                // Block editor preview without a product (e.g. a template in the Site Editor):
     110                // show the button of a sample product, so it can be seen and styled.
     111                if ( ! $product_id && self::is_editor_preview() ) {
     112                        $sample     = wc_get_products(
     113                                array(
     114                                        'status' => 'publish',
     115                                        'limit'  => 1,
     116                                        'return' => 'ids',
     117                                )
     118                        );
     119                        $product_id = $sample ? (int) $sample[0] : 0;
     120                }
    91121
    92122                if ( ! $product_id ) {
    … …  
    96126                return NAWFW_Shortcodes::render_button( $product_id, $variation_id );
    97127        }
     128
     129        /**
     130         * Whether the block is being rendered for the block editor preview.
     131         */
     132        private static function is_editor_preview(): bool {
     133                return defined( 'REST_REQUEST' ) && REST_REQUEST && current_user_can( 'edit_posts' ) && function_exists( 'wc_get_products' );
     134        }
    98135}
  • nitroweb-amazing-wishlist-for-woocommerce/tags/1.7.4/includes/class-nawfw-plugin.php

    r3829857 r3831643  
    7878                require_once NAWFW_PATH . 'includes/class-nawfw-wpml.php';
    7979                require_once NAWFW_PATH . 'includes/class-nawfw-blocks.php';
     80                require_once NAWFW_PATH . 'includes/class-nawfw-block-placement.php';
    8081                require_once NAWFW_PATH . 'includes/class-nawfw-elementor.php';
    8182                require_once NAWFW_PATH . 'includes/class-nawfw-nav-menu.php';
    … …  
    100101                NAWFW_WPML::init();
    101102                NAWFW_Blocks::init();
     103                NAWFW_Block_Placement::init();
    102104                NAWFW_Elementor::init();
    103105                NAWFW_Nav_Menu::init();
  • nitroweb-amazing-wishlist-for-woocommerce/tags/1.7.4/includes/class-nawfw-shortcodes.php

    r3829857 r3831643  
    218218                $variation_id = $product->is_type( 'variation' ) ? $product_id : 0;
    219219
     220                NAWFW_Block_Placement::mark_product_page_button( $product_id );
     221                if ( $product->get_parent_id() ) {
     222                        NAWFW_Block_Placement::mark_product_page_button( $product->get_parent_id() );
     223                }
     224
    220225                echo wp_kses( self::render_button( $product_id, $variation_id ), nawfw_allowed_wishlist_html() );
    221226        }
    … …  
    242247                }
    243248                echo '<span class="nawfw-on-image-wrap">' . wp_kses( self::apply_loop_icon_only_class( self::render_button( $product->get_id(), 0 ) ), nawfw_allowed_wishlist_html() ) . '</span>';
     249        }
     250
     251        /**
     252         * Loop (product card) button markup for a product, with the icon-only class applied.
     253         *
     254         * @param int $product_id Product ID.
     255         */
     256        public static function loop_button_html( int $product_id ): string {
     257                return self::apply_loop_icon_only_class( self::render_button( $product_id, 0 ) );
    244258        }
    245259
  • nitroweb-amazing-wishlist-for-woocommerce/tags/1.7.4/nitroweb-amazing-wishlist-for-woocommerce.php

    r3829857 r3831643  
    33 * Plugin Name: Nitroweb Amazing Wishlist for WooCommerce
    44 * Description: Wishlist plugin for WooCommerce with guest support, AJAX interactions, sharing, price-drop and back-in-stock alerts, and WPML support.
    5  * Version: 1.7.3
     5 * Version: 1.7.4
    66 * Author: Nitroweb
    77 * Author URI: https://nitroweb.gr/
    … …  
    3838define( 'NAWFW_LOADED', __FILE__ );
    3939
    40 define( 'NAWFW_VERSION', '1.7.3' );
     40define( 'NAWFW_VERSION', '1.7.4' );
    4141define( 'NAWFW_FILE', __FILE__ );
    4242define( 'NAWFW_PATH', plugin_dir_path( __FILE__ ) );
  • nitroweb-amazing-wishlist-for-woocommerce/tags/1.7.4/readme.txt

    r3829857 r3831643  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.7.3
     7Stable tag: 1.7.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    1919[Free plugin documentation](https://amazingwpplugins.com/documentation/nitroweb-amazing-wishlist-for-woocommerce-free-plugin-documentation/) covers setup, shortcodes, sharing, alerts, and troubleshooting.
    2020
     21https://youtu.be/okFDvATpMJ4
     22
    2123= Core Wishlist Features =
    2224
    2325* **Add to Wishlist** button on single product pages and shop/archive loops
     26* Works with block themes: the button is added automatically to Product Collection blocks too (related products, product grids on any page), and to product pages without an Add to Cart button (out of stock or not purchasable)
    2427* Configurable button position: after Add to Cart, overlaid on the product image, icon-only, or fully manual placement
    2528* Customizable button text, icon (heart, bookmark, star, or none), and colours (text, border, background — including hover states)
    … …  
    119122== Changelog ==
    120123
     124= 1.7.4 — 27 Nov 2026 =
     125* New: The button appears on product pages without an Add to Cart button (out of stock or not purchasable), with classic and block-based product templates.
     126* New: Product Collection blocks outside the shop templates (related products on block-based product pages, product grids on any page) get the button automatically, following the "Show on Loop" and "Loop Button Position" settings. Cards where the Add to Wishlist Button block was placed by hand are left as they are.
     127* New: The Add to Wishlist Button block picks up the product from its block context (for example a product card in a Product Collection), and the editor preview shows the button even in templates without a product.
     128
    121129= 1.7.3 =
    122130* Escape wishlist buttons, icons, product images, and prices when rendering.
    … …  
    159167== Upgrade Notice ==
    160168
     169= 1.7.4 =
     170Adds the button to out-of-stock product pages and to Product Collection blocks (related products, product grids).
     171
    161172= 1.7.3 =
    162173Updates wishlist output escaping and uses WordPress.org language packs.
  • nitroweb-amazing-wishlist-for-woocommerce/trunk/assets/css/nawfw-frontend.css

    r3829857 r3831643  
    110110}
    111111
     112/* Product pages without an Add to Cart button (out of stock, not purchasable). */
     113.nawfw-product-page-button {
     114        margin: 0 0 1em;
     115}
     116
     117.nawfw-product-page-button .nawfw-add-button,
     118.nawfw-block-loop-button .nawfw-add-button {
     119        margin-left: 0;
     120}
     121
     122/* Product Collection blocks (related products, grids on pages). */
     123.nawfw-block-loop-button {
     124        margin-top: 8px;
     125}
     126
     127.wc-block-components-product-image:has(> .nawfw-on-image-wrap) {
     128        position: relative;
     129}
     130
    112131/* --------------------------------------------------------------------------
    113132   "Icon Only in Loop"
  • nitroweb-amazing-wishlist-for-woocommerce/trunk/assets/js/nawfw-blocks.js

    r3829857 r3831643  
    4242                        variationId: { type: 'number', default: 0 }
    4343                },
     44                usesContext: [ 'postId', 'postType' ],
    4445                edit: function ( props ) {
    4546                        var attributes = props.attributes;
    … …  
    7576                                el( ServerSideRender, {
    7677                                        block: 'nawfw/add-to-wishlist-button',
    77                                         attributes: attributes
     78                                        attributes: attributes,
     79                                        // Product of the block context (e.g. a product card in a Product Collection).
     80                                        urlQueryArgs: props.context && props.context.postId ? { post_id: props.context.postId } : {}
    7881                                } )
    7982                        );
  • nitroweb-amazing-wishlist-for-woocommerce/trunk/includes/class-nawfw-blocks.php

    r3829857 r3831643  
    5050                                        ),
    5151                                ),
     52                                'uses_context'    => array( 'postId', 'postType' ),
    5253                                'render_callback' => array( __CLASS__, 'render_button_block' ),
    5354                        )
    … …  
    8384         * Render button block.
    8485         *
    85          * @param array $attributes Attributes.
     86         * The product is the one set in the block settings, else the product of the
     87         * block context (product card in a Product Collection, product template),
     88         * else the current post.
     89         *
     90         * @param array         $attributes Attributes.
     91         * @param string        $content    Inner content (unused).
     92         * @param WP_Block|null $block      Block instance.
    8693         * @return string
    8794         */
    88         public static function render_button_block( array $attributes = array() ): string {
    89                 $product_id   = ! empty( $attributes['productId'] ) ? (int) $attributes['productId'] : (int) get_the_ID();
     95        public static function render_button_block( array $attributes = array(), $content = '', $block = null ): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found -- Block render callback signature.
    9096                $variation_id = ! empty( $attributes['variationId'] ) ? (int) $attributes['variationId'] : 0;
     97                $product_id   = ! empty( $attributes['productId'] ) ? (int) $attributes['productId'] : 0;
     98
     99                if ( ! $product_id && $block instanceof WP_Block && ! empty( $block->context['postId'] ) ) {
     100                        $product_id = (int) $block->context['postId'];
     101                }
     102                if ( ! $product_id ) {
     103                        $product_id = (int) get_the_ID();
     104                }
     105                if ( $product_id && 'product' !== get_post_type( $product_id ) && 'product_variation' !== get_post_type( $product_id ) ) {
     106                        $product_id = 0;
     107                }
     108
     109                // Block editor preview without a product (e.g. a template in the Site Editor):
     110                // show the button of a sample product, so it can be seen and styled.
     111                if ( ! $product_id && self::is_editor_preview() ) {
     112                        $sample     = wc_get_products(
     113                                array(
     114                                        'status' => 'publish',
     115                                        'limit'  => 1,
     116                                        'return' => 'ids',
     117                                )
     118                        );
     119                        $product_id = $sample ? (int) $sample[0] : 0;
     120                }
    91121
    92122                if ( ! $product_id ) {
    … …  
    96126                return NAWFW_Shortcodes::render_button( $product_id, $variation_id );
    97127        }
     128
     129        /**
     130         * Whether the block is being rendered for the block editor preview.
     131         */
     132        private static function is_editor_preview(): bool {
     133                return defined( 'REST_REQUEST' ) && REST_REQUEST && current_user_can( 'edit_posts' ) && function_exists( 'wc_get_products' );
     134        }
    98135}
  • nitroweb-amazing-wishlist-for-woocommerce/trunk/includes/class-nawfw-plugin.php

    r3829857 r3831643  
    7878                require_once NAWFW_PATH . 'includes/class-nawfw-wpml.php';
    7979                require_once NAWFW_PATH . 'includes/class-nawfw-blocks.php';
     80                require_once NAWFW_PATH . 'includes/class-nawfw-block-placement.php';
    8081                require_once NAWFW_PATH . 'includes/class-nawfw-elementor.php';
    8182                require_once NAWFW_PATH . 'includes/class-nawfw-nav-menu.php';
    … …  
    100101                NAWFW_WPML::init();
    101102                NAWFW_Blocks::init();
     103                NAWFW_Block_Placement::init();
    102104                NAWFW_Elementor::init();
    103105                NAWFW_Nav_Menu::init();
  • nitroweb-amazing-wishlist-for-woocommerce/trunk/includes/class-nawfw-shortcodes.php

    r3829857 r3831643  
    218218                $variation_id = $product->is_type( 'variation' ) ? $product_id : 0;
    219219
     220                NAWFW_Block_Placement::mark_product_page_button( $product_id );
     221                if ( $product->get_parent_id() ) {
     222                        NAWFW_Block_Placement::mark_product_page_button( $product->get_parent_id() );
     223                }
     224
    220225                echo wp_kses( self::render_button( $product_id, $variation_id ), nawfw_allowed_wishlist_html() );
    221226        }
    … …  
    242247                }
    243248                echo '<span class="nawfw-on-image-wrap">' . wp_kses( self::apply_loop_icon_only_class( self::render_button( $product->get_id(), 0 ) ), nawfw_allowed_wishlist_html() ) . '</span>';
     249        }
     250
     251        /**
     252         * Loop (product card) button markup for a product, with the icon-only class applied.
     253         *
     254         * @param int $product_id Product ID.
     255         */
     256        public static function loop_button_html( int $product_id ): string {
     257                return self::apply_loop_icon_only_class( self::render_button( $product_id, 0 ) );
    244258        }
    245259
  • nitroweb-amazing-wishlist-for-woocommerce/trunk/nitroweb-amazing-wishlist-for-woocommerce.php

    r3829857 r3831643  
    33 * Plugin Name: Nitroweb Amazing Wishlist for WooCommerce
    44 * Description: Wishlist plugin for WooCommerce with guest support, AJAX interactions, sharing, price-drop and back-in-stock alerts, and WPML support.
    5  * Version: 1.7.3
     5 * Version: 1.7.4
    66 * Author: Nitroweb
    77 * Author URI: https://nitroweb.gr/
    … …  
    3838define( 'NAWFW_LOADED', __FILE__ );
    3939
    40 define( 'NAWFW_VERSION', '1.7.3' );
     40define( 'NAWFW_VERSION', '1.7.4' );
    4141define( 'NAWFW_FILE', __FILE__ );
    4242define( 'NAWFW_PATH', plugin_dir_path( __FILE__ ) );
  • nitroweb-amazing-wishlist-for-woocommerce/trunk/readme.txt

    r3829857 r3831643  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.7.3
     7Stable tag: 1.7.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    1919[Free plugin documentation](https://amazingwpplugins.com/documentation/nitroweb-amazing-wishlist-for-woocommerce-free-plugin-documentation/) covers setup, shortcodes, sharing, alerts, and troubleshooting.
    2020
     21https://youtu.be/okFDvATpMJ4
     22
    2123= Core Wishlist Features =
    2224
    2325* **Add to Wishlist** button on single product pages and shop/archive loops
     26* Works with block themes: the button is added automatically to Product Collection blocks too (related products, product grids on any page), and to product pages without an Add to Cart button (out of stock or not purchasable)
    2427* Configurable button position: after Add to Cart, overlaid on the product image, icon-only, or fully manual placement
    2528* Customizable button text, icon (heart, bookmark, star, or none), and colours (text, border, background — including hover states)
    … …  
    119122== Changelog ==
    120123
     124= 1.7.4 — 27 Nov 2026 =
     125* New: The button appears on product pages without an Add to Cart button (out of stock or not purchasable), with classic and block-based product templates.
     126* New: Product Collection blocks outside the shop templates (related products on block-based product pages, product grids on any page) get the button automatically, following the "Show on Loop" and "Loop Button Position" settings. Cards where the Add to Wishlist Button block was placed by hand are left as they are.
     127* New: The Add to Wishlist Button block picks up the product from its block context (for example a product card in a Product Collection), and the editor preview shows the button even in templates without a product.
     128
    121129= 1.7.3 =
    122130* Escape wishlist buttons, icons, product images, and prices when rendering.
    … …  
    159167== Upgrade Notice ==
    160168
     169= 1.7.4 =
     170Adds the button to out-of-stock product pages and to Product Collection blocks (related products, product grids).
     171
    161172= 1.7.3 =
    162173Updates wishlist output escaping and uses WordPress.org language packs.
Note: See TracChangeset for help on using the changeset viewer.