remove old style acf block
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\ACF;
|
||||
|
||||
class CloneGroup
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
public function block_background()
|
||||
{
|
||||
return [
|
||||
'contrast',
|
||||
'bg_colour',
|
||||
'bg_tint',
|
||||
];
|
||||
}
|
||||
|
||||
public function block_intro()
|
||||
{
|
||||
return [
|
||||
'overline',
|
||||
'heading',
|
||||
'blurb',
|
||||
'intro_alignment',
|
||||
];
|
||||
}
|
||||
|
||||
public function block_footer()
|
||||
{
|
||||
return [
|
||||
'blurb_footer',
|
||||
'links',
|
||||
'footer_alignment',
|
||||
];
|
||||
}
|
||||
|
||||
public function block_settings()
|
||||
{
|
||||
return [
|
||||
'section_anchor_id',
|
||||
'padding_top',
|
||||
'padding_bottom',
|
||||
'container_width',
|
||||
'angle_status',
|
||||
'angle_position',
|
||||
'angle_direction',
|
||||
'angle_colour',
|
||||
'angle_tint',
|
||||
];
|
||||
}
|
||||
|
||||
public function block_all()
|
||||
{
|
||||
return array_merge($this->block_intro(), $this->block_footer(), $this->block_settings(), $this->block_background());
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,7 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Blocks\\": "resources/views/acf-blocks"
|
||||
"App\\": "app/"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
@if(@$data['section_anchor_id'])
|
||||
<div id="{{ $data['section_anchor_id'] }}" class="section-anchor"></div>
|
||||
@endif
|
||||
|
||||
<section
|
||||
id="{{ $block['id'] }}"
|
||||
class="badegg-block
|
||||
@if(@$data['section_classes']) {{ implode(' ', $data['section_classes']) }} @endif
|
||||
{{ @$block['className'] }}
|
||||
">
|
||||
|
||||
<div class="section-{{ $block['name'] }}-inner">
|
||||
<div class="container container-{{ @$data['container_width'] ? $data['container_width'] : 'medium' }} block-content wysiwyg">
|
||||
<InnerBlocks
|
||||
allowedBlocks="{!! esc_attr( wp_json_encode( $data['allowed_blocks'] ) ) !!}"
|
||||
template="{!! esc_attr( wp_json_encode( $data['template'] ) ) !!}"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 40 KiB |
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Blocks\Editor;
|
||||
use App\Utilities;
|
||||
use App\ACF;
|
||||
|
||||
class Editor
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action('acf/init', [$this, 'init']);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
acf_register_block_type([
|
||||
'name' => 'badegg-editor',
|
||||
'title' => __('Text Editor'),
|
||||
'description' => __('Long form text content with support for things like headings, lists, and images.'),
|
||||
'render_callback' => [ $this, 'render'],
|
||||
'category' => 'badegg',
|
||||
'icon' => 'media-document',
|
||||
'supports' => [
|
||||
'align' => false,
|
||||
'jsx' => true,
|
||||
],
|
||||
'example' => [
|
||||
'attributes' => [
|
||||
'mode' => 'preview',
|
||||
'data' => [
|
||||
'inserter' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function render($block, string $content = '', bool $is_preview = false, int $post_id = 0)
|
||||
{
|
||||
$name = basename(__FILE__, '.php');
|
||||
$themeURL = get_template_directory_uri();
|
||||
|
||||
if($is_preview && @$block['data']['inserter']):
|
||||
echo '<img style="display: block; width: 100%" src="' . $themeURL . '/resources/views/acf-blocks/' . $name . '/' . $name . '.jpg" />';
|
||||
return;
|
||||
endif;
|
||||
|
||||
$CssClasses = new Utilities\CssClasses;
|
||||
$Colour = new Utilities\Colour;
|
||||
$CloneGroup = new ACF\CloneGroup;
|
||||
|
||||
$data = [];
|
||||
|
||||
$fields = [
|
||||
|
||||
];
|
||||
|
||||
$fields = array_merge($fields, $CloneGroup->block_all());
|
||||
|
||||
foreach($fields as $field):
|
||||
$data[$field] = get_field($field);
|
||||
endforeach;
|
||||
|
||||
unset($block['data']);
|
||||
$block['name'] = str_replace('acf/', '', $block['name']);
|
||||
|
||||
$data = array_merge($data, $block);
|
||||
$data['section_classes'] = $CssClasses->section($data);
|
||||
$data['allowed_blocks'] = \App\Blocks\list_inner();
|
||||
$data['template'] = $this->default_template();
|
||||
$data['block'] = $block;
|
||||
|
||||
echo \Roots\view("acf-blocks.$name.$name", [
|
||||
'data' => $data,
|
||||
'block' => $block,
|
||||
])->render();
|
||||
}
|
||||
|
||||
public function default_template()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'core/heading',
|
||||
[
|
||||
'level' => 1,
|
||||
'placeholder' => 'Heading',
|
||||
],
|
||||
],
|
||||
[
|
||||
'core/paragraph',
|
||||
[
|
||||
'placeholder' => 'You can type your own text, change the heading level, or delete it altogether. You can also type over this text.',
|
||||
],
|
||||
],
|
||||
[
|
||||
'core/paragraph',
|
||||
[
|
||||
'placeholder' => 'To adjust block settings, click the Text Editor icon floating above this block to display them in the sidebar.',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user