PluginProbe
Elementor Website Builder – more than just a page builder / 3.4.3
Elementor Website Builder – more than just a page builder v3.4.3
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 +34 -46 4.2.03.4.3 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,20 @@
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 238 // 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
239 + _deprecated_function( $function, esc_html( $version ), $replacement ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
242 240 }
243 241 }
244 242
245 243 /**
@@ -246,14 +244,15 @@
246 244 * Deprecated Hook
247 245 *
248 246 * Handles the deprecation process for hooks.
249 247 *
248 + * @since 3.1.0
249 + *
250 250 * @param string $hook
251 251 * @param string $version
252 252 * @param string $replacement Optional. Default is ''
253 253 * @param string $base_version Optional. Default is `null`
254 - * @throws \Exception Deprecation error.
255 - * @since 3.1.0
254 + * @throws \Exception
256 255 */
257 256 public function deprecated_hook( $hook, $version, $replacement = '', $base_version = null ) {
258 257 $print_deprecated = $this->check_deprecation( $hook, $version, $replacement, $base_version );
259 258
@@ -272,9 +271,9 @@
272 271 * @param string $argument
273 272 * @param string $version
274 273 * @param string $replacement
275 274 * @param string $message
276 - * @throws \Exception Deprecation error.
275 + * @throws \Exception
277 276 */
278 277 public function deprecated_argument( $argument, $version, $replacement = '', $message = '' ) {
279 278 $print_deprecated = $this->check_deprecation( $argument, $version, $replacement );
280 279
@@ -308,16 +307,17 @@
308 307 * Do Deprecated Action
309 308 *
310 309 * A method used to run deprecated actions through Elementor's deprecation process.
311 310 *
312 - * @param string $hook
313 - * @param array $args
314 - * @param string $version
315 - * @param string $replacement
311 + * @since 3.1.0
312 + *
313 + * @param string $hook
314 + * @param array $args
315 + * @param string $version
316 + * @param string $replacement
316 317 * @param null|string $base_version
317 318 *
318 - * @throws \Exception Deprecation error.
319 - * @since 3.1.0
319 + * @throws \Exception
320 320 */
321 321 public function do_deprecated_action( $hook, $args, $version, $replacement = '', $base_version = null ) {
322 322 if ( ! has_action( $hook ) ) {
323 323 return;
@@ -332,35 +332,23 @@
332 332 * Apply Deprecated Filter
333 333 *
334 334 * A method used to run deprecated filters through Elementor's deprecation process.
335 335 *
336 - * @param string $hook
337 - * @param array $args
338 - * @param string $version
339 - * @param string $replacement
336 + * @since 3.2.0
337 + *
338 + * @param string $hook
339 + * @param array $args
340 + * @param string $version
341 + * @param string $replacement
340 342 * @param null|string $base_version
341 343 *
342 344 * @return mixed
343 - * @throws \Exception Deprecation error.
344 - * @since 3.2.0
345 + * @throws \Exception
345 346 */
346 347 public function apply_deprecated_filter( $hook, $args, $version, $replacement = '', $base_version = null ) {
347 348 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;
349 + return;
354 350 }
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 351
364 352 $this->deprecated_hook( $hook, $version, $replacement, $base_version );
365 353
366 354 return apply_filters_ref_array( $hook, $args );