babble
babble copied to clipboard
Wrap `trigger_error` calls in checks for `WP_DEBUG`
Wherever we have trigger_error
calls
- We should ensure the error message is not translated
- We should swap them to
new Exception
instead oftrigger_error
- We should wrap them in a conditional check which ensures they only get called if
WP_DEBUG
is defined and true
So this:
trigger_error( sprintf( __( 'Warning: The translated name for the post type %s is longer than %d characters. This *will* cause problems.', 'babble' ),
esc_html( $post_type ),
20
) );
But this:
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
throw new exception( sprintf( 'Warning: The translated name for the post type %s is longer than 20 characters. This *will* cause problems.' ), esc_html( $post_type ) );
}