0 Comments


🎯 Live Chess Tournament Broadcasting Plugin for WordPress Using Cutechess-CLI

📌 Overview

This article outlines the creation and installation of a custom WordPress plugin to livestream chess tournaments played via Cutechess CLI. The plugin will be installed on a typical Hostinger Business Web Hosting environment for the website https://ijccrl.com. This enables administrators to show live updates of chess games in PGN or FEN format directly on their WordPress site.


🔧 Requirements

✅ Server Requirements

  • Linux-based hosting (Hostinger’s Business Cloud Hosting is sufficient)
  • PHP 7.4 or later
  • Shell access for executing cutechess-cli
  • WordPress 6.0+
  • MySQL database

✅ Tools Required

  • cutechess-cli installed on the server (via terminal)
  • Access to plugin directory:
    /home/u*****/domains/ijccrl.com/public_html/wp-content/plugins/
    (Your actual path may look like:)
    https://srv1787-files.hstgr.io/e958bfa79cf81ceb/files/public_html/wp-content/plugins/

🧩 Plugin Features

  • Start and monitor games via cutechess-cli
  • Display ongoing games in PGN/FEN format
  • Shortcode to embed games in posts/pages
  • AJAX-based live updates every N seconds
  • Admin interface to control the tournament feed

🗂 Plugin File Structure

wp-content/
└── plugins/
    └── live-chess-broadcast/
        ├── live-chess-broadcast.php
        ├── admin/
           └── settings-page.php
        ├── assets/
           └── css/
               └── style.css
        ├── includes/
           ├── cutechess-handler.php
           └── ajax-handler.php
        └── templates/
            └── board-display.php

🔨 Plugin Code: live-chess-broadcast.php

<?php
/**
 * Plugin Name: Live Chess Broadcast
 * Description: Livestream Cutechess CLI tournaments directly to your WordPress site.
 * Version: 1.0
 * Author: IJCCRL
 */

defined('ABSPATH') or die('No script kiddies please!');

define('LCB_PATH', plugin_dir_path(__FILE__));
define('LCB_URL', plugin_dir_url(__FILE__));

// Load files
require_once LCB_PATH . 'includes/cutechess-handler.php';
require_once LCB_PATH . 'includes/ajax-handler.php';

// Register shortcode
function lcb_display_board_shortcode($atts) {
    ob_start();
    include LCB_PATH . 'templates/board-display.php';
    return ob_get_clean();
}
add_shortcode('live_chess_board', 'lcb_display_board_shortcode');

// Enqueue CSS
function lcb_enqueue_styles() {
    wp_enqueue_style('lcb-style', LCB_URL . 'assets/css/style.css');
}
add_action('wp_enqueue_scripts', 'lcb_enqueue_styles');

Livestream Chess Tournaments Cutechess-cli

🧠 Example: Cutechess Tournament Command

cutechess-cli -engine cmd=./stockfish name=Stockfish -engine cmd=./komodo name=Komodo -each tc=10+0.1 -games 1 -pgnout /path-to-wp/uploads/livegame.pgn

Store PGN in /wp-content/uploads/livegame.pgn and fetch using PHP.


📁 includes/cutechess-handler.php

<?php
function lcb_get_live_pgn() {
    $pgn_file = WP_CONTENT_DIR . '/uploads/livegame.pgn';
    if (file_exists($pgn_file)) {
        return file_get_contents($pgn_file);
    }
    return 'No live game found.';
}

🔁 includes/ajax-handler.php

<?php
add_action('wp_ajax_nopriv_lcb_refresh', 'lcb_ajax_refresh');
add_action('wp_ajax_lcb_refresh', 'lcb_ajax_refresh');

function lcb_ajax_refresh() {
    echo lcb_get_live_pgn();
    wp_die();
}

📜 templates/board-display.php

<div id="lcb-live-board">
    <pre id="lcb-pgn-content">Loading live game...</pre>
</div>

<script>
function fetchPGN() {
    fetch("<?php echo admin_url('admin-ajax.php?action=lcb_refresh'); ?>")
        .then(response => response.text())
        .then(data => {
            document.getElementById('lcb-pgn-content').innerText = data;
        });
}
setInterval(fetchPGN, 5000);
fetchPGN();
</script>

🎨 Basic CSS: assets/css/style.css

#lcb-live-board {
    background: #f3f3f3;
    padding: 15px;
    border: 1px solid #ccc;
    font-family: monospace;
    white-space: pre-wrap;
}

🔌 Installation Path Example (Hostinger)

Upload plugin folder to:
/home/uXXXXXXXX/domains/ijccrl.com/public_html/wp-content/plugins/live-chess-broadcast/
Or via FTP interface via:
https://srv1787-files.hstgr.io/e958bfa79cf81ceb/files/public_html/wp-content/plugins/live-chess-broadcast/

Then activate in:
WordPress Dashboard → Plugins → Live Chess Broadcast → Activate


🎯 Usage Instructions

  1. Ensure cutechess-cli is installed on your hosting (via SSH).
  2. Configure your tournament command to output PGN to wp-content/uploads/livegame.pgn.
  3. Place shortcode [live_chess_board] in any page/post.
  4. Watch live updates!

🧪 Notes and Tips

  • You may need to schedule cutechess-cli matches via cron jobs.
  • Consider using tools like pgn4web, chess.js, or chessboard.js for graphical board rendering in future upgrades.
  • Use WP_CONTENT_DIR constants for reliable file path referencing across environments.

📬 Need Help?

If your hosting restricts shell access, you may need a VPS or SSH-enabled cloud server. Contact Hostinger Support to ensure your account supports execution of binaries like cutechess-cli.


Let me know if you’d like me to generate a .zip version of this plugin or assist with a graphical live board integration.


The .zip file for the Live Chess Broadcast WordPress plugin has been created successfully. You can download it using the link below:

👉 Download live-chess-broadcast.zip

You can now upload this ZIP file directly through your WordPress admin dashboard:

  1. Go to Plugins → Add New.
  2. Click Upload Plugin.
  3. Choose the .zip file and click Install Now.
  4. Activate the plugin after installation.

Let me know if you’d like to add a graphical chessboard or more advanced features!

Rating List Chess Engines

Jorge Ruiz Centelles

Filólogo y amante de la antropología social africana

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts