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?
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- How come `wp_options` table does not have an index on `autoload`?
- What are the advantages to the Settings API?
- Adding Widget form fields dynamically
- Is get_option() faster than accessing get_transient()?
- 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?
- 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!
- 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
- WordPress plugin options and jQuery
- WordPress Plugin Setting’s POST
- Performance of several get_option() calls
- Extend plugin options page
- Backslashes being stripped from CSS
- Dequeue theme stylesheets but keep widget styling on custom page template
- 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?
- Storing product price data in the database
- WP_Editor – Saving Value into Plugin Option – Stripping HTML
- Correct check for any admin page with editor
- Multiple options pages validation for a plugin
- get_option() not returning expected value from plugin
- Parse form values before sending to options.php
- 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
- 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.
- Make a plugin page out of influence of the theme’s style
- Plugin Options Array Set to Undefined
- Checked() function on a multidimensional array
- My stylesheets are not enqueuing
- Issue on Checkbox with Custom Option Page
- 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
- How to Change CSS Colors from Custom Plugin Settings Page
- Settings API: Setting default option via ‘get_option’ fails
- 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
- Does WordPress default CSS have Grids?
- How to insert HTML/CSS/JS into my iframe plugin?
- why does get_option( ‘home’ ) not work while using in plugin [closed]
- Plugin Options not saving options and doesn’t work
- How To Protect Plugin Display From Being Affected By Theme’s CSS
- Load stylesheet in edit category page?
- What could cause a WP Option to get truncated?
- CSS not being applied using wp_enqueue_style
- Decontruct serialized data array from wp_options
- How to add some basic inline CSS using existing plugin or theme?
- Add multiple checkboxes as single field to Custom Shipping Method Settings Page
- How does one update complex options?
- Why does theme’s reset CSS have higher precedence of plugin’s CSS?
- Twenty-seventy theme remove additional CSS from head
- Plugins Settings page not updating
- How to create plugin settings page for each admin user?
- Plugin setting page – update_option problem
- add_settings_error on validating plugin options API
- Unable to link CSS file
- Array/List Edit in Backend
- How can I add the Post ID to Class Name in Jquery?
- What should I use instead of get_blog_option?
- Tie specific functions to options-update for limiting API requests
- Can’t switch theme after activation
- the correct way to use options from settings page [closed]
- Saving multiple fields as array
- Options don’t save, validation callback not executed
- Modify a Themes Appearance >> Header admin screen from a plugin
- Settings API not Saving to Database or Display
- Admin Message after Plugin Option Updated