-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrontblocks.php
More file actions
110 lines (97 loc) · 2.84 KB
/
frontblocks.php
File metadata and controls
110 lines (97 loc) · 2.84 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
<?php
/**
* Plugin Name: FrontBlocks for Gutenberg/GeneratePress
* Plugin URI: https://wordpress.org/plugins/frontblocks/
* Description: Blocks and helpers that extends Gutenberg and GeneratePress blocks.
* Version: 1.3.3
* 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.0
* 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.3.3' );
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';
}
require_once FRBL_PLUGIN_PATH . 'includes/Plugin_Main.php';
add_action(
'plugins_loaded',
function () {
FrontBlocks\Plugin_Main::get_instance();
}
);
/**
* 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( admin_url( 'themes.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' );
/**
* 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 );
}