No you don’t need esc_attr()
function to print out fixed static text.
You only need it to print out dynamic or generated text, so that if the attributes have any special characters that may break your HTML, esc_attr
will escape that properly.
In your particular case, you can just write:
echo '<label><input type="checkbox" id="custom_header" name="custom_header" value="1" '. $checked .'> Activate Custom Header</label>';
However, if you had any generated or user input text, then you should’ve used esc_attr()
. For example:
$style = "__Some generated text from database or user input__";
echo '<label><input type="checkbox" id="custom_header" name="custom_header" value="1" '. $checked .' style="' . esc_attr($style) . '"> Activate Custom Header</label>';
Related Posts:
- Enforcing password complexity
- Permanently remove first image from posts
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- Renaming wp-content folder dynamically
- One button to change all settings in theme customizer?
- How do I create a WP user outside of WordPress and auto login?
- Is it unsafe to put php in the /wp-content/uploads directory?
- Twitter feed is showing blank in WP site [closed]
- Design view breaking on Pages
- Passing array in add_option()
- Create a quick start wordpress installation [closed]
- How should I best target dynamically served content?
- Changing the template hierarchy
- How to Insert Shortcodes into Theme?
- Warning: Use of undefined constant HTTP_USER_AGENT – assumed ‘HTTP_USER_AGENT’ (this will throw an Error in a future version of PHP)
- Evaluations of two wordpress security plans against php code injection attack
- Set WordPress Default Template
- Custom Theme, Custom shortcode not working
- WordPress custom login form using Ajax
- Adding custom directory and PHP files in wordpress
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Show full posts in archive
- Detect session/cookie variable in wordpress to prevent access to documents
- SQL Injection blocked by firewall
- How to prevent XSS alter custom global javascript object & methods in WordPress
- Connect WordPress with SharePoint [closed]
- Reconfiguring WordPress site
- adding custom user input fields in WordPress admin dashboard gives error The link you followed has expired. Please try again
- Move category description below post list in blog
- Customizer: active_callback and sanitize_callback incompatibility?
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Correct and safe way to include php content in my page
- What does this mean in wordpress? Easy question
- Showing latest post without 301 redirect
- Translate wordpress date from Italian to English
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- How to add API security keys into JS of wordpress securely
- Hardening uploads folder in IIS breaks images
- WordPress Customizer Default Image
- Do I have anything to worry about when switching to a default theme to test for plugin conflictions?
- Troll the hackers by redirecting them
- how to prevent wordpress admin from logging in via woocommerce my-account page
- How to add the sidebar to all the pages except the home page? [closed]
- Header not properly displaying on archive.php
- Save Custom CSS file in the upload folder dynamically?
- home.php show blog posts as grid view
- Amend theme php to include certain category in header
- Override index with a custom PHP page
- Updating From Mobile App – Exposing Site to Hacking
- Randomize Color Scheme Selection in Theme
- Accidentally deleted php code in WordPress website [closed]
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- How can I assign separate stylesheets to different pages?
- Commas in Tag Cloud
- Is there a (offical) way for a theme to deactivate itself and show a message in admin?
- security concerns if using html data-* attribute for l10n?
- how to get wordpress page url php code [duplicate]
- WordPress redirects page query parameter in URL
- Publish button now showing content after saving
- How to put search bar & logo in the “primary navigation” storefront theme?
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- I am having issue in divi woocomerce checkout module. (DIVI theme)
- Styling a category link
- echo cutom css code to WordPress page template file ? is this safe?
- Not able to remove caption shortcode from the content
- Commenting requires wordpress login, wordpress discussion and post comments tick boxes are checked
- Conditional Banners
- The style.php file inside theme-engine folder has other content on FTP
- How to override theme’s public static function inside of a trait?
- $.ajax results in 403 forbidden
- Invalid Argument foreach
- Site infected by link
- How to Change Site Elements based on referring URL
- How can I render more than multiple posts on template-parts with post formats
- how to use 2 index.php file One for mobile and one for desktop
- Deny php execution in /wp-includes – using .htaccess in /wp-includes VS root folder
- loop to return tags in woocommerce in alphabetical order?
- need to edit php file of child theme to remove an element
- user update profile for custom code
- Use Custiomizer to setup meta theme color tag
- Rotating Header Images
- Custom Theme, Editor won’t wrap text (i.e. change width)
- What is the best practice for restricting a section to logged in users?
- Two theme locations for two menus, but only one is showing up
- two wordpress sites, two themes, one database, same content
- calling a function from a class in your template
- Showing custom field contents without listing description
- Hide cart when empty [closed]
- WP Knowledge Base Theme bug – Subcategories and Articles, Need to change WP_Query
- Image not displayed
- Inserting A Feed and Sidebar into an HTML Page
- how to register a second page-template
- Gallery requires a featured image but does not show it in posts/pages
- Catchable fatal error in appcloud free theme by Tokokoo
- How to quickly/easily make an analysis (reverse engineering) of WordPress?
- How to create and add js and css file when server is not on my PC?
- Link a lightbox thumbnail to a post instead of opening the lightbox
- a problem in class in class-wp-hook.php
- what to do after instlling cyberpanel on VPS
- Using Featured Image as Hero Background in Word Press