=== Subscribe Button Bar for YouTube Embed Videos ===
Contributors: josevarghese
Tags: youtube, subscribe, button, video, social
Requires at least: 5.0
Tested up to: 7.0
Stable tag: 1.0.3
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Donate link: https://buymeacoffee.com/josevarghese

A professional tool to add a YouTube subscribe button bar under your videos. Essential for channel growth and viewer conversion.

== Description ==

**Subscribe Button Bar for YouTube Embed Videos** is a robust WordPress plugin designed to seamlessly integrate YouTube subscription functionality into your website. It automatically detects YouTube videos within your content and strategically places a customizable **YouTube subscribe button bar** directly beneath them.

This plugin serves as an effective **video marketing** tool, creating a sleek, non-intrusive **call to action** that encourages viewers to subscribe to your channel immediately. Whether you aim to **increase YouTube subscribers**, improve viewer engagement, or ensure a consistent user experience with a fully responsive design, Subscribe Button Bar provides the professional features necessary for channel growth.

**Key Features:**

*   **Intelligent Auto-Detection**: Automatically identifies YouTube iframes within your posts and pages and injects the subscribe bar — no manual setup per post needed.
*   **Shortcode Support**: Place the subscribe bar anywhere — pages without videos, sidebars, landing pages — using a simple shortcode.
*   **Gutenberg Block**: A native block editor block lets you drop the subscribe bar exactly where you want it in the visual editor.
*   **Flexible Channel Input**: Enter your Channel ID, @handle, or paste any YouTube channel URL — the plugin figures out the rest.
*   **Fully Customizable**: Tailor colors, text, theme, and layout to match your brand.
*   **Responsive Design**: Looks great on desktops, tablets, and mobile phones.
*   **Performance Optimized**: Lightweight with no jQuery dependency on the frontend.
*   **MutationObserver Support**: Catches YouTube videos added dynamically (AJAX pagination, lazy loading).

**Customization Options:**

1. **Enable/Disable Toggle**: Master switch to turn the subscribe bar on or off globally.
2. **YouTube Channel**: Enter your Channel ID, @handle, or any YouTube channel URL.
3. **Theme Selection**: Choose between Default (light) and Dark themes.
4. **Subscriber Count**: Show or hide the subscriber count on the button.
5. **Layout Options**: Default (icon + "Subscribe" text) or Full (channel avatar + channel name).
6. **Custom Text**: Add personalized text that appears before the button.
7. **Background Color**: Customize the bar's background color.
8. **Text Color**: Customize the text color.
9. **Post Type Control**: Restrict the bar to specific post types (posts, pages, custom post types).
10. **Per-Post Exclusion**: Exclude specific posts or pages by ID.

---

**Using the Shortcode**

Place the subscribe bar anywhere on your site — pages without YouTube videos, sidebars, footers, or landing pages — using:

`[subscribe_button_bar]`

This uses your global plugin settings. You can override any setting per-use with optional attributes:

`[subscribe_button_bar channel="@yourchannel" text="Subscribe for weekly videos!" theme="dark" layout="full" count="hidden" bg_color="#1a1a1a" text_color="#ffffff"]`

**Shortcode Attributes:**

| Attribute | Values | Default | Description |
|-----------|--------|---------|-------------|
| `url` | YouTube or Shorts video URL | *(none)* | Embed a YouTube video or Short and place the subscribe bar below it. Accepts `youtube.com/watch?v=`, `youtu.be/`, `youtube.com/shorts/`, or `youtube.com/embed/` URLs. |
| `channel` | Channel ID, @handle, or URL | Global setting | Override the YouTube channel for this bar only. |
| `text` | Any string | Global setting | Text displayed before the subscribe button. |
| `theme` | `default`, `dark` | Global setting | Button color scheme. |
| `layout` | `default`, `full` | Global setting | `default` shows the subscribe icon and text; `full` shows channel avatar and name. |
| `count` | `true`, `hidden` | Global setting | Show or hide the subscriber count. |
| `bg_color` | Hex color (e.g. `#ffffff`) | Global setting | Background color of the bar. |
| `text_color` | Hex color (e.g. `#000000`) | Global setting | Text color of the bar. |

**Examples:**

Minimal — uses all global settings:
`[subscribe_button_bar]`

Embed a video with a subscribe bar below it:
`[subscribe_button_bar url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"]`

Embed a YouTube Short with a subscribe bar below it:
`[subscribe_button_bar url="https://www.youtube.com/shorts/VIDEO_ID"]`

Embed a video and override the channel and text:
`[subscribe_button_bar url="https://youtu.be/dQw4w9WgXcQ" channel="@yourchannel" text="Subscribe for more!"]`

Bar only — custom channel with dark theme:
`[subscribe_button_bar channel="@yourchannel" theme="dark" text="Subscribe for weekly videos"]`

Full layout, no subscriber count:
`[subscribe_button_bar layout="full" count="hidden"]`

---

**Using the Gutenberg Block**

In the block editor, search for **"Subscribe Button Bar"** in the block inserter (or type `/subscribe`). The block renders server-side so it always reflects your current settings.

The block sidebar includes:

