Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 29
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
VideoPress_Divi_Extension
0.00% covered (danger)
0.00%
0 / 27
0.00% covered (danger)
0.00%
0 / 6
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 hook_et_builder_modules_loaded
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 hook_et_builder_ready
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 _initialize
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 register_js_assets
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
2
 wp_hook_enqueue_scripts
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Divi integration for Videopress.
4 *
5 * @package automattic/jetpack-videopress
6 **/
7
8use Automattic\Jetpack\Assets;
9
10if ( ! defined( 'ABSPATH' ) ) {
11    exit( 0 );
12}
13
14/**
15 * Divi extension.
16 **/
17class VideoPress_Divi_Extension extends DiviExtension {
18
19    /**
20     * The extension's js file namespace.
21     *
22     * @var string
23     */
24    const JETPACK_VIDEOPRESS_DIVI_PKG_NAMESPACE = 'jetpack-videopress-divi-pkg';
25
26    /**
27     * The gettext domain for the extension's translations.
28     *
29     * @since 0.14.0
30     *
31     * @var string
32     */
33    public $gettext_domain = 'jetpack-videopress-pkg';
34
35    /**
36     * The extension's WP Plugin name.
37     *
38     * @since 0.14.0
39     *
40     * @var string
41     */
42    public $name = 'videopress-divi';
43
44    /**
45     * The extension's version
46     *
47     * @since 0.14.0
48     *
49     * @var string
50     */
51    public $version = '1.0.0';
52
53    /**
54     * The VideoPress_Divi_Module.
55     *
56     * @since 0.14.0
57     *
58     * @var VideoPress_Divi_Module
59     */
60    private $videopress_divi_module;
61
62    /**
63     * Plugin directory.
64     *
65     * @var string
66     */
67    public $plugin_dir;
68
69    /**
70     * Plugin directory URL.
71     *
72     * @var string
73     */
74    public $plugin_dir_url;
75
76    /**
77     * The constructor.
78     *
79     * @param string $name The name.
80     * @param array  $args The args.
81     */
82    public function __construct( $name = 'videopress-divi', $args = array() ) {
83        $this->plugin_dir     = plugin_dir_path( __FILE__ );
84        $this->plugin_dir_url = plugin_dir_url( $this->plugin_dir );
85
86        parent::__construct( $name, $args );
87    }
88
89    /**
90     * Executes when the ET builder module is loaded.
91     *
92     * @override
93     */
94    public function hook_et_builder_modules_loaded() {
95        $this->hook_et_builder_ready();
96    }
97
98    /**
99     * Loads custom modules when the builder is ready.
100     *
101     * @override
102     */
103    public function hook_et_builder_ready() {
104        require_once plugin_dir_path( __FILE__ ) . 'class-videopress-divi-module.php';
105        $this->videopress_divi_module = new VideoPress_Divi_Module();
106    }
107
108    /**
109     * Performs initialization tasks.
110     *
111     * @Override
112     */
113    protected function _initialize() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
114        DiviExtensions::add( $this );
115
116        $this->_set_debug_mode();
117        $this->_set_bundle_dependencies();
118
119        // Register callbacks.
120        register_activation_hook( trailingslashit( $this->plugin_dir ) . $this->name . '.php', array( $this, 'wp_hook_activate' ) );
121
122        add_action( 'et_builder_ready', array( $this, 'hook_et_builder_ready' ), 9 );
123        add_action( 'wp_enqueue_scripts', array( $this, 'wp_hook_enqueue_scripts' ) );
124        add_action( 'admin_enqueue_scripts', array( $this, 'admin_hook_enqueue_scripts' ) );
125        add_action( 'wp_enqueue_scripts', array( $this, 'register_js_assets' ) );
126    }
127
128    /**
129     * Register the extension's js assets.
130     */
131    public function register_js_assets() {
132        Assets::register_script(
133            self::JETPACK_VIDEOPRESS_DIVI_PKG_NAMESPACE,
134            '../../build/divi-editor/index.js',
135            __FILE__,
136            array(
137                'in_footer'    => true,
138                'css_path'     => '../../build/divi-editor/index.css',
139                'textdomain'   => 'jetpack-videopress-pkg',
140                'dependencies' => array( 'jquery' ),
141            )
142        );
143
144        Assets::enqueue_script( self::JETPACK_VIDEOPRESS_DIVI_PKG_NAMESPACE );
145    }
146
147    /**
148     * Enqueue frontend stuff.
149     *
150     * @override
151     */
152    public function wp_hook_enqueue_scripts() {
153    }
154}