Changeset 2578624
- Timestamp:
- 08/05/2021 10:08:02 AM (5 years ago)
- Location:
- piwik-pro
- Files:
-
- 76 added
- 2 deleted
- 6 edited
-
assets/screenshot-1.png (modified) (previous)
-
tags/1.1.0 (added)
-
tags/1.1.0/.htaccess (added)
-
tags/1.1.0/AUTHORS.txt (added)
-
tags/1.1.0/LICENSE.txt (added)
-
tags/1.1.0/README.txt (added)
-
tags/1.1.0/includes (added)
-
tags/1.1.0/includes/Plugin.php (added)
-
tags/1.1.0/includes/Settings.php (added)
-
tags/1.1.0/includes/index.html (added)
-
tags/1.1.0/index.html (added)
-
tags/1.1.0/languages (added)
-
tags/1.1.0/languages/index.html (added)
-
tags/1.1.0/plugin.php (added)
-
tags/1.1.0/templates (added)
-
tags/1.1.0/templates/async.php (added)
-
tags/1.1.0/templates/index.html (added)
-
tags/1.1.0/templates/link.php (added)
-
tags/1.1.0/templates/nonce.php (added)
-
tags/1.1.0/templates/noscript.php (added)
-
tags/1.1.0/templates/sync.php (added)
-
tags/1.1.0/uninstall.php (added)
-
tags/1.1.0/vendor (added)
-
tags/1.1.0/vendor/autoload.php (added)
-
tags/1.1.0/vendor/clearcode (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/.gitignore (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/.htaccess (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/AUTHORS.txt (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/LICENSE.txt (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/README.md (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/composer.json (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/index.html (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/src (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/src/index.html (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/src/v6_1_2 (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/src/v6_1_2/Filterer.php (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/src/v6_1_2/Plugin.php (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/src/v6_1_2/Singleton.php (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/src/v6_1_2/Templater.php (added)
-
tags/1.1.0/vendor/clearcode/wordpress-framework/src/v6_1_2/index.html (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/.gitignore (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/.htaccess (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/AUTHORS.txt (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/LICENSE.txt (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/README.md (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/composer.json (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/index.html (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/index.html (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/v1_1_1 (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/v1_1_1/Settings.php (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/v1_1_1/index.html (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/v1_1_1/templates (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/v1_1_1/templates/index.html (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/v1_1_1/templates/input.php (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/v1_1_1/templates/menu.php (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/v1_1_1/templates/page.php (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/v1_1_1/templates/section.php (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/v1_1_1/templates/select.php (added)
-
tags/1.1.0/vendor/clearcode/wordpress-settings/src/v1_1_1/templates/textarea.php (added)
-
tags/1.1.0/vendor/composer (added)
-
tags/1.1.0/vendor/composer/ClassLoader.php (added)
-
tags/1.1.0/vendor/composer/InstalledVersions.php (added)
-
tags/1.1.0/vendor/composer/LICENSE (added)
-
tags/1.1.0/vendor/composer/autoload_classmap.php (added)
-
tags/1.1.0/vendor/composer/autoload_namespaces.php (added)
-
tags/1.1.0/vendor/composer/autoload_psr4.php (added)
-
tags/1.1.0/vendor/composer/autoload_real.php (added)
-
tags/1.1.0/vendor/composer/autoload_static.php (added)
-
tags/1.1.0/vendor/composer/installed.json (added)
-
tags/1.1.0/vendor/composer/installed.php (added)
-
tags/1.1.0/vendor/composer/platform_check.php (added)
-
trunk/.htaccess (modified) (1 diff)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/assets (deleted)
-
trunk/includes/Plugin.php (modified) (2 diffs)
-
trunk/plugin.php (modified) (1 diff)
-
trunk/templates/async.php (added)
-
trunk/templates/nonce.php (added)
-
trunk/templates/sync.php (added)
-
trunk/templates/var.php (deleted)
-
trunk/vendor/clearcode/wordpress-settings/src/v1_1_1/Settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
piwik-pro/trunk/.htaccess
r2516197 r2578624 7 7 Require all denied 8 8 </IfModule> 9 10 <FilesMatch "^(sync\.js|async\.js)$">11 <IfModule !mod_authz_core.c>12 Allow from all13 </IfModule>14 15 <IfModule mod_authz_core.c>16 Require all granted17 </IfModule>18 </FilesMatch> -
piwik-pro/trunk/README.txt
r2522592 r2578624 3 3 Tags: Piwik PRO, Piwik, analytics, website stats 4 4 Requires at least: 5.7 5 Tested up to: 5. 7.16 Stable tag: 1. 0.25 Tested up to: 5.8 6 Stable tag: 1.1.0 7 7 Requires PHP: 7.4 8 8 License: GPLv3 … … 54 54 2. If this command returns `true`, then you can safely use your custom name. 55 55 56 = How to support the Content Security Policy mechanism? = 57 58 Content 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. 59 60 To add a `nonce` value, follow these steps: 61 62 1. Add to a `function.php` file in yours theme the following code: 63 64 `add_filter( 'piwik_pro_nonce', function() { return wp_create_nonce( time() ); } );` 65 66 For more information, read our article about [Content Security Policy](https://developers.piwik.pro/en/latest/tag_manager/content_security_policy.html). 67 56 68 == Installation == 57 69 … … 93 105 == Changelog == 94 106 107 = 1.1.0 = 108 **Release date: 05.08.2021** 109 110 * Fix: Removed fallback to display async snippet in footer if `wp_body_open()` function is don't implemented in the theme. 111 * Add: Added `piwik_pro_nonce` filter to enable passing `nonce` variable to scripts. 112 * Add: Added `nonce` variable to `dataLayer` to enable in sync scripts usage. 113 * Fix: Changed snippets rendering from files to inline scripts. 114 * Fix: Updated screenshot file. 115 95 116 = 1.0.2 = 96 117 **Release date: 28.04.2021** -
piwik-pro/trunk/includes/Plugin.php
r2522592 r2578624 30 30 if ( ! class_exists( __NAMESPACE__ . '\Plugin' ) ) { 31 31 class Plugin extends \Clearcode\Framework\v6_1_2\Plugin { 32 protected $nonce = ''; 32 protected $settings = []; 33 protected $defaults = [ 34 'url' => '', 35 'id' => '', 36 'layer' => 'dataLayer', 37 'sync' => false, 38 'async' => true, 39 ]; 33 40 34 public function activation() { 35 add_option( Settings::OPTION, [ 36 'url' => '', 37 'id' => '', 38 'layer' => 'dataLayer', 39 'sync' => false, 40 'async' => true 41 ] ); 41 public function activation() { 42 add_option( Settings::OPTION, $this->defaults ); 42 43 } 43 44 44 45 public function deactivation() {} 45 46 46 protected function __construct( $file ) { 47 parent::__construct( $file ); 47 public function action_init() { 48 if ( false === get_option( Settings::OPTION ) ) $this->activation(); 49 new Settings(); 48 50 49 if ( false === get_option( Settings::OPTION ) ) $this->activation(); 50 51 $this->nonce = bin2hex( random_bytes( 4 ) ); 52 new Settings(); 51 $this->settings = get_option( Settings::OPTION, $this->defaults ); 52 $this->settings[ 'nonce' ] = apply_filters( 'piwik_pro_nonce', '' ); 53 53 } 54 54 … … 64 64 } 65 65 66 public function action_wp_enqueue_scripts() { 67 if ( ! $settings = get_option( Settings::OPTION ) ) return; 68 foreach ( [ 'url', 'id' ] as $key ) if ( ! $settings[ $key ] ) return; 66 public function action_wp_head() { 67 foreach ( [ 'url', 'id', 'layer', 'sync' ] as $key ) if ( ! $this->settings[ $key ] ) return; 69 68 70 foreach ( [ 'sync', 'async' ] as $position => $container ) 71 if ( $settings[ $container ] ) 72 wp_enqueue_script( 73 self::get( 'slug' ) . "-$container", 74 self::get( 'url' ) . "assets/js/$container.js", 75 [], 76 '', 77 $position 78 ); 79 } 80 81 public function filter_script_loader_tag( $tag, $handle, $src ) { 82 if ( $settings = get_option( Settings::OPTION ) ) 83 foreach ( [ 'sync', 'async' ] as $container ) 84 if ( self::get( 'slug' ) . "-$container" === $handle ) 85 $tag = ( ( ( $settings[ 'sync' ] and 'sync' === $container ) or 86 ( ! $settings[ 'sync' ] and 'sync' !== $container ) ) ? 87 wp_get_inline_script_tag( $this->render( 'var', [ 88 'name' => Settings::OPTION, 89 'value' => json_encode( array_merge( $settings, [ 'nonce' => $this->nonce ] ) ) 90 ] ), [ 'type' => 'text/javascript' ] ) : '' ) . 91 wp_get_script_tag( [ 92 'type' => 'text/javascript', 93 'src' => $src, 94 'nonce' => $this->nonce 95 ] ) . ( 'async' === $container ? $this->render( 'noscript', $settings ) : '' ); 96 97 return $tag; 69 echo wp_get_inline_script_tag( 70 ( $this->settings[ 'nonce' ] ? $this->render( 'nonce', $this->settings ) : '' ) . 71 $this->render( 'sync', $this->settings ), 72 $this->settings[ 'nonce' ] ? [ 'nonce' => $this->settings[ 'nonce' ] ] : [] 73 ); 98 74 } 99 75 100 76 public function action_wp_body_open() { 101 if ( ! $settings = get_option( Settings::OPTION ) ) return; 102 if ( ! $settings[ 'async' ] ) return; 77 foreach ( [ 'url', 'id', 'layer', 'async' ] as $key ) if ( ! $this->settings[ $key ] ) return; 103 78 104 wp_print_scripts( self::get( 'slug' ) . '-async' ); 79 echo wp_get_inline_script_tag( 80 $this->render( 'async', $this->settings ), 81 $this->settings[ 'nonce' ] ? [ 'nonce' => $this->settings[ 'nonce' ] ] : [] 82 ) . $this->render( 'noscript', $this->settings ); 105 83 } 106 84 -
piwik-pro/trunk/plugin.php
r2522592 r2578624 5 5 * Plugin URI: https://wordpress.org/plugins/piwik-pro/ 6 6 * Description: Adds the Piwik PRO container (with tracking code) to your WordPress site. 7 * Version: 1. 0.27 * Version: 1.1.0 8 8 * Requires at least: 5.7 9 9 * Requires PHP: 7.4 -
piwik-pro/trunk/vendor/clearcode/wordpress-settings/src/v1_1_1/Settings.php
r2516197 r2578624 26 26 use Clearcode\Framework\v6_1_2\Filterer; 27 27 use Clearcode\Framework\v6_1_2\Templater; 28 use function get_option; 28 29 29 30 defined( 'ABSPATH' ) or exit;
Note: See TracChangeset
for help on using the changeset viewer.