*/ class Reuna_Blocos_Admin { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts() { } /** * Register the assets for the block editor. * * @since 1.5.0 */ public function enqueue_block_editor_assets() { wp_enqueue_script('reuna-blocos/editor.js', plugin_dir_url(__FILE__) . 'dist/js/editor.js', ['wp-blocks', 'wp-dom-ready', 'wp-edit-post'], $this->version, true); } /** * Register the material block. * * @since 1.0.0 */ public function register_material_block_type() { acf_register_block_type([ 'name' => 'material', 'title' => __('Material', 'reuna-blocos'), 'description' => __('Material para download', 'reuna-blocos'), 'category' => 'common', 'icon' => 'media-default', 'keywords' => ['material', 'reuna'], 'render_template' => plugin_dir_path(__FILE__) . 'views/material.php', 'enqueue_assets' => function() { wp_enqueue_style('reuna-blocos/blocos.css', plugin_dir_url(__FILE__) . 'dist/css/blocos.css', [], $this->version); }, ]); } /** * Register the custom fields for the material block. * * @since 1.0.0 */ public function register_material_fields() { register_extended_field_group([ 'title' => 'Material', 'fields' => [ Image::make('Capa')->returnFormat('id'), Repeater::make('Arquivos')->fields([ File::make('Arquivo'), Text::make('Botão'), ]) ->layout('block') ->buttonLabel('Adicionar arquivo'), ColorPicker::make('Cor')->defaultValue('#F15A31'), ], 'location' => [ Location::if('block', 'acf/material'), ], ]); } }