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
- When unit testing a plugin, does the plugin need to be in the wp-content/plugins directory of the WordPress tests install?
- How can I prevent a plugin from updating unless it’s minimum PHP version is met?
- Make the css of the widget overwrite theme css
- Determining where fopen() is writing files when used from WordPress AJAX call [closed]
- How Restrict access to admin dashboard by specific static ip?
- Override Theme CSS with CSS from a plugin
- How to get images from EDD post?
- Add multiple attributes to product from php
- How to initialize something in unit test before the init hook being called?
- Add category to body class
- Plugin Development sqlite or WordPress’ database
- How to review WordPress website php version compatibility?
- How to add page using HTML, CSS and JS?
- Download any file after submitting a form [closed]
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- woocommerce 3.2.1 not sending order notification emails
- Create mobile navigation header with settings integration
- How to style the RSS wordpress?
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- wp_get_post_terms is difference obj model than the one in rest api response
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- WpDataTables – View Image Directory
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- Server configuration for WordPress – Do I need install PHP-SSH extensions for WordPress on Fedora28?
- WordPress shows error related to allow_url_fopen
- Widgets Scripts don’t load – but load when I reload the page
- How to replace WordPress Media Upload Window with user’s device window?
- wp_footer hook only working on homepage not in other pages
- Using color picker in plugin, does input attribute order matter?
- WordPress custom taxonomy not showing
- My WordPress site when down after installing a plugin and now all I get is a simple white screen [closed]
- Override plugin styles via my custom theme
- Pass user role to javascript code inside body
- Integrating boxtal PHP library into a custom WordPress Plugin
- Images under 1MB are not being compressed
- UTF-32be error WordPress
- Sanitize $_GET variable when comparing
- Getting a ressource ID, from a WC_Order_Item_Product/Order
- Customize Menu | Styling LESS/SCSS code formats
- ACF – How to set the menu order for the relationship field
- Passing PHP Variables to AJAX Loaded Pages
- How to theme code blocks formatted by the prettify.js embedded with WP-Markdown?
- How do I override all stylesheets and scripts without a plugin
- Send Array from JS to php file then insert it in wp database through a plugin
- Offer Download Links for Product Images
- How to get the custom field value using SQL query
- Possible way of having multiple Gutenberg instances for a page?
- How to change the WordPress Plugin Watson Assistant Chatbot BOX Size?
- Woocommerce add products to cart
- Changing wordpress/woocommerce notices default message to other languages (text)
- Why does my custom plugin only function correctly once per page?
- Using id to show item
- I can’t view the orders on the woocomerce dashboard with the brainblocks plugin
- WP Migrate DB Pro plugin cannot transfer Media files to remote server
- Is admin section completely customizable in terms of styling?
- How to echo meta_key in easy digital downloads receipt (Purchase Confirmation page)
- Plugin error “array_key_exists(): The first argument should be either a string or an integer” [closed]
- I want add repository theme folder
- Migrating custom php we wrote from functions.php into a site-specific plugin
- What is the correct entry point for capturing coverage data
- plugins_loaded action is not working properly
- Creating a user ‘add custom field’ section
- WordPress function to add text
- disable lightbox in a plugin [closed]
- How to Set Limit with WordPress Get Bookmarks Shortcode
- TheCartPress plugin – Make every item in store unique
- avatar displays outside of targeted area
- ACF: Hide a div or template section when a custom field (in a field group) is empty
- Function not being called on form submit, only blank admin-post.php page
- cURL External API request displays content above other content on page
- WordPress Convert queries to slashes using function.php