[wp-hackers] prevent theme's functions.php from loading in wp-settings

Andrew Nacin wp at andrewnacin.com
Sat May 3 23:24:10 UTC 2014


Well, you could stop it from being called. But trying to prevent
functions.php from loading just to stop a single get_option() call is like
amputating a limb because of a paper cut.

If you're seeing that query, then the featured-content option isn't
initialized. Just add that option manually (something the theme probably
does upon save or something) and you'll avoid the SQL query. Example:
add_option( 'featured-content', array() );


On Sat, May 3, 2014 at 7:19 PM, Paul Menard <paul at codehooligans.com> wrote:

> Greetings. I custom processing loop outside of WordPress. This is a custom
> AJAX handler and depending on the POST arguments I do some stuff outside of
> WordPress or as in this case I load WP via the following.
>
> define( 'SHORTINIT', false );
> define( 'WP_USE_THEMES', false );
> define( 'WP_DEBUG', false );
>
> // Load in WP core.
> require( $configs_array['ABSPATH'] .'wp-load.php' );
>
> So as anyone knows wp-load.php then calls wp-config.php which in turn calls
> wp-settings.php
>
> Within wp-settings.php line 324 begins the logic and my issue.
>
> if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
> if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH .
> '/functions.php' ) )
> include( STYLESHEETPATH . '/functions.php' );
> if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
> include( TEMPLATEPATH . '/functions.php' );
> }
>
> Seems I had always thought setting the define 'WP_USER_THEME' as false
> would prevent the theme from loading. I guess I was wrong.
>
> What I'm really trying to prevent is a query used within the TwentyFourteen
> theme in twentyfourteen/inc/featured-content.php where registers an action
> for when 'wp_load' action hits. This in turn causes a get_option call for
> featured content in line 471 Not that this is a big query.
>
> $saved = (array) get_option( 'featured-content' );
>
>  Just bugs me that I can't stop it from being called.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list