← All changes
|
includes/deprecated/class-charitable-deprecated.php
+12
-10
1.7.0.7
→
1.8.13
View file →
| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | * A helper class for logging deprecated arguments, functions and methods. |
| 4 | 4 | * |
| 5 | 5 | * @package Charitable/Classes/Charitable_Deprecated |
| 6 | 6 | * @author David Bisset |
| 7 | - * @copyright Copyright (c) 2022, WP Charitable LLC | |
| 7 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 9 | * @version 1.4.0 |
| 10 | 10 | * @version 1.5.9 |
| 11 | 11 | */ |
| @@ -67,13 +67,9 @@ | ||
| 67 | 67 | * |
| 68 | 68 | * @return Charitable_Deprecated |
| 69 | 69 | */ |
| 70 | 70 | public static function get_instance() { |
| 71 | - if ( is_null( self::$instance ) ) { | |
| 72 | - self::$instance = new self(); | |
| 73 | - } | |
| 74 | - | |
| 75 | - return self::$instance; | |
| 71 | + return self::$instance ??= new self(); | |
| 76 | 72 | } |
| 77 | 73 | |
| 78 | 74 | /** |
| 79 | 75 | * Log a deprecated argument. |
| @@ -90,14 +86,16 @@ | ||
| 90 | 86 | return false; |
| 91 | 87 | } |
| 92 | 88 | |
| 93 | 89 | if ( ! is_null( $extra_message ) ) { |
| 90 | + // translators: 1: function name, 2: version number, 3: extra message, 4: plugin name. | |
| 94 | 91 | $message = sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s of %4$s! %3$s', 'charitable' ), $function, $version, $extra_message, $this->context ); |
| 95 | 92 | } else { |
| 93 | + // translators: 1: function name, 2: version number, 3: plugin name. | |
| 96 | 94 | $message = sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s of %3$s with no alternatives available.', 'charitable' ), $function, $version, $this->context ); |
| 97 | 95 | } |
| 98 | 96 | |
| 99 | - trigger_error( $message ); | |
| 97 | + trigger_error( $message ); // phpcs:ignore | |
| 100 | 98 | |
| 101 | 99 | return true; |
| 102 | 100 | } |
| 103 | 101 | |
| @@ -116,14 +114,16 @@ | ||
| 116 | 114 | return false; |
| 117 | 115 | } |
| 118 | 116 | |
| 119 | 117 | if ( ! is_null( $replacement ) ) { |
| 118 | + // translators: 1: function name, 2: version number, 3: replacement function name, 4: plugin name. | |
| 120 | 119 | $message = sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s of %4$s! Use %3$s instead.', 'charitable' ), $function, $version, $replacement, $this->context ); |
| 121 | 120 | } else { |
| 121 | + // translators: 1: function name, 2: version number, 3: plugin name. | |
| 122 | 122 | $message = sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s of %3$s with no alternatives available.', 'charitable' ), $function, $version, $this->context ); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - trigger_error( $message ); | |
| 125 | + trigger_error( $message ); // phpcs:ignore | |
| 126 | 126 | |
| 127 | 127 | return true; |
| 128 | 128 | } |
| 129 | 129 | |
| @@ -141,13 +141,15 @@ | ||
| 141 | 141 | if ( ! $this->is_logging_enabled() ) { |
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $version = is_null( $version ) ? '' : sprintf( __( '(This message was added in %s version %s.)', 'charitable' ), $this->context, $version ); | |
| 145 | + // translators: 1: function name, 2: error message, 3: version number. | |
| 146 | + $version = is_null( $version ) ? '' : sprintf( __( '(This message was added in %1$s version %2$s.)', 'charitable' ), $this->context, $version ); | |
| 146 | 147 | |
| 148 | + // translators: 1: function name, 2: error message, 3: version number. | |
| 147 | 149 | $message = sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', 'charitable' ), $function, $message, $version ); |
| 148 | 150 | |
| 149 | - trigger_error( $message ); | |
| 151 | + trigger_error( $message ); // phpcs:ignore | |
| 150 | 152 | |
| 151 | 153 | return true; |
| 152 | 154 | } |
| 153 | 155 | |