PluginProbe
Image Slider Block / 1.3.6
Image Slider Block v1.3.6
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.6, at slider-block.php

136 lines 4.4 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.6
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 define( 'SLIDER_BLOCK_VERSION', "1.3.6" );
30 define( 'SLIDER_BLOCK_ADMIN_URL', plugin_dir_url( __FILE__ ) );
31 define( 'SLIDER_BLOCK_ADMIN_PATH', dirname( __FILE__ ) );
32
33 $script_asset_path = SLIDER_BLOCK_ADMIN_PATH . "/dist/index.asset.php";
34 if ( ! file_exists( $script_asset_path ) ) {
35 throw new Error(
36 'You need to run `npm start` or `npm run build` for the "block/testimonial" block first.'
37 );
38 }
39 $index_js = SLIDER_BLOCK_ADMIN_URL . 'dist/index.js';
40 $script_asset = require $script_asset_path;
41 $all_dependencies = array_merge( $script_asset['dependencies'], [
42 'wp-blocks',
43 'wp-i18n',
44 'wp-element',
45 'wp-block-editor',
46 'slider-block-controls-util',
47 'essential-blocks-slickjs',
48 'essential-blocks-eb-animation'
49 ] );
50
51 wp_register_script(
52 'create-block-slider-block-editor-script',
53 $index_js,
54 $all_dependencies,
55 $script_asset['version'],
56 true
57 );
58
59 $animate_css = SLIDER_BLOCK_ADMIN_URL . 'lib/css/animate.min.css';
60 wp_register_style(
61 'essential-blocks-animation',
62 $animate_css,
63 [],
64 SLIDER_BLOCK_VERSION
65 );
66
67 $slick_css = SLIDER_BLOCK_ADMIN_URL . 'lib/css/slick.css';
68 wp_register_style(
69 'slick-style',
70 $slick_css,
71 [],
72 SLIDER_BLOCK_VERSION
73 );
74
75 $slick_js = SLIDER_BLOCK_ADMIN_URL . 'lib/js/slick.min.js';
76 wp_register_script(
77 'essential-blocks-slickjs',
78 $slick_js,
79 ["jquery"],
80 SLIDER_BLOCK_VERSION,
81 true
82 );
83
84 $load_animation_js = SLIDER_BLOCK_ADMIN_URL . 'lib/js/eb-animation-load.js';
85 wp_register_script(
86 'essential-blocks-eb-animation',
87 $load_animation_js,
88 ["jquery"],
89 SLIDER_BLOCK_VERSION,
90 true
91 );
92
93 $style_css = SLIDER_BLOCK_ADMIN_URL . 'dist/style.css';
94 //Frontend & Editor Style
95 wp_register_style(
96 'create-block-slider-block-frontend-style',
97 $style_css,
98 [
99 'slick-style',
100 'essential-blocks-animation'
101 ],
102 SLIDER_BLOCK_VERSION
103 );
104
105 //Frontend Style
106 $frontend_js = SLIDER_BLOCK_ADMIN_URL . 'dist/frontend/index.js';
107 $frontend_asset = require SLIDER_BLOCK_ADMIN_PATH . '/dist/frontend/index.asset.php';
108 wp_register_script(
109 'slider-block-frontend-js',
110 $frontend_js,
111 $frontend_asset['dependencies'],
112 $frontend_asset['version'],
113 true
114 );
115
116 if ( ! WP_Block_Type_Registry::get_instance()->is_registered( 'essential-blocks/slider' ) ) {
117 register_block_type(
118 Slider_Helper::get_block_register_path( "slider-block/slider-block", SLIDER_BLOCK_ADMIN_PATH ),
119 [
120 'editor_script' => 'create-block-slider-block-editor-script',
121 'editor_style' => 'create-block-slider-block-frontend-style',
122 'render_callback' => function ( $attributes, $content ) {
123 if ( ! is_admin() ) {
124 wp_enqueue_style( 'create-block-slider-block-frontend-style' );
125 wp_enqueue_script( 'essential-blocks-slickjs' );
126 wp_enqueue_script( 'essential-blocks-eb-animation' );
127 wp_enqueue_script( 'slider-block-frontend-js' );
128 }
129 return $content;
130 }
131 ]
132 );
133 }
134 }
135 add_action( 'init', 'create_block_slider_block_init', 99 );
136