* * @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