<?php
/**
 * Plugin Name: Visibility Controls for Editor Blocks
 * Description: Hide Gutenberg blocks by device, login status, and custom breakpoints. Syncs with WordPress Hide block when available.
 * Tags: block, visibility, gutenberg, responsive, breakpoints
 * Version: 1.2.8
 * Requires at least: 5.0
 * Requires PHP: 7.4
 * Author: Denis Doroshchuk
 * Author URI: https://doroshchuk.me/
 * Text Domain: visibility-controls-for-editor-blocks
 * Domain Path: /languages
 * License: GPLv3.0
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$gbvc_is_premium = 'visibility-controls-for-editor-blocks-pro' === basename( __DIR__ );

if ( $gbvc_is_premium ) {
	register_activation_hook(
		__FILE__,
		static function (): void {
			if ( function_exists( 'deactivate_plugins' ) ) {
				deactivate_plugins( 'visibility-controls-for-editor-blocks/visibility-controls-for-editor-blocks.php' );
			}
		}
	);
}

if ( function_exists( 'gbvc_fs' ) ) {
	gbvc_fs()->set_basename( $gbvc_is_premium, __FILE__ );
	return;
}

if ( ! function_exists( 'gbvc_fs' ) ) {
	// Create a helper function for easy SDK access.
	function gbvc_fs() {
		global $gbvc_fs;

		if ( ! isset( $gbvc_fs ) ) {
			// Include Freemius SDK.
			require_once __DIR__ . '/vendor/freemius/start.php';

			$gbvc_fs = fs_dynamic_init(
				array(
					'id'                  => '29179',
					'slug'                => 'visibility-controls-for-editor-blocks',
					'premium_slug'        => 'visibility-controls-for-editor-blocks-pro',
					'type'                => 'plugin',
					'public_key'          => 'pk_e6a53b83c36649824485a84562e90',
					'is_premium'          => 'visibility-controls-for-editor-blocks-pro' === basename( __DIR__ ),
					'premium_suffix'      => 'Pro',
					'has_premium_version' => true,
					'has_addons'          => false,
					'has_paid_plans'      => true,
					'is_org_compliant'    => true,
					'menu'                => array(
						'slug'    => 'gbvc-settings',
						'support' => false,
						'parent'  => array(
							'slug' => 'options-general.php',
						),
					),
				)
			);
		}

		return $gbvc_fs;
	}

	// Init Freemius.
	gbvc_fs();
	// Signal that SDK was initiated.
	do_action( 'gbvc_fs_loaded' );
}


define( 'GBVC_PLUGIN_FILE', __FILE__ );
define( 'GBVC_PLUGIN_DIR', __DIR__ . '/' );

require_once GBVC_PLUGIN_DIR . 'includes/plugin.php';
