From 7676f9891c38ac6fe373c52502bdb8ae1bbd6f11 Mon Sep 17 00:00:00 2001 From: inwerpsel Date: Mon, 19 Oct 2020 18:13:03 +0200 Subject: [PATCH] PLANET-5605 Always add apps login filter * This filter is needed to prevent the cookie from being set anywhere but the login page. If you don't add the filter then the cookie is always set. * The checks were in place to prevent other things from setting cookies. Those things are not there anymore, so we don't need the checks. --- src/Cookies.php | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/src/Cookies.php b/src/Cookies.php index 32f079345e..43c6d8a035 100644 --- a/src/Cookies.php +++ b/src/Cookies.php @@ -6,32 +6,11 @@ * Class Cookies */ class Cookies { - - const COOKIE_NAME = 'greenpeace'; - /** * Cookies constructor. */ public function __construct() { - $this->hooks(); - } - - /** - * Register actions for WordPress hooks and filters. - */ - private function hooks() { - $options = get_option( 'planet4_options' ); - $enforce_cookies_policy = isset( $options['enforce_cookies_policy'] ) ? true : false; - - // Do not add any hook if enforce cookies setting is not set. - if ( false === $enforce_cookies_policy ) { - return; - } - // If our cookie is not set then register the following filters. - if ( '2' !== $this->read_cookie( self::COOKIE_NAME ) ) { - - add_filter( 'gal_set_login_cookie', [ $this, 'filter_google_login_set_login_cookie' ], 10, 1 ); - } + add_filter( 'gal_set_login_cookie', [ $this, 'filter_google_login_set_login_cookie' ], 10, 1 ); } /** @@ -48,22 +27,4 @@ public function filter_google_login_set_login_cookie( $dosetcookie ) { return 'wp-login.php' === $pagenow; } - - - /** - * Get an entry from $_COOKIE super global - * - * @param string $name Cookie name. - * - * @since 1.9 - * - * @return bool Return false if entry does not exist, otherwise return cookie value. - */ - public function read_cookie( $name = '' ) { - if ( isset( $_COOKIE[ $name ] ) ) { - return $_COOKIE[ $name ]; - } else { - return false; - } - } }