From 5bc5af6108465fe2554058da2ec5c0d010060b96 Mon Sep 17 00:00:00 2001 From: Dylan Munson <65001528+CodeyGuyDylan@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:43:50 -0600 Subject: [PATCH] Return video count with rest of videopress stats --- .../my-jetpack/src/class-initializer.php | 16 ++++++++++------ .../my-jetpack/src/class-rest-product-data.php | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php index 256cb32d415ed..2b96ea802e97d 100644 --- a/projects/packages/my-jetpack/src/class-initializer.php +++ b/projects/packages/my-jetpack/src/class-initializer.php @@ -278,10 +278,7 @@ public static function enqueue_scripts() { array( 'blocked_logins' => (int) get_site_option( 'jetpack_protect_blocked_attempts', 0 ) ) ), ), - 'videopress' => array( - 'featuredStats' => self::get_videopress_stats(), - 'videoCount' => array_sum( (array) wp_count_attachments( 'video' ) ), - ), + 'videopress' => self::get_videopress_stats(), ) ); @@ -309,13 +306,20 @@ public static function enqueue_scripts() { * @return array|WP_Error */ public static function get_videopress_stats() { + $video_count = array_sum( (array) wp_count_attachments( 'video' ) ); + if ( ! class_exists( 'Automattic\Jetpack\VideoPress\Stats' ) ) { - return array(); + return array( + 'videoCount' => $video_count, + ); } $videopress_stats = new VideoPress_Stats(); - return $videopress_stats->get_featured_stats(); + return array( + 'featuredStats' => $videopress_stats->get_featured_stats(), + 'videoCount' => $video_count, + ); } /** diff --git a/projects/packages/my-jetpack/src/class-rest-product-data.php b/projects/packages/my-jetpack/src/class-rest-product-data.php index 15530adb28174..123d8cf0965e1 100644 --- a/projects/packages/my-jetpack/src/class-rest-product-data.php +++ b/projects/packages/my-jetpack/src/class-rest-product-data.php @@ -114,7 +114,7 @@ public static function get_site_backup_undo_event() { * This will collect a count of all the items that could be backed up * This is used to show what backup could be doing if it is not enabled * - * @return WP_Error|\WP_REST_Response + * @return WP_Error|array */ public static function count_things_that_can_be_backed_up() { $image_mime_type = 'image';