<?php
/**
 * Plugin Name: PTPiano
 * Description: An interactive, browser-based piano plugin for learning and exploring chords and notes.
 * Version: 1.3.2
 * Author: santechidea
 * Author URI:  https://wordpress.santechidea.net
 * License: GPLv2 or later
 * Plugin URI: https://wordpress.santechidea.net/sti-wp-plugins/
 * Text Domain: ptpiano
 */
 
 if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

// Define constants with unique prefix
define('PTPIAN_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('PTPIAN_PLUGIN_URL', plugin_dir_url(__FILE__));

// Include core functions
include_once(PTPIAN_PLUGIN_DIR . '/functions.php');

/**
 * Shortcode handler for [PT-Piano]
 */
function ptpian_render_shortcode() {
    ob_start(); 
	
	// Get plugin settings
	$res_chordtxt         = get_option('ptpian_chordtxt_switch');
	$res_chordmajor       = get_option('ptpian_chordmajor_switch');
	$res_chordminor       = get_option('ptpian_chordminor_switch');
	$res_chorddim         = get_option('ptpian_chorddim_switch');
	$res_chordagu        = get_option('ptpian_chordagu_switch');
	
	$res_color           = get_option('ptpian_bgcolor_control');
	$res_txt_color      = get_option('ptpian_txtcolor_control');
	$res_theme_piano      = get_option('ptpian_theme');
	$res_txt_piano_color  = get_option('ptpian_txtcolor_piano');
	$res_mark_piano_color   = get_option('ptpian_markcolor_piano');

	// Set hidden classes
	$major_hidden_class = !$res_chordmajor ? 'hidden' : '';
	$minor_hidden_class = !$res_chordminor ? 'hidden' : '';
	$dim_hidden_class   = !$res_chorddim   ? 'hidden' : '';
	$agu_hidden_class   = !$res_chordagu   ? 'hidden' : '';

    // Output player wrapper
    echo '<div class="wrapper" style="background-color:' . esc_attr($res_color) . '">';
    include_once(PTPIAN_PLUGIN_DIR . '/PT_Piano_Player.php');
    echo '</div>';

    return ob_get_clean();
}
add_shortcode('PT-Piano', 'ptpian_render_shortcode');
?>