PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.5
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.5
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / inc / admin / heartbeat.php

heartbeat.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.5, at inc/admin/heartbeat.php

46 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
3
4 global $pagenow;
5
6 /**
7 * Prepare the data that goes back with the Heartbeat API.
8 *
9 * @since 1.4.5
10 */
11 add_filter( 'heartbeat_received', '_imagify_heartbeat_received', 10, 2 );
12 function _imagify_heartbeat_received( $response, $data ) {
13 if( isset( $data['imagify_heartbeat'] ) && 'update_bulk_data' === $data['imagify_heartbeat'] ) {
14 $saving_data = imagify_count_saving_data();
15 $user = new Imagify_User();
16
17 $response['imagify_bulk_data'] = array(
18 'already_optimized_attachments' => $saving_data['count'],
19 'optimized_attachments' => imagify_count_optimized_attachments(),
20 'unoptimized_attachments' => imagify_count_unoptimized_attachments(),
21 'errors_attachments' => imagify_count_error_attachments(),
22 'optimized_attachments_percent' => imagify_percent_optimized_attachments(),
23 'optimized_percent' => $saving_data['percent'],
24 'original_human' => size_format( $saving_data['original_size'], 1 ),
25 'optimized_human' => size_format( $saving_data['optimized_size'], 1 ),
26 'unconsumed_quota' => $user->get_percent_unconsumed_quota(),
27 );
28 }
29
30 return $response;
31 }
32
33
34 /**
35 * Update the Heartbeat API settings
36 *
37 * @since 1.4.5
38 */
39 if ( 'upload.php' === $pagenow && isset( $_GET['page'] ) && 'imagify-bulk-optimization' === $_GET['page'] ) {
40 add_filter( 'heartbeat_settings', '_imagify_heartbeat_settings', PHP_INT_MAX );
41 }
42
43 function _imagify_heartbeat_settings( $settings ) {
44 $settings['interval'] = 30;
45 return $settings;
46 }