pdb->insert_id;
$banner->set_id( $id );
$banner->set_slug( $banner->get_name() );
$slug = $banner->get_slug() . '-' . $id; // Append ID to the slug of the each banner.
$banner->set_slug( $slug );
$banner->save();
$banner->set_id( $wpdb->insert_id );
}
do_action( 'cky_after_update_banner' );
}
/**
* Update an existing banner locally.
*
* @param object $banner Banner object.
* @return void
*/
public function update_item( $banner ) {
global $wpdb;
$data = array(
'name' => $banner->get_name(),
'slug' => $banner->get_slug(),
'status' => ( true === $banner->get_status() ? 1 : 0 ),
'settings' => wp_json_encode( $banner->get_settings() ),
'banner_default' => ( true === $banner->get_default() ? 1 : 0 ),
'contents' => wp_json_encode( $banner->get_contents() ),
);
$wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery,WordPress.DB.PreparedSQL.NotPrepared
$wpdb->prefix . 'cky_banners',
$data,
array( 'banner_id' => $banner->get_id() ),
array(
'%s',
'%s',
'%d',
'%s',
'%d',
'%s',
)
);
if ( defined( 'CKY_BULK_REQUEST' ) && CKY_BULK_REQUEST ) {
return;
}
do_action( 'cky_after_update_banner' );
}
/**
* Delete a banner locally.
*
* @param object $id Banner id.
* @return boolean
*/
public function delete_item( $id ) {
global $wpdb;
$status = $wpdb->delete( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
$wpdb->prefix . 'cky_banners',
array(
'banner_id' => $id,
)
);
do_action( 'cky_after_update_banner' );
return $status;
}
/**
* Prepare banner data to response.
*
* @param object $item Banner object.
* @return object
*/
public function prepare_item( $item ) {
if ( false === is_object( $item ) ) {
return false;
}
$data = new stdClass();
$data->banner_id = isset( $item->banner_id ) ? absint( $item->banner_id ) : 0;
$data->name = isset( $item->name ) ? sanitize_text_field( $item->name ) : '';
$data->slug = isset( $item->slug ) ? sanitize_text_field( $item->slug ) : '';
$data->settings = isset( $item->settings ) ? $this->prepare_json( $item->settings ) : array();
$data->contents = isset( $item->contents ) ? $this->prepare_json( $item->contents ) : array();
$data->banner_default = isset( $item->banner_default ) ? absint( $item->banner_default ) : 0;
$data->status = isset( $item->status ) ? absint( $item->status ) : 0;
if (isset($data->settings['settings']['type']) && ($data->settings['settings']['type'] === "classic")) {
$data->settings['settings']['preferenceCenterType'] = "pushdown";
}
return $data;
}
/**
* Decode a JSON string if necessary
*
* @param string $data String data.
* @return array
*/
public function prepare_json( $data ) {
return is_string( $data ) ? json_decode( $data, true ) : $data;
}
/**
* Load default banner
*
* @return void
*/
protected function load_default() {
$banner = new \CookieYes\Lite\Admin\Modules\Banners\Includes\Banner();
$banner->set_name( 'GDPR' );
$banner->set_status( true );
$banner->set_default( true );
$banner->save();
$banner = new \CookieYes\Lite\Admin\Modules\Banners\Includes\Banner();
$banner->set_name( 'CCPA' );
$banner->set_settings( self::get_default_configs( 'ccpa' ) );
$banner->save();
}
/**
* Get banner
*
* @return object|bool
*/
public function get_active_banner() {
$items = $this->get_items();
$current_lang = cky_current_language();
foreach ( $items as $key => $item ) {
$banner = new Banner( $item->banner_id, $current_lang );
if ( true === $banner->get_status() ) {
$banner->set_language( $current_lang );
return $banner;
}
}
return false;
}
/**
* Returns the active banner item from DB.
*
* @return array
*/
public function get_active_item() {
global $wpdb;
if ( false === $this->data_exist() ) {
return array();
}
$item = $wpdb->get_row( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
"SELECT * FROM `{$wpdb->prefix}cky_banners` WHERE `status` = 1;"
);
return $this->prepare_item( $item );
}
/**
* Load template from either a localhost or web app
*
* @param Banner $object Banner object.
* @return object
*/
public function get_template( $object ) {
return new \CookieYes\Lite\Admin\Modules\Banners\Includes\Template( $object );
}
/**
* Check banner status
*
* @return boolean
*/
public function check_status() {
global $wpdb;
if ( false === $this->table_exist() ) {
return false;
}
$items = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(banner_id) FROM {$wpdb->prefix}cky_banners WHERE status = %d", 1 ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
return $items > 0 ? true : false;
}
/**
* Return the default settings of a banner.
*
* @param string $type Consent type. Default value "gdpr".
* @return array
*/
public static function get_default_configs( $type = 'gdpr' ) {
$settings = wp_cache_get( 'default', 'cky_banner_settings_' . $type );
if ( ! $settings ) {
$settings = cky_read_json_file( dirname( __FILE__ ) . '/configs/' . $type . '.json' );
wp_cache_set( 'default', $settings, 'cky_banner_settings_' . $type, 12 * HOUR_IN_SECONDS );
}
return $settings;
}
}
Fatal error: Uncaught Error: Class 'CookieYes\Lite\Admin\Modules\Banners\Includes\Controller' not found in /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/banners/api/class-api.php:55
Stack trace:
#0 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/banners/class-banners.php(55): CookieYes\Lite\Admin\Modules\Banners\Api\Api->__construct()
#1 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/banners/class-banners.php(39): CookieYes\Lite\Admin\Modules\Banners\Banners->load_apis()
#2 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/includes/class-modules.php(54): CookieYes\Lite\Admin\Modules\Banners\Banners->init()
#3 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/class-admin.php(179): CookieYes\Lite\Includes\Modules->__construct('banners')
#4 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/class-admin.php(81): Cooki in /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/banners/api/class-api.php on line 55