This is a terrible way to make sure you are in the right context. The normal way is to load your class only when it is really needed, not earlier.
A side effect is that the following code cannot be cached, because that line is evaluated on run time, not on compile time. The same applies to function_exists().
Summary: Don’t do that.
Related Posts:
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- OOP PHP class extends TwentyTwenty_Customize in Child Theme
- Illegal string offset in PHP function in via Theme Customizer
- Change CSS Variable value in Theme Customizer Live Preview
- WordPress Customizer – How to save list of checkbox of pages?
- add_action in namespace not working
- Does an activated plugin automatically mean its methods are available to other WP functions?
- Need help setting default setting value for radio button in theme customizer
- Is having multiple theme customizers for different pages possible?
- How to export/import theme customizer settings?
- Remove Customize Background and Header from Appearance admin menu without CSS or JS
- Site Title and Tagline in Theme Options Page
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- reason of splitting theme files to multiple files
- Editor role cannot save custom theme options
- wp_customize_image_control default value
- WordPress customizer: load controls in a custom div
- Dynamically change feature image in customiser
- Best way to extends core classes in theme?
- One button to change all settings in theme customizer?
- Site Title and Tagline in Pagelines DMS Options Panel
- Check if Favicon is set in Customizer
- WordPress Customizer: How can you have multiple active callbacks on one control?
- Design view breaking on Pages
- OOP Plugin Development. Including external object
- Dynamically loaded Theme components based on Customizer Settings values : changes not appearing in Customizer preview – (Workaround found)
- Customizer Show/Hide Logo and Site Title
- WordPress Customizer not setting default value upon initial install?
- How to add default images into theme customizer image control?
- Theme Customizer – Dynamic CSS PHP File
- How to override .htaccess with new rules without ftp or edit it manual
- WP Plugin + OOP: Adding Menu Page doesn’t create required effect
- Show different Customizer Settings on Page-Tamplates
- How to get custom image size for image uploaded in Customizer
- Initiate only latest version of a class
- Passing array in add_option()
- How can one utilize a variable as a callback function name for add_settings_field
- How to do conditional publishing?
- Crop image from get_theme_mod Customizer field
- How to check if a Customizer setting is set?
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- Undefined method class::construct() when creating a plugin
- How can I access string value in an array?
- WordPress Customizer Default Image
- Warning: Illegal string offset on theme options page [closed]
- Changing the color scheme based on the url visited
- Need oop for wordpress theme? [duplicate]
- Link blogname and blogdescription to the Options Framework
- How to add drag and drop functionalities to a div inside option panel
- Usage of call back function of add_meta_box()
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Cant register rest routs from class instance
- Extending WP_Customize_Media_Control to return filename
- Please show me how to use an if/else statement in combination with wp_enqueue
- Check class_exists before class definition / Doxygen problem
- Undefined index for default custom theme option
- Customizer: How to change Header Image description
- get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control
- PHP Helper Class to create shortcodes
- Use SCSSPHP to compile Theme Customizer Values into .SCSS files ready to compile to CSS
- Class property seems to lose scope, attached to save_post action?
- PHP if have image display image, if else text
- Php file that doesn’t recognize wordpress functions
- Deactivate a plugin on wp version
- Need advice on theme customizer and child themes
- Get options from database using php class
- what does $options = get_option(‘test_theme’); do?
- Using theme options to change a border-radius value
- Getting text from custom field from customizer
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Grabing default from cuztomizer php file instead of other php script
- add_action in namespace not working
- Call to “admin_notices” hook from a static method
- Why would the child theme load in the Customize preview, but not on the site itself?
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- Use PHP Class in WordPress functions
- How can I edit a php custom page template to work in other themes?
- can I extend the WP_Query class to deal with ‘duplicate’ posts created by joining to wp_posts?
- How to add locations input to user profile?
- Access variable from another class that was passed in constructor
- How to add typehints to function in functions.php when argument is an object?
- Proper use of Output Buffer for a whole php clas
- Customizer textarea with script tag won’t work in live preview
- Allow user to choose header style
- Remove specific javascript when viewing page in Customizer?
- How to find php variable of wordpress theme settings
- Customizer: How to Sanitize a Decimal Number Range
- How to update option field in database on clicking the publish button in customizer
- Calling WordPress hook from within a class: call to undefined function error
- Make customizer panel or section button
- make an array in wordpress cusmization api?
- Multiple sections in Theme Customizer overwritten
- Use Custiomizer to setup meta theme color tag
- Default Image not showing up in Customizer for WP_Customize_Cropped_Image_Control
- Sort on two variables
- Using get_theme_mod with checkbox to display content
- customizer live preview layout picker
- PHP calling function within a class
- What is wrong with assigning values to a WP_List_Table class?
- Access preview settings in php