*/ private static $cache = array(); /** * Rows of one section: each row is array( label, value, state ), state is * 'ok', 'warn', 'error' or '' (plain information). * * @return array section title => rows. */ public static function sections() { return array( __( 'cPOD Kit', 'cpod-kit' ) => self::cpod_rows(), __( 'WordPress', 'cpod-kit' ) => self::wordpress_rows(), __( 'Server', 'cpod-kit' ) => self::server_rows(), __( 'WooCommerce', 'cpod-kit' ) => self::woocommerce_rows(), __( 'Order storage (HPOS)', 'cpod-kit' ) => self::hpos_rows(), __( 'Theme', 'cpod-kit' ) => self::theme_rows(), ); } /** * Version, edition, modules and background jobs. * * @return array */ public static function cpod_rows() { $rows = array(); $rows[] = array( __( 'Version', 'cpod-kit' ), CPOD_VERSION . ' (' . ( TopBar::is_pro() ? 'Pro' : 'Free' ) . ')', '' ); foreach ( Modules::all() as $id => $module ) { list( $badge ) = Menu::state_badge( $id ); $state = Modules::state( $id ); $rows[] = array( $module['name'], $badge, 'running' === $state ? 'ok' : ( 'off' === $state ? '' : 'warn' ) ); } $jobs = self::jobs(); /* translators: 1: number of waiting jobs, 2: number of failed jobs */ $rows[] = array( __( 'Background jobs', 'cpod-kit' ), sprintf( __( '%1$d waiting, %2$d failed', 'cpod-kit' ), $jobs['pending'], $jobs['failed'] ), $jobs['failed'] ? 'warn' : '' ); /** * Rows of the cPOD Kit section of System Status. * * @param array $rows array( label, value, state ) rows. */ return (array) apply_filters( 'cpod_status_rows', $rows ); } /** * WordPress version, site and debug settings. * * @return array */ public static function wordpress_rows() { global $wp_version; $required = self::plugin_header( 'Requires at least' ); $rows = array(); $rows[] = array( __( 'Version', 'cpod-kit' ), (string) $wp_version, $required && version_compare( (string) $wp_version, $required, '<' ) ? 'error' : 'ok' ); $rows[] = array( __( 'Site address', 'cpod-kit' ), home_url(), '' ); $rows[] = array( __( 'Multisite', 'cpod-kit' ), is_multisite() ? __( 'Yes', 'cpod-kit' ) : __( 'No', 'cpod-kit' ), '' ); $rows[] = array( __( 'Language', 'cpod-kit' ), get_locale(), '' ); $memory = self::memory_limit( defined( 'WP_MEMORY_LIMIT' ) ? (string) constant( 'WP_MEMORY_LIMIT' ) : '', (string) ini_get( 'memory_limit' ) ); $rows[] = array( __( 'Memory limit', 'cpod-kit' ), $memory['label'], $memory['state'] ); $rows[] = array( __( 'Debug mode', 'cpod-kit' ), defined( 'WP_DEBUG' ) && WP_DEBUG ? __( 'On', 'cpod-kit' ) : __( 'Off', 'cpod-kit' ), '' ); $rows[] = array( __( 'Debug log', 'cpod-kit' ), defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ? __( 'On', 'cpod-kit' ) : __( 'Off', 'cpod-kit' ), '' ); $rows[] = array( __( 'Cron', 'cpod-kit' ), defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ? __( 'WP-Cron off (server cron expected)', 'cpod-kit' ) : __( 'WP-Cron on', 'cpod-kit' ), '' ); return $rows; } /** * PHP and database. * * @return array */ public static function server_rows() { global $wpdb; $required = self::plugin_header( 'Requires PHP' ); $rows = array(); $rows[] = array( 'PHP', PHP_VERSION, $required && version_compare( PHP_VERSION, $required, '<' ) ? 'error' : 'ok' ); $rows[] = array( __( 'PHP memory limit', 'cpod-kit' ), (string) ini_get( 'memory_limit' ), '' ); $rows[] = array( __( 'PHP max execution time', 'cpod-kit' ), (string) ini_get( 'max_execution_time' ), '' ); $rows[] = array( __( 'Database', 'cpod-kit' ), is_object( $wpdb ) && method_exists( $wpdb, 'db_server_info' ) ? (string) $wpdb->db_server_info() : '', '' ); $rows[] = array( __( 'Web server', 'cpod-kit' ), isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '', '' ); return $rows; } /** * WooCommerce version and cart/checkout pages. * * @return array */ public static function woocommerce_rows() { $rows = array(); if ( ! defined( 'WC_VERSION' ) ) { $rows[] = array( __( 'Version', 'cpod-kit' ), __( 'Not active', 'cpod-kit' ), 'error' ); return $rows; } $min = self::plugin_header( 'WC requires at least' ); $tested = self::plugin_header( 'WC tested up to' ); $state = 'ok'; $value = WC_VERSION; if ( $min && version_compare( WC_VERSION, $min, '<' ) ) { $state = 'error'; /* translators: %s: version number */ $value .= ' ' . sprintf( __( '(cPOD Kit needs %s or newer)', 'cpod-kit' ), $min ); } elseif ( $tested && version_compare( self::major_minor( WC_VERSION ), self::major_minor( $tested ), '>' ) ) { $state = 'warn'; /* translators: %s: version number */ $value .= ' ' . sprintf( __( '(newer than the last version tested, %s)', 'cpod-kit' ), $tested ); } $rows[] = array( __( 'Version', 'cpod-kit' ), $value, $state ); $rows[] = array( __( 'Cart page', 'cpod-kit' ), self::page_kind( 'cart' ), '' ); $rows[] = array( __( 'Checkout page', 'cpod-kit' ), self::page_kind( 'checkout' ), '' ); return $rows; } /** * Order storage: which store is used, sync mode, plugins that did not declare HPOS support. * * @return array */ public static function hpos_rows() { $info = self::hpos(); $rows = array(); if ( null === $info['enabled'] ) { $rows[] = array( __( 'Order storage', 'cpod-kit' ), __( 'Unknown (WooCommerce too old or not active)', 'cpod-kit' ), '' ); return $rows; } $rows[] = array( __( 'Order storage', 'cpod-kit' ), $info['enabled'] ? __( 'High-performance order storage (HPOS)', 'cpod-kit' ) : __( 'WordPress posts storage', 'cpod-kit' ), 'ok' ); $rows[] = array( __( 'Compatibility mode (sync)', 'cpod-kit' ), $info['sync'] ? __( 'On', 'cpod-kit' ) : __( 'Off', 'cpod-kit' ), '' ); $rows[] = array( __( 'cPOD Kit', 'cpod-kit' ), __( 'Compatible (declared)', 'cpod-kit' ), 'ok' ); if ( null !== $info['incompatible'] ) { $rows[] = array( __( 'Plugins not declared compatible', 'cpod-kit' ), $info['incompatible'] ? implode( ', ', $info['incompatible'] ) : __( 'None', 'cpod-kit' ), $info['incompatible'] ? 'warn' : 'ok', ); } return $rows; } /** * HPOS state. * * @return array{enabled: bool|null, sync: bool, incompatible: string[]|null} */ public static function hpos() { if ( isset( self::$cache['hpos'] ) ) { return self::$cache['hpos']; } $out = array( 'enabled' => null, 'sync' => false, 'incompatible' => null, ); $util = 'Automattic\\WooCommerce\\Utilities\\OrderUtil'; if ( class_exists( $util ) && is_callable( array( $util, 'custom_orders_table_usage_is_enabled' ) ) ) { $out['enabled'] = (bool) call_user_func( array( $util, 'custom_orders_table_usage_is_enabled' ) ); $out['sync'] = 'yes' === get_option( 'woocommerce_custom_orders_table_data_sync_enabled' ); } $controller = 'Automattic\WooCommerce\Internal\Features\FeaturesController'; if ( null !== $out['enabled'] && function_exists( 'wc_get_container' ) && class_exists( $controller ) ) { try { /** * FeaturesController is internal to WooCommerce and not in the stubs, so the container is read as a plain object. * * @var object $container */ $container = wc_get_container(); $features = method_exists( $container, 'get' ) ? $container->get( $controller ) : null; if ( method_exists( $features, 'get_compatible_plugins_for_feature' ) ) { $list = (array) $features->get_compatible_plugins_for_feature( 'custom_order_tables', true ); $files = array_merge( isset( $list['incompatible'] ) ? (array) $list['incompatible'] : array(), isset( $list['uncertain'] ) ? (array) $list['uncertain'] : array() ); $names = array(); $all = self::installed_plugins(); foreach ( array_unique( $files ) as $file ) { $names[] = isset( $all[ $file ]['Name'] ) ? $all[ $file ]['Name'] : $file; } sort( $names ); $out['incompatible'] = $names; } } catch ( \Throwable $e ) { $out['incompatible'] = null; } } self::$cache['hpos'] = $out; return $out; } /** * Active theme and parent theme. * * @return array */ public static function theme_rows() { $theme = wp_get_theme(); $parent = $theme->parent(); $base = $parent ? $parent : $theme; $tested = in_array( strtolower( (string) $base->get_template() ), self::TESTED_THEMES, true ); $rows = array(); $rows[] = array( __( 'Theme', 'cpod-kit' ), $theme->get( 'Name' ) . ' ' . $theme->get( 'Version' ), '' ); if ( $parent ) { $rows[] = array( __( 'Parent theme', 'cpod-kit' ), $parent->get( 'Name' ) . ' ' . $parent->get( 'Version' ), '' ); } $rows[] = array( __( 'Block theme', 'cpod-kit' ), function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ? __( 'Yes', 'cpod-kit' ) : __( 'No', 'cpod-kit' ), '' ); $rows[] = array( __( 'Tested with cPOD Kit', 'cpod-kit' ), $tested ? __( 'Yes', 'cpod-kit' ) : __( 'Not in the tested list (Flatsome, Astra, Storefront); it usually works', 'cpod-kit' ), $tested ? 'ok' : '' ); return $rows; } /** * Active plugins (site and network), sorted by name. * * @return array file => data. */ public static function active_plugins() { if ( isset( self::$cache['active'] ) ) { return self::$cache['active']; } $files = (array) get_option( 'active_plugins', array() ); if ( is_multisite() ) { $files = array_merge( $files, array_keys( (array) get_site_option( 'active_sitewide_plugins', array() ) ) ); } $all = self::installed_plugins(); $out = array(); foreach ( array_unique( $files ) as $file ) { $file = (string) $file; $out[ $file ] = array( 'name' => isset( $all[ $file ]['Name'] ) && '' !== $all[ $file ]['Name'] ? (string) $all[ $file ]['Name'] : $file, 'version' => isset( $all[ $file ]['Version'] ) ? (string) $all[ $file ]['Version'] : '', 'author' => isset( $all[ $file ]['Author'] ) ? wp_strip_all_tags( (string) $all[ $file ]['Author'] ) : '', ); } uasort( $out, static function ( $a, $b ) { return strcasecmp( $a['name'], $b['name'] ); } ); self::$cache['active'] = $out; return $out; } /** * Must-use plugins: file => name. * * @return array */ public static function mu_plugins() { if ( ! function_exists( 'get_mu_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $out = array(); foreach ( (array) get_mu_plugins() as $file => $data ) { $out[ $file ] = ! empty( $data['Name'] ) ? (string) $data['Name'] : (string) $file; } return $out; } /** * Known overlaps. Each rule: module id, folder names of plugins that do the * same job, words that point to the same job in other plugin names, what can * happen, and the kind ('overlap' or 'note' for advice that is not a clash). * * @return array */ public static function rules() { $rules = array( 'size-chart' => array( 'module' => 'size-chart', 'folders' => array( 'woo-advanced-product-size-chart', 'product-size-chart-for-woo', 'size-chart-for-woocommerce', 'woo-product-size-chart', 'ct-size-guide' ), 'words' => array( 'size chart', 'size guide', 'sizing chart' ), 'kind' => 'overlap', 'effect' => __( 'Two size guide buttons or popups can show on the same product.', 'cpod-kit' ), ), 'estimated-delivery' => array( 'module' => 'estimated-delivery', 'folders' => array( 'estimated-delivery-for-woocommerce', 'order-delivery-date-for-woocommerce', 'woo-estimated-shipping-date' ), 'words' => array( 'estimated delivery', 'delivery date', 'shipping date', 'delivery time' ), 'kind' => 'overlap', 'effect' => __( 'Two delivery estimates with different dates can show on the product page.', 'cpod-kit' ), ), 'swatches' => array( 'module' => 'pod-profile', 'folders' => array( 'woo-variation-swatches', 'variation-swatches-for-woocommerce', 'wpc-variation-swatches', 'yith-woocommerce-color-label-variations' ), 'words' => array( 'swatch' ), 'kind' => 'overlap', 'effect' => __( 'Two color and size pickers can show, or one hides the other. Use one of them on POD products.', 'cpod-kit' ), ), 'product-sections' => array( 'module' => 'product-sections', 'folders' => array( 'yikes-inc-easy-custom-woocommerce-product-tabs', 'woocommerce-tab-manager', 'yith-woocommerce-tab-manager', 'woo-product-tabs', 'product-tabs-for-woocommerce' ), 'words' => array( 'product tab', 'tab manager', 'custom tabs' ), 'kind' => 'overlap', 'effect' => __( 'Shipping, returns or details tabs can show twice, or the tab order changes.', 'cpod-kit' ), ), 'quick-view' => array( 'module' => 'quick-view', 'folders' => array( 'yith-woocommerce-quick-view', 'woo-smart-quick-view', 'quick-view-for-woocommerce', 'woo-quick-view' ), 'words' => array( 'quick view', 'quickview' ), 'kind' => 'overlap', 'effect' => __( 'Two Quick View buttons can show on the shop page.', 'cpod-kit' ), ), 'upsell' => array( 'module' => 'upsell', 'folders' => array( 'woo-bought-together', 'yith-woocommerce-frequently-bought-together', 'woo-product-bundle' ), 'words' => array( 'bought together', 'frequently bought', 'upsell', 'cross-sell', 'cross sell', 'buy more' ), 'kind' => 'overlap', 'effect' => __( 'Offers and bundle discounts can show twice or add up in the cart.', 'cpod-kit' ), ), 'checkout-extras' => array( 'module' => 'checkout-extras', 'folders' => array(), 'words' => array( 'trust badge', 'checkout countdown', 'checkout timer' ), 'kind' => 'overlap', 'effect' => __( 'Two countdowns or two sets of trust badges can show at checkout.', 'cpod-kit' ), ), 'cache' => array( 'module' => '', 'folders' => array( 'litespeed-cache', 'wp-rocket', 'autoptimize', 'w3-total-cache', 'wp-fastest-cache', 'sg-cachepress', 'wp-optimize', 'breeze', 'perfmatters', 'flying-press', 'wp-super-cache', 'hummingbird-performance' ), 'words' => array(), 'kind' => 'note', 'effect' => __( 'Cache and CSS/JS optimizers keep old files. Clear their cache after updating cPOD Kit, and exclude cPOD Kit scripts from "delay JS" if the pickers or popups stop working.', 'cpod-kit' ), ), 'addons' => array( 'module' => 'pod-profile', 'folders' => array( 'woo-custom-product-addons', 'woo-custom-product-addons-pro', 'advanced-product-fields-for-woocommerce', 'advanced-product-fields-for-woocommerce-pro' ), 'words' => array(), 'kind' => 'note', 'effect' => __( 'Tested with cPOD Kit: product options from this plugin work together with the Color & Size picker.', 'cpod-kit' ), ), ); /** * Filters the overlap rules of System Status. * * @param array $rules id => array( module, folders, words, kind, effect ). */ return (array) apply_filters( 'cpod_status_conflicts', $rules ); } /** * Active plugins that overlap a running module, or need a note. * * @param array|null $plugins Active plugins (file => name, version), default: the site's. * @param callable $running Returns whether a module id is running (for tests). * @return array[] Each: array( rule, module, module_name, plugin, file, kind, effect, match ). */ public static function conflicts( $plugins = null, $running = null ) { if ( null === $plugins && isset( self::$cache['conflicts'] ) ) { return self::$cache['conflicts']; } $plugins = null === $plugins ? self::active_plugins() : $plugins; $running = is_callable( $running ) ? $running : array( Modules::class, 'is_running' ); $found = array(); foreach ( self::rules() as $rule_id => $rule ) { $module = isset( $rule['module'] ) ? (string) $rule['module'] : ''; if ( '' !== $module && ! call_user_func( $running, $module ) ) { continue; } $folders = isset( $rule['folders'] ) ? array_map( 'strtolower', (array) $rule['folders'] ) : array(); $words = isset( $rule['words'] ) ? array_map( 'strtolower', (array) $rule['words'] ) : array(); foreach ( $plugins as $file => $data ) { if ( self::is_cpod( $file ) ) { continue; } $folder = strtolower( (string) strtok( (string) $file, '/' ) ); $name = strtolower( isset( $data['name'] ) ? (string) $data['name'] : '' ); $match = ''; if ( in_array( $folder, $folders, true ) || in_array( preg_replace( '/-(premium|pro)$/', '', $folder ), $folders, true ) ) { $match = 'known'; } else { foreach ( $words as $word ) { if ( '' !== $word && false !== strpos( $name, $word ) ) { $match = 'name'; break; } } } if ( '' === $match ) { continue; } $manifest = '' !== $module ? Modules::get( $module ) : null; $found[] = array( 'rule' => (string) $rule_id, 'module' => $module, 'module_name' => $manifest ? (string) $manifest['name'] : '', 'plugin' => isset( $data['name'] ) ? (string) $data['name'] : (string) $file, 'file' => (string) $file, 'kind' => isset( $rule['kind'] ) && 'note' === $rule['kind'] ? 'note' : 'overlap', 'effect' => isset( $rule['effect'] ) ? (string) $rule['effect'] : '', 'match' => $match, ); } } if ( func_num_args() === 0 ) { self::$cache['conflicts'] = $found; } return $found; } /** * Number of possible overlaps (notes not counted). * * @return int */ public static function overlap_count() { $n = 0; foreach ( self::conflicts() as $row ) { if ( 'overlap' === $row['kind'] ) { ++$n; } } return $n; } /** * Waiting and failed background jobs of cPOD Kit. * * @return array{pending: int, failed: int} */ public static function jobs() { if ( isset( self::$cache['jobs'] ) ) { return self::$cache['jobs']; } $out = array( 'pending' => 0, 'failed' => 0, ); $cron = function_exists( '_get_cron_array' ) ? _get_cron_array() : array(); foreach ( (array) $cron as $hooks ) { foreach ( (array) $hooks as $hook => $events ) { if ( in_array( $hook, self::JOB_HOOKS, true ) ) { $out['pending'] += count( (array) $events ); } } } if ( function_exists( 'as_get_scheduled_actions' ) ) { foreach ( self::JOB_HOOKS as $hook ) { foreach ( array( 'pending' => 'pending', 'failed' => 'failed', ) as $key => $status ) { $ids = as_get_scheduled_actions( array( 'hook' => $hook, 'status' => $status, 'per_page' => 100, ), 'ids' ); $out[ $key ] += is_array( $ids ) ? count( $ids ) : 0; } } } self::$cache['jobs'] = $out; return $out; } /** * The whole status as plain text, for "Copy report" and support requests. * * @return string */ public static function report_text() { $lines = array( '### cPOD Kit System Status ###', '' ); foreach ( self::sections() as $title => $rows ) { $lines[] = '## ' . $title; foreach ( $rows as $row ) { $lines[] = $row[0] . ': ' . $row[1] . self::state_mark( $row[2] ); } $lines[] = ''; } $lines[] = '## ' . __( 'Possible conflicts', 'cpod-kit' ); $conflicts = self::conflicts(); if ( ! $conflicts ) { $lines[] = __( 'None found', 'cpod-kit' ); } foreach ( $conflicts as $row ) { $lines[] = $row['plugin'] . ( $row['module_name'] ? ' <> ' . $row['module_name'] : '' ) . ' [' . $row['kind'] . ']: ' . $row['effect']; } $lines[] = ''; $active = self::active_plugins(); /* translators: %d: number of plugins */ $lines[] = '## ' . sprintf( __( 'Active plugins (%d)', 'cpod-kit' ), count( $active ) ); foreach ( $active as $data ) { $lines[] = $data['name'] . ' ' . $data['version'] . ( $data['author'] ? ' – ' . $data['author'] : '' ); } $mu = self::mu_plugins(); if ( $mu ) { $lines[] = ''; $lines[] = '## ' . __( 'Must-use plugins', 'cpod-kit' ); foreach ( $mu as $name ) { $lines[] = $name; } } return implode( "\n", $lines ) . "\n"; } /** * Text mark of a state, for the plain-text report. * * @param string $state ok|warn|error|''. * @return string */ public static function state_mark( $state ) { switch ( $state ) { case 'warn': return ' [!]'; case 'error': return ' [x]'; default: return ''; } } /** * Every installed plugin (WordPress caches the list for the request). * * @return array */ private static function installed_plugins() { if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } return (array) get_plugins(); } /** * Whether a plugin file is cPOD Kit itself (Free or Pro). * * @param string $file Plugin file relative to the plugins folder. * @return bool */ private static function is_cpod( $file ) { $folder = strtolower( (string) strtok( (string) $file, '/' ) ); return in_array( $folder, array( 'cpod-kit', 'cpod-kit-pro' ), true ) || ( defined( 'CPOD_FILE' ) && plugin_basename( CPOD_FILE ) === $file ); } /** * A header of the running cPOD Kit main file. * * @param string $name Header name, e.g. "Requires PHP". * @return string */ private static function plugin_header( $name ) { if ( ! isset( self::$cache['headers'] ) ) { self::$cache['headers'] = function_exists( 'get_file_data' ) && defined( 'CPOD_FILE' ) ? get_file_data( CPOD_FILE, array( 'Requires at least' => 'Requires at least', 'Requires PHP' => 'Requires PHP', 'WC requires at least' => 'WC requires at least', 'WC tested up to' => 'WC tested up to', ) ) : array(); } return isset( self::$cache['headers'][ $name ] ) ? trim( (string) self::$cache['headers'][ $name ] ) : ''; } /** * "11.2.1" → "11.2". * * @param string $version Version. * @return string */ private static function major_minor( $version ) { $parts = explode( '.', (string) $version ); return $parts[0] . '.' . ( isset( $parts[1] ) ? (int) $parts[1] : 0 ); } /** * Whether the cart or checkout page uses its block or the classic shortcode. * * @param string $page cart|checkout. * @return string */ private static function page_kind( $page ) { $id = function_exists( 'wc_get_page_id' ) ? (int) wc_get_page_id( $page ) : 0; $post = $id > 0 ? get_post( $id ) : null; if ( ! $post ) { return __( 'Not set', 'cpod-kit' ); } if ( has_block( 'woocommerce/' . $page, $post ) ) { return __( 'Block', 'cpod-kit' ); } if ( has_shortcode( (string) $post->post_content, 'woocommerce_' . $page ) ) { return __( 'Classic shortcode', 'cpod-kit' ); } return __( 'Other (page builder or template)', 'cpod-kit' ); } /** * Memory WordPress really gets: WordPress raises PHP's limit to * WP_MEMORY_LIMIT when that is higher and never lowers it, so the larger * of the two applies. Warns only under 128 MB. * * @param string $wp WP_MEMORY_LIMIT, e.g. "40M". * @param string $ini PHP memory_limit, e.g. "256M" or "-1". * @return array{label: string, state: string} */ public static function memory_limit( $wp, $ini ) { $wp = trim( (string) $wp ); $ini = trim( (string) $ini ); if ( '-1' === $ini ) { $label = __( 'Unlimited', 'cpod-kit' ); return array( 'label' => '' !== $wp ? $label . ' (WP_MEMORY_LIMIT ' . $wp . ')' : $label, 'state' => '', ); } $wp_bytes = '' !== $wp ? self::bytes( $wp ) : 0; $ini_bytes = '' !== $ini ? self::bytes( $ini ) : 0; $bytes = max( $wp_bytes, $ini_bytes ); if ( $bytes <= 0 ) { return array( 'label' => '' !== $wp ? $wp : $ini, 'state' => '', ); } $label = $ini_bytes > $wp_bytes ? $ini : $wp; if ( '' !== $wp && $label !== $wp ) { $label .= ' (WP_MEMORY_LIMIT ' . $wp . ')'; } return array( 'label' => $label, 'state' => $bytes < 128 * 1024 * 1024 ? 'warn' : '', ); } /** * Bytes of a size like "256M". * * @param string $size Size. * @return int */ private static function bytes( $size ) { return function_exists( 'wp_convert_hr_to_bytes' ) ? (int) wp_convert_hr_to_bytes( (string) $size ) : 0; } }