| @@ -1,17 +1,17 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Plugin Name: Gutenify - Visual Site Builder Blocks & Site Templates | |
| 4 | - * Description: Gutenify - Visual Site Builder Blocks & Site Templates is a collection of Gutenberg Advance Fullsite Editing Blocks & site templates that is compatible with WordPress Full Site Editing to help you create the website you always wanted. | |
| 3 | + * Plugin Name: Gutenify - Visual Site Builder Blocks & Starter Templates | |
| 4 | + * Description: Gutenify - Visual Site Builder Blocks & Starter Templates is a collection of Gutenberg Advance Fullsite Editing Blocks & starter templates that is compatible with WordPress Full Site Editing to help you create the website you always wanted. | |
| 5 | 5 | * Author: Gutenify |
| 6 | 6 | * Author URI: https://www.gutenify.com |
| 7 | 7 | * Plugin URI: https://www.gutenify.com |
| 8 | - * Version: 1.6.5 | |
| 8 | + * Version: 1.8.0 | |
| 9 | 9 | * Text Domain: gutenify |
| 10 | 10 | * Domain Path: /languages |
| 11 | 11 | * Tested up to: 7.0 |
| 12 | 12 | * Requires at least: 6.4 |
| 13 | - * Requires PHP: 5.5 | |
| 13 | + * Requires PHP: 7.4 | |
| 14 | 14 | * License: GPLv3 |
| 15 | 15 | * License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 16 | 16 | * |
| 17 | 17 | * |
| @@ -21,12 +21,19 @@ | ||
| 21 | 21 | // Exit if accessed directly. |
| 22 | 22 | defined('ABSPATH') || exit; |
| 23 | 23 | |
| 24 | 24 | // Define constants. |
| 25 | -define('GUTENIFY_VERSION', '1.6.5'); | |
| 25 | +define('GUTENIFY_VERSION', '1.8.0'); | |
| 26 | 26 | define('GUTENIFY_BASE_DIR', plugin_dir_path(__FILE__)); |
| 27 | 27 | define('GUTENIFY_BASE_URL', trailingslashit(plugin_dir_url(__FILE__))); |
| 28 | 28 | define('GUTENIFY_BASE_FILE', __FILE__); |
| 29 | +// First PRO version that no longer bundles its own copies of the blocks | |
| 30 | +// that moved into this plugin (Popup, Hover Card, Hover Card Normal/Hover, | |
| 31 | +// WooCommerce Product Images Slider) -- PRO versions below this still | |
| 32 | +// declare the exact same class/function names as this plugin's copies. | |
| 33 | +// Used by exclude_blocks_still_bundled_in_old_pro() below to avoid a fatal | |
| 34 | +// "Cannot redeclare" error when an old PRO is active. | |
| 35 | +define('GUTENIFY_MOVED_BLOCKS_MIN_PRO_VERSION', '1.5.0'); | |
| 29 | 36 | define( |
| 30 | 37 | 'GUTENIFY_BRAND_LOGO', |
| 31 | 38 | 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDEwODAgMTA4MCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTA4MCAxMDgwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KICAuc3QwIHsNCiAgICBmaWxsOiAjRkZGRkZGOw0KICB9DQoNCiAgLnN0MSB7DQogICAgZmlsbDogIzY3QkM0NTsNCiAgfQ0KDQo8L3N0eWxlPg0KPGc+DQogIDxnPg0KICAgIDxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik04MjguNSw1NTIuOWMtNi44LDE1Mi45LTEzMy4zLDI3NS4xLTI4Ny45LDI3NS4xYy0xNTguOSwwLTI4OC4yLTEyOS4zLTI4OC4yLTI4OC4yDQoJCSAgICAgIGMwLTE1MC42LDExNi4yLTI3NC41LDI2My41LTI4Ny4xVjAuNEMyMjkuMSwxMy4yLDAuNSwyNDkuOSwwLjUsNTM5LjljMCwyOTguMiwyNDEuNyw1NDAuMSw1NDAuMSw1NDAuMQ0KCQkgICAgICBjMjkzLjksMCw1MzMtMjM0LjgsNTM5LjgtNTI3SDgyOC41VjU1Mi45eiIgLz4NCiAgICA8cmVjdCB4PSI1MTguOSIgeT0iMjU0LjYiIGNsYXNzPSJzdDEiIHdpZHRoPSIzMDkuOCIgaGVpZ2h0PSIyOTguMiIgLz4NCiAgPC9nPg0KPC9nPg0KPC9zdmc+DQo=' |
| 32 | 39 | ); |
| @@ -78,10 +85,52 @@ | ||
| 78 | 85 | */ |
| 79 | 86 | private function define_hooks() |
| 80 | 87 | { |
| 81 | 88 | add_filter('gutenify_plugin_constants', array($this, 'add_plugin_constants')); |
| 89 | + add_filter('gutenify_active_blocks', array($this, 'exclude_blocks_still_bundled_in_old_pro')); | |
| 82 | 90 | // Uncomment if you want activation redirect. |
| 83 | 91 | // add_action( 'activated_plugin', array( $this, 'activation_redirect' ) ); |
| 92 | + } | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * This plugin's own bootstrap() always requires its own block files | |
| 96 | + * first, then -- only if PRO is already loaded -- calls gutenify_pro(), | |
| 97 | + * which runs PRO's bootstrap and requires PRO's block files too (see | |
| 98 | + * bootstrap() below). PRO versions older than | |
| 99 | + * GUTENIFY_MOVED_BLOCKS_MIN_PRO_VERSION still carry their own copies | |
| 100 | + * of Popup, Hover Card, Hover Card Normal/Hover, and WooCommerce | |
| 101 | + * Product Images Slider under the identical class/function names, so | |
| 102 | + * letting both plugins load their own copies fatals with "Cannot | |
| 103 | + * redeclare class/function ...". | |
| 104 | + * | |
| 105 | + * Deferring to the old PRO's own (already-working, ungated) | |
| 106 | + * registration of these blocks avoids the collision entirely -- PRO | |
| 107 | + * being active is exactly the condition under which these blocks | |
| 108 | + * should be active anyway. | |
| 109 | + * | |
| 110 | + * Relies on GUTENIFY_PRO_VERSION being defined by this point, same as | |
| 111 | + * the version_compare() check in bootstrap() below -- both depend on | |
| 112 | + * PRO's plugin file having already loaded, which is guaranteed by the | |
| 113 | + * standard install flow (PRO's activation hook installs/activates | |
| 114 | + * this plugin, so PRO's entry in `active_plugins` precedes this | |
| 115 | + * plugin's). | |
| 116 | + * | |
| 117 | + * @param array $blocks | |
| 118 | + * @return array | |
| 119 | + */ | |
| 120 | + public function exclude_blocks_still_bundled_in_old_pro($blocks) | |
| 121 | + { | |
| 122 | + $old_pro_still_has_these_blocks = defined('GUTENIFY_PRO_VERSION') | |
| 123 | + && version_compare(GUTENIFY_PRO_VERSION, GUTENIFY_MOVED_BLOCKS_MIN_PRO_VERSION, '<'); | |
| 124 | + | |
| 125 | + if (!$old_pro_still_has_these_blocks) { | |
| 126 | + return $blocks; | |
| 127 | + } | |
| 128 | + | |
| 129 | + return array_diff( | |
| 130 | + $blocks, | |
| 131 | + array('popup', 'hover-card', 'hover-card-normal', 'hover-card-hover', 'wc-product-images-slider') | |
| 132 | + ); | |
| 84 | 133 | } |
| 85 | 134 | |
| 86 | 135 | /** |
| 87 | 136 | * Provide plugin constants merged with args. |