AboutUs.class.php
3 years ago
BackwardsCompatibility.class.php
4 years ago
Blocks.class.php
4 years ago
CustomPostTypes.class.php
1 year ago
Dashboard.class.php
3 years ago
DeactivationSurvey.class.php
4 years ago
Helper.class.php
4 years ago
InstallationWalkthrough.class.php
4 years ago
Permissions.class.php
4 years ago
ReviewAsk.class.php
4 years ago
Settings.class.php
1 year ago
Widgets.class.php
4 years ago
WooCommerceIntegration.class.php
4 years ago
template-functions.php
1 year ago
Blocks.class.php
80 lines
| 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 | } |