=' ) ) { add_action( 'admin_notices', [ $this, 'fail_wp_version' ] ); return; } add_action( 'after_setup_theme', function() { if ( ! class_exists( 'ACF' ) || ! version_compare( acf()->version, '6.1.0', '>=' ) ) { add_action( 'admin_notices', [ $this, 'fail_acf_required' ] ); return; } add_filter( 'network_admin_plugin_action_links_acf-field-blocks/acf-field-blocks.php', array( $this, 'filter_plugin_action_links' ) ); add_filter( 'plugin_action_links_acf-field-blocks/acf-field-blocks.php', array( $this, 'filter_plugin_action_links' ) ); add_action( 'activated_plugin', array( $this, 'deactivate_other_instances' ) ); add_action( 'pre_current_active_plugins', array( $this, 'plugin_deactivated_notice' ) ); add_action( 'admin_init', array( $this, 'handle_admin_actions' ) ); $this->define_constants(); $this->autoload(); }); } /** * Define all constants */ public function define_constants() { define( 'ACF_FIELD_BLOCKS_VERSION', '1.6.6' ); define( 'ACF_FIELD_BLOCKS_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); define( 'ACF_FIELD_BLOCKS_URL', plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ); } /** * Load autoloader and register the namespace */ public function autoload() { require_once ACF_FIELD_BLOCKS_PATH . '/autoloader.php'; $autoloader = new \ACFFieldBlocks\Autoloader(); $autoloader->add_namespace( '\ACFFieldBlocks', ACF_FIELD_BLOCKS_PATH . '/inc/' ); $autoloader->add_namespace( '\ACFFieldBlocks\Pro', ACF_FIELD_BLOCKS_PATH . '/pro/' ); $autoloader->register(); \ACFFieldBlocks\Blocks::instance(); if ( is_dir( ACF_FIELD_BLOCKS_PATH . '/pro/' ) ) { \ACFFieldBlocks\Pro\Blocks::instance(); \ACFFieldBlocks\Pro\Rest::instance(); \ACFFieldBlocks\Pro\Block_Visibility::instance(); } else { add_action( 'admin_notices', array( $this, 'review_notice' ) ); } \ACFFieldBlocks\Rest::instance(); } /** * Handle admin actions */ public function handle_admin_actions() { if ( isset( $_GET['afb_action'] ) && ! empty( $_GET['afb_action'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['afb_action'] ) ), 'hide_review_notice' ) ) { update_option( 'acf_field_blocks_hide_review_notice', true ); wp_safe_redirect( admin_url() ); exit; } } /** * Show review notice. */ public function review_notice() { $activation_date = get_option( 'acf_field_blocks_first_activate' ); $is_hide = get_option( 'acf_field_blocks_hide_review_notice', false ); if ( ! empty( $activation_date ) && time() > ( intval( $activation_date ) + ( 2 * WEEK_IN_SECONDS ) ) && false === $is_hide ) { ?>
%s', wpautop( $message ) ); echo wp_kses_post( $html_message ); } /** * Warn user when the site doesn't have the minimum required WordPress version. */ public function fail_acf_required() { /* translators: %s: WordPress version */ $message = sprintf( esc_html__( 'Blocks for ACF Fields requires the Advanced Custom Fields plugin version %s+ to be activated. The plugin is currently not running.', 'acf-field-blocks' ), '6.1.0' ); $html_message = sprintf( '