Elementor   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 62
rs 10
c 0
b 0
f 0
wmc 7
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A instance() 0 6 2
A __construct() 0 7 3
A __clone() 0 3 1
A unregister_widget() 0 3 1
1
<?php
2
/**
3
 * Black Studio TinyMCE Widget - Compatibility with Elementor plugin
4
 *
5
 * @package Black_Studio_TinyMCE_Widget
6
 */
7
8
namespace Black_Studio_TinyMCE_Widget\Compatibility\Plugin;
9
10
// Exit if accessed directly.
11
if ( ! defined( 'ABSPATH' ) ) {
12
	exit;
13
}
14
15
if ( ! class_exists( 'Black_Studio_TinyMCE_Widget\\Compatibility\\Plugin\\Elementor', false ) ) {
16
17
	/**
18
	 * Class that provides compatibility code for Elementor
19
	 *
20
	 * @package Black_Studio_TinyMCE_Widget
21
	 * @since 3.0.0
22
	 */
23
	final class Elementor {
24
25
		/**
26
		 * The single instance of the class
27
		 *
28
		 * @var object
29
		 * @since 3.0.0
30
		 */
31
		protected static $_instance = null;
32
33
		/**
34
		 * Return the single class instance
35
		 *
36
		 * @return object
37
		 * @since 3.0.0
38
		 */
39
		public static function instance() {
40
			if ( is_null( self::$_instance ) ) {
41
				self::$_instance = new self();
42
			}
43
			return self::$_instance;
44
		}
45
46
		/**
47
		 * Class constructor
48
		 *
49
		 * @uses is_admin()
50
		 * @uses add_filter()
51
		 * @uses add_action()
52
		 *
53
		 * @since 3.0.0
54
		 */
55
		protected function __construct() {
56
			$action = filter_input( INPUT_GET, 'action' );
57
			if ( is_admin() && 'elementor' === $action ) {
58
				add_filter( 'black_studio_tinymce_enable', '__return_false', 100 );
59
				add_action( 'widgets_init', array( $this, 'unregister_widget' ), 20 );
60
			}
61
		}
62
63
		/**
64
		 * Prevent the class from being cloned
65
		 *
66
		 * @return void
67
		 * @since 3.0.0
68
		 */
69
		protected function __clone() {
70
			_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; uh?' ), '3.0' );
71
		}
72
		/**
73
		 * Unregister Widget for Elementor plugin
74
		 *
75
		 * @uses unregister_widget()
76
		 *
77
		 * @return void
78
		 * @since 3.0.0
79
		 */
80
		public function unregister_widget() {
81
			unregister_widget( 'WP_Widget_Black_Studio_TinyMCE' );
82
		}
83
84
	} // END class
85
86
} // END class_exists
87