Automattic / babble

Multilingual WordPress done right.
https://wordpress.org/plugins/babble/
245 stars 50 forks source link

Wrap `trigger_error` calls in checks for `WP_DEBUG` #245

Open simonwheatley opened 9 years ago

simonwheatley commented 9 years ago

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 ) );
}