WP Manifestindependent plugin directory
manifest / social / wp-telegram-publisher

TG Publisher

A powerful WordPress plugin that seamlessly integrates with Telegram Bot API to automatically publish your WordPress content to multiple Telegram channels.

by Reza Qalekhani · github.com/reza-qalekhani/wp-telegram-publisher · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/reza-qalekhani/wp-telegram-publisher/archive/refs/heads/main.zip

Send WordPress posts and pages to Telegram channels with custom content support. Automate your content distribution and reach your Telegram audience directly from your WordPress dashboard.

📝 Description

WP Telegram Publisher is a powerful WordPress plugin that seamlessly integrates with Telegram Bot API to automatically publish your WordPress content to multiple Telegram channels. Perfect for content creators, news outlets, and businesses looking to expand their reach across Telegram while maintaining a single source of truth in WordPress.

The plugin provides flexible message templating, support for featured images, inline buttons with styling options, and comprehensive logging to track all message deliveries.

✨ Features

  • 🔄 Automatic Publishing — Automatically send posts and pages to configured Telegram channels when they're published
  • 📱 Multiple Channels — Support for multiple Telegram channels with individual channel configurations
  • 📝 Custom Templates — Create and manage custom message templates with placeholder support ({title}, {excerpt}, {url})
  • 🖼️ Featured Images — Automatically include featured images in Telegram messages as photos
  • 🔗 Inline Buttons — Add "Read More" buttons with customizable styling options:
    • Default
    • Primary (Blue)
    • Success (Green)
    • Danger (Red)
  • ✋ Manual Sending — Send posts to Telegram on-demand from the WordPress editor
  • 🚫 Per-Post Control — Exclude individual posts from being sent to Telegram
  • 📊 Message Logging — Comprehensive logging with timestamps to track all message deliveries and errors
  • 📦 Multi-Type Support — Send any public post type (posts, pages, custom post types)
  • 🌍 Internationalization — Full translation support (includes Persian/Farsi)
  • 🔧 Custom API Base URL — Support for custom Telegram API endpoints
  • 👤 Per-Channel Footers — Add custom footers to messages on a per-channel basis
  • ⚙️ Flexible Configuration — Configurable from WordPress admin with intuitive settings page

💻 Requirements

  • PHP: 7.0 or higher
  • WordPress: 5.0 or higher
  • Telegram Bot: A valid Telegram Bot Token (obtainable from @BotFather)
  • Telegram Channel: Channel access with permissions to publish messages

🛠️ Installation

  1. Download the plugin files
  2. Upload the wp-telegram-publisher folder to /wp-content/plugins/ directory
  3. Activate the plugin through the 'Plugins' menu in WordPress
  4. Navigate to Settings → TG Publisher to configure your Telegram bot and channels

⚙️ Configuration

1. Telegram Bot Setup

First, create a Telegram bot by talking to @BotFather:

  • Start a conversation with @BotFather
  • Send /newbot command
  • Follow the prompts to create your bot
  • Copy the API token provided

2. Plugin Settings

Go to Settings → TG Publisher in your WordPress admin to configure:

Essential Settings

  • Telegram Bot Token — Your bot's API token from @BotFather
  • Channels — Add one or more Telegram channels:
    • Channel Name (display name)
    • Channel ID (chat ID, typically starts with -100)
    • Channel Footer (optional custom footer text)
  • Post Types — Select which post types should be sent to Telegram
  • Read More Text — Customize the button text (default: "Read More")
  • Button Style — Choose the inline button styling

