⚡ Bolt: Defer heavy theme check and extension loading to plugins_loaded#63
⚡ Bolt: Defer heavy theme check and extension loading to plugins_loaded#63mdjwel wants to merge 1 commit into
Conversation
…n loading - Removed `wp_get_theme()` call from `core_includes` (called in `__construct`), which was forcing early theme initialization on every request. - Moved `Heading_Highlighted.php` and `Features_Badge.php` inclusion to `init_plugin` (hooked to `plugins_loaded`), where `wp_get_theme()` is safely called. - Added lazy loading for these extensions: they are now only required if the specific feature is enabled in options, in addition to the existing premium/theme checks. - Preserved all existing logic regarding premium/theme restrictions. Co-authored-by: mdjwel <12756152+mdjwel@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Deferred the loading of
Heading_HighlightedandFeatures_Badgeextensions and thewp_get_theme()call from the plugin constructor to theplugins_loadedhook.🎯 Why:
wp_get_theme()is a relatively expensive operation that was running unconditionally on every request during plugin load (beforeplugins_loaded). This forced WordPress to initialize the theme subsystem earlier than necessary.📊 Impact: Reduced bootstrap overhead on every request. Additionally, the extension files are now only parsed if their specific features are enabled, further reducing memory and CPU usage for users with these features disabled.
🔬 Measurement: Verified with a script that
wp_get_theme()is no longer called during the plugin file load.PR created automatically by Jules for task 17991864568001082086 started by @mdjwel