BULK_REQUEST' ) ) { define( 'CKY_BULK_REQUEST', true ); } $item_objects = array(); $objects = array(); $data = $request['banners']; foreach ( $data as $_banner ) { $object = $this->prepare_item_for_database( $_banner ); $object->save(); $item_objects[] = $object; } foreach ( $item_objects as $data ) { $data = $this->prepare_item_for_response( $data, $request ); $objects[] = $this->prepare_response_for_collection( $data ); } do_action( 'cky_after_update_banner' ); return rest_ensure_response( $objects ); } catch ( Exception $e ) { return new WP_Error( $e->getCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); } } /** * Load banner preview. * * @param WP_REST_Request $request WP_REST_Request object. * @return WP_Error|WP_REST_Response */ public function get_preview( $request ) { $data = array(); if ( ! defined( 'CKY_PREVIEW_REQUEST' ) ) { define( 'CKY_PREVIEW_REQUEST', true ); } $object = $this->prepare_item_for_database( $request ); $language = isset( $request['language'] ) ? $request['language'] : cky_default_language(); $object->set_language( $language ); $template = $object->get_template(); $data['html'] = $template['html']; $data['styles'] = $template['styles']; return rest_ensure_response( $data ); } /** * Load presets * * @param WP_REST_Request $request WP_REST_Request object. * @return WP_Error|WP_REST_Response */ public function get_presets( $request ) { $registered = $this->get_collection_params(); $presets = array(); if ( isset( $registered['ver'], $request['ver'] ) ) { $template = new \CookieYes\Lite\Admin\Modules\Banners\Includes\Template( false ); $presets = $template->get_presets( $request['ver'] ); } return rest_ensure_response( $presets ); } /** * Load default banner configs * * @return WP_Error|WP_REST_Response */ public function get_configs() { $configs = array( 'gdpr' => $this->controller->get_default_configs(), 'ccpa' => $this->controller->get_default_configs( 'ccpa' ), ); return rest_ensure_response( $configs ); } /** * Format data to provide output to API * * @param object $object Object of the corresponding item. * @param array $request Request params. * @return array */ public function prepare_item_for_response( $object, $request ) { $data = $this->get_formatted_item_data( $object ); $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); return rest_ensure_response( $data ); } /** * Format the support before sending. * * @param Banner $object Banner object. * @return object */ public function get_formatted_item_data( $object ) { return array( 'id' => $object->get_id(), 'slug' => $object->get_slug(), 'name' => $object->get_name(), 'status' => $object->get_status(), 'default' => $object->get_default(), 'properties' => $object->get_settings(), 'contents' => $object->get_contents(), ); } /** * Prepare a single item for create or update. * * @param WP_REST_Request $request Request object. * @return object */ public function prepare_item_for_database( $request ) { $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; $object = new Banner( $id ); $object->set_name( $request['name'] ); $object->set_default( $request['default'] ); $object->set_status( $request['status'] ); $object->set_settings( $request['properties'] ); $object->set_contents( $request['contents'] ); return $object; } /** * Get the query params for collections. * * @return array */ public function get_collection_params() { return array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 'search' => array( 'description' => __( 'Limit results to those matching a string.', 'cookie-law-info' ), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg', ), 'ver' => array( 'description' => __( 'Version', 'cookie-law-info' ), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg', ), 'language' => array( 'description' => __( 'Language of the banner', 'cookie-law-info' ), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg', ), ); } /** * Get the Consent logs's schema, conforming to JSON Schema. * * @return array */ public function get_item_schema() { $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'Banners', 'type' => 'object', 'properties' => array( 'id' => array( 'description' => __( 'Unique identifier for the resource.', 'cookie-law-info' ), 'type' => 'integer', 'context' => array( 'view' ), 'readonly' => true, ), 'name' => array( 'description' => __( 'Banner name for reference', 'cookie-law-info' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'slug' => array( 'description' => __( 'Banner unique name', 'cookie-law-info' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), 'settings' => array( 'description' => __( 'Banner settings.', 'cookie-law-info' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), ), 'contents' => array( 'description' => __( 'Banner contents.', 'cookie-law-info' ), 'type' => 'object', 'context' => array( 'view', 'edit' ), ), 'default' => array( 'description' => __( 'Indicates whether the banner is default or not', 'cookie-law-info' ), 'type' => 'boolean', 'context' => array( 'view', 'edit' ), ), 'date_created' => array( 'description' => __( 'The date the banner was created, as GMT.', 'cookie-law-info' ), 'type' => 'date-time', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), 'date_modified' => array( 'description' => __( 'The date the banner was last modified, as GMT.', 'cookie-law-info' ), 'type' => 'date-time', 'context' => array( 'view', 'edit' ), ), ), ); return $this->add_additional_fields_schema( $schema ); } } // End the class.
Fatal error: Uncaught Error: Class 'CookieYes\Lite\Admin\Modules\Banners\Api\Api' not found in /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/banners/class-banners.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(39): CookieYes\Lite\Admin\Modules\Banners\Banners->load_apis() #1 /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() #2 /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') #3 /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() #4 /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-la in /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/banners/class-banners.php on line 55