Skip to content

Commit

Permalink
Merge pull request #1206 from greenpeace/fix-gal-cookie-set-on-non-lo…
Browse files Browse the repository at this point in the history
…gin-pages

Always add apps login filter
  • Loading branch information
Inwerpsel authored Oct 21, 2020
2 parents 8d54605 + 7676f98 commit 6738993
Showing 1 changed file with 1 addition and 40 deletions.
41 changes: 1 addition & 40 deletions src/Cookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand All @@ -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;
}
}
}

0 comments on commit 6738993

Please sign in to comment.