PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / 1.8.0
Gutenify – Visual Site Builder Blocks & Starter Templates v1.8.0
1.9.0 1.8.0 1.7.0 1.6.6 1.6.5 1.6.4 trunk 0.0.1 0.0.2 0.0.3 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 74 releases
← All changes | gutenify.php +164 -97 0.0.3 → 1.8.0 View file →
@@ -1,155 +1,222 @@
1 1 <?php
2 2 /**
3 - * Plugin Name: Gutenify
4 - * Plugin URI: http://gutenify.com/?page=plugin
5 - * Description: WordPress plugin with great collection of page building WordPress blocks for the new Gutenberg WordPress block editor.
6 - * Version: 0.0.3
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.
7 5 * Author: Gutenify
8 - * Author URI: http://gutenify.com/?page=author
9 - * Requires at least: 5.3.2
10 - * Requires PHP: 5.5
11 - * Tested up to: 5.3.2
6 + * Author URI: https://www.gutenify.com
7 + * Plugin URI: https://www.gutenify.com
8 + * Version: 1.8.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
12 16 *
13 - * Text Domain: gutenify
14 - * Domain Path: /i18n/languages/
15 17 *
16 18 * @package Gutenify
17 - * @category Core
18 - * @author Gutenify
19 19 */
20 20
21 +// Exit if accessed directly.
22 +defined('ABSPATH') || exit;
21 23
22 -// Exit if accessed directly.
23 -if ( ! defined( 'ABSPATH' ) ) {
24 - exit;
25 -}
24 +// Define constants.
25 +define('GUTENIFY_VERSION', '1.8.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 +);
26 40
27 -if ( ! class_exists( 'Gutenify' ) ) :
41 +if (!class_exists('Gutenify')) {
28 42
29 - /**
30 - * Main Gutenify Class (singleton).
31 - *
32 - * @since 0.0.1
33 - */
34 - final class Gutenify {
43 + final class Gutenify
44 + {
35 45
36 46 /**
37 - * Gutenify version.
47 + * Holds the class instance.
38 48 *
39 - * @var string
49 + * @var Gutenify
40 50 */
41 - public $version = '0.0.3';
51 + private static $instance = null;
42 52
43 53 /**
44 - * The single instance of the class.
54 + * Plugin base URL.
45 55 *
46 - * @var Gutenify
47 - * @since 0.0.1
56 + * @var string
48 57 */
49 - protected static $_instance = null;
58 + private static $base_url = '';
50 59
51 60 /**
52 - * Main Gutenify Instance.
53 - * Ensures only one instance of Gutenify is loaded or can be loaded.
61 + * Get the singleton instance.
54 62 *
55 - * @static
56 - * @see Gutenify()
57 - * @return Gutenify - Main instance.
63 + * @return Gutenify
58 64 */
59 - public static function instance() {
60 - if ( is_null( self::$_instance ) ) {
61 - self::$_instance = new self();
65 + public static function instance()
66 + {
67 + if (is_null(self::$instance)) {
68 + self::$instance = new self();
62 69 }
63 - return self::$_instance;
70 + return self::$instance;
64 71 }
65 72
66 73 /**
67 - * Gutenify Constructor.
74 + * Gutenify constructor.
68 75 */
69 - function __construct() {
70 - $this->define_constants();
71 - $this->includes();
72 - $this->init_hooks();
76 + private function __construct()
77 + {
78 + self::$base_url = GUTENIFY_BASE_URL;
79 + $this->define_hooks();
80 + $this->bootstrap();
73 81 }
74 82
75 83 /**
76 - * Define Gutenify Constants.
84 + * Define plugin hooks.
77 85 */
78 - private function define_constants() {
79 - $this->define( 'GUTENIFY_PLUGIN_FILE', __FILE__ );
80 - $this->define( 'GUTENIFY_ABSPATH', dirname( __FILE__ ) . '/' );
81 - $this->define( 'GUTENIFY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
82 - $this->define( 'GUTENIFY_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
83 - $this->define( 'GUTENIFY_VERSION', $this->version );
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' ) );
84 92 }
85 93
86 94 /**
87 - * Hook into actions and filters.
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 ...".
88 104 *
89 - * @since 0.0.1
90 - * @return void
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
91 119 */
92 - private function init_hooks() {
93 - Gutenify_Blocks_Loader::init();
94 - add_action( 'init', array( $this, 'set_script_translations' ) );
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 + );
95 133 }
96 134
97 135 /**
98 - * Include required core files used in admin and on the frontend.
136 + * Provide plugin constants merged with args.
99 137 *
100 - * @return void
138 + * @param array $args
139 + * @return array
101 140 */
102 - function includes() {
103 - include_once('inc/class-helpers.php');
104 - include_once('inc/class-blocks-loader.php');
105 - }
106 -
107 - /**
108 - * Define constants.
109 - */
110 - public function define( $name, $value ) {
111 - if ( ! defined( $name ) ) {
112 - define( $name, $value );
113 - }
141 + public function add_plugin_constants($args)
142 + {
143 + return wp_parse_args($args, $this->get_constants());
114 144 }
115 145
116 146 /**
117 - * What type of request is this?
147 + * Get all plugin constants as array.
118 148 *
119 - * @param string $type admin, ajax, cron or frontend.
120 - * @return bool
149 + * @return array
121 150 */
122 - private function is_request( $type ) {
123 - switch ( $type ) {
124 - case 'admin' :
125 - return is_admin();
126 - case 'ajax' :
127 - return defined( 'DOING_AJAX' );
128 - case 'cron' :
129 - return defined( 'DOING_CRON' );
130 - case 'frontend' :
131 - return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
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();
132 189 }
133 190 }
134 191
135 - function set_script_translations() {
136 - wp_set_script_translations( 'gutenify-script', 'gutenify', plugin_dir_path( __FILE__ ) . 'i18n/languages' );
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 + }
137 209 }
138 -
210 + }
211 +}
139 212
140 - }
141 -endif;
142 213 /**
143 - * Main instance of gutenify.
144 - *
145 - * Returns the main instance of Gutenify to prevent the need to use globals.
146 - *
147 - * @since 0.0.1
148 - * @return gutenify
214 + * Initialize the Gutenify plugin.
149 215 */
150 -function gutenify() {
216 +function gutenify()
217 +{
151 218 return Gutenify::instance();
152 219 }
153 220
154 -// Start gutenify.
221 +// Initialize plugin immediately.
155 222 gutenify();