ion update_item( $request ) { $object = $this->may_be_create( $request, false ); $data = $this->prepare_item_for_response( $object, $request ); return rest_ensure_response( $data ); } /** * Delete a single cookie or cookie category * * @param WP_REST_Request $request Full details about the request. * @return WP_Error|WP_REST_Response */ public function delete_item( $request ) { $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; $object = $this->get_item_object(); $object->set_id( $id ); if ( ! $object || 0 === $object->get_id() ) { return new WP_Error( 'cookieyes_rest_invalid_id', __( 'Invalid ID.', 'cookie-law-info' ), array( 'status' => 404 ) ); } $data = $this->prepare_item_for_response( $object, $request ); $object->delete(); return rest_ensure_response( $data ); } /** * Format data to provide output to API * * @param object $object Object of the corresponding item Cookie or Cookie_Categories. * @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 ); } /** * Create or update item * * @param WP_REST_Request $request WP rest request object. * @param boolean $create Decide whether to create new or update existing. * @return object */ public function may_be_create( $request, $create = false ) { $object = $this->prepare_item_for_database( $request, $create ); return $object; } /** * Prepare a single item for create or update. * * @param WP_REST_Request $request Request object. * @param boolean $create Decide whether to create new or update existing. * @return array */ public function prepare_item_for_database( $request, $create = false ) { $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0; $object = $this->get_item_object(); $object->set_id( $id ); if ( false === $create && ( ! $object || 0 === $object->get_id() ) ) { return new WP_Error( 'cookieyes_rest_invalid_id', __( 'Invalid ID.', 'cookie-law-info' ), array( 'status' => 400 ) ); } $schema = $this->get_item_schema(); $properties = isset( $schema['properties'] ) && is_array( $schema['properties'] ) ? $schema['properties'] : array(); if ( ! empty( $properties ) ) { $properties_keys = array_keys( array_filter( $properties, function( $property ) { return isset( $property['readonly'] ) && true === $property['readonly'] ? false : true; } ) ); foreach ( $properties_keys as $key ) { $value = isset( $request[ $key ] ) ? $request[ $key ] : ''; if ( true === $create && empty( $value ) ) { continue; } if ( is_callable( array( $object, "set_{$key}" ) ) ) { $object->{"set_{$key}"}( $value ); } } } $object->save(); 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' ) ), 'page' => array( 'description' => __( 'Current page of the collection.', 'cookie-law-info' ), 'type' => 'integer', 'default' => 1, 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg', 'minimum' => 1, ), 'per_page' => array( 'description' => __( 'Maximum number of items to be returned in result set.', 'cookie-law-info' ), 'type' => 'integer', 'default' => 10, 'minimum' => 1, 'maximum' => 100, 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg', ), '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', ), 'lang' => array( 'description' => __( 'Language of the cookie', 'cookie-law-info' ), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg', ), 'category' => array( 'description' => __( 'Cookie category', 'cookie-law-info' ), 'type' => 'integer', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg', ), ); } } // End the class.
Fatal error: Uncaught Error: Class 'CookieYes\Lite\Admin\Modules\Cookies\Api\API_Controller' not found in /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/cookies/api/class-categories-api.php:29 Stack trace: #0 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/class-autoloader.php(47): require() #1 [internal function]: CookieYes\Lite\Autoloader::load_class('CookieYes\\Lite\\...') #2 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/cookies/class-cookies.php(52): spl_autoload_call('CookieYes\\Lite\\...') #3 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/cookies/class-cookies.php(33): CookieYes\Lite\Admin\Modules\Cookies\Cookies->load_apis() #4 /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() #5 /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/c in /var/www/html/helitower.com.br/web/wp-content/plugins/cookie-law-info/lite/admin/modules/cookies/api/class-categories-api.php on line 29