# wpfunnels/3.13.1/includes/core/widgets/block/class-manager.php

WPFunnels – Funnel Builder for WooCommerce with Checkout &amp; One Click Upsell, version 3.13.1. 241 lines.

- Page: https://pluginprobe.com/plugins/wpfunnels/3.13.1/code/includes/core/widgets/block/class-manager.php
- Raw: https://pluginprobe.com/plugins/wpfunnels/3.13.1/raw/includes/core/widgets/block/class-manager.php
- Modified: 2026-04-07T09:00:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wpfunnels/3.13.1/code/includes/core/widgets/block/class-manager.php#L10-L20`.

```php
<?php
/**
 * Gutenberg widgets manager
 * 
 * @package
 */
namespace WPFunnels\Widgets\Gutenberg;

use WPFunnels\Wpfnl;
use WPFunnels\Wpfnl_functions;

/**
 * BlockTypesController class.
 *
 * @since    5.0.0
 * @internal
 */
final class Manager {

    /**
     * Instance
     *
     * @since 1.0.0
     *
     * @access private
     * @static
     *
     * @var Gutenberg_Block The single instance of the class.
     */
    private static $_instance = null;


    /**
     * Instance
     *
     * Ensures only one instance of the class is loaded or can be loaded.
     *
     * @return Gutenberg_Block An instance of the class.
     * @since  1.0.0
     *
     * @access public
     * @static
     */
    public static function instance()
    {

        if (is_null(self::$_instance)) {
            self::$_instance = new self();
        }
        return self::$_instance;

    }

    public function __construct(  ) {
        $this->init();
    }

    /**
     * Initialize class features.
     */
    protected function init() {
        add_action('enqueue_block_editor_assets', array( $this, 'wpfnl_checkout_block_editor_assets' ));
        add_action( 'init', array( $this, 'register_assets' ) );
        add_action( 'init', array( $this, 'register_blocks' ) );
		add_action( 'wp_footer', array( $this, 'wpfnl_inline_footer_scripts' ) );
		add_action( 'wp_head', array( $this, 'add_block_inline_css' ), 100 );
		add_filter( 'block_categories_all', array( $this, 'register_block_category' ), 10, 2 );
		new Wpfnl_Gutenberg_Editor();
	}

    /**
     * Inline jquery for editor-end floating label checkout.
     */
    public function wpfnl_checkout_block_editor_assets() {
        wp_enqueue_script( 'wpfunnels-editor-script', plugins_url( 'block/wpfunnels-editor-script.js', __DIR__ ), ['jquery'], WPFNL_VERSION, true );
        $this->enqueue_imported_template_inline_css();
        
        $post_id = get_the_ID();
        if ( ! $post_id && isset($_GET['post']) ) {
            $post_id = intval($_GET['post']);
        }
        
        if ( 'yes' === (get_post_meta($post_id, '_wpfnl_enhanced_phone_field_enabled', true) ? get_post_meta($post_id, '_wpfnl_enhanced_phone_field_enabled', true) : 'no') ) {
            wp_enqueue_style('intl-tel-input-style', WPFNL_URL . 'public/assets/phone/css/intlTelInput.css', array(), WPFNL_VERSION);
            wp_enqueue_script('intl-tel-input-script', WPFNL_URL . 'public/assets/phone/js/intlTelInput.min.js', array('jquery'), WPFNL_VERSION, true);
            wp_enqueue_script('intl-tel-input-utils', WPFNL_URL . 'public/assets/phone/js/utils.js', array('intl-tel-input-script'), WPFNL_VERSION, true);
            
            wp_localize_script(
                'wpfunnels-editor-script',
                'wpfnl_obj',
                [
                    'phone_utils_url' => WPFNL_URL . 'public/assets/phone/js/utils.js',
                    'phone_help_text' => get_post_meta($post_id, '_wpfnl_phone_help_text', true) ? get_post_meta($post_id, '_wpfnl_phone_help_text', true) : '',
                ]
            );
        }
    }

    /**
     * Enqueue imported Gutenberg template inline CSS in editor mode.
     */
    private function enqueue_imported_template_inline_css() {
        $post_id = get_the_ID();

        if ( ! $post_id && isset( $_GET['post'] ) ) {
            $post_id = intval( $_GET['post'] );
        }

        if ( ! $post_id ) {
            return;
        }

        $custom_css = get_post_meta( $post_id, 'rex_gutenberg_css', true );

        if ( ! $custom_css ) {
            return;
        }

        wp_register_style( 'rex-gutenberg-css', false );
        wp_enqueue_style( 'rex-gutenberg-css' );
        wp_add_inline_style( 'rex-gutenberg-css', $custom_css );
    }

    
    /**
     * Register blocks, hooking up assets and render functions as needed.
     */
    public function register_blocks() {
        $block_types = $this->get_block_types();

        foreach ( $block_types as $block_type ) {
            $block_type_class    = __NAMESPACE__ . '\\BlockTypes\\' . $block_type;
            $block_type_instance = new $block_type_class();
        }
    }


    /**
     * Get list of block types.
     *
     * @return array
     */
    protected function get_block_types() {
        $block_types = array(
            'NextStepButton',
            'CheckoutForm',
            'OrderDetails',
            'OptinForm',
        );
        
        // Add OfferButton only if Pro is not active
        if ( ! Wpfnl_functions::is_wpfnl_pro_activated() ) {
            $block_types[] = 'OfferButton';
        }
        
        return apply_filters('wpfunnels/gutenberg_block_types', $block_types);
    }


	/**
	 * Register assets for gutenberg
	 *
	 * @since 2.0.3
	 */
    public function register_assets() {
        wp_register_style( 'wpfnl-blocks-editor-style', plugins_url( 'block/assets/dist/wpfnl-blocks-editor-style.css', __DIR__ ), [], '2.0.3', 'all' );
        wp_register_style( 'wpfnl-blocks-style',plugins_url( 'block/assets/dist/wpfnl-blocks-style.css', __DIR__ ), [], '2.0.3', 'all' );
    }


	/**
	 * Load Inline Footer Script
	 *
	 * @since 1.3.0
	 */
	public function wpfnl_inline_footer_scripts() {
		global $wp_query;
		$is_previewing= $wp_query->is_preview();
		$can_edit= current_user_can( 'edit_posts' );
		if($is_previewing || $can_edit){
			?>
			<script>
				// Set Preview CSS
				document.addEventListener("DOMContentLoaded", function() {
					const cussrent_url = window.location.href;
					let cssInline = document.createElement('style');
					cssInline.type = 'text/css';
					cssInline.id = 'wpfnl-block-js-preview';
					cssInline.innerHTML =JSON.parse( localStorage.getItem('qubelyCSS'));
					window.document.getElementsByTagName("head")[0].appendChild(cssInline);
				})

			</script>
			<?php
		}
	}


	/**
	 * Check current post page open and css path exists
	 * Then read the css file content from css path
	 * Then add inline css to the header
	 */
	public function add_block_inline_css() {
		$upload_dir     = wp_get_upload_dir();
		$upload_css_dir = trailingslashit( $upload_dir['basedir'] );
		$post_id = get_the_ID();
		if ( $post_id ) {
			$css_path       = $upload_css_dir . "wpfunnels/css/wpfnl-css-{$post_id}.css";
			$json_path      = $upload_css_dir . "wpfunnels/css/wpfnl-json-{$post_id}.json";

			if ( file_exists( $css_path ) ) {
				$blockCss = file_get_contents( $css_path );
				echo '<style type="text/css">' . $blockCss . '</style>';
			} else {
				echo '<style type="text/css">' . get_post_meta( get_the_ID(), '_wpfunnels_gb_css', true ) . '</style>';
			}
		}
	}

	/**
	 * Register WPFunnels block category
	 *
	 * @param array $categories Block categories.
	 * @param object $post Post object.
	 * @return array Modified block categories.
	 */
	public function register_block_category( $categories, $post ) {
		return array_merge(
			$categories,
			array(
				array(
					'slug'  => 'wpfunnels',
					'title' => __( 'WPFunnels', 'wpfnl' ),
					'icon'  => null,
				),
			)
		);
	}
}

```
