Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit 437c9a0

Browse files
committed
Merge branch 'feature/acf-page-builder-templates' into develop
2 parents 97e1b3e + 1373943 commit 437c9a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+8698
-75
lines changed

config/scaffold/wp-config-sample.php

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
* @link https://codex.wordpress.org/Debugging_in_WordPress
9191
*/
9292
define( 'WP_DEBUG', getenv( 'APP_DEBUG' ) === 'true' ? true : false );
93+
define( 'WP_DEBUG_DISPLAY', getenv( 'APP_DEBUG' ) === 'true' ? true : false );
9394

9495
if ( getenv( 'APP_ENV' ) !== 'local' ) {
9596
define( 'AUTOMATIC_UPDATER_DISABLED', true );

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Une liste (non exaustive) des commandes utiles de [WPCLI](https://wp-cli.org/fr/
6464
| `wp plugin activate` | Activer un plugin |
6565
| `wp plugin deactivate` | Désactiver un plugin |
6666
| `wp search-replace 'http://old-domain.com/' 'http://new-domain.com/' --precise --recurse-objects --all-tables-with-prefix` | Remplacer toutes les URL's pour migrer une base de données. ⚠ Faire un backup avant de lancer cette commande, ajouter le paramètre `–dry-run` pour lancer la commande sans effectuer de changements |
67-
| ` wp language core install fr_FR && wp language core activate fr_FR` | Installer une nouvelle langue de back-office (changer `fr_FR` par la langue souhaitée) |
67+
| `wp language core install fr_FR && wp language core activate fr_FR` | Installer une nouvelle langue de back-office (changer `fr_FR` par la langue souhaitée) |
6868

6969

7070
### Ajouter des plugins et mu-plugins

tailwind.config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @default https://github.com/studiometa/tailwind-config/blob/develop/src/index.js
66
*/
77
module.exports = {
8-
presets: [require('tailwindcss/defaultConfig'), require('@studiometa/tailwind-config')],
8+
presets: [require('tailwindcss/defaultConfig'), require('@studiometa/tailwind-config').config],
99
// Extends the default Studio Meta Tailwind configuration here...
1010
// plugins: [...],
1111
// theme: {...},
@@ -14,5 +14,8 @@ module.exports = {
1414
'./web/wp-content/themes/studiometa/src/js/**/*.js',
1515
'./web/wp-content/themes/studiometa/src/js/**/*.vue',
1616
'./web/wp-content/themes/studiometa/templates/**/*.twig',
17+
'./vendor/studiometa/ui/package/ui/**/*.twig',
18+
'./vendor/studiometa/ui/package/ui/**/*.js',
19+
'tailwind.safelist.txt',
1720
],
1821
};

tailwind.safelist.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
inset-0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
*
4+
* Abstract Block class.
5+
*
6+
* @see https://github.com/stoutlogic/acf-builder
7+
* @package Studiometa
8+
*/
9+
10+
namespace Studiometa\Blocks;
11+
12+
use StoutLogic\AcfBuilder\FieldsBuilder;
13+
14+
/** Interface **/
15+
abstract class AbstractBlock implements BlockInterface {
16+
/**
17+
* Get Field Block
18+
*
19+
* @param string $name key name.
20+
* @return FieldsBuilder
21+
*/
22+
public static function get_block( string $name ) {
23+
return new FieldsBuilder( $name );
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
*
4+
* Video Block for templating
5+
*
6+
* @see https://github.com/stoutlogic/acf-builder
7+
* @package Studiometa
8+
*/
9+
10+
namespace Studiometa\Blocks;
11+
12+
use StoutLogic\AcfBuilder\FieldsBuilder;
13+
14+
/** Class **/
15+
class Accordion extends AbstractBlock {
16+
17+
/**
18+
* Return Field block to use in template
19+
*
20+
* @param string $name block name.
21+
*/
22+
public static function get_block( $name = 'block_accordion' ) {
23+
$accordion_block = new FieldsBuilder( $name );
24+
$accordion_block
25+
->addText( 'title', array( 'label' => __( 'Titre du block', 'studiometa' ) ) )
26+
->addRepeater( 'list' )
27+
->addText( 'title', array( 'label' => __( 'Titre', 'studiometa' ) ) )
28+
->addWysiwyg( 'content', array( 'label' => __( 'Contenu', 'studiometa' ) ) )
29+
->endRepeater();
30+
31+
return $accordion_block;
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
*
4+
* Block Interface.
5+
*
6+
* @see https://github.com/stoutlogic/acf-builder
7+
* @package Studiometa
8+
*/
9+
10+
namespace Studiometa\Blocks;
11+
12+
use StoutLogic\AcfBuilder\FieldsBuilder;
13+
14+
/** Interface **/
15+
interface BlockInterface {
16+
17+
/**
18+
* Get field block
19+
*
20+
* @param string $name key name.
21+
* @return FieldsBuilder
22+
*/
23+
public static function get_block( string $name );
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
*
4+
* Image Block for templating
5+
*
6+
* @see https://github.com/stoutlogic/acf-builder
7+
* @package Studiometa
8+
*/
9+
10+
namespace Studiometa\Blocks;
11+
12+
use StoutLogic\AcfBuilder\FieldsBuilder;
13+
14+
/** Class **/
15+
class Image extends AbstractBlock {
16+
17+
/**
18+
* Return Field block to use in template
19+
*
20+
* @param string $name block name.
21+
*/
22+
public static function get_block( $name = 'block_image' ) {
23+
$image_block = new FieldsBuilder( $name );
24+
$image_block->addImage(
25+
'image',
26+
array(
27+
'label' => __( 'Image', 'studiometa' ),
28+
'instructions' => 'Format HD à privilégier',
29+
)
30+
);
31+
32+
return $image_block;
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
*
4+
* Video Block for templating
5+
*
6+
* @see https://github.com/stoutlogic/acf-builder
7+
* @package Studiometa
8+
*/
9+
10+
namespace Studiometa\Blocks;
11+
12+
use StoutLogic\AcfBuilder\FieldsBuilder;
13+
14+
/** Class **/
15+
class ImageText extends AbstractBlock {
16+
17+
/**
18+
* Return Field block to use in template
19+
*
20+
* @param string $name block name.
21+
*/
22+
public static function get_block( $name = 'block_image_text' ) {
23+
$push_block = new FieldsBuilder( $name );
24+
$push_block->addImage( 'image', array( 'label' => __( 'Image', 'studiometa' ) ) )
25+
->addWysiwyg( 'content', array( 'label' => __( 'Contenu', 'studiometa' ) ) )
26+
->addLink(
27+
'cta',
28+
array(
29+
'label' => __( 'Bouton CTA', 'studiometa' ),
30+
'instructions' => __( 'Ajoute un CTA, si non renseigné il ne sera pas visible', 'studiometa' ),
31+
'return_format' => 'array',
32+
),
33+
)
34+
->addRadio(
35+
'text_position',
36+
array(
37+
'label' => __( 'Position du bloc texte', 'studiometa' ),
38+
'default_value' => 'left',
39+
'choices' => array(
40+
'left' => __( 'Gauche', 'studiometa' ),
41+
'right' => __( 'Droite', 'studiometa' ),
42+
),
43+
)
44+
);
45+
46+
return $push_block;
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Blocks
2+
3+
Some default blocks we used in our projects
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
*
4+
* Video Block for templating
5+
*
6+
* @see https://github.com/stoutlogic/acf-builder
7+
* @package Studiometa
8+
*/
9+
10+
namespace Studiometa\Blocks;
11+
12+
use StoutLogic\AcfBuilder\FieldsBuilder;
13+
14+
/** Class **/
15+
class Text extends AbstractBlock {
16+
17+
/**
18+
* Return Field block to use in template
19+
*
20+
* @param string $name block name.
21+
*/
22+
public static function get_block( $name = 'block_wysiwyg' ) {
23+
$wysiwyg_block = new FieldsBuilder( $name );
24+
$wysiwyg_block->addWysiwyg(
25+
'content',
26+
array(
27+
'label' => __( 'Contenu', 'studiometa' ),
28+
'toolbar' => 'full',
29+
)
30+
);
31+
return $wysiwyg_block;
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
*
4+
* Video Block for templating
5+
*
6+
* @see https://github.com/stoutlogic/acf-builder
7+
* @package Studiometa
8+
*/
9+
10+
namespace Studiometa\Blocks;
11+
12+
use StoutLogic\AcfBuilder\FieldsBuilder;
13+
14+
/** Class **/
15+
class Video extends AbstractBlock {
16+
17+
/**
18+
* Return Field block to use in template
19+
*
20+
* @param string $name block name.
21+
*/
22+
public static function get_block( $name = 'block_video' ) {
23+
$video_block = new FieldsBuilder( $name );
24+
$video_block->addText( 'title', array( 'label' => __( 'Titre de la vidéo', 'studiometa' ) ) )
25+
->addFile(
26+
'video',
27+
array(
28+
'label' => __( 'Vidéo', 'studiometa' ),
29+
'instructions' => __( 'Format MP4 à privilégier', 'studiometa' ),
30+
)
31+
)
32+
->addImage(
33+
'video_cover',
34+
array(
35+
'label' => __( 'Image de couverture', 'studiometa' ),
36+
)
37+
)
38+
->addText(
39+
'video_legend',
40+
array(
41+
'label' => __( 'Légende vidéo', 'studiometa' ),
42+
'instructions' => __( 'Caché si non renseigné', 'studiometa' ),
43+
)
44+
);
45+
46+
return $video_block;
47+
}
48+
}

web/wp-content/themes/studiometa/app/Managers/ACFManager.php

+17-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@
1212

1313
use Studiometa\WPToolkit\Managers\ManagerInterface;
1414
use StoutLogic\AcfBuilder\FieldsBuilder;
15+
use Studiometa\Blocks\Accordion;
16+
use Studiometa\Blocks\Image;
17+
use Studiometa\Blocks\ImageText;
18+
use Studiometa\Blocks\Text;
19+
use Studiometa\Blocks\Video;
1520

1621
/** Class **/
1722
class ACFManager implements ManagerInterface {
1823
/**
1924
* {@inheritdoc}
2025
*/
2126
public function run() {
22-
add_action( 'acf/init', array( $this, 'register_acf_example_group' ) );
27+
add_action( 'acf/init', array( $this, 'register_acf_builder_group' ) );
2328
}
2429

2530
/**
@@ -28,10 +33,16 @@ public function run() {
2833
*
2934
* @return void
3035
*/
31-
public function register_acf_example_group() {
32-
$example_group = new FieldsBuilder( 'example_group' );
33-
$example_group->addImage( 'image' )
34-
->setLocation( 'post_type', '==', 'post' );
35-
acf_add_local_field_group( $example_group->build() );
36+
public function register_acf_builder_group() {
37+
$builder_group = new FieldsBuilder( 'builder_group', array( 'title' => 'Page builder' ) );
38+
// @phpstan-ignore-next-line
39+
$builder_group->addFlexibleContent( 'builder', array( 'button_label' => __( 'Ajouter section', 'studiometa' ) ) )
40+
->addLayout( Video::get_block() )
41+
->addLayout( ImageText::get_block() )
42+
->addLayout( Text::get_block() )
43+
->addLayout( Image::get_block() )
44+
->addLayout( Accordion::get_block() )
45+
->setLocation( 'page_template', '==', 'page-template-builder.php' );
46+
acf_add_local_field_group( $builder_group->build() );
3647
}
3748
}

0 commit comments

Comments
 (0)