| @@ -2,11 +2,62 @@ | ||
| 2 | 2 | |
| 3 | 3 | // don't load directly |
| 4 | 4 | defined( 'ABSPATH' ) || exit; |
| 5 | 5 | |
| 6 | +final class Borderless_Wpbakery { | |
| 7 | + | |
| 8 | + public function __construct() { | |
| 9 | + | |
| 10 | + // We safely integrate with WPBakery with this hook | |
| 11 | + add_action( 'plugins_loaded', [ $this, 'wpbakery_check' ] ); | |
| 6 | 12 | |
| 7 | -/*-----------------------------------------------------------------------------------*/ | |
| 8 | -/* WPBakery | |
| 9 | -/*-----------------------------------------------------------------------------------*/ | |
| 13 | + add_action('admin_enqueue_scripts',array($this,'wpbakery_icon_fonts_styles')); | |
| 14 | + | |
| 15 | + } | |
| 16 | + | |
| 17 | + // Check if WPBakery is installed | |
| 18 | + public function wpbakery_check() { | |
| 19 | + if ( defined( 'WPB_VC_VERSION' ) ) { | |
| 20 | + add_action( 'init', [ $this, 'wpbakery_init' ] ); | |
| 21 | + return; | |
| 22 | + } else { | |
| 23 | + return; | |
| 24 | + } | |
| 25 | + } | |
| 26 | + | |
| 27 | + public function wpbakery_init() { | |
| 28 | + | |
| 29 | + require_once( BORDERLESS__WPBAKERY . "/lean-map.php"); | |
| 30 | + require_once( BORDERLESS__WPBAKERY . "/paramns/icon-manager-param.php" ); | |
| 31 | + | |
| 32 | + } | |
| 10 | 33 | |
| 11 | -require_once( BORDERLESS__WPBAKERY . "/lean-map.php"); | |
| 12 | -require_once( BORDERLESS__WPBAKERY . "/paramns/icon-manager-param.php" ); | |
| 34 | + function wpbakery_icon_fonts_styles($hook) { | |
| 35 | + | |
| 36 | + // enqueue css files on backend | |
| 37 | + if($hook == "post.php" || $hook == "post-new.php" || $hook == 'visual-composer_page_vc-roles'){ | |
| 38 | + if((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || is_ssl()) { | |
| 39 | + $scheme = 'https'; | |
| 40 | + } | |
| 41 | + else { | |
| 42 | + $scheme = 'http'; | |
| 43 | + } | |
| 44 | + $this->paths = wp_upload_dir(); | |
| 45 | + $this->paths['fonts'] = 'borderless_icon_fonts'; | |
| 46 | + $this->paths['fonturl'] = set_url_scheme($this->paths['baseurl'].'/'.$this->paths['fonts'], $scheme); | |
| 47 | + $fonts = get_option('borderless_icon_fonts'); | |
| 48 | + if(is_array($fonts)) | |
| 49 | + { | |
| 50 | + foreach($fonts as $font => $info) | |
| 51 | + { | |
| 52 | + if(strpos($info['style'], 'http://' ) !== false) { | |
| 53 | + wp_enqueue_style('borderless-'.$font,$info['style']); | |
| 54 | + } else { | |
| 55 | + wp_enqueue_style('borderless-'.$font,trailingslashit($this->paths['fonturl']).$info['style']); | |
| 56 | + } | |
| 57 | + } | |
| 58 | + } | |
| 59 | + } | |
| 60 | + } | |
| 61 | + | |
| 62 | +} | |
| 63 | +new Borderless_Wpbakery(); | |