| @@ -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.3.2 | |
| 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.3.2' ); | |
| 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 | |
| @@ -139,13 +173,14 @@ | ||
| 139 | 173 | */ |
| 140 | 174 | public function init_hooks() { |
| 141 | 175 | add_action( 'admin_init', array( $this, 'admin_init' ) ); |
| 142 | 176 | |
| 177 | + add_action( 'init', array( $this, 'init_hook' ) ); | |
| 178 | + | |
| 143 | 179 | add_action( 'init', array( $this, 'add_custom_fields_support' ), 100 ); |
| 144 | 180 | |
| 145 | 181 | add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_go_pro_link_plugins_page' ) ); |
| 146 | 182 | |
| 147 | - $this->php_translation(); | |
| 148 | 183 | add_action( 'wp_enqueue_scripts', array( $this, 'js_translation' ), 11 ); |
| 149 | 184 | add_action( 'enqueue_block_editor_assets', array( $this, 'js_translation_editor' ) ); |
| 150 | 185 | |
| 151 | 186 | // add Ghost Kit blocks category. |
| @@ -162,15 +197,8 @@ | ||
| 162 | 197 | add_filter( 'wp_check_filetype_and_ext', array( $this, 'wp_check_filetype_and_ext' ), 100, 3 ); |
| 163 | 198 | } |
| 164 | 199 | |
| 165 | 200 | /** |
| 166 | - * PHP translations. | |
| 167 | - */ | |
| 168 | - public function php_translation() { | |
| 169 | - load_plugin_textdomain( 'ghostkit', false, plugin_dir_path( __FILE__ ) . '/languages' ); | |
| 170 | - } | |
| 171 | - | |
| 172 | - /** | |
| 173 | 201 | * JS translation. |
| 174 | 202 | */ |
| 175 | 203 | public function js_translation() { |
| 176 | 204 | if ( ! function_exists( 'wp_set_script_translations' ) ) { |
| @@ -254,8 +282,26 @@ | ||
| 254 | 282 | $css_deps[] = 'gist-simple'; |
| 255 | 283 | $js_deps[] = 'gist-simple'; |
| 256 | 284 | } |
| 257 | 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 | + | |
| 258 | 304 | // Ghost Kit. |
| 259 | 305 | GhostKit_Assets::enqueue_style( |
| 260 | 306 | 'ghostkit-editor', |
| 261 | 307 | 'build/gutenberg/editor', |
| @@ -262,10 +308,24 @@ | ||
| 262 | 308 | $css_deps, |
| 263 | 309 | filemtime( plugin_dir_path( __FILE__ ) . 'build/gutenberg/editor.css' ) |
| 264 | 310 | ); |
| 265 | 311 | wp_style_add_data( 'ghostkit-editor', 'rtl', 'replace' ); |
| 266 | - wp_style_add_data( 'ghostkit-editor', 'suffix', '.min' ); | |
| 267 | 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 | + } | |
| 327 | + | |
| 268 | 328 | GhostKit_Assets::enqueue_script( |
| 269 | 329 | 'ghostkit-editor', |
| 270 | 330 | 'build/gutenberg/index', |
| 271 | 331 | $js_deps |
| @@ -360,8 +420,15 @@ | ||
| 360 | 420 | $this->plugin_name = $data['Name']; |
| 361 | 421 | $this->plugin_version = $data['Version']; |
| 362 | 422 | $this->plugin_slug = plugin_basename( __FILE__ ); |
| 363 | 423 | $this->plugin_name_sanitized = basename( __FILE__, '.php' ); |
| 424 | + } | |
| 425 | + | |
| 426 | + /** | |
| 427 | + * Init hook | |
| 428 | + */ | |
| 429 | + public function init_hook() { | |
| 430 | + load_plugin_textdomain( 'ghostkit', false, plugin_dir_path( __FILE__ ) . '/languages' ); | |
| 364 | 431 | } |
| 365 | 432 | |
| 366 | 433 | /** |
| 367 | 434 | * Add support for 'custom-fields' for all post types. |