*   **Video URL** — paste a YouTube video URL or Shorts URL (e.g. `youtube.com/watch?v=...` or `youtube.com/shorts/...`). The block will embed the video and place the subscribe bar directly below it. Leave empty to show only the subscribe bar.
*   **Channel Override** — enter a Channel ID, @handle, or YouTube channel URL to use a different channel on this specific page. Leave empty to use your global settings.
*   **Custom Text Override** — override the button label text for this block only. Leave empty to use your global custom text.

---

**Entering Your YouTube Channel**

The plugin accepts any of the following formats in the settings page and in the `channel` shortcode attribute:

*   Channel ID: `UCxxxxxxxxxxxxxxxxxxxxxx`
*   @Handle: `@yourchannel`
*   Channel URL: `https://www.youtube.com/channel/UCxxxxxxxxxxxxxxxxxxxxxx`
*   Handle URL: `https://www.youtube.com/@yourchannel`
*   Legacy user URL: `https://www.youtube.com/user/yourchannel`
*   Custom URL: `https://www.youtube.com/c/yourchannel`

The plugin parses the input automatically — no need to extract the channel ID manually.

**Getting Started:**

1.  Install and activate the plugin via the WordPress dashboard.
2.  Navigate to **Settings > Subscribe Button Bar**.
3.  Enter your YouTube channel — paste your Channel ID, @handle, or any YouTube channel URL.
4.  Configure your desired appearance settings and save.
5.  Embed any YouTube video in a post/page and the subscribe bar will appear automatically. Or use `[subscribe_button_bar]` to place it anywhere.

== Installation ==

1.  Upload the plugin files to the `/wp-content/plugins/subscribe-button-bar` directory, or search for "Subscribe Button Bar" in your WordPress dashboard and install it.
2.  Activate it.
3.  Go to **Settings > Subscribe Button Bar** to configure.
4.  Enter your YouTube channel (Channel ID, @handle, or URL), pick your colors, and save.

== External Services ==

This plugin uses the YouTube Subscribe Button API provided by Google's Platform Library (`https://apis.google.com/js/platform.js`). This script is loaded on pages where the subscribe bar is displayed and may send the visitor's IP address and user agent to Google.

**Policies**: [Google Privacy Policy](https://policies.google.com/privacy) | [YouTube Terms of Service](https://www.youtube.com/t/terms)

== Frequently Asked Questions ==

= How do I enter my YouTube channel? =

Go to **Settings > Subscribe Button Bar** and enter any of the following in the "YouTube Channel" field:

*   Your channel ID (starts with `UC`) — find it at https://www.youtube.com/account_advanced
*   Your @handle (e.g. `@yourchannel`)
*   Your full YouTube channel URL (e.g. `https://www.youtube.com/@yourchannel`)

The plugin parses whatever you enter and uses the correct format automatically.

= Can I place the subscribe bar on a page that doesn't have a YouTube video? =

Yes — use the shortcode `[subscribe_button_bar]` or the Gutenberg block. Both work anywhere on your site regardless of whether there's an embedded video.

= Can I use a different YouTube channel per page or post? =

Yes. Both the shortcode and the Gutenberg block support a `channel` override:

`[subscribe_button_bar channel="@otherChannel"]`

In the block editor, use the Channel Override field in the block sidebar.

= Does it work with all YouTube embed types? =

It detects standard YouTube iframes (`youtube.com/embed/` and `youtu.be`). It also uses a MutationObserver to catch videos loaded dynamically via AJAX or lazy loading.

= Can I show the subscribe bar only on certain post types? =

Yes — in the settings page under "Show On Post Types", check only the post types you want.

= Can I hide the subscribe bar on specific posts or pages? =

Yes — enter a comma-separated list of post/page IDs under "Exclude Post/Page IDs" in the settings.

= Is it mobile responsive? =

Yes. The bar adapts its layout for smaller screens and the button scales to remain usable on mobile.

= The bar isn't showing up. What should I do? =

*   Make sure the plugin is enabled in **Settings > Subscribe Button Bar**.
*   Confirm your YouTube channel is entered and saved.
*   Check that the post type is not excluded in the settings.
*   If something's still not working, create a support ticket: https://wordpress.org/support/plugin/subscribe-button-bar/#new-topic-0

== Screenshots ==

1.  Plugin settings page with all customization options
2.  Subscribe button bar displayed below a YouTube video
3.  Dark theme subscribe button example
4.  Mobile responsive design
5.  Gutenberg block in the block editor

== Changelog ==

= 1.0.3 =
* Added shortcode `[subscribe_button_bar]` with full attribute support (channel, text, theme, layout, count, bg_color, text_color)
* Added Gutenberg block — drag and drop the subscribe bar anywhere in the block editor
* Added flexible channel input — accepts Channel ID, @handle, or any YouTube channel URL; no need to look up your channel ID separately
* MutationObserver now catches YouTube videos added dynamically (lazy loading, AJAX pagination)

= 1.0.2 =
* New settings page added

= 1.0.0 =
* Initial release
* Automatic YouTube video detection
* 9 customization options
* Responsive design
* Admin settings panel
* Plugin activation notice

== Upgrade Notice ==

= 1.0.3 =
Adds shortcode support, a Gutenberg block, and flexible channel input (Channel ID, @handle, or YouTube URL all work).

= 1.0.0 =
Initial release of Subscribe Button Bar for YouTube plugin.
