PluginProbe
Image Gallery Block / 1.3.0
Image Gallery Block v1.3.0
trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0
image-gallery-block / image-gallery-block.php

image-gallery-block.php in Image Gallery Block 1.3.0, at image-gallery-block.php

162 lines 4.5 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 Gallery Block
5 * Plugin URI: https://essential-blocks.com
6 * Description: Impress your audience with beautiful image gallery with lightbox.
7 * Version: 1.3.0
8 * Author: WPDeveloper
9 * Author URI: https://wpdeveloper.net
10 * License: GPL-3.0-or-later
11 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
12 * Text Domain: image-gallery-block
13 *
14 * @package image-gallery-block
15 */
16
17 /**
18 * Registers all block assets so that they can be enqueued through the block editor
19 * in the corresponding context.
20 *
21 * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/
22 */
23
24 require_once __DIR__ . '/includes/font-loader.php';
25 require_once __DIR__ . '/includes/post-meta.php';
26 require_once __DIR__ . '/includes/helpers.php';
27 require_once __DIR__ . '/lib/style-handler/style-handler.php';
28
29 function create_block_image_gallery_block_init()
30 {
31 define('IMAGEGALLERY_BLOCK_VERSION', "1.3.0");
32 define('IMAGEGALLERY_BLOCK_ADMIN_URL', plugin_dir_url(__FILE__));
33 define('IMAGEGALLERY_BLOCK_ADMIN_PATH', dirname(__FILE__));
34
35 $script_asset_path = IMAGEGALLERY_BLOCK_ADMIN_PATH . "/dist/index.asset.php";
36 if (!file_exists($script_asset_path)) {
37 throw new Error(
38 'You need to run `npm start` or `npm run build` for the "block/testimonial" block first.'
39 );
40 }
41 $index_js = IMAGEGALLERY_BLOCK_ADMIN_URL . 'dist/index.js';
42 $script_asset = require($script_asset_path);
43 $all_dependencies = array_merge($script_asset['dependencies'], array(
44 'wp-blocks',
45 'wp-i18n',
46 'wp-element',
47 'wp-block-editor',
48 'imagegallery-block-controls-util',
49 'essential-blocks-eb-animation',
50 'image-gallery-isotope-js',
51 'image-gallery-images-loaded-js',
52 ));
53
54 wp_register_script(
55 'create-block-imagegallery-block-editor-script',
56 $index_js,
57 $all_dependencies,
58 $script_asset['version'],
59 true
60 );
61
62 $lightbox_css = IMAGEGALLERY_BLOCK_ADMIN_URL . 'lib/css/fslightbox.min.css';
63 wp_register_style(
64 'fslightbox-style',
65 $lightbox_css,
66 array(),
67 IMAGEGALLERY_BLOCK_VERSION
68 );
69
70 $lightbox_js = IMAGEGALLERY_BLOCK_ADMIN_URL . 'lib/js/fslightbox.min.js';
71 wp_register_script(
72 'fslightbox-js',
73 $lightbox_js,
74 array("jquery"),
75 IMAGEGALLERY_BLOCK_VERSION,
76 true
77 );
78
79 $images_loaded_js = IMAGEGALLERY_BLOCK_ADMIN_URL . 'lib/js/images-loaded.min.js';
80 wp_register_script(
81 'image-gallery-images-loaded-js',
82 $images_loaded_js,
83 array(),
84 IMAGEGALLERY_BLOCK_VERSION,
85 true
86 );
87
88 $isotope_js = IMAGEGALLERY_BLOCK_ADMIN_URL . 'lib/js/isotope.pkgd.min.js';
89 wp_register_script(
90 'image-gallery-isotope-js',
91 $isotope_js,
92 array(),
93 IMAGEGALLERY_BLOCK_VERSION,
94 true
95 );
96
97 $load_animation_js = IMAGEGALLERY_BLOCK_ADMIN_URL . 'lib/js/eb-animation-load.js';
98 wp_register_script(
99 'essential-blocks-eb-animation',
100 $load_animation_js,
101 array(),
102 IMAGEGALLERY_BLOCK_VERSION,
103 true
104 );
105
106 $animate_css = IMAGEGALLERY_BLOCK_ADMIN_URL . 'lib/css/animate.min.css';
107 wp_register_style(
108 'essential-blocks-animation',
109 $animate_css,
110 array(),
111 IMAGEGALLERY_BLOCK_VERSION
112 );
113
114
115 $style_css = IMAGEGALLERY_BLOCK_ADMIN_URL . 'dist/style.css';
116 //Frontend Style
117 wp_register_style(
118 'create-block-imagegallery-block-frontend-style',
119 $style_css,
120 array('essential-blocks-animation'),
121 IMAGEGALLERY_BLOCK_VERSION
122 );
123
124 //Frontend Script
125 $frontend_js = IMAGEGALLERY_BLOCK_ADMIN_URL . 'dist/frontend/index.js';
126 wp_register_script(
127 'image-gallery-block-frontend-js',
128 $frontend_js,
129 array(
130 'image-gallery-isotope-js',
131 'image-gallery-images-loaded-js',
132 ),
133 IMAGEGALLERY_BLOCK_VERSION,
134 true
135 );
136
137 if (!WP_Block_Type_Registry::get_instance()->is_registered('essential-blocks/advanced-heading')) {
138 register_block_type(
139 Image_Gallery_Helper::get_block_register_path("advanced-heading/advanced-heading", IMAGEGALLERY_BLOCK_ADMIN_PATH),
140 array(
141 'editor_script' => 'create-block-imagegallery-block-editor-script',
142 'editor_style' => 'create-block-imagegallery-block-frontend-style',
143 'render_callback' => function ($attributes, $content) {
144
145 if (!is_admin()) {
146 wp_enqueue_style('create-block-imagegallery-block-frontend-style');
147 wp_enqueue_style('fslightbox-style');
148 wp_enqueue_script('fslightbox-js');
149 wp_enqueue_script('essential-blocks-eb-animation');
150 wp_enqueue_script('image-gallery-images-loaded-js');
151 wp_enqueue_script('image-gallery-isotope-js');
152 wp_enqueue_script('image-gallery-block-frontend-js');
153 }
154
155 return $content;
156 }
157 )
158 );
159 }
160 }
161 add_action('init', 'create_block_image_gallery_block_init', 99);
162