Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
Divi
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 5
56
0.00% covered (danger)
0.00%
0 / 1
 init
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_instance
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 run
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
6
 on_fb_framework_loaded
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 initialize_extension
0.00% covered (danger)
0.00%
0 / 2
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
8namespace Automattic\Jetpack\VideoPress;
9
10/**
11 * Class Divi
12 **/
13class Divi {
14    /**
15     * The instance.
16     *
17     * @var Divi
18     **/
19    private static $instance = null;
20
21    /**
22     * Running or not.
23     *
24     * @var bool
25     **/
26    private $running = false;
27
28    /**
29     * VideoPress Divi Extension object.
30     *
31     * @var ?\VideoPress_Divi_Extension
32     **/
33    private $vidi_extension;
34
35    /**
36     * Initializes VideoPress/Divi integration.
37     *
38     * Called only once by the Initializer class
39     *
40     * @return self
41     */
42    public static function init() {
43        return self::get_instance()->run();
44    }
45
46    /**
47     * Get the instance.
48     *
49     * @return self
50     */
51    public static function get_instance() {
52        if ( null === self::$instance ) {
53            self::$instance = new self();
54        }
55        return self::$instance;
56    }
57
58    /**
59     * Run the extension.
60     *
61     * @return self
62     */
63    public function run() {
64        if ( $this->running ) {
65            return $this;
66        }
67
68        $this->running = true;
69        add_action( 'divi_extensions_init', array( $this, 'initialize_extension' ) );
70        add_action( 'et_fb_framework_loaded', array( $this, 'on_fb_framework_loaded' ) );
71
72        return $this;
73    }
74
75    /**
76     * Fires when the Frontend Builder is loaded.
77     */
78    public function on_fb_framework_loaded() {
79        Jwt_Token_Bridge::enqueue_jwt_token_bridge();
80    }
81
82    /**
83     * Creates the extension's main class instance.
84     */
85    public function initialize_extension() {
86        require_once plugin_dir_path( __FILE__ ) . 'videopress-divi/class-videopress-divi-extension.php';
87        $this->vidi_extension = new \VideoPress_Divi_Extension();
88    }
89}