Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Application
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 initialize_chat_editor
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace NewfoldLabs\WP\Module\EditorChat;
4
5use NewfoldLabs\WP\ModuleLoader\Container;
6
7/**
8 * Main Application class for the Editor Chat module.
9 */
10class Application {
11
12    /**
13     * Dependency injection container.
14     *
15     * @var Container
16     */
17    protected $container;
18
19    /**
20     * Constructor.
21     *
22     * @param Container $container Dependency injection container.
23     */
24    public function __construct( Container $container ) {
25
26        $this->container = $container;
27
28        // Delay ChatEditor initialization until WordPress functions are available.
29        if ( \did_action( 'plugins_loaded' ) ) {
30            $this->initialize_chat_editor();
31        } else {
32            \add_action( 'plugins_loaded', array( $this, 'initialize_chat_editor' ) );
33        }
34    }
35
36    /**
37     * Bootstrap ChatEditor (REST routes, temp upload dir, editor UI when applicable).
38     * Called after WordPress pluggable functions are available.
39     *
40     * @return void
41     */
42    public function initialize_chat_editor() {
43        static $initialized = false;
44
45        if ( $initialized ) {
46            return;
47        }
48
49        $initialized = true;
50        new ChatEditor();
51    }
52}