PluginProbe
Slider Ultimate / 2.2.1
Slider Ultimate v2.2.1
2.2.10 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 All 54 releases
ultimate-slider / includes / Blocks.class.php
Blocks.class.php
80 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3
4 if ( ! class_exists( 'ewdusBlocks' ) ) {
5 /**
6 * Class to handle plugin Gutenberg blocks
7 *
8 * @since 2.0.0
9 */
10 class ewdusBlocks {
11
12 public function __construct() {
13
14 add_action( 'init', array( $this, 'add_slider_block' ) );
15
16 add_filter( 'block_categories_all', array( $this, 'add_block_category' ) );
17 }
18
19 /**
20 * Add the Gutenberg block to the list of available blocks
21 * @since 2.0.0
22 */
23 public function add_slider_block() {
24
25 if ( ! function_exists( 'render_block_core_block' ) ) { return; }
26
27 $this->enqueue_assets();
28
29 $args = array(
30 'attributes' => array(
31 'category' => array(
32 'type' => 'string',
33 ),
34 'posts' => array(
35 'type' => 'string',
36 ),
37 'slider_type' => array(
38 'type' => 'string',
39 ),
40 'carousel_mode' => array(
41 'type' => 'string',
42 ),
43 'slide_indicators' => array(
44 'type' => 'string',
45 ),
46 ),
47 'editor_script' => 'ewd-us-blocks-js',
48 'editor_style' => 'ewd-us-blocks-css',
49 'render_callback' => 'ewd_us_slider_shortcode',
50 );
51
52 register_block_type( 'ultimate-slider/ewd-us-slider-block', $args );
53 }
54
55 /**
56 * Create a new category of blocks to hold our block
57 * @since 2.0.0
58 */
59 public function add_block_category( $categories ) {
60
61 $categories[] = array(
62 'slug' => 'ewd-us-blocks',
63 'title' => __( 'Ultimate Slider', 'ultimate-slider' ),
64 );
65
66 return $categories;
67 }
68
69 /**
70 * Register the necessary JS and CSS to display the block in the editor
71 * @since 2.0.0
72 */
73 public function enqueue_assets() {
74
75 wp_register_script( 'ewd-us-blocks-js', EWD_US_PLUGIN_URL . '/assets/js/ewd-us-blocks.js', array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor' ), EWD_US_VERSION );
76 wp_register_style( 'ewd-us-blocks-css', EWD_US_PLUGIN_URL . '/assets/css/ewd-us-blocks.css', array( 'wp-edit-blocks' ), EWD_US_VERSION );
77 }
78 }
79
80 }