Use wp_register_style
and wp_enqueue_style
to add the stylesheet. DO NOT simply add a stylesheet link to wp_head
. Queuing styles allows other plugins or themes to modify the stylesheet if necessary.
Your stylesheet can be a .php file:
wp_register_style('myStyleSheet', 'my-stylesheet.php');
wp_enqueue_style( 'myStyleSheet');
my-stylesheet.php would look like this:
<?php
// We'll be outputting CSS
header('Content-type: text/css');
include('my-plugin-data.php');
?>
body {
background: <?php echo $my_background_variable; ?>;
font-size: <?php echo $my_font_size; ?>;
}
Related Posts:
- Remove Internal Style Sheet if no Value Provided?
- framework for plugin/theme options panel? [closed]
- Is it ever okay to include inline CSS in plugins?
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- Is get_option function cached?
- How come `wp_options` table does not have an index on `autoload`?
- Update Option Stored in Multi-Dimensional Array
- What are the advantages to the Settings API?
- How to add sub-menu to a menu generated by wp_nav_menu by using plugin
- Adding Widget form fields dynamically
- Where to store plugin settings fields
- Is get_option() faster than accessing get_transient()?
- What’s the best method for emptying an option created with the Settings API?
- Releasing new plugin version, how to rename old options keys?
- WordPress updates defined vs add_filter?
- Creating Settings Page with dropdowns for Plugin
- How to properly sanitize strings for update_option()
- How to add a new plugin page under desired Options page?
- How do I handle multiple Submit buttons in plugin’s option page?
- How to prevent loading of all plugin’s resources?
- What is the best way to provide plugin users with a way to customized the styles
- Deletion of shared options using uninstall.php
- Why won’t register_setting() create a setting?
- Multiple entries in get_option results? or why is _multiwidget set to 1?
- Dropdown list of pages to get page id to store in plugin options
- update_option is not working!
- update_option_{$option} Too Few Arguments
- Save user-specific options in WordPress admin
- How to store accumulate multiple option values in a single array using Options_API
- What is better way to use Bootstrap inside admin panel?
- wp_enqueue_style built in styles
- Creating option to allow user to select the page my plugin content will display on
- Unified Approach for Placing Option Pages
- array_map() for sanitizing $_POST
- WordPress plugin options and jQuery
- WordPress Plugin Setting’s POST
- Performance of several get_option() calls
- Extend plugin options page
- Can I use the different settings sections over different pages using the save options group?
- Options API – Validation Callback $input is NULL
- Backslashes being stripped from CSS
- Dequeue theme stylesheets but keep widget styling on custom page template
- Best choice of options/settings framework for plugin/theme development
- Correct way check nonce (security) using old Options API
- How to check if a stylesheet is already loaded?
- how to include javascript file and css file in wordpress
- How to store a medium amount of options?
- How can I add a CSS rule to edit.php?
- How to add settings subpage from a plugin to a settings page created in theme?
- Plugin options not being saved or created
- How do I include background images in my stylesheets in a plugin?
- What could cause my plugin’s options/settings page not to load?
- What parameter should I pass to wp_enqueue_style to depend on the themes stylesheet?
- How to set “Site Address (URL)” programmatically on WP multisite?
- WordPress setting with select – where is my mistake?
- Using wp_parse_args to set up Plugin Default Settings
- Is there no admin ui guide for 4.x?
- Custom delete option button in plugin settings
- Storing product price data in the database
- How To Change Post Author Default?
- WP_Editor – Saving Value into Plugin Option – Stripping HTML
- Correct check for any admin page with editor
- Editing options pages?
- Multiple options pages validation for a plugin
- get_option() not returning expected value from plugin
- Parse form values before sending to options.php
- Prevent invalid or empty values from being saved to the database and retain the form field values upon error
- Update problem with update_option() in combination with register_setting()
- How to remove default style of header in wordpress metabox
- Insert/Update values to a table after blogname option etc. is updated
- Access bloginfo, get_option, and plugins_url from a non-core php file
- wordpress how to query wp_options table
- CSS not affecting widget output
- How can I avoid conflicts between plugin and theme?
- How Can I add Fields in wp-option table?
- Redirect to another page using contact form 7? [closed]
- Plugin Development/ Stop CSS clashes.
- Can’t change the style of a submit input type? [closed]
- Make a plugin page out of influence of the theme’s style
- Plugin Options Array Set to Undefined
- Checked() function on a multidimensional array
- get_option() will not work without access to wp-config.php
- Distributing Frontend Assets with Plugins
- My stylesheets are not enqueuing
- Custom Plugin – CSS works, JS doesn’t
- Issue on Checkbox with Custom Option Page
- Are there any official or unofficial guidelines for the styling of a widget?
- Make Database query only when option is updated
- The Correct Way to Use Nonce Field without Settings API
- Proper way to include stylesheet for panels
- Apply styles to blockquote element with the WYSIWYG editor
- How to Change CSS Colors from Custom Plugin Settings Page
- Settings API: Setting default option via ‘get_option’ fails
- Styles don’t load correctly. Insecure content
- Completely isolate a plugin view so it doesn’t load the theme
- how to save wp_editor html content in options table
- Custom Plugin Options Won’t Update
- Problem with display data from get_option
- Does WordPress default CSS have Grids?
- How to insert HTML/CSS/JS into my iframe plugin?