| 1 |
<?php |
| 2 |
/** |
| 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 |
* Author: Gutenify |
| 6 |
* Author URI: https://www.gutenify.com |
| 7 |
* Plugin URI: https://www.gutenify.com |
| 8 |
* Version: 1.7.0 |
| 9 |
* Text Domain: gutenify |
| 10 |
* Domain Path: /languages |
| 11 |
* Tested up to: 7.0 |
| 12 |
* Requires at least: 6.4 |
| 13 |
* Requires PHP: 7.4 |
| 14 |
* License: GPLv3 |
| 15 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 16 |
* |
| 17 |
* |
| 18 |
* @package Gutenify |
| 19 |
*/ |
| 20 |
|
| 21 |
// Exit if accessed directly. |
| 22 |
defined('ABSPATH') || exit; |
| 23 |
|
| 24 |
// Define constants. |
| 25 |
define('GUTENIFY_VERSION', '1.7.0'); |
| 26 |
define('GUTENIFY_BASE_DIR', plugin_dir_path(__FILE__)); |
| 27 |
define('GUTENIFY_BASE_URL', trailingslashit(plugin_dir_url(__FILE__))); |
| 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'); |
| 36 |
define( |
| 37 |
'GUTENIFY_BRAND_LOGO', |
| 38 |
'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDEwODAgMTA4MCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTA4MCAxMDgwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KICAuc3QwIHsNCiAgICBmaWxsOiAjRkZGRkZGOw0KICB9DQoNCiAgLnN0MSB7DQogICAgZmlsbDogIzY3QkM0NTsNCiAgfQ0KDQo8L3N0eWxlPg0KPGc+DQogIDxnPg0KICAgIDxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik04MjguNSw1NTIuOWMtNi44LDE1Mi45LTEzMy4zLDI3NS4xLTI4Ny45LDI3NS4xYy0xNTguOSwwLTI4OC4yLTEyOS4zLTI4OC4yLTI4OC4yDQoJCSAgICAgIGMwLTE1MC42LDExNi4yLTI3NC41LDI2My41LTI4Ny4xVjAuNEMyMjkuMSwxMy4yLDAuNSwyNDkuOSwwLjUsNTM5LjljMCwyOTguMiwyNDEuNyw1NDAuMSw1NDAuMSw1NDAuMQ0KCQkgICAgICBjMjkzLjksMCw1MzMtMjM0LjgsNTM5LjgtNTI3SDgyOC41VjU1Mi45eiIgLz4NCiAgICA8cmVjdCB4PSI1MTguOSIgeT0iMjU0LjYiIGNsYXNzPSJzdDEiIHdpZHRoPSIzMDkuOCIgaGVpZ2h0PSIyOTguMiIgLz4NCiAgPC9nPg0KPC9nPg0KPC9zdmc+DQo=' |
| 39 |
); |
| 40 |
|
| 41 |
if (!class_exists('Gutenify')) { |
| 42 |
|
| 43 |
final class Gutenify |
| 44 |
{ |
| 45 |
|
| 46 |
/** |
| 47 |
* Holds the class instance. |
| 48 |
* |
| 49 |
* @var Gutenify |
| 50 |
*/ |
| 51 |
private static $instance = null; |
| 52 |
|
| 53 |
/** |
| 54 |
* Plugin base URL. |
| 55 |
* |
| 56 |
* @var string |
| 57 |
*/ |
| 58 |
private static $base_url = ''; |
| 59 |
|
| 60 |
/** |
| 61 |
* Get the singleton instance. |
| 62 |
* |
| 63 |
* @return Gutenify |
| 64 |
*/ |
| 65 |
public static function instance() |
| 66 |
{ |
| 67 |
if (is_null(self::$instance)) { |
| 68 |
self::$instance = new self(); |
| 69 |
} |
| 70 |
return self::$instance; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Gutenify constructor. |
| 75 |
*/ |
| 76 |
private function __construct() |
| 77 |
{ |
| 78 |
self::$base_url = GUTENIFY_BASE_URL; |
| 79 |
$this->define_hooks(); |
| 80 |
$this->bootstrap(); |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Define plugin hooks. |
| 85 |
*/ |
| 86 |
private function define_hooks() |
| 87 |
{ |
| 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')); |
| 90 |
// Uncomment if you want activation redirect. |
| 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 |
); |
| 133 |
} |
| 134 |
|
| 135 |
/** |
| 136 |
* Provide plugin constants merged with args. |
| 137 |
* |
| 138 |
* @param array $args |
| 139 |
* @return array |
| 140 |
*/ |
| 141 |
public function add_plugin_constants($args) |
| 142 |
{ |
| 143 |
return wp_parse_args($args, $this->get_constants()); |
| 144 |
} |
| 145 |
|
| 146 |
/** |
| 147 |
* Get all plugin constants as array. |
| 148 |
* |
| 149 |
* @return array |
| 150 |
*/ |
| 151 |
public function get_constants() |
| 152 |
{ |
| 153 |
$title = 'Gutenify'; |
| 154 |
return array( |
| 155 |
'title' => $title, |
| 156 |
'prefix' => 'gutenify', |
| 157 |
'slug' => 'gutenify', |
| 158 |
'authorWebSite' => 'https://gutenify.com', |
| 159 |
'authorDemoWebSite' => 'https://demo.gutenify.com', |
| 160 |
'authorWebSiteProPage' => 'https://gutenify.com/pricing', |
| 161 |
'authorWebSiteSupport' => 'https://gutenify.com/product-support', |
| 162 |
'plugin_main_slug' => 'gutenify', |
| 163 |
'plugin_main_camel_case_name' => 'gutenify', |
| 164 |
'plugin_main_function_prefix' => 'gutenify', |
| 165 |
'plugin_main_base_url' => GUTENIFY_BASE_URL, |
| 166 |
'plugin_main_base_dir' => GUTENIFY_BASE_DIR, |
| 167 |
'plugin_main_version' => GUTENIFY_VERSION, |
| 168 |
'plugin_main_post_type_prefix' => 'gutenify', |
| 169 |
'plugin_main_site_domain' => 'gutenify.com', |
| 170 |
'core_base_dir' => GUTENIFY_BASE_DIR . 'core/', |
| 171 |
'core_base_url' => GUTENIFY_BASE_URL . 'core/', |
| 172 |
'brand_color' => '#2196f3', |
| 173 |
'pro_title' => $title . ' Pro', |
| 174 |
); |
| 175 |
} |
| 176 |
|
| 177 |
/** |
| 178 |
* Load bootstrap and pro if available. |
| 179 |
*/ |
| 180 |
private function bootstrap() |
| 181 |
{ |
| 182 |
require_once GUTENIFY_BASE_DIR . 'core/inc/bootstrap.php'; |
| 183 |
if ( |
| 184 |
function_exists('gutenify_pro') |
| 185 |
&& defined('GUTENIFY_PRO_VERSION') |
| 186 |
&& version_compare(GUTENIFY_PRO_VERSION, '1.1.5', '>') |
| 187 |
) { |
| 188 |
gutenify_pro(); |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
/** |
| 193 |
* Optionally redirect to Gutenify page on plugin activation. |
| 194 |
* |
| 195 |
* @param string $plugin Plugin basename. |
| 196 |
*/ |
| 197 |
public function activation_redirect($plugin) |
| 198 |
{ |
| 199 |
if (function_exists('get_current_screen')) { |
| 200 |
$screen = get_current_screen(); |
| 201 |
if (!empty($screen->id) && 'appearance_page_tgmpa-install-plugins' === $screen->id) { |
| 202 |
return false; |
| 203 |
} |
| 204 |
} |
| 205 |
if ($plugin === plugin_basename(__FILE__)) { |
| 206 |
wp_safe_redirect(admin_url('admin.php?page=gutenify')); |
| 207 |
exit; |
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 213 |
/** |
| 214 |
* Initialize the Gutenify plugin. |
| 215 |
*/ |
| 216 |
function gutenify() |
| 217 |
{ |
| 218 |
return Gutenify::instance(); |
| 219 |
} |
| 220 |
|
| 221 |
// Initialize plugin immediately. |
| 222 |
gutenify(); |
| 223 |
|