A class provides structure, and if it’s what you need to do it then do it. The alternative would be a global variable, which is bad practice and should be avoided ( and makes reliable unit testing near impossible )
However, your entire premise is unnecessary. WordPress already stores the option in its caches, so no second database call occurs.
Otherwise yes, a class or object would be the answer
Related Posts:
- Check if a menu is empty?
- WordPress Template Engine?
- Walker class: Problems with understanding how walk() method can be called without error
- How to get the post count for the last x days filtering by categories
- Display only text to WordPress loop without loosing the text formatting
- How to create shortcodes that pull custom field data from general settings
- Where exactly do I write define( ‘WP_DEBUG’, true ) in wp-config file
- How to display related posts from parent category
- Making a follow button, Ajax not talking to php
- get understrap pagination to work with custom query
- Replace existing content from specific WooCommerce admin orders list column
- WordPress 3 – how are passwords stored and how do I compare to them?
- Use is_product_category() properly
- list posts and wrap them alphabetically A-Z
- Style wp_page_menu() items
- Link to the parent post in attachment page
- Convert all images to PNG on file upload
- White Screen of Death – wp-admin
- How to update WP about renamed files
- WordPress 5 WP REST routes – No errors
- Custom page archive query by url var calling page twice on one of my custom queries?
- Any possible way to make $wpdb->get_results() return anything else than array?
- Add prefix to link url
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Change list item content in menu navigation to add a child element with specific class
- Selectbox in admin panel function linking to CSS
- Is it better to create a function or a variable for current_theme_supports?
- wordpress allow user to edit user profile with custom fields
- Making BuddyPress Activity Stream (Post Type) Featured Images Clickable [closed]
- Which field should I edit to make the checkbox marked by default?
- Add filter when image is uploaded?
- How can I save unique user data on my site? [closed]
- Add New User, extra fields which are required?
- Repeating admin-ajax.php not found error in admin
- Remove a div from RSS feed
- Keyword checking in Gravity Forms
- how to refresh div on template part?
- Any way to add -1 suffix to the end of every new post?
- Are all hooks/functions tied to Kses meant for sanitization?
- Get URL Parameters from referer
- Using custom tables for old posts
- Adding logo to WordPress header
- Change page title from page using php via php executed from page/post itself
- Download images from media library to computer in BULK?
- add_filter only for front office
- How to array only one key from another array
- Detecting if parent page has gallery
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- Form Submission Not Working In Custom Theme
- Convert a string into a decimal number for use in query
- How to get specific attribute from DB
- customize woocommerce templates and display store on home
- Delete or edit postmeta with specific meta_key?
- Concatenate Custom Field Value & HTML Value
- How do I properly code my footer? See example
- how to hide or disable some part in specify page
- Use of IF statement in Header file
- Kohana Frontend, WordPress Backend
- apply_filters with several different values?
- Advanced Query posts
- Triggering a timewall after X days
- How do you create a custom category widget that you can style?
- Add Custom Category Description When Empty
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- echo cutom css code to WordPress page template file ? is this safe?
- Custom plugin: how do I call a PHP file if settings option is set to true?
- PHP `iconv` not working inside a WordPress site
- How to edit button permalink inside function.php using a child theme?
- How to make a “page-option” in WordPress
- Replacing entire tag with shortcode – JavaScript [duplicate]
- How do I visualize the author’s post from the front end?
- How to add a full working piece of website already coded, to a large scale Website design project?
- Elementor to custom wordpress page
- Query to show average # of months all accounts with specific role have been active
- Send email to users when they get new followers
- Conditionally change WordPress core language
- Remove item from post_meta array via AJAX
- Use PHP to inject HTML into before page renders?
- Query doesn’t display text data with apostrophes
- WooCommerce Custom Tab with ACF Repeater Field
- My WP Website Shows HTTP ERROR 500
- add menu page in loop menu order
- CSS loading as empty file in Custom Theme
- Calling WordPress hook from within a class: call to undefined function error
- Dynamically Create Posts Via XML File
- pages disable after wordpress update
- How to only fetch certain Tag ID’s
- AdWords API with WP
- How to set a cookie based on a page Get variable?
- Editing the contents of just one div on a page from wordpress
- Postmeta not saving
- How to change the menu color
- Display latest 5 posts on homepage
- Display Current Time using shortcode
- SQL – How to echo out inside of where statement
- How to create different templates for woocommerce single-product.php?
- How can I update a value of a field depending on outside source?
- Restricting access to a file for everyone except logged in users
- WordPress Block Editor Gutenberg running code inside ! is_admin()
- Tags being Inserted in html from plugin PHP not passing through the_content