Plugin Directory

Changeset 2452232


Ignore:
Timestamp:
01/08/2021 01:39:17 AM (5 years ago)
Author:
marcospassos
Message:

Update to version 1.0.4 from GitHub

Location:
croct
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • croct/tags/1.0.4/croct.php

    r2387816 r2452232  
    66 * Plugin Name:       Croct
    77 * Plugin URI:        https://croct.com/wordpress
    8  * Version:           1.0.3
     8 * Version:           1.0.4
    99 * Description:       Content Personalization for WordPress.
    1010 * Requires at least: 4.0
  • croct/tags/1.0.4/src/Dependency/BootstrapScript.php

    r2384748 r2452232  
    77final class BootstrapScript implements InlineDependency
    88{
     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})();
     33JS;
     34
    935    /** @var string */
    1036    private $appId;
     37
     38    /** @var string */
     39    private $plugHandle;
     40
     41    /** @var string */
     42    private $croctWpHandle;
    1143
    1244    /** @var bool */
     
    1547    /**
    1648     * @param string $appId
     49     * @param string $plugHandle
     50     * @param string $croctWpHandle
    1751     * @param bool   $debugMode
    1852     */
    19     public function __construct($appId, $debugMode)
     53    public function __construct($appId, $plugHandle, $croctWpHandle, $debugMode)
    2054    {
    2155        $this->appId = $appId;
     56        $this->plugHandle = $plugHandle;
     57        $this->croctWpHandle = $croctWpHandle;
    2258        $this->debugMode = $debugMode;
    2359    }
     
    4177    {
    4278        return \sprintf(
    43             'wpCroct.init(%s);',
     79            self::SCRIPT,
     80            \json_encode($this->plugHandle . '-js'),
     81            \json_encode($this->croctWpHandle . '-js'),
    4482            \json_encode([
    4583                'appId' => $this->appId,
  • croct/tags/1.0.4/src/Plugin.php

    r2387816 r2452232  
    1313final class Plugin
    1414{
    15     const VERSION = '1.0.3';
     15    const VERSION = '1.0.4';
    1616
    1717    const OPTIONS_GROUP = 'croct';
     
    127127            new PlugScript(),
    128128            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            ),
    130135        ];
    131136
  • croct/trunk/croct.php

    r2387816 r2452232  
    66 * Plugin Name:       Croct
    77 * Plugin URI:        https://croct.com/wordpress
    8  * Version:           1.0.3
     8 * Version:           1.0.4
    99 * Description:       Content Personalization for WordPress.
    1010 * Requires at least: 4.0
  • croct/trunk/src/Dependency/BootstrapScript.php

    r2384748 r2452232  
    77final class BootstrapScript implements InlineDependency
    88{
     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})();
     33JS;
     34
    935    /** @var string */
    1036    private $appId;
     37
     38    /** @var string */
     39    private $plugHandle;
     40
     41    /** @var string */
     42    private $croctWpHandle;
    1143
    1244    /** @var bool */
     
    1547    /**
    1648     * @param string $appId
     49     * @param string $plugHandle
     50     * @param string $croctWpHandle
    1751     * @param bool   $debugMode
    1852     */
    19     public function __construct($appId, $debugMode)
     53    public function __construct($appId, $plugHandle, $croctWpHandle, $debugMode)
    2054    {
    2155        $this->appId = $appId;
     56        $this->plugHandle = $plugHandle;
     57        $this->croctWpHandle = $croctWpHandle;
    2258        $this->debugMode = $debugMode;
    2359    }
     
    4177    {
    4278        return \sprintf(
    43             'wpCroct.init(%s);',
     79            self::SCRIPT,
     80            \json_encode($this->plugHandle . '-js'),
     81            \json_encode($this->croctWpHandle . '-js'),
    4482            \json_encode([
    4583                'appId' => $this->appId,
  • croct/trunk/src/Plugin.php

    r2387816 r2452232  
    1313final class Plugin
    1414{
    15     const VERSION = '1.0.3';
     15    const VERSION = '1.0.4';
    1616
    1717    const OPTIONS_GROUP = 'croct';
     
    127127            new PlugScript(),
    128128            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            ),
    130135        ];
    131136
Note: See TracChangeset for help on using the changeset viewer.