| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly. |
| 4 |
} |
| 5 |
|
| 6 |
if (!class_exists('YTPPlugin')) { |
| 7 |
class YTPPlugin |
| 8 |
{ |
| 9 |
function __construct() |
| 10 |
{ |
| 11 |
add_action('enqueue_block_assets', [$this, 'enqueueBlockAssets']); |
| 12 |
add_action('init', [$this, 'onInit']); |
| 13 |
} |
| 14 |
|
| 15 |
function enqueueBlockAssets() |
| 16 |
{ |
| 17 |
wp_register_script('plyrIoJS', YTP_PLUGIN_DIR . 'public/js/plyr.js', [], YTP_PLUGIN_VERSION, true); |
| 18 |
wp_register_style('plyrIoCSS', YTP_PLUGIN_DIR . 'public/css/plyr.css', [], YTP_PLUGIN_VERSION); |
| 19 |
} |
| 20 |
|
| 21 |
function onInit() |
| 22 |
{ |
| 23 |
// register_block_type(__DIR__ . '/build/blocks/youtube-player'); |
| 24 |
register_block_type(__DIR__ . '/build/blocks/video'); |
| 25 |
register_block_type(__DIR__ . '/build/blocks/parent'); |
| 26 |
|
| 27 |
$localized_data = [ |
| 28 |
'ajaxURL' => admin_url('admin-ajax.php'), |
| 29 |
'nonce' => wp_create_nonce('wp_ajax'), |
| 30 |
'is_premium' => false, |
| 31 |
'brandColor' => \YTP\Helper\Utils::getOptionDeep('ytp_option', 'brandColor', '#00AFFA'), |
| 32 |
]; |
| 33 |
|
| 34 |
wp_localize_script('yt-player-video-editor-script', 'ytpPlayer', $localized_data); |
| 35 |
wp_localize_script('yt-player-parent-editor-script', 'ytpPlayer', $localized_data); |
| 36 |
} |
| 37 |
} |
| 38 |
new YTPPlugin(); |
| 39 |
} |
| 40 |
|