self::sku_count(), 'order_count' => self::order_count(), 'live_gateways' => self::live_gateways(), ); } private static function sku_count() { $counts = wp_count_posts( 'product' ); return ( $counts && isset( $counts->publish ) ) ? (int) $counts->publish : 0; } private static function order_count() { // Completed + processing = demand that actually moved money through the // store. The anti-fraud gate cares that real orders exist, not drafts. if ( function_exists( 'wc_orders_count' ) ) { return (int) wc_orders_count( 'completed' ) + (int) wc_orders_count( 'processing' ); } return 0; } /** * IDs of enabled gateways that appear to be in LIVE (not test/sandbox) * mode. A live card gateway is the single strongest "this is a real store" * signal — dummy stores never wire up live processing. We report the raw * gateway ids and leave the "which ids count as real" policy to the backend. * * @return string[] */ private static function live_gateways() { if ( ! function_exists( 'WC' ) || ! WC() || ! method_exists( WC(), 'payment_gateways' ) ) { return array(); } $mgr = WC()->payment_gateways(); if ( ! $mgr ) { return array(); } $gateways = $mgr->get_available_payment_gateways(); if ( ! is_array( $gateways ) ) { return array(); } $live = array(); foreach ( $gateways as $gw_id => $gw ) { if ( self::gateway_is_live( $gw ) ) { $live[] = (string) $gw_id; } } return $live; } /** * Best-effort live-vs-test detection. Most gateways expose a `testmode` (or * `sandbox`) setting of 'yes'/'no'; when present and 'yes' the gateway is * NOT live. Gateways with no test concept (bank transfer, COD) have no * sandbox, so we report them — the backend decides whether they qualify. */ private static function gateway_is_live( $gw ) { if ( ! is_object( $gw ) || ! method_exists( $gw, 'get_option' ) ) { return false; } if ( 'yes' === $gw->get_option( 'testmode' ) ) { return false; } if ( 'yes' === $gw->get_option( 'sandbox' ) ) { return false; } return true; } }