Skip to content

Repository files navigation

Insert Header Footer & Body Code

Insert Header Footer & Body Code is a lightweight WordPress plugin for inserting custom header, body, and footer code snippets, structured data, schema markup, analytics scripts, verification tags, and body classes without editing theme files.

The plugin is useful for SEO, AEO (Answer Engine Optimization), GEO (Generative Engine Optimization), Google Tag Manager, analytics integrations, JSON-LD schema insertion, custom tracking scripts, and AI search optimization workflows.

SEO, AEO & GEO Use Cases

This plugin can be used to:

  • insert SEO verification tags
  • add JSON-LD structured data
  • inject schema markup
  • add Google Analytics and Google Tag Manager scripts
  • manage custom tracking snippets
  • support AI search and generative engine optimization workflows
  • customize body classes for advanced CSS targeting

Project Status

This repository is prepared for a public first release and ongoing maintenance as an open-source WordPress plugin project.

Why This Plugin Is Useful

This plugin was originally built with advanced conditional insertion controls and body class management in mind. It gives site administrators a practical way to:

  • insert site-wide header, body, and footer code
  • add conditional code to specific posts, pages, and custom post types
  • add conditional code to taxonomy term archive views
  • attach custom body classes to selected items and terms

That makes it useful for analytics snippets, verification tags, structured data, CSS targeting, campaign-specific scripts, and similar controlled front-end changes.

Key Features

  • Global header, body, and footer code fields
  • Conditional post type enablement for per-item code fields
  • Conditional post type enablement for per-item custom body class fields
  • Conditional taxonomy enablement for term-level code fields
  • Conditional taxonomy enablement for term-level custom body class fields
  • Native WordPress settings screens, meta boxes, and term fields
  • Body class sanitization into valid CSS class tokens
  • Raw snippet handling reserved for users with the unfiltered_html capability

Installation

End-user plugin ZIP

  1. Download a clean release ZIP.
  2. In WordPress admin, go to Plugins > Add New > Upload Plugin.
  3. Upload the ZIP and activate the plugin.
  4. Open Settings > Header Footer Body Code.

Development checkout

  1. Clone this repository.
  2. Place the plugin folder inside your local WordPress wp-content/plugins/ directory, or symlink it there if you prefer.
  3. Activate the plugin in your local WordPress installation.
  4. Run tests locally before making changes.

Development

The plugin is intentionally kept lightweight and WordPress-native.

Development-oriented files may exist in this source repository, including:

  • tests/
  • composer.json
  • composer.lock
  • phpunit.xml.dist
  • .phpcs.xml.dist

These files help maintain the project, but they are not required in the end-user plugin ZIP.

Testing

PHPUnit is configured for lightweight utility and settings tests.

Requirement:

  • Composer installed locally

Run tests on Windows

If you are already inside the plugin directory:

composer install
vendor\bin\phpunit --configuration phpunit.xml.dist

Or:

composer install
composer test

If you want to run the commands from another location:

Set-Location "path\to\insert-header-footer-body-code"
composer install
vendor\bin\phpunit --configuration phpunit.xml.dist

Or:

Set-Location "path\to\insert-header-footer-body-code"
composer install
composer test

Run tests on macOS or Linux

cd /path/to/insert-header-footer-body-code
composer install
vendor/bin/phpunit --configuration phpunit.xml.dist

Release and Packaging Notes

This GitHub repository is intended to be development-friendly.

For a clean end-user plugin ZIP, include only the runtime plugin files such as:

  • insert-header-footer-body-code.php
  • readme.txt
  • uninstall.php
  • includes/
  • languages/

Exclude development files from the release ZIP, including:

  • tests/
  • composer.json
  • composer.lock
  • phpunit.xml.dist
  • .phpcs.xml.dist
  • vendor/
  • local logs, caches, and temporary build files

See RELEASE.md for a concise release checklist.

License

This project is licensed under the GNU General Public License, version 2.0 or later.

See LICENSE for details.

About

WordPress plugin for inserting header, body, and footer code snippets, schema markup, JSON-LD, analytics scripts, SEO tags, and AI search optimization integrations.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages