PluginProbe ʕ •ᴥ•ʔ
FrontBlocks for Gutenberg/GeneratePress / 1.5.2
FrontBlocks for Gutenberg/GeneratePress v1.5.2
1.5.2 1.5.1 1.4.0 1.5.0 trunk 0.2.0 0.2.1 0.2.2 0.2.3 0.2.4 0.2.5 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 ci-artifacts
frontblocks / frontblocks.php
frontblocks Last commit date
assets 2 days ago includes 2 days ago vendor 2 days ago frontblocks.php 2 days ago readme.md 2 days ago readme.txt 2 days ago
frontblocks.php
141 lines
1 <?php
2 /**
3 * Plugin Name: FrontBlocks for Gutenberg/GeneratePress
4 * Plugin URI: https://wordpress.org/plugins/frontblocks/
5 * Description: Blocks and helpers that extends Gutenberg and GeneratePress blocks.
6 * Version: 1.5.2
7 * Author: Closemarketing
8 * Author URI: https://close.marketing
9 * Text Domain: frontblocks
10 * Domain Path: /languages
11 * License: GPL-2.0+
12 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
13 *
14 * Requires at least: 5.0
15 * Requires PHP: 7.0
16 *
17 * @package FrontBlocks
18 * @author Closemarketing
19 * @copyright 2025 Closemarketing
20 * @license GPL-2.0+
21 *
22 * @wordpress-plugin
23 *
24 * Prefix: frbl_
25 */
26
27 defined( 'ABSPATH' ) || die( 'No script kiddies please!' );
28
29 define( 'FRBL_VERSION', '1.5.2' );
30 define( 'FRBL_PLUGIN', __FILE__ );
31 define( 'FRBL_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
32 define( 'FRBL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
33
34 // Load Composer autoloader.
35 if ( file_exists( FRBL_PLUGIN_PATH . 'vendor/autoload.php' ) ) {
36 require_once FRBL_PLUGIN_PATH . 'vendor/autoload.php';
37 }
38
39 require_once FRBL_PLUGIN_PATH . 'includes/Plugin_Main.php';
40
41 add_action(
42 'plugins_loaded',
43 function () {
44 FrontBlocks\Plugin_Main::get_instance();
45 }
46 );
47
48 /**
49 * Redirect to settings page on plugin activation.
50 */
51 function frbl_plugin_activation_redirect() {
52 // Bail if activating from network or bulk activation.
53 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Checking WordPress activation parameter, not processing form data.
54 if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
55 return;
56 }
57
58 // Redirect to settings page.
59 if ( get_option( 'frbl_activation_redirect', false ) ) {
60 delete_option( 'frbl_activation_redirect' );
61 wp_safe_redirect( admin_url( 'themes.php?page=frontblocks-settings' ) );
62 exit;
63 }
64 }
65 add_action( 'admin_init', 'frbl_plugin_activation_redirect' );
66
67 /**
68 * Set redirect flag on plugin activation.
69 */
70 function frbl_set_activation_redirect() {
71 add_option( 'frbl_activation_redirect', true );
72 }
73 register_activation_hook( __FILE__, 'frbl_set_activation_redirect' );
74
75 /**
76 * Record the activation date used by the review notice (see
77 * FrontBlocks\Admin\ReviewNotice). Done here, via register_activation_hook(),
78 * rather than from that class's own constructor: that class is only
79 * instantiated on 'plugins_loaded', which — for a plugin's own first
80 * activation — has already fired (or won't fire again) by the time
81 * WordPress includes this file and runs the activation hooks, so an
82 * 'activated_plugin' listener registered there would never catch it.
83 */
84 function frbl_set_activation_date() {
85 if ( ! get_option( 'frbl_activation_date' ) ) {
86 update_option( 'frbl_activation_date', time(), false );
87 }
88 }
89 register_activation_hook( __FILE__, 'frbl_set_activation_date' );
90
91 /**
92 * Check if FrontBlocks PRO is active.
93 *
94 * @return bool
95 */
96 function frbl_is_pro_active() {
97 return defined( 'FRBLP_PRO_ACTIVE' ) && FRBLP_PRO_ACTIVE;
98 }
99
100 /**
101 * Check if After Add to Cart Block is enabled.
102 *
103 * @return bool True if enabled.
104 */
105 function frbl_is_after_add_to_cart_enabled() {
106 if ( ! frbl_is_pro_active() ) {
107 return false;
108 }
109
110 $options = get_option( 'frontblocks_settings', array() );
111 return (bool) ( $options['enable_after_add_to_cart'] ?? false );
112 }
113
114 /**
115 * Check if Horizontal Product Form is enabled.
116 *
117 * @return bool True if enabled.
118 */
119 function frbl_is_horizontal_product_form_enabled() {
120 if ( ! frbl_is_pro_active() ) {
121 return false;
122 }
123
124 $options = get_option( 'frontblocks_settings', array() );
125 return (bool) ( $options['horizontal_product_form'] ?? false );
126 }
127
128 /**
129 * Check if Checkout Inline Fields is enabled.
130 *
131 * @return bool True if enabled.
132 */
133 function frbl_is_checkout_inline_enabled() {
134 if ( ! frbl_is_pro_active() ) {
135 return false;
136 }
137
138 $options = get_option( 'frontblocks_settings', array() );
139 return (bool) ( $options['checkout_inline'] ?? false );
140 }
141