-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
184 additions
and
108 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
<?php | ||
|
||
namespace DummyNamespace; | ||
|
||
use Log1x\AcfComposer\Block; | ||
use Log1x\AcfComposer\Builder; | ||
|
||
class DummyClass extends Block | ||
{ | ||
/** | ||
* The block slug. | ||
* | ||
* @var string | ||
*/ | ||
public $slug = 'DummySnake'; | ||
|
||
/** | ||
* The block category. | ||
* | ||
* @var string | ||
*/ | ||
public $category = 'DummyCategory'; | ||
|
||
/** | ||
* The block icon. | ||
* | ||
* @var string|array | ||
*/ | ||
public $icon = 'editor-ul'; | ||
|
||
/** | ||
* The block keywords. | ||
* | ||
* @var array | ||
*/ | ||
public $keywords = []; | ||
|
||
/** | ||
* The block post type allow list. | ||
* | ||
* @var array | ||
*/ | ||
public $post_types = [DummyPostTypes]; | ||
|
||
/** | ||
* The parent block type allow list. | ||
* | ||
* @var array | ||
*/ | ||
public $parent = []; | ||
|
||
/** | ||
* The ancestor block type allow list. | ||
* | ||
* @var array | ||
*/ | ||
public $ancestor = []; | ||
|
||
/** | ||
* The default block mode. | ||
* | ||
* @var string | ||
*/ | ||
public $mode = 'preview'; | ||
|
||
/** | ||
* The default block alignment. | ||
* | ||
* @var string | ||
*/ | ||
public $align = ''; | ||
|
||
/** | ||
* The default block text alignment. | ||
* | ||
* @var string | ||
*/ | ||
public $align_text = ''; | ||
|
||
/** | ||
* The default block content alignment. | ||
* | ||
* @var string | ||
*/ | ||
public $align_content = ''; | ||
|
||
/** | ||
* The supported block features. | ||
* | ||
* @var array | ||
*/ | ||
public $supports = [ | ||
DummySupports | ||
]; | ||
|
||
/** | ||
* The block styles. | ||
* | ||
* @var array | ||
*/ | ||
public $styles = ['light', 'dark']; | ||
|
||
/** | ||
* The block preview example data. | ||
* | ||
* @var array | ||
*/ | ||
public $example = [ | ||
'items' => [ | ||
['item' => 'Item one'], | ||
['item' => 'Item two'], | ||
['item' => 'Item three'], | ||
], | ||
]; | ||
|
||
/** | ||
* The block template. | ||
* | ||
* @var array | ||
*/ | ||
public $template = [ | ||
'core/heading' => ['placeholder' => 'Hello World'], | ||
'core/paragraph' => ['placeholder' => 'Welcome to the DummyTitle block.'], | ||
]; | ||
|
||
/** | ||
* The block name. | ||
*/ | ||
public function getName(): string | ||
{ | ||
return __('DummyTitle', 'sage'); | ||
} | ||
|
||
/** | ||
* The block description. | ||
*/ | ||
public function getDescription(): string | ||
{ | ||
return __('DummyDescription', 'sage'); | ||
} | ||
|
||
/** | ||
* Data to be passed to the block before rendering. | ||
*/ | ||
public function with(): array | ||
{ | ||
return [ | ||
'items' => $this->items(), | ||
]; | ||
} | ||
|
||
/** | ||
* The block field group. | ||
*/ | ||
public function fields(): array | ||
{ | ||
$fields = Builder::make('DummySnake'); | ||
|
||
$fields | ||
->addRepeater('items') | ||
->addText('item') | ||
->endRepeater(); | ||
|
||
return $fields->build(); | ||
} | ||
|
||
/** | ||
* Retrieve the items. | ||
* | ||
* @return array | ||
*/ | ||
public function items() | ||
{ | ||
return get_field('items') ?: $this->example['items']; | ||
} | ||
|
||
/** | ||
* Assets enqueued when rendering the block. | ||
*/ | ||
public function assets(array $block): void | ||
{ | ||
// | ||
} | ||
} |