Opened 6 years ago
Closed 6 years ago
#41237 closed feature request (maybelater)
All error messages including core at one place
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
Why can't we manage all error messages at one place. Suppose we need any custom messages for rest apis and websites combining both is a headache.
Change History (5)
#2
follow-up:
↓ 3
@
6 years ago
- Milestone Awaiting Review deleted
- Resolution set to maybelater
- Status changed from new to closed
- Version 4.8 deleted
There is nothing stopping you from doing this in a plugin. For example:
<?php function myplugin_get_error( $code ) { switch ( $code ) { case 'not_allowed': return new WP_Error( 'not_allowed', __( 'This operation is not allowed.', 'myplugin' ) ); case 'not_implemented': return new WP_Error( 'not_implemented', __( 'This operation is not implemented yet.', 'myplugin' ) ); } }
It's possible that a pattern like this would also be a good fit for parts of core.
#3
in reply to:
↑ 2
@
6 years ago
- Resolution maybelater deleted
- Status changed from closed to reopened
But what is the hook to add this function. Just if we write add this function will we be able to get all errors that are generating.
Replying to jnylen0:
There is nothing stopping you from doing this in a plugin. For example:
<?php function myplugin_get_error( $code ) { switch ( $code ) { case 'not_allowed': return new WP_Error( 'not_allowed', __( 'This operation is not allowed.', 'myplugin' ) ); case 'not_implemented': return new WP_Error( 'not_implemented', __( 'This operation is not implemented yet.', 'myplugin' ) ); } }It's possible that a pattern like this would also be a good fit for parts of core.
#5
@
6 years ago
- Milestone Awaiting Review deleted
- Resolution set to maybelater
- Status changed from reopened to closed
This is not something that exists today in WordPress core, and it is unlikely to be worked on soon. I am closing this ticket again, please feel free to leave comments but do not reopen it.
There is nothing stopping you from structuring a plugin or theme this way.
Can you perhaps elaborate a bit more on which error messages you mean?
Is the problem that you need to write them multiple times for different areas instead of being able to refer to a common error message?