agence-adeliom / lumberjack-admin
Installs: 4 388
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: >=8.0.2
- rareloop/lumberjack-core: ^5.0|^6.0
- symfony/string: ^5.4|^6.0
- symfony/translation-contracts: ^3.0
- vinkla/extended-acf: ^13.0
- 1.x-dev
- 1.0.57
- 1.0.56
- 1.0.55
- 1.0.54
- 1.0.53
- 1.0.52
- 1.0.51
- 1.0.50
- 1.0.49
- 1.0.48
- 1.0.47
- 1.0.44
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-11-20 17:30:40 UTC
README
Register WordPress Admin ans ACF block interfaces.
Requirements
- PHP 8.0 or greater
- Composer
- Lumberjack
Installation
composer require agence-adeliom/lumberjack-admin
# Copy the configuration file
cp vendor/agence-adeliom/lumberjack-admin/config/gutenberg.php web/app/themes/YOUR_THEME/config/gutenberg.php
Register the service provider into web/app/themes/YOUR_THEME/config/app.php
'providers' => [ ... \Adeliom\Lumberjack\Admin\AdminProvider::class ]
Usage
Create an admin interface like for Options pages or Custom Post Types
Create your admin class to manage post types :
<?php namespace App\Admin; use Adeliom\Lumberjack\Admin\AbstractAdmin; use Traversable; class PostAdmin extends AbstractAdmin { public const TITLE = "Post edit interface"; /** * @see https://github.com/vinkla/extended-acf#fields * @return Traversable */ public static function getFields(): Traversable { yield Text::make('Post subtitle', 'subtitle'); } /** * @see https://github.com/vinkla/extended-acf#location */ public static function getLocation(): Traversable { yield Location::where('post_type', '==', 'post'); } }
Create your admin class to manage options :
<?php namespace App\Admin; use Adeliom\Lumberjack\Admin\AbstractAdmin; use Traversable; class OptionsAdmin extends AbstractAdmin { public const TITLE = "Options"; public const IS_OPTION_PAGE = true; /** * User defined ACF fields * @see https://github.com/vinkla/extended-acf#fields * @return \Traversable|null */ public static function getFields(): ?\Traversable { yield Text::make('Gtag code', 'gtag'); } }
Check the full class declaration at src/AbstractAdmin.php
Create a ACF Gutenberg block
<?php namespace App\Block; use Adeliom\Lumberjack\Admin\AbstractBlock; use Extended\ACF\Fields\WysiwygEditor;use Traversable; class WysiwygBlock extends AbstractBlock { public const NAME = "wysiwyg"; public const TITLE = "Text Editor"; public const DESCRIPTION = "Simple HTML content"; /** * User defined ACF fields * @see https://github.com/vinkla/extended-acf#fields * @return \Traversable|null */ public static function getFields(): ?\Traversable { yield WysiwygEditor::make('HTML Content', 'content'); } }
The twig template attached to this block is views/block/wysiwyg.html.twig
.
Edit Gutenberg settings
Add new categories
<?php //web/app/themes/YOUR_THEME/config/gutenberg.php return [ 'categories' => [ [ 'slug' => 'content', 'title' => __('Content'), 'icon' => null, ] ] ];
Globally disable blocks
<?php //web/app/themes/YOUR_THEME/config/gutenberg.php return [ ... 'settings' => [ ... "disable_blocks" => false ], ... ];
disable_blocks
can handle multiple type :
false
mean that all blocks are alloweda regex
you can use a regex to disallow every blocks matching this regex. ex./((core|yoast|yoast-seo|gravityforms)\/\w*)/
a array
you can use a array with wildcards. ex:[ 'core/*', 'yoast/breadcrumb' ]
Globally disable blocks
<?php //web/app/themes/YOUR_THEME/config/gutenberg.php return [ ... 'settings' => [ ... "disable_blocks" => false ], ... ];
disable_blocks
can handle multiple type :
false
mean that all blocks are alloweda regex
you can use a regex to disallow every blocks matching this regex. ex./((core|yoast|yoast-seo|gravityforms)\/\w*)/
a array
you can use a array with wildcards. ex:[ 'core/*', 'yoast/breadcrumb' ]
Configure Gutenberg
<?php //web/app/themes/YOUR_THEME/config/gutenberg.php return [ ... 'templates' => [ ... "KEY" => [...] ], ... ];
KEY
can handle multiple type :
- post type including custom post type. ex. post, page, project ...
- template ex. tpl-home.php
- id ex. 150
- post id ex. page-10
Settings
[ "enabled" => true, "blocks" => [], "template" => null, "template_lock" => null ]
enabled
: Ability to disable gutenberg for the key. true
by default
blocks
: List of allowed blocks. You can allow (ex. acf/text
, acf/*
) or disallow blocks (ex. !core/embed
, !core/*
)
template
: Allow specifying a default initial state for an editor. null
by default. see more
template_lock
: Ability to lock gutenberg for the key. null
by default. see more
License
Lumberjack Admin is released under the MIT License.