queue ); $counts = get_transient( 'asmith_so_asset_counts' ); if ( ! is_array( $counts ) ) { $counts = array(); } $counts['scripts'] = $count; $counts['scripts_list'] = $wp_scripts->queue; $counts['timestamp'] = time(); set_transient( 'asmith_so_asset_counts', $counts, HOUR_IN_SECONDS ); } /** * Count enqueued styles and store in transient. */ public function count_styles() { global $wp_styles; if ( ! ( $wp_styles instanceof WP_Styles ) ) { return; } $count = count( $wp_styles->queue ); $counts = get_transient( 'asmith_so_asset_counts' ); if ( ! is_array( $counts ) ) { $counts = array(); } $counts['styles'] = $count; $counts['styles_list'] = $wp_styles->queue; $counts['timestamp'] = time(); set_transient( 'asmith_so_asset_counts', $counts, HOUR_IN_SECONDS ); } /** * Get the cached asset counts. * * @return array */ public function get_counts() { if ( null !== $this->counts ) { return $this->counts; } $counts = get_transient( 'asmith_so_asset_counts' ); if ( ! is_array( $counts ) ) { $counts = array( 'scripts' => 0, 'styles' => 0, ); } $this->counts = $counts; return $this->counts; } }