Opened 7 years ago
Last modified 4 months ago
#41934 new enhancement
Update load.php with wp_is_bad_request function
Reported by: | rpayne7264 | 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 (8)
#2
in reply to:
↑ description
@
7 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();
#4
@
4 months ago
- Keywords close added
Hi @rpayne7264, Sorry it took so long for someone to review this.
It's unclear to me of the benefits of this proposed function. For much the same reasons outlined in https://core.trac.wordpress.org/ticket/17246#comment:7, plugins can already do checks of their own when needed and core can't make many assumptions do to the number different configurations.
#5
@
4 months ago
- Keywords close removed
The benefits of this proposed function is so that there is a core function that everyone can use to check if the WordPress site is being loaded due to a missing script file or missing image file or missing css file. WordPress re-loads the webpage for each occurrence of a missing script file or missing image file or missing css file. That needs to be addressed. The proposed function is akin to already-existing functions like wp_doing_ajax and wp_is_json_request.
test file for proposed wp_is_bad_request enhancement