Plugin Directory

Changeset 2860907


Ignore:
Timestamp:
02/06/2023 03:28:27 PM (3 years ago)
Author:
piwikpro
Message:

Version 1.2.0

Location:
piwik-pro
Files:
82 added
3 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • piwik-pro/trunk/README.txt

    r2740350 r2860907  
    11=== Piwik PRO ===
    22Contributors: piwikpro, piotrpress
    3 Tags: Piwik PRO, Piwik, analytics, website stats
     3Tags: Piwik PRO, Piwik, analytics, website stats, woocommerce
    44Requires at least: 5.7
    5 Tested up to: 6.0
    6 Stable tag: 1.1.1
     5Tested up to: 6.1.1
     6Stable tag: 1.2.0
    77Requires PHP: 7.4
    88License: GPLv3
     
    1313== Description ==
    1414
    15 A simple plugin to add the [Piwik PRO](https://piwik.pro/) container (with tracking code) to your WordPress site.
     15A simple plugin to add the [Piwik PRO](https://piwik.pro/) container (with tracking code) to your WordPress site and automatically track ecommerce from your WooCommerce store.
    1616
    1717= What is Piwik PRO? =
     
    4646* **Additional container (sync):** Add this container if you want to use sync tags. It loads tags before the page content loads.
    4747
     48= WooCommerce: Does this plugin automatically track ecommerce? =
     49
     50Yes, this plugin automatically tracks events like ecommerce orders and abandoned carts, which result in full ecommerce reporting in Piwik PRO. To see the collected data, just turn on [ecommerce reports](https://help.piwik.pro/support/reports/ecommerce-reports/) in:
     51
     52`Piwik PRO > Menu > Administration > Reports > Show ecommerce reports.`
     53
    4854= When should I rename the data layer? =
    4955
     
    5864Content Security Policy restricts third-party tools from loading codes on the website and allows to fetch only approved origins of content. To support Content Security Policy mechanism, you need to add a `nonce` value as an attribute to containers and scripts that these containers load.
    5965
    60 To add a `nonce` value, follow these steps:
    61 
    62 1. Add to a `function.php` file in yours theme the following code:
     66To add a `nonce` value add to a `function.php` file in yours theme the following code:
    6367
    6468`add_filter( 'piwik_pro_nonce', function() { return wp_create_nonce( time() ); } );`
     
    105109== Changelog ==
    106110
     111= 1.2.0 =
     112**Release date: 06.02.2023**
     113
     114* Add: Added support for `getTrackingSource()` Piwik PRO's event.
     115* Add: Added support for `trackEcommerceCartUpdate()` and `trackEcommerceOrder()` Piwik PRO's events for `WooCommerce` plugin.
     116* Fix: Remove `piwik_pro` option in every site in multisite installation during uninstallation.
     117
     118= 1.1.1 =
     119**Release date: 06.10.2022**
     120
     121* Test: Tested up to WordPress 6.0
     122
    107123= 1.1.0 =
    108124**Release date: 05.08.2021**
  • piwik-pro/trunk/includes/Plugin.php

    r2578624 r2860907  
    22
    33/*
    4     Copyright (C) 2021 by Piwik PRO <https://piwik.pro>
     4    Copyright (C) 2023 by Piwik PRO <https://piwik.pro>
    55    and associates (see AUTHORS.txt file).
    66
     
    2424namespace PiwikPRO;
    2525
    26 use Clearcode\Framework\v6_1_2\Templater;
     26use PiwikPRO\Vendor\Clearcode\Framework\v6_1_3\Templater;
    2727
    2828defined( 'ABSPATH' ) or exit;
    2929
    3030if ( ! class_exists( __NAMESPACE__ . '\Plugin' ) ) {
    31     class Plugin extends \Clearcode\Framework\v6_1_2\Plugin {
     31    class Plugin extends \PiwikPRO\Vendor\Clearcode\Framework\v6_1_3\Plugin {
    3232        protected $settings = [];
    3333        protected $defaults = [
     
    8383        }
    8484
     85        public function action_wp_footer() {
     86            foreach ( [ 'url', 'id', 'layer' ] as $key ) if ( ! $this->settings[ $key ] ) return;
     87            if ( ! $this->settings[ 'sync' ] and ! $this->settings[ 'async' ] ) return;
     88
     89            echo wp_get_inline_script_tag(
     90                $this->render( 'push', [ 'arguments' => [
     91                    'setTrackingSource',
     92                    'wordpress',
     93                    self::get( 'version' )
     94                ] ] )
     95            );
     96
     97            if ( ! class_exists( 'WooCommerce' ) ) return;
     98            if ( is_order_received_page() and $order = $this->get_order() ) {
     99                foreach ( $order->get_items() as $order_item )
     100                    echo wp_get_inline_script_tag(
     101                        $this->render( 'push', [ 'arguments' => array_merge(
     102                            [ 'addEcommerceItem' ],
     103                            $this->get_product_data( $order_item[ 'product_id' ], $order_item[ 'quantity' ] )
     104                        ) ] )
     105                    );
     106
     107                echo wp_get_inline_script_tag(
     108                    $this->render( 'push', [ 'arguments' => [
     109                        'trackEcommerceOrder',
     110                        $order->get_id(),
     111                        floatval( $order->get_total() ),
     112                        floatval( $order->get_subtotal() ),
     113                        floatval( $order->get_total_tax() ),
     114                        floatval( $order->get_shipping_total() ),
     115                        floatval( $order->get_total_discount() )
     116                    ] ] )
     117                );
     118            } elseif( WC()->cart->get_cart_contents() ) {
     119                foreach ( WC()->cart->get_cart_contents() as $cart_item )
     120                    echo wp_get_inline_script_tag(
     121                        $this->render( 'push', [ 'arguments' => array_merge(
     122                            [ 'addEcommerceItem' ],
     123                            $this->get_product_data( $cart_item[ 'product_id' ], $cart_item[ 'quantity' ] )
     124                        ) ] )
     125                    );
     126
     127                echo wp_get_inline_script_tag(
     128                    $this->render( 'push', [ 'arguments' => [
     129                        'trackEcommerceCartUpdate',
     130                        floatval( WC()->cart->get_totals()[ 'total' ] )
     131                    ] ] )
     132                );
     133            }
     134        }
     135
     136        protected function get_order() {
     137            global $wp;
     138
     139            $order_id = is_numeric( $wp->query_vars[ 'order-received' ] ) ? intval( $wp->query_vars[ 'order-received' ] ) : 0;
     140            if ( ! $order_id ) return null;
     141
     142            $order = wc_get_order( $order_id );
     143            return ( $order and ! $order->has_status( 'failed' ) ) ? $order : null;
     144        }
     145
     146        protected function get_product_data( $product_id, $quantity = 1 ) {
     147            return ( $product = wc_get_product( $product_id ) ) ? [
     148                $product->get_sku() ?: (string)$product->get_id(),
     149                $product->get_name(),
     150                $this->get_product_categories( $product->get_id() ),
     151                floatval( $product->get_price() ),
     152                intval( $quantity )
     153            ] : [];
     154        }
     155
     156        protected function get_product_categories( $product_id ) {
     157            $categories = [];
     158            foreach ( get_the_terms( $product_id, 'product_cat' ) as $term )
     159                $categories[] = $term->name;
     160
     161            switch ( count( $categories ) ) {
     162                case 0: return '';
     163                case 1: return $categories[ 0 ];
     164                default : return array_slice( $categories, 0, 5 );
     165            }
     166        }
     167
    85168        protected function render( $template, $args ) {
    86169            return call_user_func(
  • piwik-pro/trunk/includes/Settings.php

    r2522592 r2860907  
    22
    33/*
    4     Copyright (C) 2021 by Piwik PRO <https://piwik.pro>
     4    Copyright (C) 2023 by Piwik PRO <https://piwik.pro>
    55    and associates (see AUTHORS.txt file).
    66
     
    2424namespace PiwikPRO;
    2525
    26 use Clearcode\Framework\v6_1_2\Templater;
     26use PiwikPRO\Vendor\Clearcode\Framework\v6_1_3\Templater;
    2727
    2828defined( 'ABSPATH' ) or exit;
    2929
    3030if ( ! class_exists( __NAMESPACE__ . '\Settings' ) ) {
    31     class Settings extends \Clearcode\Settings\v1_1_1\Settings {
     31    class Settings extends \PiwikPRO\Vendor\Clearcode\Settings\v1_1_3\Settings {
    3232        const OPTION = 'piwik_pro';
    3333        const PAGE = 'piwik-pro';
  • piwik-pro/trunk/plugin.php

    r2628598 r2860907  
    55 * Plugin URI:        https://wordpress.org/plugins/piwik-pro/
    66 * Description:       Adds the Piwik PRO container (with tracking code) to your WordPress site.
    7  * Version:           1.1.1
     7 * Version:           1.2.0
    88 * Requires at least: 5.7
    99 * Requires PHP:      7.4
     
    1515 * Domain Path:       /languages/
    1616
    17    Copyright (C) 2021 by Piwik PRO <https://piwik.pro>
     17   Copyright (C) 2023 by Piwik PRO <https://piwik.pro>
    1818   and associates (see AUTHORS.txt file).
    1919
  • piwik-pro/trunk/uninstall.php

    r2516197 r2860907  
    22
    33/*
    4     Copyright (C) 2021 by Piwik PRO <https://piwik.pro>
     4    Copyright (C) 2023 by Piwik PRO <https://piwik.pro>
    55    and associates (see AUTHORS.txt file).
    66
     
    2424defined( 'WP_UNINSTALL_PLUGIN' ) or exit;
    2525
    26 delete_option( 'piwik_pro' );
     26if ( is_multisite() ) foreach ( get_sites() as $site ) delete_blog_option( $site->blog_id, 'piwik_pro' );
     27else delete_option( 'piwik_pro' );
  • piwik-pro/trunk/vendor/autoload.php

    r2516197 r2860907  
    1 <?php
    2 
    3 // autoload.php @generated by Composer
    4 
    5 require_once __DIR__ . '/composer/autoload_real.php';
    6 
    7 return ComposerAutoloaderInit60fe4dd621c54e72c9975ba653775fc5::getLoader();
     1<?php return spl_autoload_register( function( string $class ) {
     2    $map = require __DIR__ . '/classmap.php';
     3    if ( isset( $map[ $class ] ) ) require dirname( __DIR__ ) . $map[ $class ];
     4} );
  • piwik-pro/trunk/vendor/clearcode/wordpress-framework/README.md

    r2516197 r2860907  
    1111# License
    1212
    13 GPL3.0+ see LICENSE.txt and AUTHORS.txt
     13GPL3.0+ see [LICENSE.txt](LICENSE.txt) and [AUTHORS.txt](AUTHORS.txt)
  • piwik-pro/trunk/vendor/clearcode/wordpress-framework/composer.json

    r2516197 r2860907  
    2525    },
    2626    "require": {
    27         "php": ">=7.2"
     27        "php": ">=7.4"
    2828    },
    2929    "autoload": {
  • piwik-pro/trunk/vendor/clearcode/wordpress-settings/README.md

    r2516197 r2860907  
    7070# License
    7171
    72 GPL3.0+ see LICENSE.txt and AUTHORS.txt
     72GPL3.0+ see [LICENSE.txt](LICENSE.txt) and [AUTHORS.txt](AUTHORS.txt)
  • piwik-pro/trunk/vendor/clearcode/wordpress-settings/composer.json

    r2516197 r2860907  
    2525  },
    2626  "require": {
    27     "php": ">=7.2",
    28     "clearcode/wordpress-framework": "6.1.2"
     27    "php": ">=7.4",
     28    "clearcode/wordpress-framework": "6.1.3"
    2929  },
    3030  "autoload": {
Note: See TracChangeset for help on using the changeset viewer.