| 1 |
<?php |
| 2 |
/** |
| 3 |
* Divi Extension class. |
| 4 |
* |
| 5 |
* @package ConvertKit |
| 6 |
* @author ConvertKit |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Registers Plugin as an extension in Divi. |
| 11 |
* |
| 12 |
* @package ConvertKit |
| 13 |
* @author ConvertKit |
| 14 |
*/ |
| 15 |
class ConvertKit_Divi_Extension extends DiviExtension { |
| 16 |
|
| 17 |
/** |
| 18 |
* The gettext domain for the extension's translations. |
| 19 |
* |
| 20 |
* @since 2.5.6 |
| 21 |
* |
| 22 |
* @var string |
| 23 |
*/ |
| 24 |
public $gettext_domain = 'convertkit'; |
| 25 |
|
| 26 |
/** |
| 27 |
* The extension's WP Plugin name. |
| 28 |
* |
| 29 |
* @since 2.5.6 |
| 30 |
* |
| 31 |
* @var string |
| 32 |
*/ |
| 33 |
public $name = 'convertkit-divi'; |
| 34 |
|
| 35 |
/** |
| 36 |
* The extension's version. |
| 37 |
* |
| 38 |
* @since 2.5.6 |
| 39 |
* |
| 40 |
* @var string |
| 41 |
*/ |
| 42 |
public $version = '2.5.6'; |
| 43 |
|
| 44 |
/** |
| 45 |
* Constructor. |
| 46 |
* |
| 47 |
* @since 2.5.6 |
| 48 |
* |
| 49 |
* @param string $name Extension name. |
| 50 |
* @param array $args Arguments. |
| 51 |
*/ |
| 52 |
public function __construct( $name = 'convertkit-divi', $args = array() ) { |
| 53 |
|
| 54 |
$this->plugin_dir = CONVERTKIT_PLUGIN_PATH . '/includes/integrations/divi/'; |
| 55 |
$this->plugin_dir_url = CONVERTKIT_PLUGIN_URL . 'includes/integrations/divi/'; |
| 56 |
|
| 57 |
// Divi Builder Plugin calls `divi_extensions_init` later, resulting in convertkit_get_blocks() containing data. |
| 58 |
// Using `init` to populate _builder_js_data is too late, so we do this now. |
| 59 |
$this->_builder_js_data = convertkit_get_blocks(); |
| 60 |
|
| 61 |
// Divi Theme calls `divi_extensions_init` earlier, resulting in convertkit_get_blocks() not containing any data. |
| 62 |
// Using `init` to repopulate _builder_js_data resolves. |
| 63 |
add_action( 'init', array( $this, 'init' ) ); |
| 64 |
|
| 65 |
// Call parent construct. |
| 66 |
parent::__construct( $name, $args ); |
| 67 |
|
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Store any JS data that can be accessed by builder-bundle.min.js using window.ConvertkitDiviBuilderData. |
| 72 |
* |
| 73 |
* @since 2.8.0 |
| 74 |
*/ |
| 75 |
public function init() { |
| 76 |
|
| 77 |
$this->_builder_js_data = convertkit_get_blocks(); |
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
new ConvertKit_Divi_Extension(); |
| 84 |
|