Code Duplication    Length = 27-27 lines in 2 locations

projects/plugins/jetpack/functions.global.php 2 locations

@@ 35-61 (lines=27) @@
32
 * @param string $replacement Optional. The function that should have been called. Default null.
33
 * @param string $version     The version of Jetpack that deprecated the function.
34
 */
35
function jetpack_deprecated_function( $function, $replacement, $version ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
36
	// Bail early for non-Jetpack deprecations.
37
	if ( 0 !== strpos( $version, 'jetpack-' ) ) {
38
		return;
39
	}
40
41
	// Look for when a function will be removed based on when it was deprecated.
42
	$removed_version = jetpack_get_future_removed_version( $version );
43
44
	// If we could find a version, let's log a message about when removal will happen.
45
	if (
46
		! empty( $removed_version )
47
		&& ( defined( 'WP_DEBUG' ) && WP_DEBUG )
48
		/** This filter is documented in core/src/wp-includes/functions.php */
49
		&& apply_filters( 'deprecated_function_trigger_error', true )
50
	) {
51
		error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
52
			sprintf(
53
				/* Translators: 1. Function name. 2. Jetpack version number. */
54
				__( 'The %1$s function will be removed from the Jetpack plugin in version %2$s.', 'jetpack' ),
55
				$function,
56
				$removed_version
57
			)
58
		);
59
60
	}
61
}
62
add_action( 'deprecated_function_run', 'jetpack_deprecated_function', 10, 3 );
63
64
/**
@@ 75-101 (lines=27) @@
72
 * @param string $version     The version of WordPress that deprecated the file.
73
 * @param string $message     A message regarding the change.
74
 */
75
function jetpack_deprecated_file( $file, $replacement, $version, $message ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
76
	// Bail early for non-Jetpack deprecations.
77
	if ( 0 !== strpos( $version, 'jetpack-' ) ) {
78
		return;
79
	}
80
81
	// Look for when a file will be removed based on when it was deprecated.
82
	$removed_version = jetpack_get_future_removed_version( $version );
83
84
	// If we could find a version, let's log a message about when removal will happen.
85
	if (
86
		! empty( $removed_version )
87
		&& ( defined( 'WP_DEBUG' ) && WP_DEBUG )
88
		/** This filter is documented in core/src/wp-includes/functions.php */
89
		&& apply_filters( 'deprecated_file_trigger_error', true )
90
	) {
91
		error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
92
			sprintf(
93
				/* Translators: 1. File name. 2. Jetpack version number. */
94
				__( 'The %1$s file will be removed from the Jetpack plugin in version %2$s.', 'jetpack' ),
95
				$file,
96
				$removed_version
97
			)
98
		);
99
100
	}
101
}
102
add_action( 'deprecated_file_included', 'jetpack_deprecated_file', 10, 4 );
103
104
/**