<?php

/**
 * Plugin Name: YGS Alternate Language
 * Plugin URI: https://theygsgroup.com
 * Description: Allows blocks to have alternate copy per vertical: Publisher, Corporation, Assoication
 * Version: 1.0.0
 * Author: The YGS Group
 *
 * @package ygs-contentlang
 */

defined( 'ABSPATH' ) || exit;

/**
 * Load all translations for our plugin from the MO file.
*/
add_action( 'init', 'ygs_contentlang_init' );

function ygs_contentlang_langauge_init() {
	load_plugin_textdomain( 'ygs-contentlang', false, basename( __DIR__ ) . '/languages' );
}

/**
 * Registers all block assets so that they can be enqueued through Gutenberg in
 * the corresponding context.
 *
 * Passes translations to JavaScript.
 */
function ygs_contentlang_register_block() {

	if ( ! function_exists( 'register_block_type' ) ) {
		// Gutenberg is not active.
		return;
	}

	wp_register_script(
		'ygs-contentlang',
		plugins_url( 'block.js', __FILE__ ),
		array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor', 'underscore' ),
		filemtime( plugin_dir_path( __FILE__ ) . 'block.js' )
	);

	wp_register_style(
		'ygs-contentlang',
		plugins_url( 'style.css', __FILE__ ),
		array( ),
		filemtime( plugin_dir_path( __FILE__ ) . 'style.css' )
	);
//MATT CONTINUE HERE:::::
	register_block_type( 'ygs-contentlang/alt-content', array(
		'style' => 'gutenberg-examples-05',
		'editor_script' => 'gutenberg-examples-05',
	) );

  if ( function_exists( 'wp_set_script_translations' ) ) {
    /**
     * May be extended to wp_set_script_translations( 'my-handle', 'my-domain',
     * plugin_dir_path( MY_PLUGIN ) . 'languages' ) ). For details see
     * https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/
     */
    wp_set_script_translations( 'gutenberg-examples-05', 'gutenberg-examples' );
  }

}
add_action( 'init', 'gutenberg_examples_05_register_block' );
