C:\xampp\htdocs\landing\wp-content\updraft\plugins-old\imagify\inc\admin\custom-folders.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
defined
'ABSPATH' ) || die( 'Cheatin’ uh?' );

add_filter'upgrader_post_install''imagify_sync_theme_plugin_files_on_update'IMAGIFY_INT_MAX);
/**
 * Sync files right after a theme or plugin has been updated.
 *
 * @since  1.7
 * @author Grégory Viguier
 *
 * @param  bool  $response   Installation response.
 * @param  array $hook_extra Extra arguments passed to hooked filters.
 * @param  array $result     Installation result data.
 * @return bool
 */
function imagify_sync_theme_plugin_files_on_update$response$hook_extra$result ) {
    global 
$wpdb;

    if ( ( empty( 
$hook_extra['plugin'] ) && empty( $hook_extra['theme'] ) ) || empty( $result['destination'] ) ) {
        return 
$response;
    }

    
$folders_to_sync get_site_transient'imagify_themes_plugins_to_sync' );
    
$folders_to_sync is_array$folders_to_sync ) ? $folders_to_sync : array();

    
$folders_to_sync[] = $result['destination'];

    
set_site_transient'imagify_themes_plugins_to_sync'$folders_to_syncDAY_IN_SECONDS );

    return 
$response;
}

add_action'admin_init''imagify_sync_theme_plugin_files_after_update' );
/**
 * Sync files after some themes or plugins have been updated.
 *
 * @since  1.7.1.2
 * @author Grégory Viguier
 */
function imagify_sync_theme_plugin_files_after_update() {
    global 
$wpdb;

    
$folders_to_sync get_site_transient'imagify_themes_plugins_to_sync' );

    if ( ! 
$folders_to_sync || ! is_array$folders_to_sync ) ) {
        return;
    }

    
delete_site_transient'imagify_themes_plugins_to_sync' );

    
$folders_db Imagify_Folders_DB::get_instance();
    
$files_db   Imagify_Files_DB::get_instance();

    if ( ! 
$folders_db->can_operate() || ! $files_db->can_operate() ) {
        return;
    }

    foreach ( 
$folders_to_sync as $folder_path ) {
        
$folder_path trailingslashit$folder_path );

        if ( 
Imagify_Files_Scan::is_path_forbidden$folder_path ) ) {
            
// This theme or plugin must not be optimized.
            
continue;
        }

        
// Get the related folder.
        
$placeholder Imagify_Files_Scan::add_placeholder$folder_path );
        
$folder      Imagify_Folders_DB::get_instance()->get_in'path'$placeholder );

        if ( ! 
$folder ) {
            
// This theme or plugin is not in the database.
            
continue;
        }

        
// Sync the folder files.
        
Imagify_Custom_Folders::synchronize_files_from_folders( array(
            
$folder['folder_id'] => array(
                
'folder_id'   => $folder['folder_id'],
                
'path'        => $placeholder,
                
'active'      => $folder['active'],
                
'folder_path' => $folder_path,
            ),
        ) );
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586