Advanced Settings

  • Telegram API Base URL — Use a custom Telegram API endpoint (default: https://api.telegram.org)
    • Useful for custom API implementations or proxy setups

3. Message Templates

The plugin includes a default template with the following placeholders:

<b>{title}</b>

{excerpt}

<i>Read full article:</i> {url}

Available placeholders:

  • {title} — Post title
  • {excerpt} — Post excerpt
  • {url} — Post URL/link
  • {content} — Full post content (when applicable)

4. Finding Your Channel ID

To get your Telegram channel's chat ID:

  1. Create/use your Telegram channel
  2. Add your bot as an administrator
  3. Send a message to the channel
  4. Visit: https://api.telegram.org/bot{YOUR_BOT_TOKEN}/getUpdates
  5. Look for the chat ID (usually starts with -100)

🚀 Usage

Automatic Publishing

Once configured, every time you publish a new post or page:

  1. The plugin checks if it should be sent to Telegram
  2. Generates the message from the template
  3. Includes the featured image (if set)
  4. Adds the "Read More" button with the post URL
  5. Sends to all configured channels

Manual Sending

To manually send a post to Telegram:

  1. Open the post editor
  2. Find the Telegram Publisher meta box (right sidebar)
  3. Click "Send to Telegram Now" button
  4. Check the result message

Excluding Posts

To exclude a specific post from being sent to Telegram:

  1. Open the post editor
  2. In the Telegram Publisher meta box
  3. Check "Exclude from Telegram"
  4. Save the post

Checking Message Status

The plugin shows the current status of each post:

  • Sent to Telegram (green) — Message successfully delivered
  • Excluded from Telegram (orange) — Post is excluded
  • Error sending to Telegram (red) — Failed to deliver

📁 Project Structure

wp-telegram-publisher/
├── wp-telegram-publisher.php          # Main plugin file with headers
├── composer.json                       # Composer dependencies
├── README.md                           # This file
├── includes/
│   ├── class-wp-telegram-publisher.php            # Main plugin class
│   ├── class-wp-telegram-publisher-settings.php   # Settings page handler
│   └── class-wp-telegram-publisher-api.php        # Telegram API integration
├── assets/
│   ├── css/
│   │   └── admin.css                   # Admin interface styles
│   ├── js/
│   │   └── admin.js                    # Admin interface JavaScript
│   └── worker/
│       ├── index.php                   # Worker script
│       └── content.txt                 # Worker content
├── languages/
│   ├── wp-telegram-publisher.pot       # Translation template
│   ├── wp-telegram-publisher-fa_IR.po  # Persian translation
│   └── wp-telegram-publisher-fa_IR.mo  # Persian translation (compiled)
└── vendor/
    └── ...                             # Composer dependencies

🏗️ Architecture

The plugin follows a modular, object-oriented architecture:

Core Components

  1. Main Plugin Class (WP_Telegram_Publisher)

    • Initializes the plugin
    • Manages post status transitions
    • Handles meta box rendering
    • Manages AJAX requests
  2. Settings Handler (WP_Telegram_Publisher_Settings)

    • Registers plugin settings
    • Renders the settings page
    • Handles configuration form submissions
  3. API Integration (WP_Telegram_Publisher_API)

    • Communicates with Telegram Bot API
    • Sends messages and photos
    • Logs all message attempts
    • Handles errors and responses

Data Storage

Database Tables:

  • wp_telegram_publisher_logs — Message sending history with timestamps

    • Channel ID and name
    • Message type (text, photo, with/without buttons)
    • Message content
    • Delivery status
    • Error messages
  • wp_telegram_publisher_templates — Message templates

    • Template name
    • Template content
    • Default template flag

WordPress Options:

  • wp_telegram_publisher_bot_token — Bot API token
  • wp_telegram_publisher_channels — Channel configuration array
  • wp_telegram_publisher_post_types — Selected post types
  • wp_telegram_publisher_read_more_text — Button text
  • wp_telegram_publisher_button_style — Button styling
  • wp_telegram_publisher_api_base_url — Custom API endpoint

🔌 API & Integrations

Telegram Bot API

The plugin integrates with the Telegram Bot API using:

  • sendMessage — For text messages with optional buttons
  • sendPhoto — For messages with featured images

WordPress Hooks & Filters

Actions:

  • transition_post_status — Triggered when post status changes (publish/draft)
  • wp_telegram_publisher_send_to_channels — Custom action for sending messages
  • wp_ajax_send_post_to_telegram — AJAX handler for manual sending
  • wp_ajax_get_template_content — AJAX handler for template preview

Filters:

The plugin respects standard WordPress filters for post data extraction.

🌍 Internationalization

The plugin is fully internationalized with:

  • Text domain: wp-telegram-publisher
  • Language files location: /languages/
  • Currently supported: English, Persian (Farsi)

Translation Files

  • wp-telegram-publisher.pot — Translation template for translators
  • wp-telegram-publisher-fa_IR.po — Persian source translations
  • wp-telegram-publisher-fa_IR.mo — Persian compiled translations

To add new language support, create a .po file in the /languages/ directory following WordPress translation conventions.

🧪 Development

Project Files Overview

  • wp-telegram-publisher.php — Main plugin file (plugin header, initialization, database setup)
  • class-wp-telegram-publisher.php — Core plugin functionality
  • class-wp-telegram-publisher-settings.php — Settings page and configuration
  • class-wp-telegram-publisher-api.php — Telegram API communication
  • admin.js — Admin interface interactivity
  • admin.css — Admin interface styling

Database Setup

The plugin automatically creates/upgrades necessary database tables on activation:

wp_telegram_publisher_logs
wp_telegram_publisher_templates

Testing Locally

  1. Set up a local WordPress installation
  2. Create a test Telegram bot via @BotFather
  3. Configure the plugin with your test bot token
  4. Create a test Telegram channel/group
  5. Add the bot to the channel with admin permissions
  6. Configure the plugin with the channel ID

🚀 Build & Release

Version Management

Current version: 1.2

Plugin files to update for new releases:

  1. wp-telegram-publisher.php — Update version in plugin header and constants
  2. Create/update changelog in documentation

Release Process

  1. Update version number in wp-telegram-publisher.php
  2. Test all features thoroughly
  3. Update documentation if needed
  4. Commit changes with version tag

🤝 Contributing

Contributions are welcome! When contributing:

  1. Follow WordPress coding standards
  2. Test your changes thoroughly
  3. Ensure internationalization compatibility
  4. Document new features

📜 License

This plugin is open-source and free to use, modify, and distribute.

📋 Changelog

Version 1.2

  • Added inline button styling options (Primary, Success, Danger)
  • Implemented message logging with timestamps
  • Added support for custom Telegram API endpoints
  • Added per-channel footer support
  • Improved error handling and reporting

Version 1.1

  • Added timestamp index to logs table for better performance
  • Enhanced database schema
  • Improved stability

Version 1.0

  • Initial release
  • Basic message sending functionality
  • Settings page
  • Multi-channel support

👨‍💻 Author

Reza Qalekhani

❤️ Show Your Support

If you find this project useful, please:

  • ⭐ Give it a star on GitHub
  • 🔗 Share it with your network
  • 💬 Leave feedback and suggestions
  • 🐛 Report bugs and issues

Made with ❤️ by Reza Qalekhani

Last Updated: 2026-06-18