C:\xampp\htdocs\landing\wp-content\plugins\wp-smushit\core\integrations\class-avada.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
<?php
/**
 * Avada integration module.
 *
 * @since 3.3.0
 * @package Smush\Core\Integrations
 */

namespace Smush\Core\Integrations;

use 
Smush\Core\Modules\CDN;
use 
Smush\Core\Modules\Helpers\Parser;
use 
Smush\Core\Settings;

if ( ! 
defined'WPINC' ) ) {
    die;
}

/**
 * Class Avada
 */
class Avada {

    
/**
     * CDN module instance.
     *
     * @var CDN $cdn
     */
    
private $cdn;

    
/**
     * Avada constructor.
     *
     * @since 3.3.0
     *
     * @param CDN $cdn  CDN module.
     */
    
public function __constructCDN $cdn ) {
        
$settings Settings::get_instance();

        if ( 
$settings->get'cdn' ) ) {
            
$this->cdn $cdn;
            
add_filter'smush_cdn_bg_image_tag', array( $this'replace_cdn_links' ) );
        }
    }


    
/**
     * Replace images from data-bg-url with CDN links.
     *
     * @since 3.3.0
     *
     * @param string $img  Image.
     *
     * @return string
     */
    
public function replace_cdn_links$img ) {
        
$image_src Parser::get_attribute$img'data-bg-url' );
        if ( 
$image_src ) {
            
// Store the original source to be used later on.
            
$original_src $image_src;

            
// Replace the data-bg-url of the image with CDN link.
            
if ( $this->cdn->is_supported_path$image_src ) ) {
                
$image_src $this->cdn->generate_cdn_url$image_src );

                if ( 
$image_src ) {
                    
$img preg_replace'#(data-bg-url=["|\'])' $original_src '(["|\'])#i''\1' $image_src '\2'$img);
                }
            }
        }

        return 
$img;
    }

}
x

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