_json_encode( $object->get_description() ),
'prior_consent' => ( true === $object->get_prior_consent() ? 1 : 0 ),
'visibility' => ( true === $object->get_visibility() ? 1 : 0 ),
'priority' => $object->get_priority(),
'sell_personal_data' => ( true === $object->get_sell_personal_data() ? 1 : 0 ),
'meta' => wp_json_encode( $object->get_meta() ),
'date_created' => $object->get_date_created(),
'date_modified' => $object->get_date_modified(),
),
array(
'%s',
'%s',
'%s',
'%d',
'%d',
'%d',
'%d',
'%s',
'%d',
'%s',
'%s',
'%s',
)
);
$object->set_id( $wpdb->insert_id );
do_action( 'cky_after_update_cookie_category' );
}
/**
* Update an existing category on a local db.
*
* @param object $object category object.
* @return void
*/
public function update_item( $object ) {
global $wpdb;
$wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
$wpdb->prefix . 'cky_cookie_categories',
array(
'name' => wp_json_encode( $object->get_name() ),
'slug' => $object->get_slug(),
'description' => wp_json_encode( $object->get_description() ),
'prior_consent' => ( true === $object->get_prior_consent() ? 1 : 0 ),
'visibility' => ( true === $object->get_visibility() ? 1 : 0 ),
'priority' => $object->get_priority(),
'sell_personal_data' => ( true === $object->get_sell_personal_data() ? 1 : 0 ),
'meta' => wp_json_encode( $object->get_meta() ),
'date_modified' => $object->get_date_modified(),
),
array( 'category_id' => $object->get_id() ),
array(
'%s',
'%s',
'%s',
'%d',
'%d',
'%d',
'%d',
'%s',
'%d',
'%s',
'%s',
)
);
if ( defined( 'CKY_BULK_REQUEST' ) && CKY_BULK_REQUEST ) {
return;
}
do_action( 'cky_after_update_cookie_category' );
}
/**
* Properly sanitize category data before sending to the controllers.
*
* @param object $item Category raw data.
* @return object
*/
public function prepare_item( $item ) {
if ( false === is_object( $item ) ) {
return false;
}
$object = new stdClass();
$object->category_id = isset( $item->category_id ) ? absint( $item->category_id ) : 0;
$object->name = isset( $item->name ) ? cky_sanitize_content( $this->prepare_json( $item->name ) ) : '';
$object->slug = isset( $item->slug ) ? sanitize_text_field( $item->slug ) : '';
$object->description = isset( $item->description ) ? cky_sanitize_content( $this->prepare_json( $item->description ) ) : '';
$object->prior_consent = isset( $item->prior_consent ) ? absint( $item->prior_consent ) : '';
$object->priority = isset( $item->priority ) ? absint( $item->priority ) : '';
$object->visibility = isset( $item->visibility ) ? absint( $item->visibility ) : 0;
$object->sell_personal_data = isset( $item->sell_personal_data ) ? absint( $item->sell_personal_data ) : 1;
$object->meta = isset( $item->meta ) ? cky_sanitize_content( $this->prepare_json( $item->meta ) ) : '';
$object->date_created = isset( $item->date_created ) ? sanitize_text_field( $item->date_created ) : '';
$object->date_modified = isset( $item->date_modified ) ? sanitize_text_field( $item->date_modified ) : '';
return $object;
}
/**
* Delete a category from database.
*
* @param object $object Category object.
* @return void
*/
public function delete_item( $object ) {
global $wpdb;
$wpdb->delete( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
$wpdb->prefix . 'cky_cookie_categories',
array(
'category_id' => $object->get_id(),
)
);
do_action( 'cky_after_update_cookie_category' );
}
/**
* Get contents by language.
*
* @return array
*/
public static function get_defaults() {
$contents = wp_cache_get( 'cky_category_contents_en', 'cky_category_contents' );
if ( ! $contents ) {
$contents = cky_read_json_file( dirname( __FILE__ ) . '/contents/categories/en.json' );
wp_cache_set( 'cky_category_contents_en', $contents, 'cky_category_contents', 12 * HOUR_IN_SECONDS );
}
return $contents;
}
/**
* Load default cookies.
*
* @return void
*/
protected function load_default() {
$categories = self::get_defaults();
$lang = cky_default_language();
foreach ( $categories as $slug => $category ) {
$object = new \CookieYes\Lite\Admin\Modules\Cookies\Includes\Cookie_Categories();
$name[ $lang ] = isset( $category['name'] ) ? $category['name'] : '';
$description[ $lang ] = isset( $category['description'] ) ? $category['description'] : '';
$object->set_name( $name );
$object->set_description( $description );
$object->set_slug( $slug );
if ( 'necessary' === $slug ) {
$object->set_prior_consent( true );
}
$object->save();
}
}
/**
* Decode a JSON string if necessary
*
* @param string $data String data.
* @return array
*/
public function prepare_json( $data ) {
if ( empty( $data ) ) {
return array();
}
return is_string( $data ) ? json_decode( $data, true ) : $data;
}
/**
* Load items from the cache.
*
* @param boolean $id Category ID.
* @return array|object
*/
protected function get_cache( $id = false ) {
$key = 'all';
$categories = array();
$items = Cache::get( $key, $this->cache_group );
if ( false === $items ) {
return false;
}
if ( ! empty( $items ) ) {
foreach ( $items as $data ) {
$item = $this->prepare_item( $data );
if ( ! empty( $item ) ) {
$item->cookies = $data->cookies;
$categories[ $item->category_id ] = $item;
}
}
}
return isset( $id ) && isset( $categories[ $id ] ) ? $categories[ $id ] : $categories;
}
/**
* Get cookies of each category.
*
* @param string $category Category slug or id.
* @return array
*/
public function get_cookies( $category = '' ) {
$cookies = array();
if ( empty( $category ) ) {
return array();
}
$items = Cookie_Controller::get_instance()->get_items_by_category( $category );
foreach ( $items as $data ) {
$object = new Cookie( $data );
$cookies[] = $object->get_prepared_data();
}
return $cookies;
}
}
Fatal error: Uncaught Error: Class 'CookieYes\Lite\Admin\Modules\Cookies\Includes\Category_Controller' not found in /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/cookies/class-cookies.php:34
Stack trace:
#0 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/includes/class-modules.php(54): CookieYes\Lite\Admin\Modules\Cookies\Cookies->init()
#1 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/class-admin.php(179): CookieYes\Lite\Includes\Modules->__construct('cookies')
#2 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/class-admin.php(81): CookieYes\Lite\Admin\Admin->load_modules()
#3 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/includes/class-cli.php(153): CookieYes\Lite\Admin\Admin->__construct('cookie-law-info', '3.2.4')
#4 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/includes/class-cli.php(95): CookieYes\Lite\Includes\CLI->define_ in /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/cookies/class-cookies.php on line 34