babble icon indicating copy to clipboard operation
babble copied to clipboard

Wrap `trigger_error` calls in checks for `WP_DEBUG`

Open simonwheatley opened this issue 9 years ago • 0 comments

Wherever we have trigger_error calls

  1. We should ensure the error message is not translated
  2. We should swap them to new Exception instead of trigger_error
  3. 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 ) );
}

simonwheatley avatar Mar 04 '15 22:03 simonwheatley