e https://stackoverflow.com/a/52641198/2883487 */ public static function deepFixMixedUTF8Encoding($data) { if (is_array($data)) { foreach ($data as $key => $value) { $data[$key] = static::deepFixMixedUTF8Encoding($value); } } else if (is_string($data)) { return mb_convert_encoding($data, "UTF-8", "UTF-8"); } return $data; } /** * Get current locale's code. The language code's part that comes before underscore '_' char is returned. * * @return string Language code of the current locale of WP * @since 1.8.0 */ public static function getLocaleCode() { // Get the locale from WP $locale = get_locale(); // If there exists a locale and it contains an underscore if ($locale && Str::contains($locale, '_')) { // Get the part coming before the underscore $exploded = explode('_', $locale); $locale = $exploded[0]; // Otherwise, if there is no locale, set a default code. } else if (!$locale) { $locale = 'en'; } return $locale; } /** * Get published sites. * * @return array See {@link get_posts}. * @uses get_posts * @since 1.9.0 */ public static function getSites() { // If the value was prepared before, return it. if (static::$SITES) return static::$SITES; // Get the sites $sites = get_posts(['post_type' => Environment::postType(), 'numberposts' => -1]); // Define a default title for the sites that do not have a title. $defaultTitle = _wpcc('(no title)'); // Prepare the sites array_walk($sites, function($item) use (&$defaultTitle) { /** @var WP_Post $item */ // If the site does not have a title, set its title as the default title. if (!$item->post_title) $item->post_title = $defaultTitle; // Add the ID to the title. $item->post_title .= " ({$item->ID})"; }); static::$SITES = $sites; return static::$SITES; } /** * @return array See {@link Utils::$authors} * @since 1.11.0 */ public static function getAuthors() { if (static::$authors === null) { // Get authors $authorsRaw = get_users([ 'orderby' => 'nicename', 'fields' => ['ID', 'user_nicename'] ]); static::$authors = []; foreach($authorsRaw as $author) { static::$authors[$author->ID] = $author->user_nicename; } } return static::$authors; } /** * Get post statuses * * @return array An associative array of post statuses where keys are unique status keys and * values are human-readable names. * * @since 1.11.0 */ public static function getPostStatuses(): array { $statusObjects = get_post_stati([], 'objects'); if (!$statusObjects) return []; $result = []; foreach($statusObjects as $statusObject) { $name = $statusObject->name ?? null; $label = $statusObject->label ?? _wpcc('Unknown'); if ($name === null) continue; $result[$name] = "$label ($name)"; } return $result; } /** * Get sites in a structure that can be used to easily show them in a select element. * * @return array A key-value pair where the keys are site IDs and the values are the site names. * @uses Utils::getSites() * @since 1.9.0 */ public static function getSitesForSelect() { // Get available sites $availableSites = Utils::getSites(); if (!$availableSites) return []; $sites = []; foreach($availableSites as $site) { $sites[$site->ID] = $site->post_title; } return $sites; } /** * Remove empty strings from a sequential array * * @param array $arr A sequential array * @return array Filtered sequential array * @since 1.9.0 */ public static function filterEmptyStrings($arr) { return array_filter($arr, function($v) { return $v !== ''; }); } /** * Check if an option is selected or not. * * @param string $optionValue * @param array|string $selectedValues * @return bool True if the option is selected. * @since 1.9.0 */ public static function isOptionSelected($optionValue, $selectedValues) { return !is_array($selectedValues) ? $selectedValues == $optionValue : array_search($optionValue, $selectedValues) !== false; } /** * Prepare a query string with the given parameters. This method creates the query string considering the given URL. * * @param string $url URL for which the query string should be prepared * @param array $params Query parameters * @return string Query string starting with either "&" or "?" depending on the given URL. * @since 1.9.0 */ public static function buildQueryString($url, $params) { if (!$params) return $url; return (Str::contains($url, '?') ? '&' : '?') . http_build_query($params); } /** * Escapes special characters in the regular expression replacement strings * * @param string $replacementStr * @return mixed * @since 1.9.0 */ public static function quoteRegexReplacementString(string $replacementStr) { return str_replace('$', '\\$', $replacementStr); } /** * @return bool True if the script is called from an AJAX request. * @since 1.9.0 */ public static function isAjax() { return defined('DOING_AJAX') && DOING_AJAX; } /** * @return bool True if the current page belongs to the plugin. Otherwise, false. * @since 1.9.0 */ public static function isPluginPage() { global $post_type; if ($post_type && strtolower($post_type) === strtolower(Environment::postType())) return true; if(!isset($_GET)) return false; // @phpstan-ignore-line return isset($_GET['post_type']) && strtolower($_GET['post_type']) === strtolower(Environment::postType()); } /** * Get the items existing in all of the arrays * * @param mixed ...$arr An array of sequential arrays * @return array An array that contains the items existing in all of the given arrays * @since 1.11.0 */ public static function arrayIntersect(...$arr): array { if (!$arr || sizeof($arr) < 2) return []; $smallestIndex = 0; $smallest = $arr[$smallestIndex]; // If the smallest array is an empty array, the intersection is an empty array. if (!$smallest) return []; // Find the smallest-size array $smallestSize = sizeof($smallest); for($i = 1; $i < sizeof($arr); $i++) { // If an array is empty, the intersection is an empty array. if (!$arr[$i]) return []; if (sizeof($arr[$i]) >= $smallestSize) continue; $smallest = $arr[$i]; $smallestSize = sizeof($smallest); $smallestIndex = $i; } // Remove the smallest-size array from the given arrays unset($arr[$smallestIndex]); // Items in the smallest-size array must exist in all other arrays. foreach($arr as $item) { if (!$smallest) return []; // @phpstan-ignore-line foreach($smallest as $k => $target) { // If the item exists, continue with the next one. if (in_array($target, $item, true)) continue; // This item does not exist in the smallest-size array. Remove it. unset($smallest[$k]); if (!$smallest) return []; // @phpstan-ignore-line } } // The smallest-size array is the intersection array. return $smallest; } /** * @param object[]|null $arr A sequential object array whose unique items are needed * @return object[] An array of unique objects * @since 1.11.0 */ public static function arrayUniqueObject(?array $arr): array { if ($arr === null || !$arr) return []; $idArray = []; foreach($arr as $item) { if (!is_object($item)) continue; // spl_object_id is a unique ID given to each object. So, the ID array can only have unique objects since // unique IDs are used as keys. If an object has the same ID as an object existing in the ID array, then // it will just be reassigned. So, ID array is unique. $idArray[spl_object_id($item)] = $item; } // Just return the values of the ID array as the final unique array. return array_values($idArray); } /** * Check if a plugin is currently active. This method is created by examining {@link is_plugin_active()} and * {@link is_plugin_active_for_network()}. These functions are available in "admin_init" event, while this method * is available any time. * * @param string|null $plugin Path of the plugin's entrypoint file relative to the "plugins" directory. For * example, for WooCommerce, this is "woocommerce/woocommerce.php". * @return bool * @since 1.11.0 */ public static function isPluginActive(?string $plugin): bool { if (!$plugin) return false; // If this is not a multi site if (!is_multisite()) { return in_array($plugin, apply_filters('active_plugins', get_option('active_plugins'))); } // This is a multi site installation. Get site-wide active plugins. $activePlugins = get_site_option('active_sitewide_plugins'); // Make sure it is an array, since the return type does not guarantee that. return !is_array($activePlugins) ? false : in_array($plugin, array_keys($activePlugins)); } /** * @return array|string[] Decimal separator options that can be shown in a select form item * @since 1.11.0 */ public static function getDecimalSeparatorOptionsForSelect(): array { return [ 'dot' => _wpcc('Dot') . ' (.)', 'comma' => _wpcc('Comma') . ' (,)', ]; } /** * Check if an array has non-empty values. This does not check inner arrays. * * @param array $arr An array * @return bool True if the array has values that are non-empty * @since 1.11.0 */ public static function hasNonEmptyValues(array $arr): bool { return !empty(array_filter($arr, function($v) { if (is_array($v) || is_object($v)) { return !empty($v); } return $v !== ''; })); } /** * Shifts the first key from a dot key. The dot key will be set to the remaining key after this operation. The first * key will be returned. The remaining key, i.e. the value of $dotKey, will be an empty string if the given $dotKey * has only one part. * * @param string|null $dotKey A dot notation key * @param string $separator The separator used in the dot key. This is typically '.' * @return string|null First key. If the dotKey is null or an empty string, returns null. If the dot key could not * be separated by using the given separator, returns null. * @since 1.11.1 */ public static function shiftFirstKey(?string &$dotKey, string $separator = '.'): ?string { if ($dotKey === null || $dotKey === '') { return null; } // Explode the dot key from the separators. Set the limit as 2 since we need the first key and the rest of the // dot key. $exploded = explode($separator, $dotKey, 2); if ($exploded) { // Get the first key $firstKey = $exploded[0]; // The remaining dot key should be in the index 1. $dotKey = $exploded[1] ?? ''; return $firstKey; } return null; } /** * Get the details of attachments with their IDs * * @param string[]|int[]|null $attachmentIds IDs of the attachments whose information is needed * @return array|null An array whose keys are attachment IDs and whose values are the information about * the attachments retrieved via {@link wp_prepare_attachment_for_js()}. * @since 1.12.0 */ public static function getAttachmentInfo(?array $attachmentIds): ?array { if (!$attachmentIds) return null; $preparedIds = array_filter(array_map(function($value) { return is_numeric($value) ? (int) $value : null; }, $attachmentIds)); // Get the attachments $attachments = get_posts([ 'numberposts' => -1, 'orderby' => 'post__in', 'include' => $preparedIds, 'post_status' => 'any', 'post_type' => 'attachment', ]); // Prepare the attachment details $result = []; foreach($attachments as $attachment) { if (!($attachment instanceof WP_Post)) continue; $info = wp_prepare_attachment_for_js($attachment) ?: null; if (!is_array($info)) continue; $result[$attachment->ID] = $info; } return $result; } }
Fatal error: Uncaught Error: Class 'WPCCrawler\Utils' not found in /home/healths/public_html/wp-content/plugins/wp-content-crawler/app/RequirementValidator.php:58 Stack trace: #0 /home/healths/public_html/wp-content/plugins/wp-content-crawler/app/WPCCrawler.php(58): WPCCrawler\RequirementValidator->validateAll() #1 /home/healths/public_html/wp-content/plugins/wp-content-crawler/app/WPCCrawler.php(44): WPCCrawler\WPCCrawler->__construct() #2 /home/healths/public_html/wp-content/plugins/wp-content-crawler/wp-content-crawler.php(28): WPCCrawler\WPCCrawler::getInstance() #3 /home/healths/public_html/wp-settings.php(473): include_once('/home/healths/p...') #4 /home/healths/public_html/wp-config.php(99): require_once('/home/healths/p...') #5 /home/healths/public_html/wp-load.php(50): require_once('/home/healths/p...') #6 /home/healths/public_html/wp-blog-header.php(13): require_once('/home/healths/p...') #7 /home/healths/public_html/index.php(17): require('/home/healths/p...') #8 {main} thrown in /home/healths/public_html/wp-content/plugins/wp-content-crawler/app/RequirementValidator.php on line 58