<?php
/**
 *
 * @package productive-forms
 */

if ( !defined('ABSPATH') ) {
    die();
}

function productive_forms_register_block_init_blog_meta() {
    $asset_file = include( PRODUCTIVE_FORMS_PLUGIN_PATH . 'includes/common/post-type/blocks/blog-meta/build/index.asset.php');
    wp_enqueue_script( 
        'productive-forms-blog-meta-script', 
        PRODUCTIVE_FORMS_PLUGIN_URI . 'includes/common/post-type/blocks/blog-meta/build/index.js', 
        $asset_file['dependencies'], 
        $asset_file['version']
    );
}

function productive_forms_register_block_init_content_element_meta() {
    $asset_file = include( PRODUCTIVE_FORMS_PLUGIN_PATH . 'includes/common/post-type/blocks/content-element/build/index.asset.php');
    wp_enqueue_script( 
        'productive-forms-content-element-meta-script', 
        PRODUCTIVE_FORMS_PLUGIN_URI . 'includes/common/post-type/blocks/content-element/build/index.js', 
        $asset_file['dependencies'], 
        $asset_file['version']
    );
}

function productive_forms_is_register_block_init_blog_meta() {
  $current_screen = get_current_screen();
  if( $current_screen ->id === PRODUCTIVE_FORMS_PLUGIN_BLOG_ELEMENT_POST_TYPE_SLUG ) {
    add_action( 'enqueue_block_editor_assets', 'productive_forms_register_block_init_blog_meta' );
  } else if( $current_screen ->id === PRODUCTIVE_FORMS_PLUGIN_CONTENT_ELEMENT_POST_TYPE_SLUG ) {
    add_action( 'enqueue_block_editor_assets', 'productive_forms_register_block_init_content_element_meta' );
  }
}
add_action( 'current_screen', 'productive_forms_is_register_block_init_blog_meta' );