Skip to content

Commit

Permalink
Replaces _doing_it_wrong() with trigger_error().
Browse files Browse the repository at this point in the history
Per Ozz, this is an incorrect usage of doing it wrong.
It should not be used for input validation. Use `trigger_error()`
instead.
  • Loading branch information
hellofromtonya committed Oct 13, 2021
1 parent a0c55e9 commit 007ef64
Showing 1 changed file with 7 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ private function is_provider_valid() {
// @todo check if provider is registered.

if ( empty( $this->webfont['provider'] ) || ! is_string( $this->webfont['provider'] ) ) {
_doing_it_wrong(
'register_webfonts',
__( 'Webfont must define a string "provider".' ),
'5.9.0'
);
trigger_error( __( 'Webfont must define a string "provider".' ) );

return false;
}
Expand All @@ -94,11 +90,7 @@ private function is_provider_valid() {
*/
private function is_font_family_valid() {
if ( empty( $this->webfont['fontFamily'] ) || ! is_string( $this->webfont['fontFamily'] ) ) {
_doing_it_wrong(
'register_webfonts',
__( 'Webfont must define a string "fontFamily".' ),
'5.9.0'
);
trigger_error( __( 'Webfont must define a string "fontFamily".' ) );

return false;
}
Expand All @@ -115,25 +107,18 @@ private function is_font_family_valid() {
*/
private function is_font_style_valid() {
if ( empty( $this->webfont['fontStyle'] ) || ! is_string( $this->webfont['fontStyle'] ) ) {
_doing_it_wrong(
'register_webfonts',
__( 'Webfont must define a string "fontStyle".' ),
'5.9.0'
);

trigger_error( __( 'Webfont must define a string "fontStyle".' ) );
return false;
}

if ( ! $this->is_font_style_value_valid( $this->webfont['fontStyle'] ) ) {
_doing_it_wrong(
'register_webfonts',
trigger_error(
sprintf(
/* translators: 1: Slant angle, 2: Given font style. */
/* translators: 1: Slant angle, 2: Given font style. */
__( 'Webfont font style must be normal, italic, oblique, or oblique %1$s. Given: %2$s.' ),
'<angle>',
$this->webfont['fontStyle']
),
'5.9.0'
)
);

return false;
Expand Down Expand Up @@ -170,11 +155,7 @@ private function is_font_style_value_valid( $font_style ) {
private function is_font_weight_valid() {
// @todo validate the value.
if ( empty( $this->webfont['fontWeight'] ) || ! is_string( $this->webfont['fontWeight'] ) ) {
_doing_it_wrong(
'register_webfonts',
__( 'Webfont must define a string "fontWeight".' ),
'5.9.0'
);
trigger_error( __( 'Webfont must define a string "fontWeight".' ) );

return false;
}
Expand Down

0 comments on commit 007ef64

Please sign in to comment.