[wp-hackers] prevent theme's functions.php from loading in wp-settings
Paul Menard
paul at codehooligans.com
Sat May 3 23:29:04 UTC 2014
Thanks Andrew. But my point was more about the theme functions.php being
loaded at all from wp-settings.php. Sure I can figure out a way to short
circuit the get_options call but that is for TwentyFourteen. What is there
is another theme used and the functions.php does many other queries I
really don't want? Just seems less efficient not being able to control this
via the WP_USE_THEMES define.
P-
On Sat, May 3, 2014 at 7:24 PM, Andrew Nacin <wp at andrewnacin.com> wrote:
> 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
> >
> _______________________________________________
> 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