PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.7.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.7.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
← All changes | class-ghost-kit.php +431 -341 2.25.03.7.2 View file →
@@ -1,11 +1,12 @@
1 1 <?php
2 2 /**
3 3 * Plugin Name: Ghost Kit
4 - * Description: Blocks collection and extensions for Gutenberg
5 - * Version: 2.25.0
4 + * Description: Animate WordPress blocks with reveal, scroll, mouse and loop effects.
5 + * Version: 3.7.2
6 + * Plugin URI: https://www.ghostkit.io/?utm_source=wordpress.org&utm_medium=readme&utm_campaign=byline
6 7 * Author: Ghost Kit Team
7 - * Author URI: https://ghostkit.io/?utm_source=wordpress.org&utm_medium=readme&utm_campaign=byline
8 + * Author URI: https://www.ghostkit.io/?utm_source=wordpress.org&utm_medium=readme&utm_campaign=byline
8 9 * License: GPLv2 or later
9 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
10 11 * Text Domain: ghostkit
11 12 *
@@ -12,409 +13,498 @@
12 13 * @package ghostkit
13 14 */
14 15
15 16 if ( ! defined( 'ABSPATH' ) ) {
16 - exit;
17 + exit;
17 18 }
18 19
19 -/**
20 - * GhostKit Class
20 +/*
21 + * Ghost Kit Pro carries its own copy of this core, so only one of the two may run.
22 + * Which copy PHP reaches first depends on the order WordPress includes plugins in,
23 + * and that order is not ours to pick: network-activated plugins come before
24 + * site-activated ones, and a third party can reorder `active_plugins`. So the
25 + * standalone plugin steps aside on its own whenever the Pro plugin is active,
26 + * before it defines anything at all.
27 + *
28 + * Only the activated plugin steps aside. The copy inside the Pro plugin, and any
29 + * copy embedded in a theme or another plugin, is not in the list below and keeps
30 + * loading as before.
21 31 */
22 -class GhostKit {
32 +$gkt_active_plugins = (array) get_option( 'active_plugins', array() );
23 33
24 - /**
25 - * The single class instance.
26 - *
27 - * @var $instance
28 - */
29 - private static $instance = null;
34 +if ( is_multisite() ) {
35 + $gkt_active_plugins = array_merge(
36 + $gkt_active_plugins,
37 + array_keys( (array) get_site_option( 'active_sitewide_plugins', array() ) )
38 + );
39 +}
30 40
31 - /**
32 - * Path to the plugin directory
33 - *
34 - * @var $plugin_path
35 - */
36 - public $plugin_path;
41 +if (
42 + in_array( plugin_basename( __FILE__ ), $gkt_active_plugins, true ) &&
43 + in_array( 'ghostkit-pro/class-ghost-kit-pro.php', $gkt_active_plugins, true ) &&
44 + // `active_plugins` goes on naming a plugin whose directory was removed by hand
45 + // and WordPress simply skips it, so stepping aside for one of those would leave
46 + // the site with neither plugin.
47 + file_exists( WP_PLUGIN_DIR . '/ghostkit-pro/class-ghost-kit-pro.php' )
48 +) {
49 + unset( $gkt_active_plugins );
50 + return;
51 +}
37 52
38 - /**
39 - * URL to the plugin directory
40 - *
41 - * @var $plugin_url
42 - */
43 - public $plugin_url;
53 +unset( $gkt_active_plugins );
44 54
45 - /**
46 - * Plugin name
47 - *
48 - * @var $plugin_name
49 - */
50 - public $plugin_name;
55 +if ( ! defined( 'GHOSTKIT_VERSION' ) ) {
56 + define( 'GHOSTKIT_VERSION', '3.7.2' );
57 +}
51 58
52 - /**
53 - * Plugin version
54 - *
55 - * @var $plugin_version
56 - */
57 - public $plugin_version;
59 +if ( ! class_exists( 'GhostKit' ) ) :
60 + /**
61 + * GhostKit Class
62 + */
63 + class GhostKit {
58 64
59 - /**
60 - * Plugin slug
61 - *
62 - * @var $plugin_slug
63 - */
64 - public $plugin_slug;
65 + /**
66 + * The single class instance.
67 + *
68 + * @var $instance
69 + */
70 + private static $instance = null;
65 71
66 - /**
67 - * Plugin name sanitized
68 - *
69 - * @var $plugin_name_sanitized
70 - */
71 - public $plugin_name_sanitized;
72 + /**
73 + * Path to the plugin directory
74 + *
75 + * @var $plugin_path
76 + */
77 + public $plugin_path;
72 78
73 - /**
74 - * GhostKit constructor.
75 - */
76 - public function __construct() {
77 - /* We do nothing here! */
78 - }
79 + /**
80 + * URL to the plugin directory
81 + *
82 + * @var $plugin_url
83 + */
84 + public $plugin_url;
79 85
80 - /**
81 - * Main Instance
82 - * Ensures only one instance of this class exists in memory at any one time.
83 - */
84 - public static function instance() {
85 - if ( is_null( self::$instance ) ) {
86 - self::$instance = new self();
87 - self::$instance->init_options();
88 - self::$instance->init_hooks();
89 - }
90 - return self::$instance;
91 - }
86 + /**
87 + * Plugin name
88 + *
89 + * @var $plugin_name
90 + */
91 + public $plugin_name;
92 92
93 - /**
94 - * Init options
95 - */
96 - public function init_options() {
97 - $this->plugin_path = plugin_dir_path( __FILE__ );
98 - $this->plugin_url = plugin_dir_url( __FILE__ );
93 + /**
94 + * Plugin version
95 + *
96 + * @var $plugin_version
97 + */
98 + public $plugin_version;
99 99
100 - // settings.
101 - require_once $this->plugin_path . 'settings/index.php';
100 + /**
101 + * Plugin slug
102 + *
103 + * @var $plugin_slug
104 + */
105 + public $plugin_slug;
102 106
103 - // additional blocks php.
104 - require_once $this->plugin_path . 'gutenberg/index.php';
107 + /**
108 + * Plugin name sanitized
109 + *
110 + * @var $plugin_name_sanitized
111 + */
112 + public $plugin_name_sanitized;
105 113
106 - // rest.
107 - require_once $this->plugin_path . 'classes/class-rest.php';
114 + /**
115 + * GhostKit constructor.
116 + */
117 + public function __construct() {
118 + /* We do nothing here! */
119 + }
108 120
109 - // parse blocks.
110 - require_once $this->plugin_path . 'classes/class-parse-blocks.php';
121 + /**
122 + * Main Instance
123 + * Ensures only one instance of this class exists in memory at any one time.
124 + */
125 + public static function instance() {
126 + if ( is_null( self::$instance ) ) {
127 + self::$instance = new self();
128 + self::$instance->init_options();
129 + self::$instance->init_hooks();
130 + }
131 + return self::$instance;
132 + }
111 133
112 - // assets.
113 - require_once $this->plugin_path . 'classes/class-assets.php';
134 + /**
135 + * Init options
136 + */
137 + public function init_options() {
138 + $this->plugin_path = plugin_dir_path( __FILE__ );
139 + $this->plugin_url = plugin_dir_url( __FILE__ );
114 140
115 - // reusable widget.
116 - require_once $this->plugin_path . 'classes/class-reusable-widget.php';
141 + require_once $this->plugin_path . 'settings/index.php';
142 + require_once $this->plugin_path . 'gutenberg/index.php';
117 143
118 - // icons.
119 - require_once $this->plugin_path . 'classes/class-icons.php';
144 + require_once $this->plugin_path . 'classes/class-rest.php';
145 + require_once $this->plugin_path . 'classes/class-parse-blocks.php';
146 + require_once $this->plugin_path . 'classes/class-assets-detector.php';
147 + require_once $this->plugin_path . 'classes/class-assets.php';
148 + require_once $this->plugin_path . 'classes/class-reusable-widget.php';
149 + require_once $this->plugin_path . 'classes/class-icons.php';
150 + require_once $this->plugin_path . 'classes/class-shapes.php';
151 + require_once $this->plugin_path . 'classes/class-typography.php';
152 + require_once $this->plugin_path . 'classes/class-fonts.php';
153 + require_once $this->plugin_path . 'classes/class-templates.php';
154 + require_once $this->plugin_path . 'classes/class-breakpoints.php';
155 + require_once $this->plugin_path . 'classes/class-ask-review.php';
156 + require_once $this->plugin_path . 'classes/class-deactivate-duplicate-plugin.php';
120 157
121 - // icons fallback.
122 - require_once $this->plugin_path . 'classes/class-icons-fallback.php';
158 + require_once $this->plugin_path . 'gutenberg/utils/encode-decode/index.php';
159 + require_once $this->plugin_path . 'gutenberg/extend/index.php';
123 160
124 - // shapes.
125 - require_once $this->plugin_path . 'classes/class-shapes.php';
161 + // 3rd.
162 + require_once $this->plugin_path . 'classes/3rd/class-astra.php';
163 + require_once $this->plugin_path . 'classes/3rd/class-page-builder-framework.php';
164 + require_once $this->plugin_path . 'classes/3rd/class-blocksy.php';
165 + require_once $this->plugin_path . 'classes/3rd/class-rank-math.php';
126 166
127 - // fonts.
128 - require_once $this->plugin_path . 'classes/class-fonts.php';
167 + // Migration.
168 + require_once $this->plugin_path . 'classes/class-migration.php';
169 + }
129 170
130 - // typography.
131 - require_once $this->plugin_path . 'classes/class-typography.php';
171 + /**
172 + * Init hooks
173 + */
174 + public function init_hooks() {
175 + add_action( 'admin_init', array( $this, 'admin_init' ) );
132 176
133 - // templates.
134 - require_once $this->plugin_path . 'classes/class-templates.php';
177 + add_action( 'init', array( $this, 'init_hook' ) );
135 178
136 - // scss compiler.
137 - require_once $this->plugin_path . 'classes/class-scss-compiler.php';
179 + add_action( 'init', array( $this, 'add_custom_fields_support' ), 100 );
138 180
139 - // breakpoints background.
140 - require_once $this->plugin_path . 'classes/class-breakpoints-background.php';
181 + add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_go_pro_link_plugins_page' ) );
141 182
142 - // breakpoints.
143 - require_once $this->plugin_path . 'classes/class-breakpoints.php';
183 + add_action( 'wp_enqueue_scripts', array( $this, 'js_translation' ), 11 );
184 + add_action( 'enqueue_block_editor_assets', array( $this, 'js_translation_editor' ) );
144 185
145 - // scroll reveal extension.
146 - require_once $this->plugin_path . 'classes/class-scroll-reveal.php';
186 + // add Ghost Kit blocks category.
187 + add_filter( 'block_categories_all', array( $this, 'block_categories_all' ), 9999 );
147 188
148 - // utils encode/decode.
149 - require_once $this->plugin_path . 'gutenberg/utils/encode-decode/index.php';
189 + // we need to enqueue the main script earlier to let 3rd-party plugins add custom styles support.
190 + add_action( 'enqueue_block_assets', array( $this, 'enqueue_block_assets' ), 9 );
150 191
151 - // custom block styles class.
152 - require_once $this->plugin_path . 'gutenberg/extend/styles/get-styles.php';
192 + // add support for excerpts to some blocks.
193 + add_filter( 'excerpt_allowed_blocks', array( $this, 'excerpt_allowed_blocks' ) );
153 194
154 - // block users custom CSS class.
155 - require_once $this->plugin_path . 'gutenberg/extend/custom-css/get-custom-css.php';
195 + // add support for additional mimes.
196 + add_filter( 'upload_mimes', array( $this, 'upload_mimes' ), 100 );
197 + add_filter( 'wp_check_filetype_and_ext', array( $this, 'wp_check_filetype_and_ext' ), 100, 3 );
198 + }
156 199
157 - // 3rd.
158 - require_once $this->plugin_path . 'classes/3rd/class-rank-math.php';
159 - }
200 + /**
201 + * JS translation.
202 + */
203 + public function js_translation() {
204 + if ( ! function_exists( 'wp_set_script_translations' ) ) {
205 + return;
206 + }
160 207
161 - /**
162 - * Init hooks
163 - */
164 - public function init_hooks() {
165 - add_action( 'admin_init', array( $this, 'admin_init' ) );
208 + wp_set_script_translations( 'ghostkit-block-countdown', 'ghostkit', plugin_dir_path( __FILE__ ) . '/languages' );
209 + }
166 210
167 - add_action( 'init', array( $this, 'add_custom_fields_support' ), 100 );
211 + /**
212 + * JS translation for editor.
213 + */
214 + public function js_translation_editor() {
215 + if ( ! function_exists( 'wp_set_script_translations' ) ) {
216 + return;
217 + }
168 218
169 - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_go_pro_link_plugins_page' ) );
219 + wp_set_script_translations( 'ghostkit-editor', 'ghostkit', plugin_dir_path( __FILE__ ) . '/languages' );
220 + wp_set_script_translations( 'ghostkit-settings', 'ghostkit', plugin_dir_path( __FILE__ ) . '/languages' );
221 + }
170 222
171 - $this->php_translation();
172 - add_action( 'wp_enqueue_scripts', array( $this, 'js_translation' ), 11 );
173 - add_action( 'enqueue_block_editor_assets', array( $this, 'js_translation_editor' ) );
223 + /**
224 + * Register Ghost Kit blocks category
225 + *
226 + * @param array $categories - available categories.
227 + * @return array
228 + */
229 + public function block_categories_all( $categories ) {
230 + return array_merge(
231 + array(
232 + array(
233 + 'slug' => 'ghostkit',
234 + 'title' => __( 'Ghost Kit', 'ghostkit' ),
235 + ),
236 + ),
237 + $categories
238 + );
239 + }
174 240
175 - // add Ghost Kit blocks category.
176 - add_filter( 'block_categories_all', array( $this, 'block_categories_all' ), 9 );
241 + /**
242 + * Enqueue editor assets
243 + */
244 + public function enqueue_block_assets() {
245 + if ( ! is_admin() ) {
246 + return;
247 + }
177 248
178 - // we need to enqueue the main script earlier to let 3rd-party plugins add custom styles support.
179 - add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ), 9 );
249 + global $current_screen;
180 250
181 - // add support for excerpts to some blocks.
182 - add_filter( 'excerpt_allowed_blocks', array( $this, 'excerpt_allowed_blocks' ) );
183 - }
251 + $css_deps = array();
252 + $js_deps = array( 'ghostkit-helper' );
184 253
185 - /**
186 - * PHP translations.
187 - */
188 - public function php_translation() {
189 - load_plugin_textdomain( 'ghostkit', false, plugin_dir_path( __FILE__ ) . '/languages' );
190 - }
254 + // Ivent.
255 + if ( apply_filters( 'gkt_enqueue_plugin_ivent', true ) ) {
256 + $js_deps[] = 'ivent';
257 + }
191 258
192 - /**
193 - * JS translation.
194 - */
195 - public function js_translation() {
196 - if ( ! function_exists( 'wp_set_script_translations' ) ) {
197 - return;
198 - }
259 + // Motion.
260 + if ( apply_filters( 'gkt_enqueue_plugin_motion', true ) ) {
261 + $js_deps[] = 'motion';
262 + }
199 263
200 - wp_set_script_translations( 'ghostkit-block-countdown', 'ghostkit', plugin_dir_path( __FILE__ ) . '/languages' );
201 - }
264 + // Jarallax.
265 + if ( apply_filters( 'gkt_enqueue_plugin_jarallax', true ) ) {
266 + $js_deps[] = 'jarallax';
267 + $js_deps[] = 'jarallax-video';
268 + }
202 269
203 - /**
204 - * JS translation for editor.
205 - */
206 - public function js_translation_editor() {
207 - if ( ! function_exists( 'wp_set_script_translations' ) ) {
208 - return;
209 - }
270 + // Luxon.
271 + if ( apply_filters( 'gkt_enqueue_plugin_luxon', true ) ) {
272 + $js_deps[] = 'luxon';
273 + }
210 274
211 - wp_set_script_translations( 'ghostkit-editor', 'ghostkit', plugin_dir_path( __FILE__ ) . '/languages' );
212 - wp_set_script_translations( 'ghostkit-settings', 'ghostkit', plugin_dir_path( __FILE__ ) . '/languages' );
213 - }
275 + // Lottie Player.
276 + if ( apply_filters( 'gkt_enqueue_plugin_lottie_player', true ) ) {
277 + $js_deps[] = 'lottie-player';
278 + }
214 279
215 - /**
216 - * Register Ghost Kit blocks category
217 - *
218 - * @param array $categories - available categories.
219 - * @return array
220 - */
221 - public function block_categories_all( $categories ) {
222 - return array_merge(
223 - array(
224 - array(
225 - 'slug' => 'ghostkit',
226 - 'title' => __( 'Ghost Kit', 'ghostkit' ),
227 - ),
228 - ),
229 - $categories
230 - );
231 - }
280 + // GistEmbed.
281 + if ( apply_filters( 'gkt_enqueue_plugin_gist_simple', true ) ) {
282 + $css_deps[] = 'gist-simple';
283 + $js_deps[] = 'gist-simple';
284 + }
232 285
233 - /**
234 - * Enqueue editor assets
235 - */
236 - public function enqueue_block_editor_assets() {
237 - global $current_screen;
286 + // In block metadata, many Ghost Kit blocks declare `style: ["ghostkit", ...]`.
287 + // Because of this, WordPress auto-enqueues the `ghostkit` style handle for those blocks
288 + // in every context where blocks are rendered, including the editor.
289 + //
290 + // `ghostkit` is our frontend stylesheet (`build/gutenberg/style.css`), while editor UI
291 + // is styled by `ghostkit-editor` (`build/gutenberg/editor.css`). Loading both in editor
292 + // causes conflicts (for example, frontend Display extension rules can hide editor blocks).
293 + //
294 + // To keep block dependency chains intact without editing all block.json files, we override
295 + // only the `ghostkit` handle in admin and make it an alias that depends on `ghostkit-editor`.
296 + // Result:
297 + // - frontend keeps using real `ghostkit` styles;
298 + // - editor resolves `ghostkit` dependencies to editor styles, avoiding CSS conflicts.
299 + if ( wp_style_is( 'ghostkit', 'registered' ) ) {
300 + wp_deregister_style( 'ghostkit' );
301 + }
302 + wp_register_style( 'ghostkit', false, array( 'ghostkit-editor' ), GHOSTKIT_VERSION );
238 303
239 - $css_deps = array();
240 - $js_deps = array( 'ghostkit-helper', 'wp-block-editor', 'wp-blocks', 'wp-date', 'wp-i18n', 'wp-element', 'wp-edit-post', 'wp-compose', 'underscore', 'wp-hooks', 'wp-components', 'wp-keycodes', 'jquery' );
304 + // Ghost Kit.
305 + GhostKit_Assets::enqueue_style(
306 + 'ghostkit-editor',
307 + 'build/gutenberg/editor',
308 + $css_deps,
309 + filemtime( plugin_dir_path( __FILE__ ) . 'build/gutenberg/editor.css' )
310 + );
311 + wp_style_add_data( 'ghostkit-editor', 'rtl', 'replace' );
241 312
242 - // Fix for Widgets screen.
243 - if ( isset( $current_screen->id ) && 'widgets' === $current_screen->id ) {
244 - $key = array_search( 'wp-edit-post', $js_deps, true );
313 + // Since WordPress 7.1 the post editor canvas is always iframed, and core collects
314 + // the iframe assets by running `enqueue_block_assets` a second time with
315 + // `should_load_block_editor_scripts_and_styles` forced to false.
316 + // The editor bundles belong to the editor chrome only - loading them in the canvas
317 + // would boot a second copy of the block editor inside the iframe. The vendor
318 + // libraries, on the other hand, are needed inside the canvas to render block previews
319 + // (for example the `lottie-player` custom element, which is registered per window).
320 + if ( ! wp_should_load_block_editor_scripts_and_styles() ) {
321 + foreach ( $js_deps as $dep ) {
322 + wp_enqueue_script( $dep );
323 + }
245 324
246 - if ( false !== $key ) {
247 - unset( $js_deps[ $key ] );
248 - }
249 - }
325 + return;
326 + }
250 327
251 - // Jarallax.
252 - if ( apply_filters( 'gkt_enqueue_plugin_jarallax', true ) ) {
253 - $js_deps[] = 'jarallax';
254 - $js_deps[] = 'jarallax-video';
255 - }
328 + GhostKit_Assets::enqueue_script(
329 + 'ghostkit-editor',
330 + 'build/gutenberg/index',
331 + $js_deps
332 + );
256 333
257 - // ScrollReveal.
258 - if ( apply_filters( 'gkt_enqueue_plugin_scrollreveal', true ) ) {
259 - $js_deps[] = 'scrollreveal';
260 - }
334 + // Load plugins in editor only (skip legacy Widgets screen).
335 + if ( ! isset( $current_screen->id ) || 'widgets' !== $current_screen->id ) {
336 + GhostKit_Assets::enqueue_script(
337 + 'ghostkit-editor-plugins',
338 + 'build/gutenberg/plugins',
339 + array( 'ghostkit-editor' )
340 + );
341 + }
342 + }
261 343
262 - // Luxon.
263 - if ( apply_filters( 'gkt_enqueue_plugin_luxon', true ) ) {
264 - $js_deps[] = 'luxon';
265 - }
344 + /**
345 + * Excerpt allowed wrapper blocks.
346 + *
347 + * @param array $blocks - allowed blocks.
348 + * @return array
349 + */
350 + public function excerpt_allowed_blocks( $blocks ) {
351 + return array_merge(
352 + $blocks,
353 + array(
354 + 'ghostkit/accordion',
355 + 'ghostkit/accordion-item',
356 + 'ghostkit/alert',
357 + 'ghostkit/button',
358 + 'ghostkit/carousel',
359 + 'ghostkit/carousel-single',
360 + 'ghostkit/changelog',
361 + 'ghostkit/counter-box',
362 + 'ghostkit/grid',
363 + 'ghostkit/grid-column',
364 + 'ghostkit/icon-box',
365 + 'ghostkit/pricing-table',
366 + 'ghostkit/pricing-table-item',
367 + 'ghostkit/tabs-v2',
368 + 'ghostkit/tabs-tab-v2',
369 + 'ghostkit/testimonial',
370 + )
371 + );
372 + }
266 373
267 - // GistEmbed.
268 - if ( apply_filters( 'gkt_enqueue_plugin_gist_simple', true ) ) {
269 - $css_deps[] = 'gist-simple';
270 - $js_deps[] = 'gist-simple';
271 - }
374 + /**
375 + * Allow JSON uploads
376 + *
377 + * @param array $mimes supported mimes.
378 + *
379 + * @return array
380 + */
381 + public function upload_mimes( $mimes ) {
382 + if ( ! isset( $mimes['json'] ) ) {
383 + $mimes['json'] = 'application/json';
384 + }
272 385
273 - // Ghost Kit.
274 - wp_enqueue_style(
275 - 'ghostkit-editor',
276 - plugins_url( 'gutenberg/editor.min.css', __FILE__ ),
277 - $css_deps,
278 - filemtime( plugin_dir_path( __FILE__ ) . 'gutenberg/editor.min.css' )
279 - );
280 - wp_style_add_data( 'ghostkit-editor', 'rtl', 'replace' );
281 - wp_style_add_data( 'ghostkit-editor', 'suffix', '.min' );
386 + return $mimes;
387 + }
282 388
283 - wp_enqueue_script(
284 - 'ghostkit-editor',
285 - plugins_url( 'gutenberg/index.min.js', __FILE__ ),
286 - $js_deps,
287 - filemtime( plugin_dir_path( __FILE__ ) . 'gutenberg/index.min.js' ),
288 - true
289 - );
290 - }
389 + /**
390 + * Allow JSON file uploads
391 + *
392 + * @param array $data File data.
393 + * @param array $file File object.
394 + * @param string $filename File name.
395 + *
396 + * @return array
397 + */
398 + public function wp_check_filetype_and_ext( $data, $file, $filename ) {
399 + $ext = isset( $data['ext'] ) ? $data['ext'] : '';
291 400
292 - /**
293 - * Excerpt allowed wrapper blocks.
294 - *
295 - * @param array $blocks - allowed blocks.
296 - * @return array
297 - */
298 - public function excerpt_allowed_blocks( $blocks ) {
299 - return array_merge(
300 - $blocks,
301 - array(
302 - 'ghostkit/accordion',
303 - 'ghostkit/accordion-item',
304 - 'ghostkit/alert',
305 - 'ghostkit/button',
306 - 'ghostkit/carousel',
307 - 'ghostkit/carousel-single',
308 - 'ghostkit/changelog',
309 - 'ghostkit/counter-box',
310 - 'ghostkit/grid',
311 - 'ghostkit/grid-column',
312 - 'ghostkit/icon-box',
313 - 'ghostkit/pricing-table',
314 - 'ghostkit/pricing-table-item',
315 - 'ghostkit/tabs-v2',
316 - 'ghostkit/tabs-tab-v2',
317 - 'ghostkit/testimonial',
318 - )
319 - );
320 - }
401 + if ( ! $ext ) {
402 + $exploded = explode( '.', $filename );
403 + $ext = strtolower( end( $exploded ) );
404 + }
321 405
322 - /**
323 - * Init variables
324 - */
325 - public function admin_init() {
326 - // get current plugin data.
327 - $data = get_plugin_data( __FILE__ );
328 - $this->plugin_name = $data['Name'];
329 - $this->plugin_version = $data['Version'];
330 - $this->plugin_slug = plugin_basename( __FILE__, '.php' );
331 - $this->plugin_name_sanitized = basename( __FILE__, '.php' );
332 - }
406 + if ( 'json' === $ext ) {
407 + $data['type'] = 'application/json';
408 + $data['ext'] = 'json';
409 + }
333 410
334 - /**
335 - * Add support for 'custom-fields' for all post types.
336 - * Required by Customizer and Custom CSS blocks.
337 - */
338 - public function add_custom_fields_support() {
339 - $available_post_types = get_post_types(
340 - array(
341 - 'show_ui' => true,
342 - ),
343 - 'object'
344 - );
411 + return $data;
412 + }
345 413
346 - foreach ( $available_post_types as $post_type ) {
347 - if ( 'attachment' !== $post_type->name ) {
348 - add_post_type_support( $post_type->name, 'custom-fields' );
349 - }
350 - }
351 - }
414 + /**
415 + * Init variables
416 + */
417 + public function admin_init() {
418 + // get current plugin data.
419 + $data = get_plugin_data( __FILE__ );
420 + $this->plugin_name = $data['Name'];
421 + $this->plugin_version = $data['Version'];
422 + $this->plugin_slug = plugin_basename( __FILE__ );
423 + $this->plugin_name_sanitized = basename( __FILE__, '.php' );
424 + }
352 425
353 - /**
354 - * Equivalent of GHOSTKIT.replaceVars method.
355 - *
356 - * @param String $str styles string.
357 - * @return String string with replaced vars.
358 - */
359 - public function replace_vars( $str ) {
360 - $breakpoints = GhostKit_Breakpoints::get_breakpoints();
361 - // TODO: Due to different formats in scss and assets there is an offset.
362 - $vars = array(
363 - 'media_sm' => '(max-width: ' . $breakpoints['xs'] . 'px)',
364 - 'media_md' => '(max-width: ' . $breakpoints['sm'] . 'px)',
365 - 'media_lg' => '(max-width: ' . $breakpoints['md'] . 'px)',
366 - 'media_xl' => '(max-width: ' . $breakpoints['lg'] . 'px)',
367 - );
426 + /**
427 + * Init hook
428 + */
429 + public function init_hook() {
430 + load_plugin_textdomain( 'ghostkit', false, plugin_dir_path( __FILE__ ) . '/languages' );
431 + }
368 432
369 - foreach ( $vars as $k => $var ) {
370 - $str = preg_replace( "/#{ghostkitvar:$k}/", $var, $str );
371 - }
433 + /**
434 + * Add support for 'custom-fields' for all post types.
435 + * Required by Customizer and Custom CSS blocks.
436 + */
437 + public function add_custom_fields_support() {
438 + $available_post_types = get_post_types(
439 + array(
440 + 'show_ui' => true,
441 + ),
442 + 'object'
443 + );
372 444
373 - return $str;
374 - }
445 + foreach ( $available_post_types as $post_type ) {
446 + if ( 'attachment' !== $post_type->name ) {
447 + add_post_type_support( $post_type->name, 'custom-fields' );
448 + }
449 + }
450 + }
375 451
376 - /**
377 - * Add Go Pro link to plugins page.
378 - *
379 - * @param Array $links - available links.
380 - *
381 - * @return array
382 - */
383 - public function add_go_pro_link_plugins_page( $links ) {
384 - return array_merge(
385 - $links,
386 - array(
387 - '<a target="_blank" href="admin.php?page=ghostkit_go_pro&utm_medium=plugins_list">' . esc_html__( 'Go Pro', 'ghostkit' ) . '</a>',
388 - )
389 - );
390 - }
452 + /**
453 + * Equivalent of GHOSTKIT.replaceVars method.
454 + *
455 + * @param string $str styles string.
456 + * @return string string with replaced vars.
457 + */
458 + public function replace_vars( $str ) {
459 + $breakpoints = GhostKit_Breakpoints::get_breakpoints();
460 + // TODO: Due to different formats in scss and assets there is an offset.
461 + $vars = array(
462 + 'media_sm' => '(max-width: ' . $breakpoints['xs'] . 'px)',
463 + 'media_md' => '(max-width: ' . $breakpoints['sm'] . 'px)',
464 + 'media_lg' => '(max-width: ' . $breakpoints['md'] . 'px)',
465 + 'media_xl' => '(max-width: ' . $breakpoints['lg'] . 'px)',
466 + );
391 467
392 - /**
393 - * Get Go Pro link
394 - *
395 - * @return string
396 - */
397 - public function go_pro_link() {
398 - return 'https://ghostkit.io/pricing/';
399 - }
468 + foreach ( $vars as $k => $var ) {
469 + $str = preg_replace( "/#{ghostkitvar:$k}/", $var, $str );
470 + }
400 471
401 - /**
402 - * Fallback function.
403 - *
404 - * @param array $blocks Blocks array with attributes.
405 - * @return string
406 - */
407 - public function parse_blocks_css( $blocks ) {
408 - return GhostKit_Assets::parse_blocks_css( $blocks );
409 - }
410 -}
472 + return $str;
473 + }
411 474
412 -/**
413 - * Function works with the GhostKit class instance
414 - *
415 - * @return object GhostKit
416 - */
417 -function ghostkit() {
418 - return GhostKit::instance();
419 -}
420 -add_action( 'plugins_loaded', 'ghostkit' );
475 + /**
476 + * Add Go Pro link to plugins page.
477 + *
478 + * @param array $links - available links.
479 + *
480 + * @return array
481 + */
482 + public function add_go_pro_link_plugins_page( $links ) {
483 + return array_merge(
484 + $links,
485 + array(
486 + '<a target="_blank" href="admin.php?page=ghostkit_go_pro&utm_medium=plugins_list">' . esc_html__( 'Go Pro', 'ghostkit' ) . '</a>',
487 + )
488 + );
489 + }
490 +
491 + /**
492 + * Get Go Pro link
493 + *
494 + * @return string
495 + */
496 + public function go_pro_link() {
497 + return 'https://www.ghostkit.io/pricing/';
498 + }
499 + }
500 +
501 + /**
502 + * Function works with the GhostKit class instance
503 + *
504 + * @return object GhostKit
505 + */
506 + function ghostkit() {
507 + return GhostKit::instance();
508 + }
509 + add_action( 'plugins_loaded', 'ghostkit' );
510 +endif;