Plugin Directory

Changeset 3349431


Ignore:
Timestamp:
08/25/2025 04:26:14 AM (7 months ago)
Author:
cookieopt2024
Message:

version 1.0.8

Location:
cookie-optimizer
Files:
13 deleted
5 edited
47 copied

Legend:

Unmodified
Added
Removed
  • cookie-optimizer/tags/1.0.8/app/Includes/CookieOptBanner.php

    r3348569 r3349431  
    1717    public $CookieOptBanner_service;
    1818    public $server_dashboard;
     19    private $is_banner_display = false;
    1920    public function __construct()
    2021    {
     
    2728            if ($package_user !== 'LOCK' && !$package->checkLimitPackage()) {
    2829                add_action('wp_enqueue_scripts', [$this, 'register_enqueue_script']);
    29                 if (function_exists('wp_body_open')) {
    30                     add_action('wp_body_open', [$this, 'my_banner_in_content'], 10);
    31                 } else {
    32                     add_action('wp_footer', [$this, 'my_banner_in_content'], 10);
    33                 }
     30                add_action('send_headers', [$this, 'set_cookie']);
     31                add_action('wp_head', [$this, 'my_banner_in_content'], 10);
     32                add_action('wp_body_open', [$this, 'my_banner_in_content'], 10);
     33                add_action('wp_footer', [$this, 'my_banner_in_content'], 10);
    3434            }
    3535        }
     
    4747            add_action('wp_ajax_nopriv_set_cookie_opt_server', [$this, 'handle_set_cookie_opt_server']);
    4848        }
     49    }
     50
     51    public function set_cookie()
     52    {
     53        $is_banner_active = get_option('cookie_opt_banner_active');
     54        if ($is_banner_active != 1) {
     55            return;
     56        }
     57
     58        if (isset($_COOKIE[COOKIE_OPT_NAME])) {
     59            return;
     60        }
     61
     62        $banner = $this->CookiePermissionService->getDataBannerToShow();
     63
     64        // default cookie values
     65        $data_cookie = [
     66            'action'      => 0,
     67            'type'        => $banner['regulation'] === 'ja' ? '1' : '',
     68            'necessary'   => 1,
     69            'functional'  => 0,
     70            'socialmedia' => 0,
     71            'performance' => 0,
     72        ];
     73
     74        $options = [
     75            'expires'  => $banner['regulation'] === 'ja' ? time() + 31556926 : 0,
     76            'path'     => '/',
     77            //'domain' => '',
     78            'secure'   => false,
     79            'httponly' => false,
     80            //'samesite' => 'Lax',
     81        ];
     82
     83        setcookie(COOKIE_OPT_NAME, wp_json_encode($data_cookie), $options);
     84
     85        $_COOKIE[COOKIE_OPT_NAME] = wp_json_encode($data_cookie);
    4986    }
    5087    public function handle_view_banner()
     
    109146                'expires'  => $expires,
    110147                'path'     => '/',
    111                 'domain'   => '',
     148                // 'domain'   => '',
    112149                'secure'   => false,
    113150                'httponly' => false,
    114                 'samesite' => 'Lax',
     151                // 'samesite' => 'Lax',
    115152            ];
    116153
     
    166203    public function my_banner_in_content()
    167204    {
     205        if ($this->is_banner_display == true) {
     206            return;
     207        }
     208
     209        $this->is_banner_display = true;
     210
    168211        $is_banner_active = get_option('cookie_opt_banner_active');
    169212        if ($is_banner_active != 1)
    170213            return null;
    171214
    172         $banner = $this->CookiePermissionService->getDataBannerToShow();
    173215
    174216        $cookie_raw = $_COOKIE[COOKIE_OPT_NAME] ?? null;
    175         $data_cookie = null;
    176 
    177         if ($cookie_raw) {
    178             $decoded = urldecode(wp_unslash($cookie_raw));
    179             $data_cookie = json_decode($decoded, true);
    180         }
    181 
    182         if (!is_array($data_cookie) || !isset($data_cookie['action'])) {
    183             $data_cookie = [
    184                 'action'      => 0,
    185                 'type'        => $banner['regulation'] === 'ja' ? '1' : '',
    186                 'necessary'   => 1,
    187                 'functional'  => 0,
    188                 'socialmedia' => 0,
    189                 'performance' => 0,
    190             ];
    191 
    192             $options = [
    193                 'expires'  => $banner['regulation'] === 'ja' ? time() + 31556926 : 0,
    194                 'path'     => '/',
    195                 'domain'   => '',
    196                 'secure'   => false,
    197                 'httponly' => false,
    198                 'samesite' => 'Lax',
    199             ];
    200 
    201             setcookie(COOKIE_OPT_NAME, wp_json_encode($data_cookie), $options);
    202         }
    203 
    204         if ($data_cookie['action'] == 1) {
    205             return;
    206         } else {
     217
     218        if (!$cookie_raw) {
     219            return;
     220        }
     221
     222        $decoded = urldecode(wp_unslash($cookie_raw));
     223        $data_cookie = json_decode($decoded, true);
     224
     225        if (!isset($data_cookie['action'])) {
     226            return;
     227        }
     228
     229        if ($data_cookie['action'] === 1) {
     230            return;
     231        }
     232
     233        if ($data_cookie['action'] === 0) {
     234
     235            $banner = $this->CookiePermissionService->getDataBannerToShow();
    207236            $condition_status = (bool)($banner['conditional']['status'] ?? false);
    208237            $rules_show = $banner['conditional']['rules']['show'] ?? [];
     
    232261            }
    233262        }
     263
    234264        return;
    235265    }
     
    242272
    243273        echo $html;
    244         return;
     274
    245275    }
    246276}
  • cookie-optimizer/tags/1.0.8/constants.php

    r3348569 r3349431  
    22
    33// Plugin version and mode
    4 define('VERSION', '1.0.7');
     4define('VERSION', '1.0.8');
    55
    66// Plugin directory details
  • cookie-optimizer/tags/1.0.8/cookie-opt.php

    r3348569 r3349431  
    1212 * Plugin URI: https://manage.medipartner.jp
    1313 * Description: Cookieをユーザーに見える化し、各法律にする準拠バナー同意ソリューション
    14  * Version: 1.0.7
     14 * Version: 1.0.8
    1515 * Requires at least: 5.3
    1616 * Requires PHP: 7.3
     
    5151 *
    5252 * @class CookieOpt
    53  * @version 1.0.7
     53 * @version 1.0.8
    5454 */
    5555class CookieOpt
     
    7676     */
    7777    public $defaults = [
    78         'version' => '1.0.7',
     78        'version' => '1.0.8',
    7979    ];
    8080
  • cookie-optimizer/tags/1.0.8/readme.txt

    r3348569 r3349431  
    55Requires PHP: 7.3
    66Tested up to: 6.7   
    7 Stable tag: 1.0.7
     7Stable tag: 1.0.8
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6565== Changelog ==
    6666
    67 = 1.0.7 =
     67= 1.0.8 =
    6868Initial release
    6969
  • cookie-optimizer/tags/1.0.8/uninstall.php

    r3348569 r3349431  
    1919 *
    2020 * @link       https://cookieoptimizer.net
    21  * @since      1.0.7
     21 * @since      1.0.8
    2222 *
    2323 * @package    Cookie Optimizer
  • cookie-optimizer/trunk/app/Includes/CookieOptBanner.php

    r3348569 r3349431  
    1717    public $CookieOptBanner_service;
    1818    public $server_dashboard;
     19    private $is_banner_display = false;
    1920    public function __construct()
    2021    {
     
    2728            if ($package_user !== 'LOCK' && !$package->checkLimitPackage()) {
    2829                add_action('wp_enqueue_scripts', [$this, 'register_enqueue_script']);
    29                 if (function_exists('wp_body_open')) {
    30                     add_action('wp_body_open', [$this, 'my_banner_in_content'], 10);
    31                 } else {
    32                     add_action('wp_footer', [$this, 'my_banner_in_content'], 10);
    33                 }
     30                add_action('send_headers', [$this, 'set_cookie']);
     31                add_action('wp_head', [$this, 'my_banner_in_content'], 10);
     32                add_action('wp_body_open', [$this, 'my_banner_in_content'], 10);
     33                add_action('wp_footer', [$this, 'my_banner_in_content'], 10);
    3434            }
    3535        }
     
    4747            add_action('wp_ajax_nopriv_set_cookie_opt_server', [$this, 'handle_set_cookie_opt_server']);
    4848        }
     49    }
     50
     51    public function set_cookie()
     52    {
     53        $is_banner_active = get_option('cookie_opt_banner_active');
     54        if ($is_banner_active != 1) {
     55            return;
     56        }
     57
     58        if (isset($_COOKIE[COOKIE_OPT_NAME])) {
     59            return;
     60        }
     61
     62        $banner = $this->CookiePermissionService->getDataBannerToShow();
     63
     64        // default cookie values
     65        $data_cookie = [
     66            'action'      => 0,
     67            'type'        => $banner['regulation'] === 'ja' ? '1' : '',
     68            'necessary'   => 1,
     69            'functional'  => 0,
     70            'socialmedia' => 0,
     71            'performance' => 0,
     72        ];
     73
     74        $options = [
     75            'expires'  => $banner['regulation'] === 'ja' ? time() + 31556926 : 0,
     76            'path'     => '/',
     77            //'domain' => '',
     78            'secure'   => false,
     79            'httponly' => false,
     80            //'samesite' => 'Lax',
     81        ];
     82
     83        setcookie(COOKIE_OPT_NAME, wp_json_encode($data_cookie), $options);
     84
     85        $_COOKIE[COOKIE_OPT_NAME] = wp_json_encode($data_cookie);
    4986    }
    5087    public function handle_view_banner()
     
    109146                'expires'  => $expires,
    110147                'path'     => '/',
    111                 'domain'   => '',
     148                // 'domain'   => '',
    112149                'secure'   => false,
    113150                'httponly' => false,
    114                 'samesite' => 'Lax',
     151                // 'samesite' => 'Lax',
    115152            ];
    116153
     
    166203    public function my_banner_in_content()
    167204    {
     205        if ($this->is_banner_display == true) {
     206            return;
     207        }
     208
     209        $this->is_banner_display = true;
     210
    168211        $is_banner_active = get_option('cookie_opt_banner_active');
    169212        if ($is_banner_active != 1)
    170213            return null;
    171214
    172         $banner = $this->CookiePermissionService->getDataBannerToShow();
    173215
    174216        $cookie_raw = $_COOKIE[COOKIE_OPT_NAME] ?? null;
    175         $data_cookie = null;
    176 
    177         if ($cookie_raw) {
    178             $decoded = urldecode(wp_unslash($cookie_raw));
    179             $data_cookie = json_decode($decoded, true);
    180         }
    181 
    182         if (!is_array($data_cookie) || !isset($data_cookie['action'])) {
    183             $data_cookie = [
    184                 'action'      => 0,
    185                 'type'        => $banner['regulation'] === 'ja' ? '1' : '',
    186                 'necessary'   => 1,
    187                 'functional'  => 0,
    188                 'socialmedia' => 0,
    189                 'performance' => 0,
    190             ];
    191 
    192             $options = [
    193                 'expires'  => $banner['regulation'] === 'ja' ? time() + 31556926 : 0,
    194                 'path'     => '/',
    195                 'domain'   => '',
    196                 'secure'   => false,
    197                 'httponly' => false,
    198                 'samesite' => 'Lax',
    199             ];
    200 
    201             setcookie(COOKIE_OPT_NAME, wp_json_encode($data_cookie), $options);
    202         }
    203 
    204         if ($data_cookie['action'] == 1) {
    205             return;
    206         } else {
     217
     218        if (!$cookie_raw) {
     219            return;
     220        }
     221
     222        $decoded = urldecode(wp_unslash($cookie_raw));
     223        $data_cookie = json_decode($decoded, true);
     224
     225        if (!isset($data_cookie['action'])) {
     226            return;
     227        }
     228
     229        if ($data_cookie['action'] === 1) {
     230            return;
     231        }
     232
     233        if ($data_cookie['action'] === 0) {
     234
     235            $banner = $this->CookiePermissionService->getDataBannerToShow();
    207236            $condition_status = (bool)($banner['conditional']['status'] ?? false);
    208237            $rules_show = $banner['conditional']['rules']['show'] ?? [];
     
    232261            }
    233262        }
     263
    234264        return;
    235265    }
     
    242272
    243273        echo $html;
    244         return;
     274
    245275    }
    246276}
  • cookie-optimizer/trunk/constants.php

    r3348569 r3349431  
    22
    33// Plugin version and mode
    4 define('VERSION', '1.0.7');
     4define('VERSION', '1.0.8');
    55
    66// Plugin directory details
  • cookie-optimizer/trunk/cookie-opt.php

    r3348569 r3349431  
    1212 * Plugin URI: https://manage.medipartner.jp
    1313 * Description: Cookieをユーザーに見える化し、各法律にする準拠バナー同意ソリューション
    14  * Version: 1.0.7
     14 * Version: 1.0.8
    1515 * Requires at least: 5.3
    1616 * Requires PHP: 7.3
     
    5151 *
    5252 * @class CookieOpt
    53  * @version 1.0.7
     53 * @version 1.0.8
    5454 */
    5555class CookieOpt
     
    7676     */
    7777    public $defaults = [
    78         'version' => '1.0.7',
     78        'version' => '1.0.8',
    7979    ];
    8080
  • cookie-optimizer/trunk/readme.txt

    r3348569 r3349431  
    55Requires PHP: 7.3
    66Tested up to: 6.7   
    7 Stable tag: 1.0.7
     7Stable tag: 1.0.8
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6565== Changelog ==
    6666
    67 = 1.0.7 =
     67= 1.0.8 =
    6868Initial release
    6969
  • cookie-optimizer/trunk/uninstall.php

    r3348569 r3349431  
    1919 *
    2020 * @link       https://cookieoptimizer.net
    21  * @since      1.0.7
     21 * @since      1.0.8
    2222 *
    2323 * @package    Cookie Optimizer
Note: See TracChangeset for help on using the changeset viewer.