Skip to content

Commit

Permalink
Return video count with rest of videopress stats
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeyGuyDylan committed Aug 7, 2024
1 parent b78c647 commit 5bc5af6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions projects/packages/my-jetpack/src/class-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
);

Expand Down Expand Up @@ -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,
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 5bc5af6

Please sign in to comment.