| @@ -1,9 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: Ghost Kit |
| 4 | - * Description: Page Builder Blocks and Extensions for Gutenberg | |
| 5 | - * Version: 3.4.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 | 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 |
| @@ -15,10 +16,45 @@ | ||
| 15 | 16 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | 17 | exit; |
| 17 | 18 | } |
| 18 | 19 | |
| 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. | |
| 31 | + */ | |
| 32 | +$gkt_active_plugins = (array) get_option( 'active_plugins', array() ); | |
| 33 | + | |
| 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 | +} | |
| 40 | + | |
| 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 | +} | |
| 52 | + | |
| 53 | +unset( $gkt_active_plugins ); | |
| 54 | + | |
| 19 | 55 | if ( ! defined( 'GHOSTKIT_VERSION' ) ) { |
| 20 | - define( 'GHOSTKIT_VERSION', '3.4.0' ); | |
| 56 | + define( 'GHOSTKIT_VERSION', '3.7.2' ); | |
| 21 | 57 | } |
| 22 | 58 | |
| 23 | 59 | if ( ! class_exists( 'GhostKit' ) ) : |
| 24 | 60 | /** |
| @@ -106,8 +142,9 @@ | ||
| 106 | 142 | require_once $this->plugin_path . 'gutenberg/index.php'; |
| 107 | 143 | |
| 108 | 144 | require_once $this->plugin_path . 'classes/class-rest.php'; |
| 109 | 145 | require_once $this->plugin_path . 'classes/class-parse-blocks.php'; |
| 146 | + require_once $this->plugin_path . 'classes/class-assets-detector.php'; | |
| 110 | 147 | require_once $this->plugin_path . 'classes/class-assets.php'; |
| 111 | 148 | require_once $this->plugin_path . 'classes/class-reusable-widget.php'; |
| 112 | 149 | require_once $this->plugin_path . 'classes/class-icons.php'; |
| 113 | 150 | require_once $this->plugin_path . 'classes/class-shapes.php'; |
| @@ -113,11 +150,8 @@ | ||
| 113 | 150 | require_once $this->plugin_path . 'classes/class-shapes.php'; |
| 114 | 151 | require_once $this->plugin_path . 'classes/class-typography.php'; |
| 115 | 152 | require_once $this->plugin_path . 'classes/class-fonts.php'; |
| 116 | 153 | require_once $this->plugin_path . 'classes/class-templates.php'; |
| 117 | - require_once $this->plugin_path . 'classes/class-scss-replace-modules.php'; | |
| 118 | - require_once $this->plugin_path . 'classes/class-scss-compiler.php'; | |
| 119 | - require_once $this->plugin_path . 'classes/class-breakpoints-background.php'; | |
| 120 | 154 | require_once $this->plugin_path . 'classes/class-breakpoints.php'; |
| 121 | 155 | require_once $this->plugin_path . 'classes/class-ask-review.php'; |
| 122 | 156 | require_once $this->plugin_path . 'classes/class-deactivate-duplicate-plugin.php'; |
| 123 | 157 | |
| @@ -248,8 +282,26 @@ | ||
| 248 | 282 | $css_deps[] = 'gist-simple'; |
| 249 | 283 | $js_deps[] = 'gist-simple'; |
| 250 | 284 | } |
| 251 | 285 | |
| 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 ); | |
| 303 | + | |
| 252 | 304 | // Ghost Kit. |
| 253 | 305 | GhostKit_Assets::enqueue_style( |
| 254 | 306 | 'ghostkit-editor', |
| 255 | 307 | 'build/gutenberg/editor', |
| @@ -256,9 +308,23 @@ | ||
| 256 | 308 | $css_deps, |
| 257 | 309 | filemtime( plugin_dir_path( __FILE__ ) . 'build/gutenberg/editor.css' ) |
| 258 | 310 | ); |
| 259 | 311 | wp_style_add_data( 'ghostkit-editor', 'rtl', 'replace' ); |
| 260 | - wp_style_add_data( 'ghostkit-editor', 'suffix', '.min' ); | |
| 312 | + | |
| 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 | + } | |
| 324 | + | |
| 325 | + return; | |
| 326 | + } | |
| 261 | 327 | |
| 262 | 328 | GhostKit_Assets::enqueue_script( |
| 263 | 329 | 'ghostkit-editor', |
| 264 | 330 | 'build/gutenberg/index', |