Changeset 2452232
- Timestamp:
- 01/08/2021 01:39:17 AM (5 years ago)
- Location:
- croct
- Files:
-
- 6 edited
- 1 copied
-
tags/1.0.4 (copied) (copied from croct/trunk)
-
tags/1.0.4/croct.php (modified) (1 diff)
-
tags/1.0.4/src/Dependency/BootstrapScript.php (modified) (3 diffs)
-
tags/1.0.4/src/Plugin.php (modified) (2 diffs)
-
trunk/croct.php (modified) (1 diff)
-
trunk/src/Dependency/BootstrapScript.php (modified) (3 diffs)
-
trunk/src/Plugin.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
croct/tags/1.0.4/croct.php
r2387816 r2452232 6 6 * Plugin Name: Croct 7 7 * Plugin URI: https://croct.com/wordpress 8 * Version: 1.0. 38 * Version: 1.0.4 9 9 * Description: Content Personalization for WordPress. 10 10 * Requires at least: 4.0 -
croct/tags/1.0.4/src/Dependency/BootstrapScript.php
r2384748 r2452232 7 7 final class BootstrapScript implements InlineDependency 8 8 { 9 const SCRIPT = <<<JS 10 (function initCroct() { 11 if (typeof croct === 'undefined') { 12 const script = document.getElementById(%s); 13 14 if (script !== null) { 15 script.addEventListener('load', initCroct); 16 } 17 18 return; 19 } 20 21 if (typeof wpCroct === 'undefined') { 22 const script = document.getElementById(%s); 23 24 if (script !== null) { 25 script.addEventListener('load', initCroct); 26 } 27 28 return; 29 } 30 31 wpCroct.init(%s); 32 })(); 33 JS; 34 9 35 /** @var string */ 10 36 private $appId; 37 38 /** @var string */ 39 private $plugHandle; 40 41 /** @var string */ 42 private $croctWpHandle; 11 43 12 44 /** @var bool */ … … 15 47 /** 16 48 * @param string $appId 49 * @param string $plugHandle 50 * @param string $croctWpHandle 17 51 * @param bool $debugMode 18 52 */ 19 public function __construct($appId, $ debugMode)53 public function __construct($appId, $plugHandle, $croctWpHandle, $debugMode) 20 54 { 21 55 $this->appId = $appId; 56 $this->plugHandle = $plugHandle; 57 $this->croctWpHandle = $croctWpHandle; 22 58 $this->debugMode = $debugMode; 23 59 } … … 41 77 { 42 78 return \sprintf( 43 'wpCroct.init(%s);', 79 self::SCRIPT, 80 \json_encode($this->plugHandle . '-js'), 81 \json_encode($this->croctWpHandle . '-js'), 44 82 \json_encode([ 45 83 'appId' => $this->appId, -
croct/tags/1.0.4/src/Plugin.php
r2387816 r2452232 13 13 final class Plugin 14 14 { 15 const VERSION = '1.0. 3';15 const VERSION = '1.0.4'; 16 16 17 17 const OPTIONS_GROUP = 'croct'; … … 127 127 new PlugScript(), 128 128 new WpCroctScript($this->baseUrl), 129 new BootstrapScript($appId, $options->isDebugModeEnabled()), 129 new BootstrapScript( 130 $appId, 131 PlugScript::HANDLE, 132 WpCroctScript::HANDLE, 133 $options->isDebugModeEnabled() 134 ), 130 135 ]; 131 136 -
croct/trunk/croct.php
r2387816 r2452232 6 6 * Plugin Name: Croct 7 7 * Plugin URI: https://croct.com/wordpress 8 * Version: 1.0. 38 * Version: 1.0.4 9 9 * Description: Content Personalization for WordPress. 10 10 * Requires at least: 4.0 -
croct/trunk/src/Dependency/BootstrapScript.php
r2384748 r2452232 7 7 final class BootstrapScript implements InlineDependency 8 8 { 9 const SCRIPT = <<<JS 10 (function initCroct() { 11 if (typeof croct === 'undefined') { 12 const script = document.getElementById(%s); 13 14 if (script !== null) { 15 script.addEventListener('load', initCroct); 16 } 17 18 return; 19 } 20 21 if (typeof wpCroct === 'undefined') { 22 const script = document.getElementById(%s); 23 24 if (script !== null) { 25 script.addEventListener('load', initCroct); 26 } 27 28 return; 29 } 30 31 wpCroct.init(%s); 32 })(); 33 JS; 34 9 35 /** @var string */ 10 36 private $appId; 37 38 /** @var string */ 39 private $plugHandle; 40 41 /** @var string */ 42 private $croctWpHandle; 11 43 12 44 /** @var bool */ … … 15 47 /** 16 48 * @param string $appId 49 * @param string $plugHandle 50 * @param string $croctWpHandle 17 51 * @param bool $debugMode 18 52 */ 19 public function __construct($appId, $ debugMode)53 public function __construct($appId, $plugHandle, $croctWpHandle, $debugMode) 20 54 { 21 55 $this->appId = $appId; 56 $this->plugHandle = $plugHandle; 57 $this->croctWpHandle = $croctWpHandle; 22 58 $this->debugMode = $debugMode; 23 59 } … … 41 77 { 42 78 return \sprintf( 43 'wpCroct.init(%s);', 79 self::SCRIPT, 80 \json_encode($this->plugHandle . '-js'), 81 \json_encode($this->croctWpHandle . '-js'), 44 82 \json_encode([ 45 83 'appId' => $this->appId, -
croct/trunk/src/Plugin.php
r2387816 r2452232 13 13 final class Plugin 14 14 { 15 const VERSION = '1.0. 3';15 const VERSION = '1.0.4'; 16 16 17 17 const OPTIONS_GROUP = 'croct'; … … 127 127 new PlugScript(), 128 128 new WpCroctScript($this->baseUrl), 129 new BootstrapScript($appId, $options->isDebugModeEnabled()), 129 new BootstrapScript( 130 $appId, 131 PlugScript::HANDLE, 132 WpCroctScript::HANDLE, 133 $options->isDebugModeEnabled() 134 ), 130 135 ]; 131 136
Note: See TracChangeset
for help on using the changeset viewer.