PluginProbe
Elementor Website Builder – more than just a page builder / 3.1.2
Elementor Website Builder – more than just a page builder v3.1.2
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | modules/dev-tools/deprecation.php +33 -75 4.1.23.1.2 View file →
@@ -1,9 +1,7 @@
1 1 <?php
2 2 namespace Elementor\Modules\DevTools;
3 3
4 -use Elementor\Utils;
5 -
6 4 if ( ! defined( 'ABSPATH' ) ) {
7 5 exit; // Exit if accessed directly.
8 6 }
9 7
@@ -20,11 +18,8 @@
20 18
21 19 public function get_settings() {
22 20 return [
23 21 'soft_notices' => $this->soft_deprecated_notices,
24 - 'soft_version_count' => self::SOFT_VERSIONS_COUNT,
25 - 'hard_version_count' => self::HARD_VERSIONS_COUNT,
26 - 'current_version' => ELEMENTOR_VERSION,
27 22 ];
28 23 }
29 24
30 25 /**
@@ -65,9 +60,9 @@
65 60 *
66 61 * @since 3.1.0
67 62 *
68 63 * @param string $version
69 - * @param int $count
64 + * @param int $count
70 65 *
71 66 * @return string|false
72 67 */
73 68 public function get_next_version( $version, $count = 1 ) {
@@ -186,10 +181,10 @@
186 181 * @param string $version
187 182 * @param string $replacement Optional
188 183 * @param string $base_version Optional. Default is `null`
189 184 *
190 - * @return bool
191 - * @throws \Exception Invalid deprecation.
185 + * @return bool|void
186 + * @throws \Exception
192 187 */
193 188 private function check_deprecation( $entity, $version, $replacement, $base_version = null ) {
194 189 if ( null === $base_version ) {
195 190 $base_version = $this->current_version;
@@ -197,9 +192,9 @@
197 192
198 193 $diff = $this->compare_version( $base_version, $version );
199 194
200 195 if ( false === $diff ) {
201 - throw new \Exception( 'Invalid deprecation diff.' );
196 + throw new \Exception( 'Invalid deprecation diff' );
202 197 }
203 198
204 199 $print_deprecated = false;
205 200
@@ -211,11 +206,14 @@
211 206 $replacement,
212 207 ];
213 208 }
214 209
215 - if ( Utils::is_elementor_debug() ) {
210 + if ( defined( 'ELEMENTOR_DEBUG' ) && ELEMENTOR_DEBUG ) {
216 211 $print_deprecated = true;
217 212 }
213 + } else {
214 + // Hard deprecated.
215 + $print_deprecated = true;
218 216 }
219 217
220 218 return $print_deprecated;
221 219 }
@@ -226,20 +224,19 @@
226 224 * Handles the deprecation process for functions.
227 225 *
228 226 * @since 3.1.0
229 227 *
230 - * @param string $function_name
228 + * @param string $function
231 229 * @param string $version
232 - * @param string $replacement Optional. Default is ''
233 - * @param string $base_version Optional. Default is `null`
234 - * @throws \Exception Deprecation error.
230 + * @param string $replacement Optional. Default is ''
231 + * @param string $base_version Optional. Default is `null`
232 + * @throws \Exception
235 233 */
236 - public function deprecated_function( $function_name, $version, $replacement = '', $base_version = null ) {
237 - $print_deprecated = $this->check_deprecation( $function_name, $version, $replacement, $base_version );
234 + public function deprecated_function( $function, $version, $replacement = '', $base_version = null ) {
235 + $print_deprecated = $this->check_deprecation( $function, $version, $replacement, $base_version );
238 236
239 237 if ( $print_deprecated ) {
240 - // PHPCS - We need to echo special characters because they can exist in function calls.
241 - _deprecated_function( $function_name, esc_html( $version ), $replacement ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
238 + _deprecated_function( $function, $version, $replacement );
242 239 }
243 240 }
244 241
245 242 /**
@@ -246,20 +243,21 @@
246 243 * Deprecated Hook
247 244 *
248 245 * Handles the deprecation process for hooks.
249 246 *
247 + * @since 3.1.0
248 + *
250 249 * @param string $hook
251 250 * @param string $version
252 251 * @param string $replacement Optional. Default is ''
253 252 * @param string $base_version Optional. Default is `null`
254 - * @throws \Exception Deprecation error.
255 - * @since 3.1.0
253 + * @throws \Exception
256 254 */
257 255 public function deprecated_hook( $hook, $version, $replacement = '', $base_version = null ) {
258 256 $print_deprecated = $this->check_deprecation( $hook, $version, $replacement, $base_version );
259 257
260 258 if ( $print_deprecated ) {
261 - _deprecated_hook( esc_html( $hook ), esc_html( $version ), esc_html( $replacement ) );
259 + _deprecated_hook( $hook, $version, $replacement );
262 260 }
263 261 }
264 262
265 263 /**
@@ -272,9 +270,9 @@
272 270 * @param string $argument
273 271 * @param string $version
274 272 * @param string $replacement
275 273 * @param string $message
276 - * @throws \Exception Deprecation error.
274 + * @throws \Exception
277 275 */
278 276 public function deprecated_argument( $argument, $version, $replacement = '', $message = '' ) {
279 277 $print_deprecated = $this->check_deprecation( $argument, $version, $replacement );
280 278
@@ -279,27 +277,24 @@
279 277 $print_deprecated = $this->check_deprecation( $argument, $version, $replacement );
280 278
281 279 if ( $print_deprecated ) {
282 280 $message = empty( $message ) ? '' : ' ' . $message;
283 - // These arguments are escaped because they are printed later, and are not escaped when printed.
284 - $error_message_args = [ esc_html( $argument ), esc_html( $version ) ];
281 + $error_message_args = [ $argument, $version ];
285 282
286 283 if ( $replacement ) {
287 284 /* translators: 1: Function argument, 2: Elementor version number, 3: Replacement argument name. */
288 - $translation_string = esc_html__( 'The %1$s argument is deprecated since version %2$s! Use %3$s instead.', 'elementor' );
285 + $translation_string = __( 'The %1$s argument is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 'elementor' );
289 286 $error_message_args[] = $replacement;
290 287 } else {
291 288 /* translators: 1: Function argument, 2: Elementor version number. */
292 - $translation_string = esc_html__( 'The %1$s argument is deprecated since version %2$s!', 'elementor' );
289 + $translation_string = __( 'The %1$s argument is <strong>deprecated</strong> since version %2$s!', 'elementor' );
293 290 }
294 291
295 292 trigger_error(
296 293 vsprintf(
297 - // PHPCS - $translation_string is already escaped above.
298 - $translation_string, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
299 - // PHPCS - $error_message_args is an array.
300 - $error_message_args // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
301 - ) . esc_html( $message ),
294 + $translation_string,
295 + $error_message_args
296 + ) . $message,
302 297 E_USER_DEPRECATED
303 298 );
304 299 }
305 300 }
@@ -308,16 +303,17 @@
308 303 * Do Deprecated Action
309 304 *
310 305 * A method used to run deprecated actions through Elementor's deprecation process.
311 306 *
312 - * @param string $hook
313 - * @param array $args
314 - * @param string $version
315 - * @param string $replacement
307 + * @since 3.1.0
308 + *
309 + * @param string $hook
310 + * @param array $args
311 + * @param string $version
312 + * @param string $replacement
316 313 * @param null|string $base_version
317 314 *
318 - * @throws \Exception Deprecation error.
319 - * @since 3.1.0
315 + * @throws \Exception
320 316 */
321 317 public function do_deprecated_action( $hook, $args, $version, $replacement = '', $base_version = null ) {
322 318 if ( ! has_action( $hook ) ) {
323 319 return;
@@ -325,44 +321,6 @@
325 321
326 322 $this->deprecated_hook( $hook, $version, $replacement, $base_version );
327 323
328 324 do_action_ref_array( $hook, $args );
329 - }
330 -
331 - /**
332 - * Apply Deprecated Filter
333 - *
334 - * A method used to run deprecated filters through Elementor's deprecation process.
335 - *
336 - * @param string $hook
337 - * @param array $args
338 - * @param string $version
339 - * @param string $replacement
340 - * @param null|string $base_version
341 - *
342 - * @return mixed
343 - * @throws \Exception Deprecation error.
344 - * @since 3.2.0
345 - */
346 - public function apply_deprecated_filter( $hook, $args, $version, $replacement = '', $base_version = null ) {
347 - if ( ! has_action( $hook ) ) {
348 - // `$args` should be an array, but in order to keep BC, we need to support non-array values.
349 - if ( is_array( $args ) ) {
350 - return $args[0] ?? null;
351 - }
352 -
353 - return $args;
354 - }
355 -
356 - // BC - See the comment above.
357 - if ( ! is_array( $args ) ) {
358 - $args = [ $args ];
359 - }
360 -
361 - // Avoid associative arrays.
362 - $args = array_values( $args );
363 -
364 - $this->deprecated_hook( $hook, $version, $replacement, $base_version );
365 -
366 - return apply_filters_ref_array( $hook, $args );
367 325 }
368 326 }