PluginProbe
Image Slider Block / 1.3.2
Image Slider Block v1.3.2
trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.4.0
slider-block / slider-block.php

slider-block.php in Image Slider Block 1.3.2, at slider-block.php

136 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Image Slider Block
5 * Description: Display Multiple Images In Beautiful Slider & Reduce Page Scroll
6 * Version: 1.3.2
7 * Author: WPDeveloper
8 * Author URI: https://wpdeveloper.net
9 * License: GPL-3.0-or-later
10 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
11 * Text Domain: slider-block
12 *
13 * @package slider-block
14 */
15
16 /**
17 * Registers all block assets so that they can be enqueued through the block editor
18 * in the corresponding context.
19 *
20 * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/
21 */
22
23 require_once __DIR__ . '/includes/font-loader.php';
24 require_once __DIR__ . '/includes/post-meta.php';
25 require_once __DIR__ . '/includes/helpers.php';
26 require_once __DIR__ . '/lib/style-handler/style-handler.php';
27
28 function create_block_slider_block_init()
29 {
30 define('SLIDER_BLOCK_VERSION', "1.3.2");
31 define('SLIDER_BLOCK_ADMIN_URL', plugin_dir_url(__FILE__));
32 define('SLIDER_BLOCK_ADMIN_PATH', dirname(__FILE__));
33
34 $script_asset_path = SLIDER_BLOCK_ADMIN_PATH . "/dist/index.asset.php";
35 if (!file_exists($script_asset_path)) {
36 throw new Error(
37 'You need to run `npm start` or `npm run build` for the "block/testimonial" block first.'
38 );
39 }
40 $index_js = SLIDER_BLOCK_ADMIN_URL . 'dist/index.js';
41 $script_asset = require($script_asset_path);
42 $all_dependencies = array_merge($script_asset['dependencies'], array(
43 'wp-blocks',
44 'wp-i18n',
45 'wp-element',
46 'wp-block-editor',
47 'slider-block-controls-util',
48 'essential-blocks-slickjs',
49 'essential-blocks-eb-animation',
50 ));
51
52 wp_register_script(
53 'create-block-slider-block-editor-script',
54 $index_js,
55 $all_dependencies,
56 $script_asset['version'],
57 true
58 );
59
60 $animate_css = SLIDER_BLOCK_ADMIN_URL . 'lib/css/animate.min.css';
61 wp_register_style(
62 'essential-blocks-animation',
63 $animate_css,
64 array(),
65 SLIDER_BLOCK_VERSION
66 );
67
68 $slick_css = SLIDER_BLOCK_ADMIN_URL . 'lib/css/slick.css';
69 wp_register_style(
70 'slick-style',
71 $slick_css,
72 array(),
73 SLIDER_BLOCK_VERSION
74 );
75
76 $slick_js = SLIDER_BLOCK_ADMIN_URL . 'lib/js/slick.min.js';
77 wp_register_script(
78 'essential-blocks-slickjs',
79 $slick_js,
80 array("jquery"),
81 SLIDER_BLOCK_VERSION,
82 true
83 );
84
85 $load_animation_js = SLIDER_BLOCK_ADMIN_URL . 'lib/js/eb-animation-load.js';
86 wp_register_script(
87 'essential-blocks-eb-animation',
88 $load_animation_js,
89 array("jquery"),
90 SLIDER_BLOCK_VERSION,
91 true
92 );
93
94 $style_css = SLIDER_BLOCK_ADMIN_URL . 'dist/style.css';
95 //Frontend & Editor Style
96 wp_register_style(
97 'create-block-slider-block-frontend-style',
98 $style_css,
99 array(
100 'slick-style',
101 'essential-blocks-animation'
102 ),
103 SLIDER_BLOCK_VERSION
104 );
105
106 //Frontend Style
107 $frontend_js = SLIDER_BLOCK_ADMIN_URL . 'dist/frontend/index.js';
108 $frontend_asset = require SLIDER_BLOCK_ADMIN_PATH . '/dist/frontend/index.asset.php';
109 wp_register_script(
110 'slider-block-frontend-js',
111 $frontend_js,
112 $frontend_asset['dependencies'],
113 $frontend_asset['version'],
114 true
115 );
116
117 if (!WP_Block_Type_Registry::get_instance()->is_registered('essential-blocks/slider')) {
118 register_block_type(
119 Slider_Helper::get_block_register_path("slider-block/slider-block", SLIDER_BLOCK_ADMIN_PATH),
120 array(
121 'editor_script' => 'create-block-slider-block-editor-script',
122 'editor_style' => 'create-block-slider-block-frontend-style',
123 'render_callback' => function ($attributes, $content) {
124 if (!is_admin()) {
125 wp_enqueue_style('create-block-slider-block-frontend-style');
126 wp_enqueue_script('essential-blocks-slickjs');
127 wp_enqueue_script('essential-blocks-eb-animation');
128 wp_enqueue_script('slider-block-frontend-js');
129 }
130 return $content;
131 }
132 )
133 );
134 }
135 }
136 add_action('init', 'create_block_slider_block_init', 99);