Opened 6 years ago
Last modified 5 years ago
#41934 new enhancement
Update load.php with wp_is_bad_request function
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.9 |
Component: | Bootstrap/Load | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
I propose adding a wp_is_bad_request function to load.php, as a way to allow plugin developers to short circuit code execution if the HTTP request that started the WordPress load process is considered a junk request. See: #17246
The existing wp_favicon_request (renamed to wp_favicon_request_x in test file) is re-written to use the proposed wp_is_bad_request function.
Attachments (3)
Change History (6)
#2
in reply to:
↑ description
@
6 years ago
For clarification:
When I say short circuit code execution, I mean: short circuit plugin code execution, not short circuit WordPress code execution.
Example:
<?php class RDP_PLUGIN { private static $_instance = NULL; private function __construct() { // prevent running code unnecessarily if(wp_is_bad_request())return; // run the plugin add_action('wp_loaded',array( $this, 'run'),1); }//__construct public static function get_instance(){ if (NULL === self::$_instance) self::$_instance = new self(); return self::$_instance; } //get_instance ... other plugin code ... } $RDP_PLUGIN = RDP_PLUGIN::get_instance();
Note: See
TracTickets for help on using
tickets.
test file for proposed wp_is_bad_request enhancement