WP Header & Footer Code Injector
A lightweight and secure WordPress plugin to easily inject custom JavaScript, CSS, or HTML into your site’s header and footer. Includes enable/disable toggle, translation-ready placeholders, and works without touching theme files. Perfect for analytics, tracking, and custom scripts.
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/aminulsarkar/wp-header-footer-injector/archive/refs/heads/main.zipEasily add custom scripts to WordPress header and footer without editing theme files. This plugin is lightweight, secure, and fully translation-ready. Perfect for Google Analytics, Facebook Pixel, custom CSS, or any JavaScript code. Includes enable/disable toggle and placeholder guidance for non-technical users.
Features
- Inject custom header and footer code safely
- Enable/disable toggle to activate/deactivate injection
- Translation-ready for internationalization
- Guided placeholders for JS and CSS examples
- Works with any theme without modifying theme files
- Sanitized inputs to prevent malicious code
- Fully compatible with modern WordPress and PHP versions
Installation
- Upload the plugin folder to
/wp-content/plugins/ - Activate the plugin through Plugins > Installed Plugins
- Navigate to the Header & Footer menu in the WordPress sidebar
- Add your code in the header or footer textarea
- Enable or disable injection using the toggle and save changes
Usage
- Header Code: Scripts injected inside
<head> - Body Open Code: Scripts injected right after
<body> - Footer Code: Scripts injected before
</body> - Placeholders show example JavaScript and CSS for guidance
- Toggle to enable or disable code injection easily
Requirements
- WordPress 5.0+
- PHP 5.6+ (recommended 7.4+)
Screenshots
- Admin settings page with header/footer textareas
- Enable/disable toggle
- Example of placeholder guidance
Changelog
1.0.0 – Initial release
- Fully functional header & footer code injection
- Enable/disable toggle
- Translation-ready
- Placeholder guidance included
License
This plugin is released under the GPLv2 or later.
Author
Aminul Sarkar – aminulsarkar.com