PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.7
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.7
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 / custom-folders.php

custom-folders.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.7, at inc/admin/custom-folders.php

67 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
3
4 add_filter( 'upgrader_post_install', 'imagify_sync_theme_plugin_files_on_update', IMAGIFY_INT_MAX, 3 );
5 /**
6 * Sync files after a theme or plugin has been updated.
7 *
8 * @since 1.7
9 * @author Grégory Viguier
10 *
11 * @param bool $response Installation response.
12 * @param array $hook_extra Extra arguments passed to hooked filters.
13 * @param array $result Installation result data.
14 */
15 function imagify_sync_theme_plugin_files_on_update( $response, $hook_extra, $result ) {
16 global $wpdb;
17
18 if ( ( empty( $hook_extra['plugin'] ) && empty( $hook_extra['theme'] ) ) || empty( $result['destination'] ) ) {
19 return $response;
20 }
21
22 $folders_db = Imagify_Folders_DB::get_instance();
23 $files_db = Imagify_Files_DB::get_instance();
24
25 if ( ! $folders_db->can_operate() || ! $files_db->can_operate() ) {
26 return;
27 }
28
29 if ( ! imagify_valid_key() ) {
30 return;
31 }
32
33 $user = new Imagify_User();
34
35 if ( $user->is_over_quota() ) {
36 return;
37 }
38
39 $folder_path = trailingslashit( $result['destination'] );
40
41 if ( Imagify_Files_Scan::is_path_forbidden( $folder_path ) ) {
42 // This theme or plugin must not be optimized.
43 return $response;
44 }
45
46 // Get the related folder.
47 $placeholder = Imagify_Files_Scan::add_placeholder( $folder_path );
48 $folder = Imagify_Folders_DB::get_instance()->get_in( 'path', $placeholder );
49
50 if ( ! $folder ) {
51 // This theme or plugin is not in the database.
52 return $response;
53 }
54
55 // Sync the folder files.
56 Imagify_Custom_Folders::synchronize_files_from_folders( array(
57 $folder['folder_id'] => array(
58 'folder_id' => $folder['folder_id'],
59 'path' => $placeholder,
60 'active' => $folder['active'],
61 'folder_path' => $folder_path,
62 ),
63 ) );
64
65 return $response;
66 }
67