Completed
Push — develop ( 14767b...cffcc3 )
by Marco
01:20
created

Elementor::instance()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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