diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 68a97467..208d4bfa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,10 +9,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Build - run: | - npm install - npm run build - name: WordPress Plugin Deploy id: deploy uses: 10up/action-wordpress-plugin-deploy@stable diff --git a/classes/Tools/Video/Player/Elementor/MediaCloudVideoWidget.php b/classes/Tools/Video/Player/Elementor/MediaCloudVideoWidget.php index 6b69d5e7..b59caf26 100644 --- a/classes/Tools/Video/Player/Elementor/MediaCloudVideoWidget.php +++ b/classes/Tools/Video/Player/Elementor/MediaCloudVideoWidget.php @@ -17,14 +17,14 @@ use Elementor\Widget_Base; use MediaCloud\Plugin\Tools\ToolsManager; use MediaCloud\Plugin\Tools\Video\Driver\Mux\Models\MuxAsset; -use MediaCloud\Plugin\Tools\Video\Driver\Mux\MuxToolProSettings; -use MediaCloud\Plugin\Tools\Video\Driver\Mux\MuxToolSettings; use MediaCloud\Plugin\Tools\Video\Player\Tool\VideoPlayerTool; use function MediaCloud\Plugin\Utilities\arrayPath; -use function MediaCloud\Plugin\Utilities\gen_uuid; -use function MediaCloud\Plugin\Utilities\vomit; class MediaCloudVideoWidget extends Widget_Base { + public function __construct($data = [], $args = null) { + parent::__construct($data, $args); + } + public function get_name() { return "mux-video"; } diff --git a/classes/Tools/Video/Player/Tool/VideoPlayerTool.php b/classes/Tools/Video/Player/Tool/VideoPlayerTool.php index b9376603..89119b68 100644 --- a/classes/Tools/Video/Player/Tool/VideoPlayerTool.php +++ b/classes/Tools/Video/Player/Tool/VideoPlayerTool.php @@ -22,7 +22,6 @@ use MediaCloud\Plugin\Tools\Video\Driver\Mux\Models\MuxAsset; use MediaCloud\Plugin\Tools\Video\Player\Elementor\MediaCloudVideoWidget; use MediaCloud\Plugin\Tools\Video\Player\VideoPlayerShortcode; -use MediaCloud\Plugin\Tools\Video\Player\VideoPlayerToolProSettings; use MediaCloud\Plugin\Tools\Video\Player\VideoPlayerToolSettings; use MediaCloud\Plugin\Utilities\UI\CSSColorParser; use function MediaCloud\Plugin\Utilities\arrayPath; @@ -37,6 +36,8 @@ class VideoPlayerTool extends Tool { /** @var null|VideoPlayerShortcode */ protected $shortCode = null; + protected static $enqueued = false; + public function __construct($toolName, $toolInfo, $toolManager) { $this->settings = VideoPlayerToolSettings::instance(); @@ -56,7 +57,11 @@ public function setup() { add_filter('render_block', [$this, 'filterBlocks'], PHP_INT_MAX - 1, 2); - static::enqueuePlayer(is_admin()); + if (is_admin() || !empty($this->settings->alwaysIncludeJS) || class_exists('Elementor\Plugin')) { + static::enqueuePlayer(is_admin()); + } else if (isset($_GET['elementor-preview'])) { + static::enqueuePlayer(false); + } if (is_admin()) { add_action('admin_enqueue_scripts', function(){ @@ -219,6 +224,12 @@ private function initShortcodeOverride() { //region Player public static function enqueuePlayer($admin = false) { + if (static::$enqueued) { + return; + } + + static::$enqueued = true; + add_action((!empty($admin)) ? 'admin_enqueue_scripts' : 'wp_enqueue_scripts', function() { wp_enqueue_script('mux_video_player_hlsjs', ILAB_PUB_JS_URL . '/mux-hls.js', null, null, true); }); @@ -229,10 +240,9 @@ public static function enqueuePlayer($admin = false) { protected function initBlocks() { add_action('init', function() { register_block_type( ILAB_BLOCKS_DIR . '/mediacloud-video-block' ); -// register_block_type( ILAB_BLOCKS_DIR . '/mediacloud-video-block/build' ); }); - add_filter('block_categories', function($categories, $post) { + add_filter('block_categories_all', function($categories, $post) { foreach($categories as $category) { if ($category['slug'] === 'mediacloud') { return $categories; @@ -313,6 +323,8 @@ protected function filterVideoBlock($block_content, $block) { $asset = MuxAsset::assetForAttachment($attachmentId); } + static::enqueuePlayer(is_admin()); + if ($asset && !empty($asset->transferData)) { if ($asset->transferData['source'] === 's3') { /** @var StorageTool $storageTool */ @@ -369,7 +381,6 @@ protected function filterVideoBlock($block_content, $block) { $classes .= " {$this->settings->playerCSSClasses}"; } -// $styles = !empty($styles) ? "style='${styles}'" : ""; $block_content = str_replace('