Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use wp_trigger_error() in _doing_it_wrong() and _deprecated_*() functions #5161

Conversation

hellofromtonya
Copy link
Contributor

@hellofromtonya hellofromtonya commented Sep 6, 2023

Uses wp_trigger_error() in _doing_it_wrong() and each _deprecated_*() function, i.e. instead of trigger_error().

To avoid redundancy, used wp_trigger_error() once. How? Saved each message to $message variable and then passed it to wp_trigger_error() at the end of the function.

Trac ticket: https://core.trac.wordpress.org/ticket/57686


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@hellofromtonya hellofromtonya changed the title Use wp_trigger_error() in _doing_it_wrong() and _deprecated_*() functions Use wp_trigger_error() in _doing_it_wrong() and _deprecated_*() functions Sep 6, 2023
Copy link
Contributor

@costdev costdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @hellofromtonya! I agree that the single call to wp_trigger_error() is best here, and the changes look clean and good to go.

);
}

wp_trigger_error( $function_name, $message );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoopsie, should not be passing the function name. _doing_it_wrong() already added it to the message.

Fixed in 0293e8f

@hellofromtonya
Copy link
Contributor Author

@hellofromtonya hellofromtonya deleted the try/use-wp_trigger_error-in-functions.php branch September 26, 2023 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants