| 1 |
<?php |
| 2 |
|
| 3 |
class MPHB_Divi extends DiviExtension { |
| 4 |
|
| 5 |
public $name = 'mphb-divi'; |
| 6 |
public $gettext_domain; |
| 7 |
public $version; |
| 8 |
|
| 9 |
private static $instance = null; |
| 10 |
|
| 11 |
/** |
| 12 |
* @return MPHB_Divi|null |
| 13 |
*/ |
| 14 |
public static function getInstance () { |
| 15 |
|
| 16 |
if ( ! isset ( self::$instance ) ) { |
| 17 |
self::$instance = new self(); |
| 18 |
} |
| 19 |
|
| 20 |
return self::$instance; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* MPHB_Divi constructor. |
| 25 |
* |
| 26 |
* @param string $name |
| 27 |
* @param array $args |
| 28 |
*/ |
| 29 |
public function __construct( $name = 'mphb-divi', $args = array() ) { |
| 30 |
|
| 31 |
$this->plugin_dir = plugin_dir_path( __FILE__ ); |
| 32 |
$this->plugin_dir_url = plugin_dir_url( $this->plugin_dir ); |
| 33 |
|
| 34 |
$this->addActions(); |
| 35 |
$this->loadIncludes(); |
| 36 |
|
| 37 |
$pluginData = get_plugin_data( plugin_dir_path( dirname( __FILE__ ) ) . 'mphb-divi.php' ); |
| 38 |
$this->version = isset( $pluginData[ 'Version' ] ) ? $pluginData[ 'Version' ] : ''; |
| 39 |
$this->gettext_domain = isset( $pluginData[ 'TextDomain' ] ) ? $pluginData[ 'TextDomain' ] : ''; |
| 40 |
|
| 41 |
parent::__construct( $name, $args ); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Add actions |
| 46 |
*/ |
| 47 |
public function addActions () { |
| 48 |
|
| 49 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueueScripts' ) ); |
| 50 |
add_action( 'customize_preview_init', array( $this, 'enqueueCustomizerScripts' ) ); |
| 51 |
add_action( 'et_fb_enqueue_assets', function () { |
| 52 |
wp_enqueue_script( 'mphb-flexslider' ); |
| 53 |
wp_enqueue_style( 'mphb-flexslider-css' ); |
| 54 |
} ); |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Enqueue scripts & styles |
| 59 |
*/ |
| 60 |
public function enqueueScripts () { |
| 61 |
|
| 62 |
wp_enqueue_style( 'mphb-divi-style', plugin_dir_url( dirname( __FILE__ ) ) . 'assets/style.css', array(), $this->version ); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Enqueue customizer scripts |
| 67 |
*/ |
| 68 |
public function enqueueCustomizerScripts () { |
| 69 |
|
| 70 |
wp_enqueue_script( 'mphb-divi-customize-preview', plugin_dir_url( dirname( __FILE__ ) ) . 'assets/customize-preview.js', array( 'jquery', 'customize-preview' ), $this->version ); |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Load plugin includes |
| 75 |
*/ |
| 76 |
private function loadIncludes () { |
| 77 |
|
| 78 |
include plugin_dir_path( dirname( __FILE__ ) ) . 'includes/functions.php'; |
| 79 |
} |
| 80 |
|
| 81 |
public function hook_et_builder_modules_loaded() { |
| 82 |
|
| 83 |
if ( file_exists( plugin_dir_path( dirname( __FILE__ ) ) . 'includes/loader.php' ) ) { |
| 84 |
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/loader.php'; |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
MPHB_Divi::getInstance(); |