PluginProbe
Video Background Block – Add Stunning Video Backgrounds to Any Section / 1.0.0
Video Background Block – Add Stunning Video Backgrounds to Any Section v1.0.0
2.0.3 2.0.2 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 2.0.0 2.0.1
video-background-block / index.php

index.php in Video Background Block – Add Stunning Video Backgrounds to Any Section 1.0.0, at index.php

48 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Video Background Block
4 * Description: Use video as background in section.
5 * Version: 1.0.0
6 * Author: bPlugins LLC
7 * Author URI: http://bplugins.com
8 * License: GPLv3
9 * License URI: https://www.gnu.org/licenses/gpl-3.0.txt
10 * Text Domain: video-background
11 */
12
13 // ABS PATH
14 if ( !defined( 'ABSPATH' ) ) { exit; }
15
16 // Constant
17 define( 'VBB_PLUGIN_VERSION', 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '1.0.0' );
18 define( 'VBB_ASSETS_DIR', plugin_dir_url( __FILE__ ) . 'assets/' );
19
20 // Video Background Block
21 class VBBVideoBackground{
22 function __construct(){
23 add_action( 'init', [$this, 'onInit'] );
24 }
25
26 function onInit() {
27 wp_register_style( 'vbb-video-bg-editor-style', plugins_url( 'dist/editor.css', __FILE__ ), [ 'wp-edit-blocks' ], VBB_PLUGIN_VERSION ); // Backend Style
28 wp_register_style( 'vbb-video-bg-style', plugins_url( 'dist/style.css', __FILE__ ), [ 'wp-editor' ], VBB_PLUGIN_VERSION ); // Both Style
29
30 register_block_type( __DIR__, [
31 'editor_style' => 'vbb-video-bg-editor-style',
32 'style' => 'vbb-video-bg-style',
33 'render_callback' => [$this, 'render']
34 ] ); // Register Block
35
36 wp_set_script_translations( 'vbb-video-bg-editor-script', 'video-background', plugin_dir_path( __FILE__ ) . 'languages' ); // Translate
37 }
38
39 function render( $attributes, $content ){
40 extract( $attributes );
41
42 ob_start(); ?>
43 <div class='wp-block-vbb-video-bg <?php echo 'align' . esc_attr( $align ); ?>' id='vbbVideoBG-<?php echo esc_attr( $cId ) ?>' data-props='<?php echo esc_attr( wp_json_encode( [ 'attributes' => $attributes, 'content' => $content ] ) ); ?>'></div>
44
45 <?php return ob_get_clean();
46 } // Render
47 }
48 new VBBVideoBackground;