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 can I see all the actions attached to an “add_action” hook?
- How can I import a class privately into a plugin?
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- Can we completely remove the WordPress Sitemaps (WordPress 5.5)?
- Updating WooCommerce variable product stock issue
- Rename existing old uploaded images containing accented French characters (not during upload)
- How to load all plugins CSS after child theme CSS?
- White text on white background in TinyMCE when wp_editor is called in WP 3.9
- I need to generate the CSS for my plugin from a function, how do i map a request to a function in the front-end?
- Loading class files via autoload method
- Adding a custom line of text to php code
- Modifying Footnote Plugin for Descriptive Title Attributes
- I would like to use create a function in my custom plugin to tell WP to use a different header
- Escape when echoed
- add_meta_box (Will display only in specific page admin WordPress)
- Make id column as AUTO INCREMENT on plugin activation
- Redirecting to home page after login as custom role WordPress
- Notepad sticky plugin
- WooCommerce Custom Product to checkout
- How to stop or remove an action being called inside a function of an extended class
- W3 Total cache “empty all caches” and no stylesheets render [closed]
- Redirecting a buddyboss profile tab to a different tab if not subscribed to a specific membership
- WooCommerce: Building a page with user input which is used to query order status and external API and return a result
- Why “Call to a member function on a non-object” in plugin only?
- What are the specifics of WordPress development I need to know? [closed]
- After upgrade to php 7 plugin/them updates broke [closed]
- How to echo text in browser instead of download junk file?
- How to create a custom post type that contains another custom post type?
- Adding CSS to custom post type admin page causes error
- Is wp-app.php or wp-apps.php needed for WordPress?
- Warning: Use of undefined constant list_all – assumed ‘list_all’ (this will throw an Error in a future version of PHP)
- How to distinguish if a plugin is not installed or just not active
- JavaScript in a PHP plugin
- Checking the count within a foreach loop
- Is there a function to list all uploaded images? How can I add one?
- Need to replace Currency Shortforms
- How to delete all categories programatically?
- How to use custom Javascript code inside a plugin?
- How to use printf to output two links?
- speed up pagination for huge database
- Building a plugin into a theme
- 2 wordpress site same database
- How to redirect to a page after the form is submitted
- Add background image/layout for single page?
- WP Insert Post If user refreshes override new post
- How to makes changes on the shop/category/tag pages but not on the product pages in woocommerce?
- How to authorize viewing and clicking a function only logged users?
- How to arrange custom posts in the backend/admin by custom taxonomy
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- the content of the uploads folder gets deleted periodically, how to figure out what causes it?
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- Custom Field used to allow a Free Story; no longer works
- How to send new visitor to a splash page for only one time in wordpress?
- How to change the width of certain paragraph or header blocks?
- Cron job shedules replace?
- Create a form and have custom menu display based on user answers?
- Can i add custom code in Source in specific page, Header from function.php?
- Problem with conditional woocommerce custom checkout field
- GET web api method from a WordPress PHP script
- Adding link on title its in description but not in title see screenshots attached
- Editing Global Variables from Inside Functions
- Posting code inside the post instead of in the template file using shortcode
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- conditional tags for the output of a plugin
- How to tweak a plugin without preventing it from updating
- Place max_execution_time in plugin [closed]
- Function not being called on form submit, only blank admin-post.php page
- WordPress Convert queries to slashes using function.php
- Getting table to format properly in RSS feed emails
- PHP Deprecated function Optional parameter $function