Add upstream
This commit is contained in:
26
wp-content/plugins/cookie-notice/includes/functions.php
Normal file
26
wp-content/plugins/cookie-notice/includes/functions.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
// exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) )
|
||||
exit;
|
||||
|
||||
/**
|
||||
* Check if cookies are accepted.
|
||||
*
|
||||
* @return boolean Whether cookies are accepted
|
||||
*/
|
||||
if ( ! function_exists( 'cn_cookies_accepted' ) ) {
|
||||
function cn_cookies_accepted() {
|
||||
return (bool) Cookie_Notice::cookies_accepted();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if cookies are set.
|
||||
*
|
||||
* @return boolean Whether cookies are set
|
||||
*/
|
||||
if ( ! function_exists( 'cn_cookies_set' ) ) {
|
||||
function cn_cookies_set() {
|
||||
return (bool) Cookie_Notice::cookies_set();
|
||||
}
|
||||
}
|
||||
34
wp-content/plugins/cookie-notice/includes/upgrade.php
Normal file
34
wp-content/plugins/cookie-notice/includes/upgrade.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) )
|
||||
exit;
|
||||
|
||||
new Cookie_Notice_Upgrade( $cookie_notice );
|
||||
|
||||
class Cookie_Notice_Upgrade {
|
||||
|
||||
private $defaults;
|
||||
|
||||
public function __construct( $cookie_notice ) {
|
||||
// attributes
|
||||
$this->defaults = $cookie_notice->get_defaults();
|
||||
|
||||
// actions
|
||||
add_action( 'init', array( $this, 'check_upgrade' ) );
|
||||
}
|
||||
|
||||
public function check_upgrade() {
|
||||
if ( ! current_user_can( 'manage_options' ) )
|
||||
return;
|
||||
|
||||
// gets current database version
|
||||
$current_db_version = get_option( 'cookie_notice_version', '1.0.0' );
|
||||
|
||||
// new version?
|
||||
if ( version_compare( $current_db_version, $this->defaults['version'], '<' ) ) {
|
||||
// updates plugin version
|
||||
update_option( 'cookie_notice_version', $this->defaults['version'], false );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user