If you really want to execute code stored in a database, a quick google search reveals that you can use the eval() function to do just that. However, many people do say that Eval is Evil…
Instead of storing the entire PHP code of an option in the database, try storing a simple boolean flag for your option and then test whether to get your template’s option data from there:
<?php
// Somewhere else in your code, store the settings option upon saving settings
update_option( 'my_setting_for_template', 1 );
// Test if get_option returns 1 from the database
if( get_option( 'my_setting_for_template' ) === 1 )
{
echo get_option('profiles_templates_html'. $template .'');
}
?>
References:
Related Posts:
- Enqueue Javascript Correctly for 3.5
- Adding Default Settings to Theme My Login plugin
- Security for data obtained from the database
- Trim Titles Only On Some Pages
- Integrating CSS Into a WP Function Call [closed]
- Options.php loop won’t show!
- Dynamic Email Handler with ‘header (“Location: …’
- start_lvl Ignored in Custom walker_nav_menu
- Enforcing password complexity
- How do I make my function add variables/values to the $post object?
- Calculate percentage of post by category
- Dynamically change feature image in customiser
- Change comments form title on a page by page basis
- Creating wordpress user registration form
- Get the title before comma
- category not display in word press grammatically
- Getting a fatal error while updating
- How do I know what variables are passed in a filter/action and what their meaning is?
- “Can’t use function return value in write context” error
- Display 4 chronological posts starting with a random post
- Select dropdown not showing selected value php
- my function doesn’t return my post from today
- Wrap each shortcode in array to div
- Warning: array_pop() expects parameter 1 to be array, boolean given
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- How to Display Image Meta underneath EVERY image in EVERY post
- get_the_terms – only top level
- Have CSS Class Added with `is_page()` WP function
- Slide in Panel WordPress Post
- Run a filter when a walker runs
- comments_number display outside specified span
- SQL QUERY – Select a value directly from the database
- Swapping wp_dropdown_categories function with wp_category_checklist
- Display fields as values in array from external SQL DB
- Passing the custom field values in the wp_get_current_user array function
- Populate dropdown with Child Pages based on Parent Page chosen
- How can I remove a function that has been added to wordpress with add_filter?
- Get value from shortcode to do something
- PHP 8, AJAX mail form to function.php doesn’t work
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- how can i use $_COOKIE[] + PostID to execute the below code?
- What’s the uses of wp_cache_set() or wp_cache_add()?
- How to create a php variable using WordPress the_title() function
- Create Page To Count Comments For Each Post In WordPress Site
- Can’t find infinite loop cause
- how to make custom ajax handler?
- How to disable controls in theme customizer?
- Saving plugin settings – ERROR: options page not found
- Moving code from theme header to functions.php
- Best way to use a large array in function
- Setting user nickname and displayname to shortened email
- Download PDF after CF7 form submission
- ::before on open/close function [closed]
- REQUIRED: get_bloginfo(‘template_url’) was found in the file search.php. Use get_template_directory_uri() instead
- Creating a mobile site by adding a new class to the body tag from functions.php
- Export Form Data to a CSV then send it as an attachment – contact form 7
- Issue with fetching mysql data and displaying results via shortcode in webpage
- How do I create a function that modifies a message in the wp-login.php file?
- Cant display an image via PHP in wordpress
- Template Loop – add switch case php
- Show all tags within a category?
- Call to undefined function error in plugin
- How do I correct the code in php? [closed]
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- Unable to Call More than One Meta Box Output
- How can I alter this code to accept a slug as well as an ID?
- Display random image url from list of input values
- Menu not styling. New menus functionality giving me a headache
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Adding an “Upgrade Subscription” button to an Elementor page
- Dropdown category field inside repeatable metabox
- Retrieve alt text by referencing the img src
- Custom function that re-writes page title breaks when the Yoast plugin is activated
- Copying and pasting to WordPress “code editor” code via the front end and clipboard
- Ajax filter with loadmore button
- update_user_meta as multiple value but with same meta key
- Delete post meta by serialized meta value
- Create a temporal post
- How to bind each “the_content” elements to a custom variables
- Permalink changes after several minutes after saving post
- Trying to publish a little bit of Javascript on the homepage AND at the bottom
- Add parent menu item in sub-menu in custom nav_walker
- Custom Bulk Actions handler not firing
- Get field in readable word
- How can disable wordpress emails notifications?
- Custom Taxonomy as Link
- How to fix blank pagination links?
- main menu page redirects to user ID
- How to have Function of a plugin using global vars into a shortcode?
- adsense code showing on random post thumb
- How can I clear the theme mod settings?
- Cant get theme to change footer color through theme customizer
- How to extend the page editor?
- ACF Date fileds to Age Convert [closed]
- How do I get Roboto Google Font to display normal font-style? [closed]
- WP Fatal error: Call to undefined function get_template_directory_uri()
- Remove default Image Sizes
- A better way to write this php function
- How to limit the number of posts in the wordpress loop in conjunction with the “download more” button?
- Need help with conditional logic for menus