Opened 11 years ago
Last modified 6 years ago
#28364 new defect (bug)
WordPress Entry Points (wp-load.php occurrences)
Reported by: | szepe.viktor | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9.1 |
Component: | Bootstrap/Load | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
I was looking for entry point by searching for wp-load.php for plugin refactoring. I mean conditionally use require().
- There are easy to identify entry points like admin-ajax.php but there are no defines e.g in async-upload.php, wp-loging.php or wp-comments-post.php
- wp-trackback.php uses a strange way to detect the core
if (empty($wp))
- xmlrpc.php uses alone
include()
all othersrequire()
- How to distinguish between admin.php and admin-post.php?
Proposal
- There should be a uniform way requiring wp-load.
- All entry point should be distinguished by different defines
List of entry points and ways to detect them
- frontend: wp-blog-header.php:12
!is_admin()
- admin GET request: wp-admin/admin.php:30
is_admin()
- admin POST request: wp-admin/admin-post.php:15
is_admin()
- admin upload: wp-admin/async-upload.php:16
@$_SERVER['SCRIPT_FILENAME'] === ABSPATH . 'wp-admin/async-upload.php'
- AJAX call: wp-admin/admin-ajax.php:20
defined('DOING_AJAX') && DOING_AJAX
- WordPress cron webserver/CLI: wp-cron.php:26
defined('DOING_CRON') && DOING_CRON
php_sapi_name() === 'cli'
- XML-RPC protocol: xmlrpc.php:29
defined('XMLRPC_REQUEST') && XMLRPC_REQUEST
Frontend low priority
- wp-comments-post.php:16
@$_SERVER['SCRIPT_FILENAME'] === ABSPATH . 'wp-comments-post.php'
- wp-trackback.php:12
1 === get_query_var('tb')
Dashboard low priority
- wp-login.php:12
- wp-signup.php:4
- wp-activate.php:12
- wp-mail.php:11
Exclude from profiling
- wp-links-opml.php:15
- wp-includes/ms-files.php:12
- wp-includes/js/tinymce/wp-mce-help.php:9
- wp-admin/install.php:36
- wp-admin/install-helper.php:39
- wp-admin/upgrade.php:18
- wp-admin/maint/repair.php:10
- wp-admin/moderation.php:10
Total: 21 entry points as of version 3.9.1
Change History (7)
#3
in reply to:
↑ description
;
follow-up:
↓ 4
@
10 years ago
- Keywords reporter-feedback added
Hi @szepe.viktor, can you provide some more detail on the problem you're looking at solving? Thanks!
- All entry point should be distinguished by different defines
I guess my key misunderstanding is around this item. An example scenario of how current core code is not working or providing enough data would be great.
#4
in reply to:
↑ 3
@
10 years ago
- Keywords reporter-feedback removed
Replying to jeremyfelt:
I guess my key misunderstanding is around this item. An example scenario of how current core code is not working or providing enough data would be great.
It's "working." His complaint is that it's inconsistent and clunky.
It's sometimes not obvious where to find the documentation, for instance OP doesn't seem to be aware of is_trackback()
. (Perhaps there could be note in the file's header? Or indeed a file-specific define, or some kind of $wp_context global.)
Last but not least, it occasionally breaks down to:
$_SERVER['SCRIPT_FILENAME'] === ABSPATH . $file_to_check
(I'm quite sure I've used a less buggy version of the above idiom over the years to detect in what precise context WP was being loaded.)
Again, it works... It's just not very convenient -- or change proof, for that matter.
Any opinions, suggestions?