1 | <?php |
||
17 | final class Black_Studio_TinyMCE_Compatibility_Plugin_Wpml { |
||
18 | |||
19 | /** |
||
20 | * The single instance of the class |
||
21 | * |
||
22 | * @var object |
||
23 | * @since 2.4.0 |
||
24 | */ |
||
25 | protected static $_instance = null; |
||
26 | |||
27 | /** |
||
28 | * Return the single class instance |
||
29 | * |
||
30 | * @return object |
||
31 | * @since 2.4.0 |
||
32 | */ |
||
33 | public static function instance() { |
||
39 | |||
40 | /** |
||
41 | * Class constructor |
||
42 | * |
||
43 | * @uses add_action() |
||
44 | * @uses add_filter() |
||
45 | * |
||
46 | * @since 2.4.0 |
||
47 | */ |
||
48 | protected function __construct() { |
||
49 | add_action( 'init', array( $this, 'init' ) ); |
||
50 | add_action( 'black_studio_tinymce_before_widget', array( $this, 'widget_before' ), 10, 2 ); |
||
51 | add_action( 'black_studio_tinymce_after_widget', array( $this, 'widget_after' ), 10, 2 ); |
||
52 | add_filter( 'black_studio_tinymce_widget_update', array( $this, 'widget_update' ), 10, 2 ); |
||
53 | add_filter( 'widget_text', array( $this, 'widget_text' ), 2, 3 ); |
||
54 | if ( ! function_exists( 'is_plugin_active' ) ) { |
||
55 | include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
||
56 | } |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Prevent the class from being cloned |
||
61 | * |
||
62 | * @return void |
||
63 | * @since 2.4.0 |
||
64 | */ |
||
65 | protected function __clone() { |
||
68 | |||
69 | /** |
||
70 | * Initialize compatibility with WPML |
||
71 | * |
||
72 | * @uses is_plugin_active() |
||
73 | * @uses has_action() |
||
74 | * @uses remove_action() |
||
75 | * |
||
76 | * @return void |
||
77 | * @since 2.4.0 |
||
78 | */ |
||
79 | public function init() { |
||
86 | |||
87 | /** |
||
88 | * Disable WPML String translation native behavior |
||
89 | * |
||
90 | * @uses is_plugin_active() |
||
91 | * @uses has_filter() |
||
92 | * @uses remove_filter() |
||
93 | * |
||
94 | * @param mixed[] $args |
||
95 | * @param mixed[] $instance |
||
96 | * @return void |
||
97 | * @since 2.4.0 |
||
98 | */ |
||
99 | public function widget_before( $args, $instance ) { |
||
116 | /** |
||
117 | * Re-Enable WPML String translation native behavior |
||
118 | * |
||
119 | * @uses is_plugin_active() |
||
120 | * @uses has_filter() |
||
121 | * @uses add_filter() |
||
122 | * |
||
123 | * @param mixed[] $args |
||
124 | * @param mixed[] $instance |
||
125 | * @return void |
||
126 | * @since 2.4.0 |
||
127 | */ |
||
128 | public function widget_after( $args, $instance ) { |
||
140 | |||
141 | /** |
||
142 | * Add widget text to WPML String translation |
||
143 | * |
||
144 | * @uses is_plugin_active() |
||
145 | * @uses icl_register_string() (WPML) |
||
146 | * |
||
147 | * @param mixed[] $instance |
||
148 | * @param object $widget |
||
149 | * @return mixed[] |
||
150 | * @since 2.4.0 |
||
151 | */ |
||
152 | public function widget_update( $instance, $widget ) { |
||
162 | |||
163 | /** |
||
164 | * Translate widget text |
||
165 | * |
||
166 | * @uses is_plugin_active() |
||
167 | * @uses icl_t() (WPML) |
||
168 | * |
||
169 | * @param string $text |
||
170 | * @param mixed[]|null $instance |
||
171 | * @param object|null $widget |
||
172 | * @return string |
||
173 | * @since 2.4.0 |
||
174 | */ |
||
175 | public function widget_text( $text, $instance = null, $widget = null ) { |
||
188 | |||
189 | } // END class Black_Studio_TinyMCE_Compatibility_Plugin_Wpml |
||
190 | |||
192 |