Plugin Directory

Changeset 3198074


Ignore:
Timestamp:
11/27/2024 11:01:14 AM (15 months ago)
Author:
dillerapp
Message:

Fixes issue with inline scripts rendering between block-based and standard themes.

Location:
diller-loyalty/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • diller-loyalty/trunk/README.txt

    r3181696 r3198074  
    44Requires at least: 4.7
    55Tested up to: 6.6.0
    6 Version: 2.4.5
    7 Stable tag: 2.4.5
     6Version: 2.4.6
     7Stable tag: 2.4.6
    88Requires PHP: 7.3
    99WC requires at least: 3.8.0
     
    6363
    6464== Changelog ==
     65= 2.4.6 =
     66* Resolves issue with inline scripts rendering between block-based and standard themes.
     67
    6568= 2.4.5 =
    6669* Resolve incorrect WP_User/Diller Member association on order completion via REST API, when called by an external automation process.
  • diller-loyalty/trunk/assets/css/diller-loyalty-bundle-public.css

    r3121966 r3198074  
    660660/* FORMS */
    661661/*============================================================================================*/
     662.diller-form input[type=tel] {
     663  width: calc(100% - 10px - 10px);
     664}
     665.diller-form .iti > input[type=tel] {
     666  width: 100%;
     667}
    662668.diller-form input[type=text],
    663669.diller-form input[type=email],
     
    666672.diller-form input[type=number],
    667673.diller-form input[type=tel],
    668 .diller-form input[type=date],
    669 .diller-form input[type=month],
    670 .diller-form input[type=week],
    671 .diller-form input[type=time],
    672 .diller-form input[type=datetime],
    673 .diller-form input[type=datetime-local],
    674 .diller-form input[type=color],
    675 .diller-form textarea {
    676   width: 100%;
    677 }
    678 .diller-form input[type=text],
    679 .diller-form input[type=email],
    680 .diller-form input[type=url],
    681 .diller-form input[type=password],
    682 .diller-form input[type=number],
    683674.diller-form select {
    684675  padding: 10px;
  • diller-loyalty/trunk/diller-loyalty.php

    r3181696 r3198074  
    66 * Plugin URI:           https://diller.no/
    77 * Description:          Diller is a loyalty platform for businesses that is easy, affordable and profitable and integrates seamlessly with your WooCommerce shop.
    8  * Version:              2.4.5
     8 * Version:              2.4.6
    99 * Author:               Diller AS
    1010 * Author URI:           https://diller.no/kontakt/
     
    1313 * Text Domain:          diller-loyalty
    1414 * Domain Path:          /languages
    15  * Stable tag:           2.4.5
     15 * Stable tag:           2.4.6
    1616 * Requires at least:    4.7
    1717 * Tested up to:         6.6.2
     
    3131// Start at version 2.0.0 and use SemVer - https://semver.org
    3232if ( ! defined( 'DILLER_LOYALTY_VERSION' ) ) {
    33     define('DILLER_LOYALTY_VERSION', '2.4.5');
     33    define('DILLER_LOYALTY_VERSION', '2.4.6');
    3434}
    3535
     
    8686}
    8787
     88if ( ! defined( 'DILLER_LOYALTY_JS_BUNDLE_PUBLIC_HANDLE' ) ) {
     89    define( 'DILLER_LOYALTY_JS_BUNDLE_PUBLIC_HANDLE', 'diller-loyalty-public-bundle');
     90}
     91
     92if ( ! defined( 'DILLER_LOYALTY_INLINE_SCRIPTS_HANDLE' ) ) {
     93    define( 'DILLER_LOYALTY_INLINE_SCRIPTS_HANDLE', 'diller-loyalty-inline-scripts');
     94}
    8895
    8996// Load plugin Activation/Deactivation code only for admin
  • diller-loyalty/trunk/includes/class-diller-loyalty-woocommerce.php

    r3181696 r3198074  
    751751        $js_params->form->validationRulesTexts->phonenumber = esc_html__("You must enter a valid mobile number", "diller-loyalty");
    752752
    753         wp_add_inline_script(DILLER_LOYALTY_JS_VENDORS_BUNDLE_HANDLE, "window.Diller_Loyalty = Object.assign({}, window.Diller_Loyalty, " . json_encode($js_params) .");", 'before' );
     753
     754        // For classic themes (e.g. Twenty Twenty-One)
     755        if(!wp_is_block_theme()){
     756            wp_add_inline_script(DILLER_LOYALTY_JS_VENDORS_BUNDLE_HANDLE, "window.Diller_Loyalty = Object.assign({}, window.Diller_Loyalty, " . json_encode($js_params) .");", 'before' );
     757            return $fields;
     758        }
     759
     760        // For "Full-site-editing (FSE) / Block" theme (e.g. Twenty Twenty-Two, Twenty Twenty-Four, etc)
     761        wp_register_script( DILLER_LOYALTY_INLINE_SCRIPTS_HANDLE, false );
     762        wp_enqueue_script( DILLER_LOYALTY_INLINE_SCRIPTS_HANDLE, false, array(DILLER_LOYALTY_JS_BUNDLE_PUBLIC_HANDLE) );
     763        wp_add_inline_script(DILLER_LOYALTY_INLINE_SCRIPTS_HANDLE, "window.Diller_Loyalty = Object.assign({}, window.Diller_Loyalty, " . json_encode($js_params) .");", 'before' );
    754764
    755765        return $fields;
  • diller-loyalty/trunk/includes/class-diller-loyalty.php

    r3181696 r3198074  
    610610
    611611    /**
    612      * Register all of the shortcodes related to the public-facing functionality
     612     * Register all the shortcodes related to the public-facing functionality
    613613     * of the plugin.
    614614     *
     
    626626        }
    627627
    628         foreach ($short_code_forms as $index => $sc_form){
     628        foreach ($short_code_forms as $sc_form){
    629629            $this->loader->register_shortcode( $sc_form->short_code_name, $sc_form, 'render' );
    630630
    631             // Enqueues scripts and styles.
    632             $this->loader->add_action( 'wp_enqueue_scripts', $sc_form, 'enqueue_styles');
    633             $this->loader->add_action( 'wp_enqueue_scripts', $sc_form, 'enqueue_scripts');
    634         }
    635     }
    636 
    637 
    638     /**
    639      * Register all of the hooks related to the public-facing functionality
     631            // Enqueue scripts and styles based on the type of the theme
     632            // Ref: https://core.trac.wordpress.org/ticket/54958#comment:9
     633            if(wp_is_block_theme()){
     634                // "Full-site-editing (FSE) / Block" theme (e.g. Twenty Twenty-Two, Twenty Twenty-Four, etc)
     635                add_action('wp_enqueue_scripts', function() use ($sc_form){
     636                    $sc_form->enqueue_scripts();
     637                    $sc_form->enqueue_styles();
     638                });
     639            }
     640            else{
     641                // Enqueues scripts and styles for Classic themes
     642                $this->loader->add_action( 'wp_enqueue_scripts', $sc_form, 'enqueue_styles');
     643                $this->loader->add_action( 'wp_enqueue_scripts', $sc_form, 'enqueue_scripts');
     644            }
     645        }
     646    }
     647
     648
     649    /**
     650     * Register all the hooks related to the public-facing functionality
    640651     * of the plugin.
    641652     *
  • diller-loyalty/trunk/includes/forms/class-diller-enrollment-form.php

    r3121966 r3198074  
    525525    }
    526526
    527 
    528     // Implements the abstract function from the trait, by calling
    529     public function get_inline_javascript_params() {
    530         return parent::get_inline_javascript_params();
    531     }
    532 
    533527    /**
    534528     * Checks for values passed in via query string that match 1 or more segments
  • diller-loyalty/trunk/includes/forms/class-diller-form.php

    r3043067 r3198074  
    135135
    136136        if(sizeof($this->inline_scripts) > 0){
    137             // Handle arg. defines where will the inline scripts be placed
    138             //wp_register_script( 'diller-loyalty-scripts', false );
    139             //wp_enqueue_script( 'diller-loyalty-scripts' );
    140             wp_add_inline_script(DILLER_LOYALTY_JS_VENDORS_BUNDLE_HANDLE, join(PHP_EOL, $this->inline_scripts), 'before' );
     137
     138            // For classic themes (e.g. Twenty Twenty-One)
     139            if(!wp_is_block_theme()){
     140                wp_add_inline_script(DILLER_LOYALTY_JS_BUNDLE_PUBLIC_HANDLE, join(PHP_EOL, $this->inline_scripts), 'before' );
     141                return;
     142            }
     143
     144            // For "Full-site-editing (FSE) / Block" theme (e.g. Twenty Twenty-Two, Twenty Twenty-Four, etc)
     145            wp_register_script( DILLER_LOYALTY_INLINE_SCRIPTS_HANDLE, false );
     146            wp_enqueue_script( DILLER_LOYALTY_INLINE_SCRIPTS_HANDLE, false, array(DILLER_LOYALTY_JS_BUNDLE_PUBLIC_HANDLE) );
     147            wp_add_inline_script(DILLER_LOYALTY_INLINE_SCRIPTS_HANDLE, join(PHP_EOL, $this->inline_scripts), 'before' );
    141148        }
    142149    }
  • diller-loyalty/trunk/includes/forms/class-diller-wc-enrollment-form.php

    r3043067 r3198074  
    189189        $this->inline_scripts[] = "window.Diller_Loyalty.modal = " . json_encode($modal_params) .";";
    190190    }
    191 
    192 
    193     // Overrides the parents function
    194     public function get_inline_javascript_params() {
    195         return parent::get_inline_javascript_params();
    196     }
    197191}
  • diller-loyalty/trunk/includes/shortcodes/class-diller-enrollment-form-shortcode.php

    r3043067 r3198074  
    3636
    3737            if ($this->form->was_submitted() && $this->form->request_validated() && $this->form->save()) {
    38                 DillerLoyalty()->display_notices( $this->form->get_id(), false );
    39                 return;
     38                return DillerLoyalty()->display_notices( $this->form->get_id(), true );
    4039            }
     40
     41            // Use ob_start() to Control Output Timing and preventing from printing the content too early
     42            ob_start();
    4143            $this->form->render();
     44            return ob_get_clean();
    4245
    4346        endif;
  • diller-loyalty/trunk/includes/shortcodes/class-diller-refer-friend-shortcode.php

    r3043067 r3198074  
    1919        $this->form->build_fields();
    2020
    21         if ($this->form->was_submitted() && $this->form->request_validated()):
    22             $this->form->save()
    23                 ? DillerLoyalty()->display_notices($this->form->get_id(), false)
    24                 : $this->form->render();
    25         else:
    26             $this->form->render();
     21        if ($this->form->was_submitted() && $this->form->request_validated() && $this->form->save()):
     22            return DillerLoyalty()->display_notices($this->form->get_id(), false);
    2723        endif;
     24
     25        // Use ob_start() to Control Output Timing and preventing from printing the content too early
     26        ob_start();
     27        $this->form->render();
     28        return ob_get_clean();
    2829    }
    2930
  • diller-loyalty/trunk/public/class-diller-loyalty-public.php

    r2698466 r3198074  
    5959        // Enqueues all the necessary 3rd party scripts bundles into a single file. This matches all the dependency files added via npm command
    6060        wp_enqueue_script( DILLER_LOYALTY_JS_VENDORS_BUNDLE_HANDLE, trailingslashit( DILLER_LOYALTY_URL ) . 'assets/js/vendors-bundle.js', array( 'jquery' ), DillerLoyalty()->get_version("assets"), true );
    61         wp_enqueue_script( 'diller-loyalty-public-bundle', trailingslashit( DILLER_LOYALTY_URL ) . 'assets/js/diller-loyalty-public-bundle.js', array( DILLER_LOYALTY_JS_VENDORS_BUNDLE_HANDLE), DillerLoyalty()->get_version("assets"), true );
     61        wp_enqueue_script( DILLER_LOYALTY_JS_BUNDLE_PUBLIC_HANDLE, trailingslashit( DILLER_LOYALTY_URL ) . 'assets/js/diller-loyalty-public-bundle.js', array( DILLER_LOYALTY_JS_VENDORS_BUNDLE_HANDLE), DillerLoyalty()->get_version("assets"), true );
    6262    }
    6363
Note: See TracChangeset for help on using the changeset viewer.