Coding Standards: Remove a one-time `$message` variable in some `_doing_it_wrong()` calls.
This brings some consistency with most other calls. Follow-up to [23378], [25605], [34745], [36219], [44108], [46111], [48156]. See #52627. Built from https://develop.svn.wordpress.org/trunk@51154 git-svn-id: http://core.svn.wordpress.org/trunk@50763 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4d3ddd056f
commit
e05ffb46a5
|
@ -38,7 +38,11 @@ final class WP_Block_Pattern_Categories_Registry {
|
||||||
*/
|
*/
|
||||||
public function register( $category_name, $category_properties ) {
|
public function register( $category_name, $category_properties ) {
|
||||||
if ( ! isset( $category_name ) || ! is_string( $category_name ) ) {
|
if ( ! isset( $category_name ) || ! is_string( $category_name ) ) {
|
||||||
_doing_it_wrong( __METHOD__, __( 'Block pattern category name must be a string.' ), '5.5.0' );
|
_doing_it_wrong(
|
||||||
|
__METHOD__,
|
||||||
|
__( 'Block pattern category name must be a string.' ),
|
||||||
|
'5.5.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +64,12 @@ final class WP_Block_Pattern_Categories_Registry {
|
||||||
*/
|
*/
|
||||||
public function unregister( $category_name ) {
|
public function unregister( $category_name ) {
|
||||||
if ( ! $this->is_registered( $category_name ) ) {
|
if ( ! $this->is_registered( $category_name ) ) {
|
||||||
/* translators: %s: Block pattern name. */
|
_doing_it_wrong(
|
||||||
$message = sprintf( __( 'Block pattern category "%s" not found.' ), $category_name );
|
__METHOD__,
|
||||||
_doing_it_wrong( __METHOD__, $message, '5.5.0' );
|
/* translators: %s: Block pattern name. */
|
||||||
|
sprintf( __( 'Block pattern category "%s" not found.' ), $category_name ),
|
||||||
|
'5.5.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,17 +41,29 @@ final class WP_Block_Patterns_Registry {
|
||||||
*/
|
*/
|
||||||
public function register( $pattern_name, $pattern_properties ) {
|
public function register( $pattern_name, $pattern_properties ) {
|
||||||
if ( ! isset( $pattern_name ) || ! is_string( $pattern_name ) ) {
|
if ( ! isset( $pattern_name ) || ! is_string( $pattern_name ) ) {
|
||||||
_doing_it_wrong( __METHOD__, __( 'Pattern name must be a string.' ), '5.5.0' );
|
_doing_it_wrong(
|
||||||
|
__METHOD__,
|
||||||
|
__( 'Pattern name must be a string.' ),
|
||||||
|
'5.5.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! isset( $pattern_properties['title'] ) || ! is_string( $pattern_properties['title'] ) ) {
|
if ( ! isset( $pattern_properties['title'] ) || ! is_string( $pattern_properties['title'] ) ) {
|
||||||
_doing_it_wrong( __METHOD__, __( 'Pattern title must be a string.' ), '5.5.0' );
|
_doing_it_wrong(
|
||||||
|
__METHOD__,
|
||||||
|
__( 'Pattern title must be a string.' ),
|
||||||
|
'5.5.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! isset( $pattern_properties['content'] ) || ! is_string( $pattern_properties['content'] ) ) {
|
if ( ! isset( $pattern_properties['content'] ) || ! is_string( $pattern_properties['content'] ) ) {
|
||||||
_doing_it_wrong( __METHOD__, __( 'Pattern content must be a string.' ), '5.5.0' );
|
_doing_it_wrong(
|
||||||
|
__METHOD__,
|
||||||
|
__( 'Pattern content must be a string.' ),
|
||||||
|
'5.5.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +85,12 @@ final class WP_Block_Patterns_Registry {
|
||||||
*/
|
*/
|
||||||
public function unregister( $pattern_name ) {
|
public function unregister( $pattern_name ) {
|
||||||
if ( ! $this->is_registered( $pattern_name ) ) {
|
if ( ! $this->is_registered( $pattern_name ) ) {
|
||||||
/* translators: %s: Pattern name. */
|
_doing_it_wrong(
|
||||||
$message = sprintf( __( 'Pattern "%s" not found.' ), $pattern_name );
|
__METHOD__,
|
||||||
_doing_it_wrong( __METHOD__, $message, '5.5.0' );
|
/* translators: %s: Pattern name. */
|
||||||
|
sprintf( __( 'Pattern "%s" not found.' ), $pattern_name ),
|
||||||
|
'5.5.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,14 +43,20 @@ final class WP_Block_Styles_Registry {
|
||||||
public function register( $block_name, $style_properties ) {
|
public function register( $block_name, $style_properties ) {
|
||||||
|
|
||||||
if ( ! isset( $block_name ) || ! is_string( $block_name ) ) {
|
if ( ! isset( $block_name ) || ! is_string( $block_name ) ) {
|
||||||
$message = __( 'Block name must be a string.' );
|
_doing_it_wrong(
|
||||||
_doing_it_wrong( __METHOD__, $message, '5.3.0' );
|
__METHOD__,
|
||||||
|
__( 'Block name must be a string.' ),
|
||||||
|
'5.3.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! isset( $style_properties['name'] ) || ! is_string( $style_properties['name'] ) ) {
|
if ( ! isset( $style_properties['name'] ) || ! is_string( $style_properties['name'] ) ) {
|
||||||
$message = __( 'Block style name must be a string.' );
|
_doing_it_wrong(
|
||||||
_doing_it_wrong( __METHOD__, $message, '5.3.0' );
|
__METHOD__,
|
||||||
|
__( 'Block style name must be a string.' ),
|
||||||
|
'5.3.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +79,12 @@ final class WP_Block_Styles_Registry {
|
||||||
*/
|
*/
|
||||||
public function unregister( $block_name, $block_style_name ) {
|
public function unregister( $block_name, $block_style_name ) {
|
||||||
if ( ! $this->is_registered( $block_name, $block_style_name ) ) {
|
if ( ! $this->is_registered( $block_name, $block_style_name ) ) {
|
||||||
/* translators: 1: Block name, 2: Block style name. */
|
_doing_it_wrong(
|
||||||
$message = sprintf( __( 'Block "%1$s" does not contain a style named "%2$s".' ), $block_name, $block_style_name );
|
__METHOD__,
|
||||||
_doing_it_wrong( __METHOD__, $message, '5.3.0' );
|
/* translators: 1: Block name, 2: Block style name. */
|
||||||
|
sprintf( __( 'Block "%1$s" does not contain a style named "%2$s".' ), $block_name, $block_style_name ),
|
||||||
|
'5.3.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,28 +52,40 @@ final class WP_Block_Type_Registry {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! is_string( $name ) ) {
|
if ( ! is_string( $name ) ) {
|
||||||
$message = __( 'Block type names must be strings.' );
|
_doing_it_wrong(
|
||||||
_doing_it_wrong( __METHOD__, $message, '5.0.0' );
|
__METHOD__,
|
||||||
|
__( 'Block type names must be strings.' ),
|
||||||
|
'5.0.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( preg_match( '/[A-Z]+/', $name ) ) {
|
if ( preg_match( '/[A-Z]+/', $name ) ) {
|
||||||
$message = __( 'Block type names must not contain uppercase characters.' );
|
_doing_it_wrong(
|
||||||
_doing_it_wrong( __METHOD__, $message, '5.0.0' );
|
__METHOD__,
|
||||||
|
__( 'Block type names must not contain uppercase characters.' ),
|
||||||
|
'5.0.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$name_matcher = '/^[a-z0-9-]+\/[a-z0-9-]+$/';
|
$name_matcher = '/^[a-z0-9-]+\/[a-z0-9-]+$/';
|
||||||
if ( ! preg_match( $name_matcher, $name ) ) {
|
if ( ! preg_match( $name_matcher, $name ) ) {
|
||||||
$message = __( 'Block type names must contain a namespace prefix. Example: my-plugin/my-custom-block-type' );
|
_doing_it_wrong(
|
||||||
_doing_it_wrong( __METHOD__, $message, '5.0.0' );
|
__METHOD__,
|
||||||
|
__( 'Block type names must contain a namespace prefix. Example: my-plugin/my-custom-block-type' ),
|
||||||
|
'5.0.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->is_registered( $name ) ) {
|
if ( $this->is_registered( $name ) ) {
|
||||||
/* translators: %s: Block name. */
|
_doing_it_wrong(
|
||||||
$message = sprintf( __( 'Block type "%s" is already registered.' ), $name );
|
__METHOD__,
|
||||||
_doing_it_wrong( __METHOD__, $message, '5.0.0' );
|
/* translators: %s: Block name. */
|
||||||
|
sprintf( __( 'Block type "%s" is already registered.' ), $name ),
|
||||||
|
'5.0.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,9 +113,12 @@ final class WP_Block_Type_Registry {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $this->is_registered( $name ) ) {
|
if ( ! $this->is_registered( $name ) ) {
|
||||||
/* translators: %s: Block name. */
|
_doing_it_wrong(
|
||||||
$message = sprintf( __( 'Block type "%s" is not registered.' ), $name );
|
__METHOD__,
|
||||||
_doing_it_wrong( __METHOD__, $message, '5.0.0' );
|
/* translators: %s: Block name. */
|
||||||
|
sprintf( __( 'Block type "%s" is not registered.' ), $name ),
|
||||||
|
'5.0.0'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3907,18 +3907,20 @@ final class WP_Customize_Manager {
|
||||||
public function remove_panel( $id ) {
|
public function remove_panel( $id ) {
|
||||||
// Removing core components this way is _doing_it_wrong().
|
// Removing core components this way is _doing_it_wrong().
|
||||||
if ( in_array( $id, $this->components, true ) ) {
|
if ( in_array( $id, $this->components, true ) ) {
|
||||||
$message = sprintf(
|
_doing_it_wrong(
|
||||||
/* translators: 1: Panel ID, 2: Link to 'customize_loaded_components' filter reference. */
|
__METHOD__,
|
||||||
__( 'Removing %1$s manually will cause PHP warnings. Use the %2$s filter instead.' ),
|
|
||||||
$id,
|
|
||||||
sprintf(
|
sprintf(
|
||||||
'<a href="%1$s">%2$s</a>',
|
/* translators: 1: Panel ID, 2: Link to 'customize_loaded_components' filter reference. */
|
||||||
esc_url( 'https://developer.wordpress.org/reference/hooks/customize_loaded_components/' ),
|
__( 'Removing %1$s manually will cause PHP warnings. Use the %2$s filter instead.' ),
|
||||||
'<code>customize_loaded_components</code>'
|
$id,
|
||||||
)
|
sprintf(
|
||||||
|
'<a href="%1$s">%2$s</a>',
|
||||||
|
esc_url( 'https://developer.wordpress.org/reference/hooks/customize_loaded_components/' ),
|
||||||
|
'<code>customize_loaded_components</code>'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'4.5.0'
|
||||||
);
|
);
|
||||||
|
|
||||||
_doing_it_wrong( __METHOD__, $message, '4.5.0' );
|
|
||||||
}
|
}
|
||||||
unset( $this->panels[ $id ] );
|
unset( $this->panels[ $id ] );
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,13 +304,16 @@ function wp_deregister_script( $handle ) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( in_array( $handle, $not_allowed, true ) ) {
|
if ( in_array( $handle, $not_allowed, true ) ) {
|
||||||
$message = sprintf(
|
_doing_it_wrong(
|
||||||
/* translators: 1: Script name, 2: wp_enqueue_scripts */
|
__FUNCTION__,
|
||||||
__( 'Do not deregister the %1$s script in the administration area. To target the front-end theme, use the %2$s hook.' ),
|
sprintf(
|
||||||
"<code>$handle</code>",
|
/* translators: 1: Script name, 2: wp_enqueue_scripts */
|
||||||
'<code>wp_enqueue_scripts</code>'
|
__( 'Do not deregister the %1$s script in the administration area. To target the front-end theme, use the %2$s hook.' ),
|
||||||
|
"<code>$handle</code>",
|
||||||
|
'<code>wp_enqueue_scripts</code>'
|
||||||
|
),
|
||||||
|
'3.6.0'
|
||||||
);
|
);
|
||||||
_doing_it_wrong( __FUNCTION__, $message, '3.6.0' );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -899,19 +899,23 @@ function is_embed() {
|
||||||
* @return bool Whether the query is the main query.
|
* @return bool Whether the query is the main query.
|
||||||
*/
|
*/
|
||||||
function is_main_query() {
|
function is_main_query() {
|
||||||
|
global $wp_query;
|
||||||
|
|
||||||
if ( 'pre_get_posts' === current_filter() ) {
|
if ( 'pre_get_posts' === current_filter() ) {
|
||||||
$message = sprintf(
|
_doing_it_wrong(
|
||||||
/* translators: 1: pre_get_posts, 2: WP_Query->is_main_query(), 3: is_main_query(), 4: Documentation URL. */
|
__FUNCTION__,
|
||||||
__( 'In %1$s, use the %2$s method, not the %3$s function. See %4$s.' ),
|
sprintf(
|
||||||
'<code>pre_get_posts</code>',
|
/* translators: 1: pre_get_posts, 2: WP_Query->is_main_query(), 3: is_main_query(), 4: Documentation URL. */
|
||||||
'<code>WP_Query->is_main_query()</code>',
|
__( 'In %1$s, use the %2$s method, not the %3$s function. See %4$s.' ),
|
||||||
'<code>is_main_query()</code>',
|
'<code>pre_get_posts</code>',
|
||||||
__( 'https://developer.wordpress.org/reference/functions/is_main_query/' )
|
'<code>WP_Query->is_main_query()</code>',
|
||||||
|
'<code>is_main_query()</code>',
|
||||||
|
__( 'https://developer.wordpress.org/reference/functions/is_main_query/' )
|
||||||
|
),
|
||||||
|
'3.7.0'
|
||||||
);
|
);
|
||||||
_doing_it_wrong( __FUNCTION__, $message, '3.7.0' );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global $wp_query;
|
|
||||||
return $wp_query->is_main_query();
|
return $wp_query->is_main_query();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,15 +64,25 @@ function add_shortcode( $tag, $callback ) {
|
||||||
global $shortcode_tags;
|
global $shortcode_tags;
|
||||||
|
|
||||||
if ( '' === trim( $tag ) ) {
|
if ( '' === trim( $tag ) ) {
|
||||||
$message = __( 'Invalid shortcode name: Empty name given.' );
|
_doing_it_wrong(
|
||||||
_doing_it_wrong( __FUNCTION__, $message, '4.4.0' );
|
__FUNCTION__,
|
||||||
|
__( 'Invalid shortcode name: Empty name given.' ),
|
||||||
|
'4.4.0'
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 !== preg_match( '@[<>&/\[\]\x00-\x20=]@', $tag ) ) {
|
if ( 0 !== preg_match( '@[<>&/\[\]\x00-\x20=]@', $tag ) ) {
|
||||||
/* translators: 1: Shortcode name, 2: Space-separated list of reserved characters. */
|
_doing_it_wrong(
|
||||||
$message = sprintf( __( 'Invalid shortcode name: %1$s. Do not use spaces or reserved characters: %2$s' ), $tag, '& / < > [ ] =' );
|
__FUNCTION__,
|
||||||
_doing_it_wrong( __FUNCTION__, $message, '4.4.0' );
|
sprintf(
|
||||||
|
/* translators: 1: Shortcode name, 2: Space-separated list of reserved characters. */
|
||||||
|
__( 'Invalid shortcode name: %1$s. Do not use spaces or reserved characters: %2$s' ),
|
||||||
|
$tag,
|
||||||
|
'& / < > [ ] ='
|
||||||
|
),
|
||||||
|
'4.4.0'
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,9 +324,12 @@ function do_shortcode_tag( $m ) {
|
||||||
$attr = shortcode_parse_atts( $m[3] );
|
$attr = shortcode_parse_atts( $m[3] );
|
||||||
|
|
||||||
if ( ! is_callable( $shortcode_tags[ $tag ] ) ) {
|
if ( ! is_callable( $shortcode_tags[ $tag ] ) ) {
|
||||||
/* translators: %s: Shortcode tag. */
|
_doing_it_wrong(
|
||||||
$message = sprintf( __( 'Attempting to parse a shortcode without a valid callback: %s' ), $tag );
|
__FUNCTION__,
|
||||||
_doing_it_wrong( __FUNCTION__, $message, '4.3.0' );
|
/* translators: %s: Shortcode tag. */
|
||||||
|
sprintf( __( 'Attempting to parse a shortcode without a valid callback: %s' ), $tag ),
|
||||||
|
'4.3.0'
|
||||||
|
);
|
||||||
return $m[0];
|
return $m[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.8-beta1-51153';
|
$wp_version = '5.8-beta1-51154';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue