Plugin Directory

Changeset 3344618


Ignore:
Timestamp:
08/14/2025 11:33:44 AM (8 months ago)
Author:
OptiMonk
Message:

Prepare release 2.1.0 in trunk

Location:
exit-intent-popups-by-optimonk/trunk
Files:
5 added
6 edited

Legend:

Unmodified
Added
Removed
  • exit-intent-popups-by-optimonk/trunk/optimonk-admin.php

    r3144112 r3344618  
    2222        self::$basePath = $pluginBasePath;
    2323        add_filter('plugin_action_links_' . plugin_basename(self::$basePath), array($this, 'addSettingsPageLink'));
     24        add_filter('woocommerce_get_settings_general', array($this, 'registrateShopId'));
     25        add_action('init', array($this, 'generateShopId'));
    2426        add_action('admin_enqueue_scripts', array($this, 'initScripts'));
    2527        add_action('admin_enqueue_scripts', array($this, 'initStyleSheet'));
     
    3032        add_action('admin_footer', array($this, 'settings_javascript'));
    3133        add_action('wp_ajax_setting_form', array($this, 'postHandler'));
     34    }
     35
     36    public function generateShopId() {
     37        if (get_option('omplugin_shop_id')) return;
     38
     39        $siteurl = get_option('siteurl');
     40        if (!$siteurl || strlen($siteurl) < 5) return;
     41
     42        $shopId = preg_replace('/^https?:\/\//', '', $siteurl) . '_' . time();
     43
     44        update_option('omplugin_shop_id', $shopId);
     45    }
     46
     47    public function registrateShopId($settings) {
     48        // [GET] /wp-json/wc/v3/settings/general/omplugin_shop_id
     49
     50        $shopId = get_option('omplugin_shop_id');
     51
     52        $settings[] = [
     53            'name' => __('UUID', 'OptiMonk'),
     54            'id' => 'omplugin_shop_id',
     55            'type' => 'text',
     56            'default' => $shopId,
     57            'desc_tip' => true,
     58            'description' => 'Uniquely identify the website for the OptiMonk.',
     59            'custom_attributes' => ['readonly' => 'readonly']
     60        ];
     61   
     62        return $settings;
    3263    }
    3364
  • exit-intent-popups-by-optimonk/trunk/optimonk-front.php

    r2822087 r3344618  
    11<?php
     2require_once(dirname(__FILE__) . "/optimonk-woo-data-injector.php");
    23
    34/**
     
    3132        $insertJavaScript = str_replace('{{siteUrl}}', $url, $insertJavaScript);
    3233
     34
     35        $current_url = home_url( add_query_arg( null, null ) );
     36        $dataInjector = new OptiMonkWooDataInjector(urldecode($current_url));
     37        $dataToInsert = $dataInjector->getData();
     38
     39        $frontDomain = OPTIMONK_FRONT_DOMAIN;
     40
    3341        echo <<<EOD
    3442<script type="text/javascript">
    3543    $insertJavaScript
     44    $dataToInsert
    3645</script>
    37 <script type="text/javascript" src="https://onsite.optimonk.com/script.js?account=$accountId" async></script>
     46<script type="text/javascript" src="https://$frontDomain/script.js?account=$accountId" async></script>
    3847EOD;
    3948    }
     
    190199            die();
    191200        }
     201
     202       if ($pluginVar && $actionVar &&
     203         $wp->query_vars['plugin'] == 'optimonk' &&
     204         $wp->query_vars['action'] == 'addToCart') {
     205
     206         WcAttributes::addToCart();
     207         die();
     208       }
    192209    }
    193210
  • exit-intent-popups-by-optimonk/trunk/optimonk.php

    r3144112 r3344618  
    55  Description: OptiMonk, the conversion optimization toolset crafted for marketers
    66  Author: OptiMonk
    7   Version: 2.0.9
     7  Version: 2.1.0
    88  Text Domain: optimonk
    99  Domain Path: /languages
     
    1111  License: GPLv2
    1212*/
     13
     14define('OM_PLUGIN_VERSION', '2.1.0');
     15define('OPTIMONK_FRONT_DOMAIN', 'onsite.optimonk.com');
    1316
    1417if (!defined('ABSPATH')) {
  • exit-intent-popups-by-optimonk/trunk/readme.txt

    r3217583 r3344618  
    44Requires at least: 2.8.0
    55Tested up to: 6.6.1
    6 Stable tag: 2.0.9
     6Stable tag: 2.1.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    186186= Popup builder log =
    187187
     188### 08/07/2025
     189
     190- New: Support for Product Recommender algorithms like Most popular, Recently viewed in WooCommerce stores
     191- New: Support for Order tracking in WooCommerce stores
     192
    188193### 11/12/2024
    189194
  • exit-intent-popups-by-optimonk/trunk/template/insert-code.js

    r3123233 r3344618  
    1818
    1919  function setCartData(cartData, adapter) {
    20     adapter.Cart.clear();
    21 
    22     cartData.cart.forEach(cartItem => {
    23       adapter.Cart.add(cartItem.sku, {quantity: cartItem.quantity, price: cartItem.price, name: cartItem.name});
    24     });
    2520    Object.keys(cartData.avs).forEach((key, value) => {
    2621      adapter.attr(`wp_${key}`, cartData.avs[key]);
     
    8479    setAssocData(pvData, adapter);
    8580
    86     if (OptiMonk.campaigns.filter(campaign => campaign.hasVisitorCartRules()).length) {
    87       observeAjaxCartActions(adapter);
    88       fetchCart(adapter);
    89     }
    90 
    9181    if (OptiMonk.campaigns.filter(campaign => campaign.hasVisitorAttributeRules()).length) {
    9282      makePostRequest("{{siteUrl}}/index.php?plugin=optimonk&action=productData", { body })
  • exit-intent-popups-by-optimonk/trunk/wc-attributes.php

    r2814225 r3344618  
    11<?php
     2require_once(dirname(__FILE__) . "/woo-version.php");
     3
    24class WcAttributes {
    35    public static function getCartVariables() {
    46        echo json_encode(self::getWooCommerceCartData());
    57    }
     8
     9    public static function addToCart() {
     10        if ( ! class_exists( 'WooCommerce' ) ) {
     11            wp_send_json_error( array( 'message' => 'WooCommerce is not active' ) );
     12            return;
     13        }
     14
     15        $product_id   = isset( $_POST['id'] ) ? absint( $_POST['id'] ) : 0;
     16        $quantity     = isset( $_POST['quantity'] ) ? absint( $_POST['quantity'] ) : 1;
     17        $variation_id = isset( $_POST['variation_id'] ) ? absint( $_POST['variation_id'] ) : 0;
     18        $variation    = isset( $_POST['variation'] ) ? $_POST['variation'] : array();
     19
     20        if ( ! $product_id ) {
     21            wp_send_json_error( array( 'message' => 'Invalid product ID' ) );
     22            return;
     23        }
     24
     25        $cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation );
     26
     27        if ( $cart_item_key ) {
     28            WC()->cart->calculate_totals();
     29
     30            wp_send_json_success( array(
     31                'cart_item_key' => $cart_item_key,
     32                'cart_count'    => WC()->cart->get_cart_contents_count(),
     33                'cart_total'    => WC()->cart->get_cart_total(),
     34                'message'       => sprintf( '%s added to your cart.', get_the_title( $product_id ) )
     35            ) );
     36        } else {
     37            wp_send_json_error( array( 'message' => 'Failed to add product to cart' ) );
     38        }
     39
     40        wp_die();
     41    }
     42
    643
    744    public static function getVariables( $url ) {
     
    2562        );
    2663
    27         if ( self::isWooCommerce() === false ) {
     64        if ( WooVersion::isWooCommerce() === false ) {
    2865            return $return;
    2966        }
     
    4481            $item_tax           = $line_subtotal_tax / $quantity;
    4582            $price              = $item_price + $item_tax;
    46 
    47             $identifier = $product->get_sku() ? $product->get_sku() : $product->get_id();
     83            $productId          = $product->get_id();
     84            $sku                = $product->get_sku();
    4885
    4986            $return['cart'][] = array(
    50                 'sku'      => $identifier,
     87                'id'       => $productId,
     88                'sku'      => $sku,
    5189                'name'     => $product_name,
    5290                'price'    => $price,
     
    112150
    113151    protected static function isWooCommerceProductPage($post) {
    114         return self::isWooCommerce() && get_post_type($post) === 'product';
    115     }
    116 
    117     protected static function isWooCommerce() {
    118         global $woocommerce;
    119 
    120         if (
    121             isset( $woocommerce ) === false
    122             || class_exists( '\WC_Product' ) === false
    123         ) {
    124             return false;
    125         }
    126 
    127         return true;
     152        return WooVersion::isWooCommerce() && get_post_type($post) === 'product';
    128153    }
    129154
    130155    protected static function wpbo_get_woo_version_number() {
    131         // If get_plugins() isn't available, require it
    132         if ( ! function_exists( 'get_plugins' ) )
    133             require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    134 
    135         // Create the plugins folder and file variables
    136         $plugin_folder = get_plugins( '/' . 'woocommerce' );
    137         $plugin_file = 'woocommerce.php';
    138 
    139         // If the plugin version number is set, return it
    140         if ( isset( $plugin_folder[$plugin_file]['Version'] ) ) {
    141             return $plugin_folder[$plugin_file]['Version'];
    142 
    143         } else {
    144             // Otherwise return null
    145             return NULL;
    146         }
     156        WooVersion::wpbo_get_woo_version_number();
    147157    }
    148158}
Note: See TracChangeset for help on using the changeset viewer.