=== WP Smart Content === Contributors: vinodsebastian Tags: wp smart content, header scripts, footer scripts, tracking code, block editor Requires at least: 5.0 Tested up to: 6.8 Requires PHP: 7.0 Stable tag: 1.2.3 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html Inject scripts, styles, HTML, CSS, or tracking code into WordPress headers, footers, sidebars, and block hooks safely. == Description == **WP Smart Content** is the easiest way to inject scripts, styles, HTML, and tracking code into WordPress headers, footers, and block hooks — all without editing theme files. Whether you need to add Google Analytics, marketing tags, custom CSS, or JavaScript snippets, this plugin provides a safe, central dashboard to manage reusable content blocks. Each block can be named, stored in the WordPress database, and targeted to specific posts, pages, or applied globally across your site. With support for both **Classic Hooks** and the new **WordPress 6.8 Block Hooks**, WP Smart Content is future-proof, flexible, and designed for modern WordPress sites. Behind the scenes, WP Smart Content injects your HTML, JavaScript, or CSS styles into the selected WordPress hook — whether a classic theme hook or a Block Hook — ensuring your content appears exactly where you want it, without modifying template files. This approach keeps your site secure, SEO-friendly, and easy to maintain. ### ✨ Key Features - **Classic Hooks support**: Add content to 'wp_head', 'wp_footer', 'wp_print_styles', 'wp_print_scripts', 'wp_meta', and 'wp_print_footer_scripts'. - **Block Hooks support (WordPress 6.8+)**: Inject content anywhere in the theme using the block editor UI. - **Grouped dropdowns**: Clear separation between Classic Hooks and Block Hooks in the admin interface. - **Global targeting**: Apply blocks to all content types, not just posts or pages. - **Safe/Raw Mode toggle**: Admins can enable Raw Mode for advanced HTML/JS injection or restrict to Safe Mode for safety. - **Translation ready**: Includes updated '.pot' file with all strings for localization. - **Reviewer‑friendly architecture**: Modularized code, clear documentation, and compliance with WordPress coding standards. ### 💡 Use Cases - Add a script to the '<head>' section without editing theme files. - Insert HTML into the '<footer>' for custom notices or widgets. - Push CSS before WordPress outputs styles for precise control. - Inject a notice after post content using Block Hooks. - Manage analytics or marketing tags centrally, without touching templates. ### 🔗 Few Supported Hooks **Classic Hooks** * wp_head – Injects content into the '<head>' section before closing tag * wp_footer – Injects content into the '<body>' section before closing tag * wp_print_styles – Injects content before WordPress outputs enqueued styles * wp_print_scripts – Injects content before WordPress outputs enqueued scripts * wp_meta – Injects content into the meta section of the sidebar * wp_print_footer_scripts – Injects content before WordPress outputs footer scripts **Block Hooks (WordPress 6.8+)** * after_post_content – Injects content immediately after the post content block * before_post_content – Injects content immediately before the post content block * after_comments – Injects content after the comments block * before_comments – Injects content before the comments block * after_entry_title – Injects content after the entry/post title block * before_entry_title – Injects content before the entry/post title block **Optional Context Hooks** * admin_head – Injects content into the '<head>' section of admin pages * admin_footer – Injects content into the '<footer>' section of admin pages * login_head – Injects content into the '<head>' section of the login page * login_footer – Injects content into the '<footer>' section of the login page * enqueue_block_assets – Injects content when block editor assets are loaded == Usage == === Usage with Block Snippet === 1. Install and activate **WP Smart Content** from the WordPress Plugins screen. 2. Go to **WP Smart Content → Add New Block** in the admin menu. 3. Enter a block name and paste your HTML, CSS, JavaScript, or tracking code. 4. Choose where to inject the block: - Header (wp_head) for scripts or tracking code - Footer (wp_footer) for notices or widgets - Before/after post content for banners or messages - Block Hooks (WordPress 6.8+) for precise placement in the block editor - Other classic hooks such as wp_print_scripts or wp_meta 5. Select targeting options: - Apply globally across the site - Restrict to specific posts, pages, or custom post types 6. Save the block. Your content will be automatically injected at the chosen location. 7. Use the **Safe/Raw Mode toggle**: - Safe Mode: Restricts advanced HTML/JS for security - Raw Mode: Allows full HTML/JS injection for trusted admins 8. Manage all blocks from the central dashboard. You can edit, enable/disable, publish/unpublish, or delete blocks anytime. 9. Result: Scripts, styles, or HTML added via injection hook locations in the theme can be easily managed. === Usage with Block UI === 1. Once WP Smart Content is activated, open the Site Editor (Appearance → Editor) for your block theme. 2. Locate Block Hook areas (header, footer, before/after post content, sidebar). 3. From the block inserter (+), add the "WP Smart Content" block or select an existing block to edit its injection hook. 4. Use WP Smart Content settings in the right sidebar (Block tab) to select an injection hook. This links your stored block snippet to the chosen hook. 5. Save the template. Your snippet will be injected automatically at the chosen location. 6. Result: Scripts, styles, or HTML are added via the Block UI without editing theme files, fully compatible with block themes. == Installation == 1. Upload 'wp-smart-content' to the '/wp-content/plugins/' directory. 2. Activate the plugin through the *Plugins* menu in WordPress. 3. A new top-level menu called *WP Smart Content* appears in the WordPress admin sidebar. == Frequently Asked Questions == = Why doesn’t my header script show up? = The template may not support the chosen hook. Don’t worry — it won’t break your site. = My site broke after installation! = Unpublish or delete the content pushed through the plugin. Ensure the content added is valid HTML, CSS, or JavaScript. = I still have plugin conflicts or the site looks messy. = Try selectively disabling other plugins to identify conflicts. = How do I uninstall the plugin? = Just uninstall it. No residual data or issues will remain. More questions? Email business[at]vinodsebastian.com — I’ll try to respond promptly. == Screenshots == 1. Administration screen – Block List (shows all reusable blocks with pagination) 2. Administration screen – Block Form (create/edit block with Safe/Raw toggle) 3. Grouped injection points dropdown (Classic vs Block Hooks clearly separated) 4. Example of Raw Mode toggle in block editor 5. Block Hooks injection after post content 6. Classic Hooks reference 7. Block Hooks reference (WordPress 6.8+) 8. Optional Context Hooks reference 9. Injecting content anywhere on the theme from blocks UI - Placement 10. Injecting content anywhere on the theme from blocks UI - Injection Point == Upgrade Notice == Version 1.2.0 introduces Block Hooks support. After upgrading, review your existing blocks to ensure they are mapped to the correct injection points. == Changelog == = 1.0.0 = * Initial launch. = 1.0.1 = * Fixed AJAX content deletion bug caused by jQuery. = 1.1.0 = * Revamped code. * Improved user experience. * Added ability to update content. * Fixed frontend display bug. * Small enhancements. = 1.1.1 = * Fixed CSS side effects. = 1.1.2 = * Fixed minor bugs. = 1.1.3 = * Fixed major bug. = 1.1.4 = * Enhancements. = 1.2.0 = * Major restructuring and modularization of files for cleaner architecture and easier maintenance. * Updated admin UI to align with WordPress theme. * Added translation readiness. * Extended support for WordPress 6.8 Block Hooks API and additional injection points. * Introduced Raw Mode toggle (admins only) with Safe Mode fallback for non-admins. * Improved pagination controls for block lists. = 1.2.1 = * Fixed major bug with block hooks API display. = 1.2.2 = * Fixed major bug with block hooks API display. * Added more Injection points. * Added ability to inject content anywhere on the theme from blocks UI. = 1.2.3 = * Corrected typos and improved readability * Enhanced user interface for better usability