Skip to content

Wrap trigger_error calls in checks for WP_DEBUG #245

Open
@simonwheatley

Description

@simonwheatley

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions