Plugin Directory

Changeset 3343442


Ignore:
Timestamp:
08/12/2025 10:27:51 AM (6 months ago)
Author:
rwky
Message:

small patch for Rank Math Pro setups

Location:
garantie-sgr/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • garantie-sgr/trunk/garantie-sgr.php

    r3343431 r3343442  
    44 * Plugin URL: https://uprise.ro
    55 * Description: Extensie WooCommerce pentru sistemul garanție-returnare SGR.
    6  * Version: 2.0.2
     6 * Version: 2.0.3
    77 * Author: Eduard V. Doloc
    88 * Author URI: https://uprise.ro
     
    1212 * WC requires at least: 7.9
    1313 * WC tested up to: 10.0
    14  * Stable tag: 2.0.2
     14 * Stable tag: 2.0.3
    1515 * Requires Plugins: woocommerce
    1616 * License: GPLv2 or later
     
    123123        'post_type'   => 'product',
    124124        'post_status' => 'publish',
    125         // Ensure product type exists *during* save_post so wc_get_product() works
    126125        'tax_input'   => array(
    127126            'product_type' => array( 'simple' ),
     
    134133    }
    135134
    136     // Core Woo metas (no HTML, so sanitize_text_field is fine for scalar metas)
     135    // Core Woo metas
    137136    update_post_meta( $product_id, '_sku', $sgr_sku );
    138137    update_post_meta( $product_id, '_price', '0.50' );
     
    144143    // Hide from catalog (product_visibility term)
    145144    if ( taxonomy_exists( 'product_visibility' ) ) {
    146         // Don’t touch other terms, just add exclude-from-catalog
    147145        wp_set_object_terms( $product_id, 'exclude-from-catalog', 'product_visibility', true );
    148146    }
     
    174172
    175173// Update path / repairs when users update without re-activating.
    176 // Run only after WooCommerce is fully initialized.
    177174add_action( 'woocommerce_init', function () {
    178175    if ( ! class_exists( 'WC_Product_Simple' ) || ! function_exists( 'wc_get_product_id_by_sku' ) ) {
     
    186183    $needs = false;
    187184
    188     // If activation set a pending flag, run now.
    189185    if ( $pending_setup ) {
    190186        $needs = true;
    191187    }
    192 
    193     // On version change or missing product ID, run now.
    194188    if ( $stored_version !== GARANTIE_SGR_VERSION ) {
    195189        $needs = true;
     
    200194
    201195    if ( $needs ) {
    202         garantie_sgr_product_create();
    203         update_option( 'garantie_sgr_version', GARANTIE_SGR_VERSION );
    204         delete_option( 'garantie_sgr_pending_setup' );
     196        // Defer actual creation until after Woo has fully initialized.
     197        add_action( 'wp_loaded', function () {
     198            $created_id = garantie_sgr_product_create();
     199            if ( $created_id ) {
     200                update_option( 'garantie_sgr_version', GARANTIE_SGR_VERSION );
     201                delete_option( 'garantie_sgr_pending_setup' );
     202            }
     203        }, 20 );
    205204    }
    206205}, 20 );
  • garantie-sgr/trunk/readme.txt

    r3343431 r3343442  
    88WC requires at least: 7.9
    99WC tested up to: 10.0
    10 Stable tag: 2.0.2
     10Stable tag: 2.0.3
    1111Requires Plugins: woocommerce
    1212License: GPLv2 or later
Note: See TracChangeset for help on using the changeset viewer.