You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

132 lines
3.0 KiB

<?php
use WordPlate\Acf\Fields\ColorPicker;
use WordPlate\Acf\Fields\File;
use WordPlate\Acf\Fields\Image;
use WordPlate\Acf\Location;
/**
* The admin-specific functionality of the plugin.
*
* @link https://horizontes.info
* @since 1.0.0
*
* @package Reuna_Blocos
* @subpackage Reuna_Blocos/admin
*/
/**
* The admin-specific functionality of the plugin.
*
* Defines the plugin name, version, and two examples hooks for how to
* enqueue the admin-specific stylesheet and JavaScript.
*
* @package Reuna_Blocos
* @subpackage Reuna_Blocos/admin
* @author Horizontes Coop. <contato@horizontes.info>
*/
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/material.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'),
File::make('Arquivo (online)'),
File::make('Arquivo (impressão)'),
ColorPicker::make('Cor')->defaultValue('#F15A31'),
],
'location' => [
Location::if('block', 'acf/material'),
],
]);
}
}