Repository navigation
Expand file tree
/
Copy pathfrontblocks.php
More file actions
165 lines (147 loc) · 5.11 KB
/
Copy pathfrontblocks.php
File metadata and controls
165 lines (147 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
/**
* Plugin Name: FrontBlocks Site Tools
* Plugin URI: https://wordpress.org/plugins/frontblocks/
* Description: Essential toolkit for a WordPress site: block editor enhancements, cookie consent, maintenance mode, image optimization, login and more.
* Version: 1.5.6
* Author: Closemarketing
* Author URI: https://close.marketing
* Text Domain: frontblocks
* Domain Path: /languages
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*
* Requires at least: 5.8
* Requires PHP: 7.0
*
* @package FrontBlocks
* @author Closemarketing
* @copyright 2025 Closemarketing
* @license GPL-2.0+
*
* @wordpress-plugin
*
* Prefix: frbl_
*/
defined( 'ABSPATH' ) || die( 'No script kiddies please!' );
define( 'FRBL_VERSION', '1.5.6' );
define( 'FRBL_PLUGIN', __FILE__ );
define( 'FRBL_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'FRBL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
// Load Composer autoloader.
if ( file_exists( FRBL_PLUGIN_PATH . 'vendor/autoload.php' ) ) {
require_once FRBL_PLUGIN_PATH . 'vendor/autoload.php';
}
// Action Scheduler, used by Image Management for background bulk operations
// (regenerating thumbnails, bulk format conversion). Its own bootstrap file
// is the "standard shared-library way" to load it: it self-registers a
// versioned instance via ActionScheduler_Versions and only initializes the
// highest version found across every plugin that bundles it, so multiple
// plugins (or WooCommerce) can safely load their own copy without conflict.
// It must be required before `plugins_loaded` runs, since it hooks into it.
if ( file_exists( FRBL_PLUGIN_PATH . 'vendor/woocommerce/action-scheduler/action-scheduler.php' ) ) {
require_once FRBL_PLUGIN_PATH . 'vendor/woocommerce/action-scheduler/action-scheduler.php';
}
require_once FRBL_PLUGIN_PATH . 'includes/Plugin_Main.php';
add_action(
'plugins_loaded',
function () {
FrontBlocks\Plugin_Main::get_instance();
}
);
/**
* Whether FrontBlocks staging mode is active on this site.
*
* Available to add-ons (and FrontBlocks PRO) so they can disable their own
* syncs, webhooks or other side effects on a staging site. The result can be
* overridden with the `frontblocks_is_staging` filter and the `FRBL_STAGING`
* constant.
*
* @return bool
*/
function frontblocks_is_staging() {
return FrontBlocks\Frontend\Staging::is_active();
}
/**
* Redirect to settings page on plugin activation.
*/
function frbl_plugin_activation_redirect() {
// Bail if activating from network or bulk activation.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Checking WordPress activation parameter, not processing form data.
if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
return;
}
// Redirect to settings page.
if ( get_option( 'frbl_activation_redirect', false ) ) {
delete_option( 'frbl_activation_redirect' );
wp_safe_redirect( class_exists( '\FrontBlocks\Admin\Settings' ) ? \FrontBlocks\Admin\Settings::get_settings_url() : admin_url( 'admin.php?page=frontblocks-settings' ) );
exit;
}
}
add_action( 'admin_init', 'frbl_plugin_activation_redirect' );
/**
* Set redirect flag on plugin activation.
*/
function frbl_set_activation_redirect() {
add_option( 'frbl_activation_redirect', true );
}
register_activation_hook( __FILE__, 'frbl_set_activation_redirect' );
/**
* Record the activation date used by the review notice (see
* FrontBlocks\Admin\ReviewNotice). Done here, via register_activation_hook(),
* rather than from that class's own constructor: that class is only
* instantiated on 'plugins_loaded', which — for a plugin's own first
* activation — has already fired (or won't fire again) by the time
* WordPress includes this file and runs the activation hooks, so an
* 'activated_plugin' listener registered there would never catch it.
*/
function frbl_set_activation_date() {
if ( ! get_option( 'frbl_activation_date' ) ) {
update_option( 'frbl_activation_date', time(), false );
}
}
register_activation_hook( __FILE__, 'frbl_set_activation_date' );
/**
* Check if FrontBlocks PRO is active.
*
* @return bool
*/
function frbl_is_pro_active() {
return defined( 'FRBLP_PRO_ACTIVE' ) && FRBLP_PRO_ACTIVE;
}
/**
* Check if After Add to Cart Block is enabled.
*
* @return bool True if enabled.
*/
function frbl_is_after_add_to_cart_enabled() {
if ( ! frbl_is_pro_active() ) {
return false;
}
$options = get_option( 'frontblocks_settings', array() );
return (bool) ( $options['enable_after_add_to_cart'] ?? false );
}
/**
* Check if Horizontal Product Form is enabled.
*
* @return bool True if enabled.
*/
function frbl_is_horizontal_product_form_enabled() {
if ( ! frbl_is_pro_active() ) {
return false;
}
$options = get_option( 'frontblocks_settings', array() );
return (bool) ( $options['horizontal_product_form'] ?? false );
}
/**
* Check if Checkout Inline Fields is enabled.
*
* @return bool True if enabled.
*/
function frbl_is_checkout_inline_enabled() {
if ( ! frbl_is_pro_active() ) {
return false;
}
$options = get_option( 'frontblocks_settings', array() );
return (bool) ( $options['checkout_inline'] ?? false );
}