Calypsoify: Delay use of core admin functions until they are loaded.#11651
Calypsoify: Delay use of core admin functions until they are loaded.#11651
Conversation
Calypsoify is loaded on `wp_loaded`, which is before core admin functions are loaded. It's only safe to use core admin functions during or after `admin_init`. Keep the current `get_user_meta()` checks where they are in `wp_loaded`, but do the rest of the setup on `admin_init`. Juggles other `admin_init` priorities to ensure things happens in the same order. Fixes #11650
|
This PR's diff is easier to see when ignoring whitespace: https://github.com/Automattic/jetpack/pull/11651/files?w=1 |
|
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: April 2, 2019. |
Doh! Silly me – I started down that route, but opened Thanks for the heavy lifting, will test and confirm this soon today. |
kwight
left a comment
There was a problem hiding this comment.
Fantastic, works as expected – thank you! <3
|
I couldn't duplicate the original failure on a fresh JN site, but this PR also works as advertised. |
…strange. What branch were you testing for JN? |
Looks like you need your site connected for the module to load? |
|
Must have tested it from an older branch before the breaking PR or something. Tried it fresh and able to duplicate/resolve with this PR. |
Fixes #11650
Changes proposed in this Pull Request:
Calypsoify is loaded on
wp_loaded, which is before core admin functions are loaded. It's only safe to use core admin functions during or afteradmin_init.This PR keeps the current
get_user_meta()checks where they are (inwp_loaded), but does the rest of the setup onadmin_init. To do that, it juggles otheradmin_initpriorities to ensure everything happens in the same order as before.Testing instructions:
Prior to this PR, the preview tab will spin forever, you'll see some errors in the JS console of the editor tab:
and there will be a fatal error in your PHP error log:
With this PR, the preview tab will eventually load, there will be fewer errors in the JS console of the editor tab, and there will be no PHP fatal errors.
Proposed changelog entry for your changes:
None needed.