PluginProbe
Themify Builder / 7.7.0
Themify Builder v7.7.0
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / includes / plugin-compat / bwpminify.php

bwpminify.php in Themify Builder 7.7.0, at includes/plugin-compat/bwpminify.php

42 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }