rotected function validate_request_permission( $check ) { $default_capability = 'view_site_health_checks'; /** * Filters the capability needed to run a given Site Health check. * * @since 5.6.0 * * @param string $default_capability The default capability required for this check. * @param string $check The Site Health check being performed. */ $capability = apply_filters( "site_health_test_rest_capability_{$check}", $default_capability, $check ); return current_user_can( $capability ); } /** * Checks if background updates work as expected. * * @since 5.6.0 * * @return array */ public function test_background_updates() { $this->load_admin_textdomain(); return $this->site_health->get_test_background_updates(); } /** * Checks that the site can reach the WordPress.org API. * * @since 5.6.0 * * @return array */ public function test_dotorg_communication() { $this->load_admin_textdomain(); return $this->site_health->get_test_dotorg_communication(); } /** * Checks that loopbacks can be performed. * * @since 5.6.0 * * @return array */ public function test_loopback_requests() { $this->load_admin_textdomain(); return $this->site_health->get_test_loopback_requests(); } /** * Checks that the site's frontend can be accessed over HTTPS. * * @since 5.7.0 * * @return array */ public function test_https_status() { $this->load_admin_textdomain(); return $this->site_health->get_test_https_status(); } /** * Checks that the authorization header is valid. * * @since 5.6.0 * * @return array */ public function test_authorization_header() { $this->load_admin_textdomain(); return $this->site_health->get_test_authorization_header(); } /** * Checks that full page cache is active. * * @since 6.1.0 * * @return array The test result. */ public function test_page_cache() { $this->load_admin_textdomain(); return $this->site_health->get_test_page_cache(); } /** * Gets the current directory sizes for this install. * * @since 5.6.0 * * @return array|WP_Error */ public function get_directory_sizes() { if ( ! class_exists( 'WP_Debug_Data' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php'; } $this->load_admin_textdomain(); $sizes_data = WP_Debug_Data::get_sizes(); $all_sizes = array( 'raw' => 0 ); foreach ( $sizes_data as $name => $value ) { $name = sanitize_text_field( $name ); $data = array(); if ( isset( $value['size'] ) ) { if ( is_string( $value['size'] ) ) { $data['size'] = sanitize_text_field( $value['size'] ); } else { $data['size'] = (int) $value['size']; } } if ( isset( $value['debug'] ) ) { if ( is_string( $value['debug'] ) ) { $data['debug'] = sanitize_text_field( $value['debug'] ); } else { $data['debug'] = (int) $value['debug']; } } if ( ! empty( $value['raw'] ) ) { $data['raw'] = (int) $value['raw']; } $all_sizes[ $name ] = $data; } if ( isset( $all_sizes['total_size']['debug'] ) && 'not available' === $all_sizes['total_size']['debug'] ) { return new WP_Error( 'not_available', __( 'Directory sizes could not be returned.' ), array( 'status' => 500 ) ); } return $all_sizes; } /** * Loads the admin textdomain for Site Health tests. * * The {@see WP_Site_Health} class is defined in WP-Admin, while the REST API operates in a front-end context. * This means that the translations for Site Health won't be loaded by default in {@see load_default_textdomain()}. * * @since 5.6.0 */ protected function load_admin_textdomain() { // Accounts for inner REST API requests in the admin. if ( ! is_admin() ) { $locale = determine_locale(); load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo", $locale ); } } /** * Gets the schema for each site health test. * * @since 5.6.0 * * @return array The test schema. */ public function get_item_schema() { if ( $this->schema ) { return $this->schema; } $this->schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'wp-site-health-test', 'type' => 'object', 'properties' => array( 'test' => array( 'type' => 'string', 'description' => __( 'The name of the test being run.' ), 'readonly' => true, ), 'label' => array( 'type' => 'string', 'description' => __( 'A label describing the test.' ), 'readonly' => true, ), 'status' => array( 'type' => 'string', 'description' => __( 'The status of the test.' ), 'enum' => array( 'good', 'recommended', 'critical' ), 'readonly' => true, ), 'badge' => array( 'type' => 'object', 'description' => __( 'The category this test is grouped in.' ), 'properties' => array( 'label' => array( 'type' => 'string', 'readonly' => true, ), 'color' => array( 'type' => 'string', 'enum' => array( 'blue', 'orange', 'red', 'green', 'purple', 'gray' ), 'readonly' => true, ), ), 'readonly' => true, ), 'description' => array( 'type' => 'string', 'description' => __( 'A more descriptive explanation of what the test looks for, and why it is important for the user.' ), 'readonly' => true, ), 'actions' => array( 'type' => 'string', 'description' => __( 'HTML containing an action to direct the user to where they can resolve the issue.' ), 'readonly' => true, ), ), ); return $this->schema; } } > 'wp_navigation', 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'order' => 'DESC', 'orderby' => 'date', 'post_status' => 'publish', 'posts_per_page' => 1, ); $navigation_post = new WP_Query( $parsed_args ); if ( count( $navigation_post->posts ) > 0 ) { return $navigation_post->posts[0]; } return null; } /** * Creates a Navigation Menu post from a Classic Menu. * * @since 6.3.0 * * @return int|WP_Error The post ID of the default fallback menu or a WP_Error object. */ private static function create_classic_menu_fallback() { // See if we have a classic menu. $classic_nav_menu = static::get_fallback_classic_menu(); if ( ! $classic_nav_menu ) { return new WP_Error( 'no_classic_menus', __( 'No Classic Menus found.' ) ); } // If there is a classic menu then convert it to blocks. $classic_nav_menu_blocks = WP_Classic_To_Block_Menu_Converter::convert( $classic_nav_menu ); if ( is_wp_error( $classic_nav_menu_blocks ) ) { return $classic_nav_menu_blocks; } if ( empty( $classic_nav_menu_blocks ) ) { return new WP_Error( 'cannot_convert_classic_menu', __( 'Unable to convert Classic Menu to blocks.' ) ); } // Create a new navigation menu from the classic menu. $classic_menu_fallback = wp_insert_post( array( 'post_content' => $classic_nav_menu_blocks, 'post_title' => $classic_nav_menu->name, 'post_name' => $classic_nav_menu->slug, 'post_status' => 'publish', 'post_type' => 'wp_navigation', ), true // So that we can check whether the result is an error. ); return $classic_menu_fallback; } /** * Determines the most appropriate classic navigation menu to use as a fallback. * * @since 6.3.0 * * @return WP_Term|null The most appropriate classic navigation menu to use as a fallback. */ private static function get_fallback_classic_menu() { $classic_nav_menus = wp_get_nav_menus(); if ( ! $classic_nav_menus || is_wp_error( $classic_nav_menus ) ) { return null; } $nav_menu = static::get_nav_menu_at_primary_location(); if ( $nav_menu ) { return $nav_menu; } $nav_menu = static::get_nav_menu_with_primary_slug( $classic_nav_menus ); if ( $nav_menu ) { return $nav_menu; } return static::get_most_recently_created_nav_menu( $classic_nav_menus ); } /** * Sorts the classic menus and returns the most recently created one. * * @since 6.3.0 * * @param WP_Term[] $classic_nav_menus Array of classic nav menu term objects. * @return WP_Term The most recently created classic nav menu. */ private static function get_most_recently_created_nav_menu( $classic_nav_menus ) { usort( $classic_nav_menus, static function ( $a, $b ) { return $b->term_id - $a->term_id; } ); return $classic_nav_menus[0]; } /** * Returns the classic menu with the slug `primary` if it exists. * * @since 6.3.0 * * @param WP_Term[] $classic_nav_menus Array of classic nav menu term objects. * @return WP_Term|null The classic nav menu with the slug `primary` or null. */ private static function get_nav_menu_with_primary_slug( $classic_nav_menus ) { foreach ( $classic_nav_menus as $classic_nav_menu ) { if ( 'primary' === $classic_nav_menu->slug ) { return $classic_nav_menu; } } return null; } /** * Gets the classic menu assigned to the `primary` navigation menu location * if it exists. * * @since 6.3.0 * * @return WP_Term|null The classic nav menu assigned to the `primary` location or null. */ private static function get_nav_menu_at_primary_location() { $locations = get_nav_menu_locations(); if ( isset( $locations['primary'] ) ) { $primary_menu = wp_get_nav_menu_object( $locations['primary'] ); if ( $primary_menu ) { return $primary_menu; } } return null; } /** * Creates a default Navigation Block Menu fallback. * * @since 6.3.0 * * @return int|WP_Error The post ID of the default fallback menu or a WP_Error object. */ private static function create_default_fallback() { $default_blocks = static::get_default_fallback_blocks(); // Create a new navigation menu from the fallback blocks. $default_fallback = wp_insert_post( array( 'post_content' => $default_blocks, 'post_title' => _x( 'Navigation', 'Title of a Navigation menu' ), 'post_name' => 'navigation', 'post_status' => 'publish', 'post_type' => 'wp_navigation', ), true // So that we can check whether the result is an error. ); return $default_fallback; } /** * Gets the rendered markup for the default fallback blocks. * * @since 6.3.0 * * @return string default blocks markup to use a the fallback. */ private static function get_default_fallback_blocks() { $registry = WP_Block_Type_Registry::get_instance(); // If `core/page-list` is not registered then use empty blocks. return $registry->is_registered( 'core/page-list' ) ? '' : ''; } } m string $category Category slug. * @return array */ public function get_cookies( $category = '' ) { $data = array(); $items = \CookieYes\Lite\Admin\Modules\Cookies\Includes\Cookie_Controller::get_instance()->get_items_by_category( $category ); foreach ( $items as $item ) { $object = new \CookieYes\Lite\Admin\Modules\Cookies\Includes\Cookie( $item ); $data[] = array( 'cookie_id' => $object->get_name(), 'type' => $object->get_type(), 'domain' => $object->get_domain(), 'duration' => $object->get_duration(), 'description' => $object->get_description(), 'website_id' => $this->get_website_id(), 'provider' => $object->get_url_pattern(), ); } return $data; } /** * Prepare and format banners prior to sync. * * @return array */ public function prepare_banners() { $items = \CookieYes\Lite\Admin\Modules\Banners\Includes\Controller::get_instance()->get_items(); $banners = array(); foreach ( $items as $item ) { $object = new \CookieYes\Lite\Admin\Modules\Banners\Includes\Banner( $item ); $banner = array( 'id' => $object->get_id(), 'name' => $object->get_name(), 'slug' => $object->get_slug(), 'default' => $object->get_default(), 'status' => ( true === $object->get_status() ? 'active' : 'inactive' ), ); $data = array_merge( $banner, array_merge( $object->get_settings(), array( 'content' => $object->get_contents() ) ) ); $data['settings']['languages']['selected'] = cky_selected_languages(); $data['settings']['languages']['default'] = cky_default_language(); $data['settings']['ruleSet'] = array( array( 'code' => 'ALL', 'regions' => array(), ), ); $banners[] = $data; } return $banners; } /** * Fetch site info from either locally or from API. * * @param array $args Array of arguments. * @return array */ public function get_info( $args = array() ) { $data = array(); if ( false === cky_is_cloud_request() ) { $data = $this->get_site_info( $args ); } else { $data = $this->get_app_info( $args ); } return $data; } /** * Get the current plan details and features list from a local DB. * * @param array $args Array of arguments. * @return array */ public function get_site_info( $args = array() ) { return $this->get_default(); } /** * Get default site info. * * @return array */ public function get_default() { $settings = new Settings(); $scan = \CookieYes\Lite\Admin\Modules\Scanner\Includes\Controller::get_instance()->get_info(); return array( 'id' => '', 'url' => get_site_url(), 'plan' => array( 'id' => '', 'slug' => 'free', 'name' => __( 'Free', 'cookie-law-info' ), 'description' => __( 'Free Plan', 'cookie-law-info' ), 'scan_limit' => '100', 'log_limit' => 5000, 'features' => array( 'multi_law' => false, 'custom_css' => false, 'custom_branding' => false, 'config_geo_rules' => false, 'max_free_websites' => 1, 'remove_powered_by' => false, 'popup_layout' => false, ), ), 'banners' => array( 'status' => \CookieYes\Lite\Admin\Modules\Banners\Includes\Controller::get_instance()->check_status(), ), 'consent_logs' => array( 'status' => $settings->get_consent_log_status(), ), 'scans' => array( 'date' => isset( $scan['date'] ) ? $scan['date'] : '', 'status' => isset( $scan['status'] ) ? $scan['status'] : false, ), 'languages' => array( 'default' => $settings->get_default_language(), ), 'tables_missing' => count( cky_missing_tables() ) > 0 ? true : false, ); } /** * Check API before initializing the plugin. * * @return void */ public function check_api() { if ( ! cky_is_cloud_request() ) { return; } $response = $this->get_app_info(); if ( is_wp_error( $response ) ) { return; } $this->maybe_update_settings( $response ); } /** * Maybe update the plugin settings if required. * * @param array $response Response from the web app. * @return void */ public function maybe_update_settings( $response ) { $settings = new Settings(); $data = $settings->get(); $data['consent_logs'] = isset( $response['consent_logs'] ) ? $response['consent_logs'] : array(); $data['languages'] = isset( $response['languages'] ) ? $response['languages'] : array(); update_option( 'cky_settings', $data ); } /** * Load site info from the web app. * * @param array $args Array of arguments. * @return array */ public function get_app_info( $args = array() ) { $data = array(); if ( ! $this->get_website_id() ) { return new WP_Error( 'cky_invalid_website_id', __( 'Invalid Website ID', 'cookie-law-info' ), array( 'status' => 404 ) ); } $response = $this->get( 'websites/' . $this->get_website_id() ); $response_code = wp_remote_retrieve_response_code( $response ); if ( 200 === $response_code ) { $response = json_decode( wp_remote_retrieve_body( $response ), true ); $user = isset( $response['user'] ) ? $response['user'] : array(); $plan = isset( $response['websiteplan'] ) ? $response['websiteplan'] : array(); $features = isset( $plan['features'] ) ? $plan['features'] : array(); $scan_timestamp = isset( $response['last_scan_at'] ) ? strtotime( sanitize_text_field( $response['last_scan_at'] ) ) : false; $scan_success_timestamp = isset( $response['last_successful_scan_at'] ) ? strtotime( sanitize_text_field( $response['last_successful_scan_at'] ) ) : false; $date = isset( $scan_timestamp ) && is_int( $scan_timestamp ) ? gmdate( 'd M Y', $scan_timestamp ) : ''; $time = isset( $scan_timestamp ) && is_int( $scan_timestamp ) ? gmdate( 'H:i:s', $scan_timestamp ) : ''; $success_date = isset( $scan_success_timestamp ) && is_int( $scan_success_timestamp ) ? gmdate( 'd M Y', $scan_success_timestamp ) : ''; $success_time = isset( $scan_success_timestamp ) && is_int( $scan_success_timestamp ) ? gmdate( 'H:i:s', $scan_success_timestamp ) : ''; $applicable_laws = isset( $response['applicableLaws'] ) ? $response['applicableLaws'] : array( 'gdpr' ); $applicable_laws = implode( ' & ', $applicable_laws ); $grace_period = isset( $response['grace_period_ends_at'] ) ? strtotime( sanitize_text_field( $response['grace_period_ends_at'] ) ) : false; $grace_period_ends = isset( $grace_period ) && is_int( $grace_period ) ? gmdate( 'F d, Y', $grace_period ) : ''; $pageview_reset_timestamp = isset( $response['pageviews']['ends_at'] ) ? strtotime( sanitize_text_field( $response['pageviews']['ends_at'] ) ) : false; $pageview_reset_date = is_int( $pageview_reset_timestamp ) ? gmdate( 'F d, Y', $pageview_reset_timestamp ) : ''; $data = array( 'id' => $this->get_website_id(), 'url' => isset( $response['url'] ) ? esc_url_raw( $response['url'] ) : esc_url_raw( get_site_url() ), 'status' => isset( $response['status'] ) ? sanitize_text_field( $response['status'] ) : '', 'banner_disabled_manually' => isset($response['banner_disabled_manually']) && true == $response['banner_disabled_manually'], 'user' => array( 'name' => isset( $user['name'] ) ? sanitize_text_field( $user['name'] ) : '', 'email' => isset( $user['email'] ) ? sanitize_email( $user['email'] ) : '', ), 'plan' => array( 'id' => isset( $plan['id'] ) ? sanitize_text_field( $plan['id'] ) : '', 'slug' => isset( $plan['slug'] ) ? sanitize_text_field( $plan['slug'] ) : '', 'name' => isset( $plan['name'] ) ? sanitize_text_field( $plan['name'] ) : '', 'description' => isset( $plan['description'] ) ? sanitize_text_field( $plan['description'] ) : '', 'scan_limit' => isset( $plan['scan_limit'] ) ? absint( $plan['scan_limit'] ) : 100, 'log_limit' => isset( $plan['log_limit'] ) ? absint( $plan['log_limit'] ) : 5000, 'log_limit' => isset( $plan['log_limit'] ) ? absint( $plan['log_limit'] ) : 5000, 'features' => array( 'multi_law' => isset( $features['multi_law'] ) && true === $features['multi_law'] ? true : false, 'custom_css' => isset( $features['custom_css'] ) && true === $features['custom_css'] ? true : false, 'custom_branding' => isset( $features['custom_branding'] ) && true === $features['custom_branding'] ? true : false, 'config_geo_rules' => isset( $features['config_geo_rules'] ) && true === $features['config_geo_rules'] ? true : false, 'max_free_websites' => isset( $plan['max_free_websites'] ) ? absint( $plan['max_free_websites'] ) : 1, 'remove_powered_by' => isset( $features['remove_powered_by'] ) && true === $features['remove_powered_by'] ? true : false, 'popup_layout' => isset( $features['popup_layout'] ) && true === $features['popup_layout'] ? true : false, ), ), 'banners' => array( 'status' => isset( $response['banner_status'] ) && 1 === $response['banner_status'] ? true : false, 'laws' => $applicable_laws, 'is_iab_enabled' => isset( $response['isIABEnabled'] ) && true === $response['isIABEnabled'], 'targetedLocation' => isset( $response['targetedLocation'] ) ? $response['targetedLocation'] : 'worldwide', ), 'consent_logs' => array( 'status' => isset( $response['visitor_log'] ) && true === $response['visitor_log'] ? true : false, ), 'scans' => array( 'date' => array( 'date' => $date, 'time' => $time, ), 'status' => isset( $response['last_scan_at'] ) && '' !== $response['last_scan_at'] ? true : false, ), 'success_scan' => array( 'date' => array( 'date' => $success_date, 'time' => $success_time, ), 'status' => isset( $response['last_successful_scan_at'] ) && '' !== $response['last_successful_scan_at'], ), 'languages' => array( 'selected' => isset( $response['language']['preferred'] ) ? cky_sanitize_text( $response['language']['preferred'] ) : array(), 'default' => isset( $response['settings_json']['defaultLanguage'] ) ? cky_sanitize_text( $response['settings_json']['defaultLanguage'] ) : 'en', ), 'tables_missing' => false, 'pageviews' => array( 'count' => isset( $response['pageviews']['views'] ) ? absint( $response['pageviews']['views'] ) : 0, 'limit' => isset( $response['pageviews']['views_limit'] ) ? absint( $response['pageviews']['views_limit'] ) : 25000, 'exceeded' => isset( $response['pageviews']['limit_exceeded'] ) && 1 === absint( $response['pageviews']['limit_exceeded'] ), 'ends_at' => $pageview_reset_date, ), 'website' => array( 'status' => isset( $response['website_status'] ) ? sanitize_text_field( $response['website_status'] ) : 'active', 'is_trial' => isset( $response['is_trial'] ) && true === $response['is_trial'], 'is_trial_with_card' => isset( $response['trial_with_card'] ) && true === $response['trial_with_card'], 'grace_period_ends_at' => $grace_period_ends, 'payment_status' => isset( $response['payment_status'] ) && true === $response['payment_status'], 'selected_plan' => isset( $plan['slug'] ) ? sanitize_text_field( $plan['slug'] ) : 'free', 'canStartOptoutTrial' => isset( $response['canStartOptoutTrial'] ) ? (bool) $response['canStartOptoutTrial'] : false, ), ); return $data; } return new WP_Error( 'cky_api_fetching_failed', __( 'Failed to fetch data from the API', 'cookie-law-info' ), array( 'status' => 400 ) ); } /** * Force update app settings if any changes from the plugin side. * * @param array $settings Settings array. * @return void */ public function maybe_update_app_settings( $settings = array() ) { if ( ! cky_is_cloud_request() || ! $this->get_website_id() ) { return; } $data = array( 'preferred_languages' => isset( $settings['languages']['selected'] ) ? $settings['languages']['selected'] : array(), 'default_language' => isset( $settings['languages']['default'] ) ? $settings['languages']['default'] : 'en', 'visitor_log' => isset( $settings['consent_logs']['status'] ) && true === $settings['consent_logs']['status'] ? 1 : 0, ); $response = $this->put( 'websites/' . $this->get_website_id(), wp_json_encode( $data ) ); $response_code = wp_remote_retrieve_response_code( $response ); if ( 200 !== $response_code ) { return new WP_Error( 'cky_api_settings_update_failed', __( 'Failed to the update the data to web app', 'cookie-law-info' ), array( 'status' => 200 ) ); } } /** * Delete the cache. * * @return void */ public function delete_cache() { wp_cache_flush(); } }
Fatal error: Uncaught Error: Class "CookieYes\Lite\Admin\Modules\Settings\Includes\Controller" not found in /htdocs/surfshop.ma/wp-content/plugins/cookie-law-info/lite/admin/modules/settings/class-settings.php:30 Stack trace: #0 /htdocs/surfshop.ma/wp-content/plugins/cookie-law-info/lite/includes/class-modules.php(54): CookieYes\Lite\Admin\Modules\Settings\Settings->init() #1 /htdocs/surfshop.ma/wp-content/plugins/cookie-law-info/lite/admin/class-admin.php(194): CookieYes\Lite\Includes\Modules->__construct('settings') #2 /htdocs/surfshop.ma/wp-content/plugins/cookie-law-info/lite/admin/class-admin.php(91): CookieYes\Lite\Admin\Admin->load_modules() #3 /htdocs/surfshop.ma/wp-content/plugins/cookie-law-info/lite/includes/class-cli.php(153): CookieYes\Lite\Admin\Admin->__construct('cookie-law-info', '3.3.5') #4 /htdocs/surfshop.ma/wp-content/plugins/cookie-law-info/lite/includes/class-cli.php(95): CookieYes\Lite\Includes\CLI->define_admin_hooks() #5 /htdocs/surfshop.ma/wp-content/plugins/cookie-law-info/lite/loader.php(31): CookieYes\Lite\Includes\CLI->__construct() #6 /htdocs/surfshop.ma/wp-content/plugins/cookie-law-info/cookie-law-info.php(151): require_once('/htdocs/surfsho...') #7 /htdocs/surfshop.ma/wp-settings.php(526): include_once('/htdocs/surfsho...') #8 /htdocs/surfshop.ma/wp-config.php(98): require_once('/htdocs/surfsho...') #9 /htdocs/surfshop.ma/wp-load.php(50): require_once('/htdocs/surfsho...') #10 /htdocs/surfshop.ma/wp-blog-header.php(13): require_once('/htdocs/surfsho...') #11 /htdocs/surfshop.ma/index.php(17): require('/htdocs/surfsho...') #12 {main} thrown in /htdocs/surfshop.ma/wp-content/plugins/cookie-law-info/lite/admin/modules/settings/class-settings.php on line 30