You should not use esc_attr in this way. It should be used only for escaping attributes in HTML tags.
As for the CSS it depends on who is the intended user. If you are doing it for a standalone site in which only the admin can edit the CSS, than you don’t need to sanitize. But if it is intended for use in a network than you need to use the wp_filter_nohtml_kses function to filter all HTML out of the CSS. You can have
echo '<style type="text/css" media="screen">' . wp_filter_nohtml_kses( $css ) . '</style>';
but it is more efficient to sanitize before you store the value in the DB.
Related Posts:
- How can I use WordPress functions in my stylesheet?
- How can I reduce the amount of files loaded/included per plugin?
- How can I make content disappear when a user logs in?
- Add CSS animation as Preloader to WordPress
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- How to sanitize uploaded file filename from a plugin?
- Add a CSS class based on categroy id to archive pages
- Changing “elapsed time” to “time remaining” on MP3-jPlayer audio player with CSS or PHP changes
- Bootstrap and Custom CSS in custom plugin are being overwritten by theme
- Delete mobile menu button [closed]
- Ability to automatically redirect a URL
- Redirect to another page using contact form 7? [closed]
- get specific value of a array | PHP
- How to make a dynamic css class whose name changes every visit to confuse scraper
- Add logo to admin menu in my plugin
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- Custom Plugin scripts from admin working in frontend
- Strange admin-ajax / CSS / $_SESSION issue
- make p tag collapsed after 3 rows
- Speeding up WordPress on a Local Network
- How do I override WordPress plugin css [closed]
- Caching of combined CSS and JS fails because of losing MIME types through combining by PHP
- How to remove a css class for any wordpress page
- Creating wordpress admin page panel [Theme Option]
- Best use adding user generated JS/CSS to a theme with a plugin
- Save selectlist value (taxonomy) in wp:wp_set_object_terms
- How to set up php,javascript and css to allow for our finished product to be displayed within a page?
- Option value not getting updated until page refresh in WordPress
- How to create a “Most Popular” & “Latest” TAB in WordPress
- How to resolve Multisite Speed issues
- add action wp_head not working
- Get a list of galleries from an album in NextGEN Gallery [closed]
- How to install and activate a plugin via an external PHP script
- how to include a simple jquery file into a wordpress plugin
- Calling a plugin in theme development
- Display a text message if the field is not found and not if found
- Unable to activate wordpress importer after installing it
- Reposition Woocommerce Message
- Get total number of comment of the posts written by an author
- How do you remove plugin edit option?
- Escape when echoed
- Scope for PHP Variables Assigned in functions.php or a plugin
- add_meta_box (Will display only in specific page admin WordPress)
- Make specific products accessible only to a user role in WooCommerce
- force customers to add only single item to card per purchase EDD [closed]
- Undefined property: WP_Post_Type::$ID
- Plugin exceeds memory limit
- How to get post URL in the_content filter?
- How to remove xmlns on language_attributes()?
- How to write one comment and publish on every post using database or plugin?
- Add a plugin before main container
- Shortcode to generate and save password in a file
- How to get subscription key or id using Woocommerce Subscriptions [closed]
- How to get member list based on role by using buddypress?
- I don’t understand how this parameter works..?
- Why wp_mail() function isn’t sending any emails and displaying ‘0’ in Chrome ‘Network’ response
- W3 Total Cache: Load CSS asynchronously for better PageSpeed score? [closed]
- How to initialize something in unit test before the init hook being called?
- adding meta data using plugin to top of head
- How do I write into a file (css)
- Missing argument 3 for wp_register_sidebar_widget()
- Make id column as AUTO INCREMENT on plugin activation
- How to Include a Loop Template File in a Plugin
- Write to / remove from default .htaccess file from plugin?
- Update Option Error: Notice: Undefined index
- How can I display a contact form for out of stock products in WooCommerce?
- ‘Customize’ button in admin bar for CSS
- Pass a php string to a javascript variable
- get shortcode value
- How to get number of Affected rows from wordpress dbDelta() function
- Show price with Geo IP location
- WordPress Ajax Callback
- Add category to body class
- The called constructor method for WP_Widget in GFWidget is deprecated since version 4.3.0! Use
- Plugin Development sqlite or WordPress’ database
- How to review WordPress website php version compatibility?
- Why isn’t “background-image: url”working with Bootstrap carousel on WP?
- How to add page using HTML, CSS and JS?
- printf – problem to understand code
- Do We Need to Validate, Sanitize, or Filter Simple Numerical Superglobals (Cookies and Post)?
- Custom Post Type Plugin not loading category template and loading 404 instead
- Sending email from inside a plugin using PHP PEAR
- Auto delete WordPress users according to time
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- How to generate CSS from a shortcode within a plugin
- How to trigger $_GET request within admin plugin page?
- Wp favorite posts get user favorites in profile using buddypress [closed]
- Storing Options in a Shortcode
- Why isn’t admin_notices displaying my text? [Simple Plugin, Beginner]
- How to generate video out of images via WordPress plugin
- Add stylesheets and js to template files when shortcode is used
- Custom CSS for plugin form
- How can I get WordPress to save comments in markdown format?
- add_query_arg not working
- problems with wordpress and php version 5.3.3-1
- How do I modify the position of a plugin?
- WooCommerce get_price returning wrong price when used via ajax
- How to ‘clone’ a wp plugin to make small changes
- Open Post Thumbnail in New Child Theme File in WordPress