frontblocks
Last commit date
.wordpress-playground
1 month ago
assets
1 month ago
includes
1 month ago
vendor
1 month ago
.phplint.yml
1 month ago
frontblocks.php
1 month ago
postcss.config.js
1 month ago
readme.md
1 month ago
readme.txt
1 month ago
tailwind.config.js
1 month ago
frontblocks.php
111 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.3.4 |
| 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.3.4' ); |
| 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 | * Check if FrontBlocks PRO is active. |
| 77 | * |
| 78 | * @return bool |
| 79 | */ |
| 80 | function frbl_is_pro_active() { |
| 81 | return defined( 'FRBLP_PRO_ACTIVE' ) && FRBLP_PRO_ACTIVE; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Check if After Add to Cart Block is enabled. |
| 86 | * |
| 87 | * @return bool True if enabled. |
| 88 | */ |
| 89 | function frbl_is_after_add_to_cart_enabled() { |
| 90 | if ( ! frbl_is_pro_active() ) { |
| 91 | return false; |
| 92 | } |
| 93 | |
| 94 | $options = get_option( 'frontblocks_settings', array() ); |
| 95 | return (bool) ( $options['enable_after_add_to_cart'] ?? false ); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Check if Horizontal Product Form is enabled. |
| 100 | * |
| 101 | * @return bool True if enabled. |
| 102 | */ |
| 103 | function frbl_is_horizontal_product_form_enabled() { |
| 104 | if ( ! frbl_is_pro_active() ) { |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | $options = get_option( 'frontblocks_settings', array() ); |
| 109 | return (bool) ( $options['horizontal_product_form'] ?? false ); |
| 110 | } |
| 111 |