Skip to content

Instantly share code, notes, and snippets.

@onesword0618
Created March 18, 2019 15:00
Show Gist options
  • Select an option

  • Save onesword0618/4587f8a5938da3f7d4f9f569403c2edb to your computer and use it in GitHub Desktop.

Select an option

Save onesword0618/4587f8a5938da3f7d4f9f569403c2edb to your computer and use it in GitHub Desktop.
WPの関数:_deprecated_argument()
<? php
function _deprecated_argument( $function, $version, $message = null ) {
/**
* Fires when a deprecated argument is called.
*
* @since 3.0.0
*
* @param string $function The function that was called.
* @param string $message A message regarding the change.
* @param string $version The version of WordPress that deprecated the argument used.
*/
// 引数をもとにアクションフックに登録している関数を実行
do_action( 'deprecated_argument_run', $function, $message, $version );
/**
* Filters whether to trigger an error for deprecated arguments.
*
* @since 3.0.0
*
* @param bool $trigger Whether to trigger the error for deprecated arguments. Default true.
*/
 // デバッグモードまたは、deprecated_argument_trigger_errorが登録されている場合
if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
if ( function_exists( '__' ) ) {
if ( ! is_null( $message ) ) {
/* translators: 1: PHP function name, 2: version number, 3: optional message regarding the change */
trigger_error( sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s' ), $function, $version, $message ) );
} else {
/* translators: 1: PHP function name, 2: version number */
trigger_error( sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $function, $version ) );
}
} else {
if ( ! is_null( $message ) ) {
trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ) );
} else {
trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
}
}
}
}
@onesword0618
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment