RemovedDeprecated.php
51 lines
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | |
| 4 | namespace Automattic\WooCommerce\Admin\Features\Navigation; |
| 5 | |
| 6 | use WC_Tracks; |
| 7 | |
| 8 | /** |
| 9 | * Handle calls to deprecated methods. |
| 10 | */ |
| 11 | class RemovedDeprecated { |
| 12 | /** |
| 13 | * Handle deprecated method calls. |
| 14 | * |
| 15 | * @param string $name The name of the deprecated method. |
| 16 | */ |
| 17 | private static function handle_deprecated_method_call( $name ) { |
| 18 | $logger = wc_get_logger(); |
| 19 | |
| 20 | if ( $logger ) { |
| 21 | $logger->warning( |
| 22 | "The WooCommerce Admin Navigation feature and its classes (Screen, Menu, CoreMenu) are deprecated since 9.3 with no alternative. Please remove the call to $name." |
| 23 | ); |
| 24 | } |
| 25 | |
| 26 | if ( class_exists( 'WC_Tracks' ) ) { |
| 27 | WC_Tracks::record_event( 'deprecated_navigation_method_called' ); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Handle calls to deprecated methods. |
| 33 | * |
| 34 | * @param string $name The name of the deprecated method. |
| 35 | * @param array $arguments The arguments passed to the deprecated method. |
| 36 | */ |
| 37 | public function __call( $name, $arguments ) { |
| 38 | self::handle_deprecated_method_call( $name ); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Handle static calls to deprecated methods. |
| 43 | * |
| 44 | * @param string $name The name of the deprecated method. |
| 45 | * @param array $arguments The arguments passed to the deprecated method. |
| 46 | */ |
| 47 | public static function __callStatic( $name, $arguments ) { |
| 48 | self::handle_deprecated_method_call( $name ); |
| 49 | } |
| 50 | } |
| 51 |