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:
- WordPress Theme variables scope
- Enforcing password complexity
- Does My Child-Theme Functions.php Need if{die} Security In It? [duplicate]
- why is translation not working on theme?
- Is having multiple theme customizers for different pages possible?
- How to export/import theme customizer settings?
- Check php version before theme activation
- How Attackers write script into my php files?
- Separate WordPress themes for each category page
- Detection of theme being used
- Permanently remove first image from posts
- reason of splitting theme files to multiple files
- How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?
- How to get the registered sidebar’s name by its id?
- 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?
- Security – Ajax and Nonce use [closed]
- Replacing mysql_real_escape_string in WordPress theme
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- Activate different theme for temporary preview
- Can I write ‘RewriteCond’ using ‘functions.php’?
- Is it unsafe to put php in the /wp-content/uploads directory?
- Nice scroll to wordpress
- Twitter feed is showing blank in WP site [closed]
- Design view breaking on Pages
- Can’t Find a Way to Edit the Home Page Content [closed]
- How do I hardcode a WordPress shortcode into my theme?
- Use different javascript files for each page on website
- Fatal error: Call to undefined function wpsc_cart_item_count()
- How to get custom image size for image uploaded in Customizer
- 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
- Access WP files on “server 1”, from “server 2” – using wp-load on an external website
- Add the shortcodes from the enfold theme to the other theme
- PHP Error in WordPress Theme
- WordPress child theme, creating a custom php template page
- How to get Post sidebar & footer including html like get_the_content() which only gets content section?
- Menu to the right of screen on desktop using Bootstrap 4
- 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
- style.min.css code issue
- Beginner Developing Theme with Bootstrap – NavMenu question
- How to add Open/Close Toggle button into Twenty Fifteen theme for hiding left sidebar?
- Local WordPress from Git repo, where to set document root?
- user update profile for custom code
- Use Custiomizer to setup meta theme color tag
- Retrieve $_POST data to send to javascript without using localize script
- Previewing/Updating some Pages causes “The requested URL was rejected” Error
- 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?
- Create a custom theme-specific page, invisible in the admin-panel?
- Editing existing pre-created menus in PHP
- Two theme locations for two menus, but only one is showing up
- Editted Theme Files Get Updated/Reverted Every So Often
- WordPress pagination broken on blog page, working for search results page
- 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
- Shortcode Display From WordPress Dashboard Page Without Using post_id
- Image not displayed
- Include a php file that is above WP installation hierarchically?
- Inserting A Feed and Sidebar into an HTML Page
- Using existing widget code! [closed]
- how to register a second page-template
- Gallery requires a featured image but does not show it in posts/pages
- WordPress Website Featured Image Replacement Issue
- doubled content
- Themes with variable width or single columns? I want to display source code
- .htaccess on multisite and roots theme?
- Move wordpress sidebar on homepage up to new position
- How can I print out a single stylesheet or javascript link?
- Catchable fatal error in appcloud free theme by Tokokoo
- How to quickly/easily make an analysis (reverse engineering) of WordPress?
- Errors while Loading Most Recent Version of jQuery
- WordPress menu links with images & class selection
- 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
- Predefine Magazine Style Layouts
- How to remove the intro animation which appears during the load up of some WordPress themes? [closed]
- How to store the_post_thumbnail() value in a variable
- Need help with Deprecated: Non-static error when update PHP 7.4 -> 8.1 with Dyad 2 theme
- 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
- Font Awesome Icons as squares [closed]
- Gulp dev environment set up for WordPress theme development
- What is considered good practice for registering menu locations?
- WordPress theme requires PHP v >=8.1 – How to a dd different PHP version to docker-composer
- The theme doesn’t load css and JS files doesn’t load in functions.php
- Updated theme conflicts with updated php version
- Upgraded php & wordpress but theme broke
- Woocommerce Select Option Popup [closed]
- WordPress generating Undefined Variable warning