Title: Docs say "before_wp_load" but everything is loaded already? · Issue #78 · wp-cli/eval-command · GitHub
Open Graph Title: Docs say "before_wp_load" but everything is loaded already? · Issue #78 · wp-cli/eval-command
X Title: Docs say "before_wp_load" but everything is loaded already? · Issue #78 · wp-cli/eval-command
Description: Bug Report Yes, I reviewed the contribution guidelines. Yes, more specifically, I reviewed the guidelines on how to write clear bug reports. Describe the current, buggy behavior https://developer.wordpress.org/cli/commands/eval-file/ Thi...
Open Graph Description: Bug Report Yes, I reviewed the contribution guidelines. Yes, more specifically, I reviewed the guidelines on how to write clear bug reports. Describe the current, buggy behavior https://developer.w...
X Description: Bug Report Yes, I reviewed the contribution guidelines. Yes, more specifically, I reviewed the guidelines on how to write clear bug reports. Describe the current, buggy behavior https://developer.w...
Opengraph URL: https://github.com/wp-cli/eval-command/issues/78
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Docs say \"before_wp_load\" but everything is loaded already?","articleBody":"## Bug Report\r\n\r\n- [x] Yes, I reviewed the [contribution guidelines](https://make.wordpress.org/cli/handbook/contributing/).\r\n- [x] Yes, more specifically, I reviewed the guidelines on [how to write clear bug reports](https://make.wordpress.org/cli/handbook/bug-reports/).\r\n\r\n**Describe the current, buggy behavior**\r\n\r\nhttps://developer.wordpress.org/cli/commands/eval-file/ \r\n>This command runs on the before_wp_load hook, just before the WP load process begins\r\n\r\nIn my layman understanding I'd assumed that this means that hooks like \"init\", \"plugins_loaded\",... haven't run yet when the code in the \"eval-file\" is executed.\r\nTurns out this is wrong. All plugins and the theme have been loaded already, \"plugins_loaded\" hook is done,...\r\n\r\nBasically everything except any CLI things hooked to `after_wp_load` are done (to also have that available, one would have to pipe to `wp shell`) \r\n\r\nThis is especially confusing since https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-add-hook/#notes shows e.g. `before_wp_config_load` after `before_wp_load` however wp-config.php has long been loaded already when the \"eval-file\" is run\r\n\r\nIs this expected or a bug?\r\nIf this is expected - would it be possible to change the description to make clear what exactly is meant with \"just before the WP load process begins\"?\r\n\r\n**Describe how other contributors can replicate this bug**\r\n\r\n`wp eval-file /foo.php --use-include`\r\n\r\nwhere foo.php contains:\r\n\r\n```\r\n\u003c?php\r\nvar_dump( did_action( 'plugins_loaded' ) );\r\n\r\n// WooCommerce is installed in the environment and active\r\nvar_dump( function_exists( 'WC' ) );\r\n```\r\n\r\n**Describe what you would expect as the correct outcome**\r\n\r\nThe current behavior is ok and changing it would probably break tons of people's scripts/code. A clarification in the docs is needed though?\r\n\r\nI also wanted to ask:\r\nhttps://make.wordpress.org/cli/handbook/references/config/\r\n--require=\r\n\r\nWhen using that, I assume that code runs actually on `before_wp_load` - so no WP code is loaded at all, when that file is executed?\r\n\r\n","author":{"url":"https://github.com/kkmuffme","@type":"Person","name":"kkmuffme"},"datePublished":"2024-11-28T13:07:33Z","url":"https://github.com/wp-cli/eval-command/issues/78"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:772b0f30-ad3d-811b-614e-596037b4942b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9850:2833F1:1113C14:1759C26:6AFB6884 |
| html-safe-nonce | ece6bf6a65f6a92bc7eea3a37bfc415904f1e1a06a1a42e1018d568e09cfc002 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODUwOjI4MzNGMToxMTEzQzE0OjE3NTlDMjY6NkFGQjY4ODQiLCJ2aXNpdG9yX2lkIjoiNDM2MzQ1MjUwMDIxODYxNTA4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | cfefe45040991c7868f221b8ab2af3c10a3a7fb9c32b2b868ea5caceae343524 |
| hovercard-subject-tag | issue:2702097662 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/wp-cli/eval-command/78/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8e225f2b9a4efc107055ebc7a9ee19495d1b81827665079b1d16e6221ef01c5d/wp-cli/eval-command/issues/78 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8e225f2b9a4efc107055ebc7a9ee19495d1b81827665079b1d16e6221ef01c5d/wp-cli/eval-command/issues/78 |
| og:image:alt | Bug Report Yes, I reviewed the contribution guidelines. Yes, more specifically, I reviewed the guidelines on how to write clear bug reports. Describe the current, buggy behavior https://developer.w... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kkmuffme |
| hostname | github.com |
| expected-hostname | github.com |
| None | ea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94 |
| turbo-cache-control | no-preview |
| go-import | github.com/wp-cli/eval-command git https://github.com/wp-cli/eval-command.git |
| octolytics-dimension-user_id | 1570774 |
| octolytics-dimension-user_login | wp-cli |
| octolytics-dimension-repository_id | 85580543 |
| octolytics-dimension-repository_nwo | wp-cli/eval-command |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 85580543 |
| octolytics-dimension-repository_network_root_nwo | wp-cli/eval-command |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ef97164c52cf59bd10558ddec9c4f482763988 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width