| 1 |
<?php |
| 2 |
/** |
| 3 |
* Builder Plugin Compatibility Code |
| 4 |
* |
| 5 |
* @package Themify_Builder |
| 6 |
* @subpackage Themify_Builder/classes |
| 7 |
*/ |
| 8 |
|
| 9 |
class Themify_Builder_Plugin_Compat_BWPMinify { |
| 10 |
|
| 11 |
static function init() { |
| 12 |
// Only apply the filter when WP Multisite with subdirectory install. |
| 13 |
if ( defined( 'SUBDOMAIN_INSTALL' ) && ! SUBDOMAIN_INSTALL ) { |
| 14 |
add_filter( 'bwp_minify_get_src', array( __CLASS__, 'bwp_minify_get_src' ) ); |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Modify the src for builder stylesheet. |
| 20 |
*/ |
| 21 |
public static function bwp_minify_get_src(string $string ):string { |
| 22 |
$split_string = explode( ',', $string ); |
| 23 |
$found_src = array(); |
| 24 |
foreach( $split_string as $src ) { |
| 25 |
if ( preg_match( '/^files\/themify-css/', $src ) ) { |
| 26 |
$found_src[] = $src; |
| 27 |
} |
| 28 |
} |
| 29 |
if ( !empty( $found_src )) { |
| 30 |
$basedir = themify_upload_dir('basedir'); |
| 31 |
$base_path = substr( $basedir, strpos( $basedir, 'wp-content' ) ); |
| 32 |
foreach ( $found_src as $replace_src ) { |
| 33 |
$key = array_search( $replace_src, $split_string ); |
| 34 |
if ( $key !== false ) { |
| 35 |
$split_string[ $key ] = trailingslashit( $base_path ) . str_replace( 'files/themify-css', 'themify-css', $split_string[ $key ] ); |
| 36 |
} |
| 37 |
} |
| 38 |
$string = implode( ',', $split_string ); |
| 39 |
} |
| 40 |
return $string; |
| 41 |
} |
| 42 |
} |