Skip to content

Commit b1cddc2

Browse files
committed
Merge branches 'master' and 'master' of github.com:40Q/acf-gutenberg
2 parents 23e2b27 + aff4c22 commit b1cddc2

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
<section class="">
1+
<section id="{{ $block->id }}" class="{{ $block->class }}" >
22
<div class="container">
33
<h2>{{ $block->title }}</h2>
44
<p>{{ $block->text }}</p>
55
<p>{{ $block->intro }}</p>
6+
<p>{{ $block->custom_prop }}</p>
67
</div>
78
</section>

resources/blocks/sample-block/sample-block.class.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ class SampleBlock extends Block
1818
public function init()
1919
{
2020
// Use this method in extended classes
21+
$this->set_custom_prop();
22+
}
23+
24+
public function set_custom_prop()
25+
{
26+
$this->custom_prop = "Here the custom prop for: ". $this->title;
2127
}
2228

2329
public function set_settings()

src/classes/Block.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ class Block
116116
'button' => false,
117117
];
118118

119+
public $theme_colors = [
120+
'primary' => 'Primary',
121+
'secondary' => 'Secondary',
122+
'light' => 'Light',
123+
'dark' => 'Dark',
124+
];
125+
119126
/**
120127
* Block constructor.
121128
*
@@ -130,6 +137,7 @@ public function __construct($block_slug)
130137
$this->set_class();
131138
$this->set_fields();
132139
$this->set_global_fields();
140+
$this->set_theme_colors();
133141
add_action('init', array($this, 'build_fields'));
134142
$this->set_props();
135143
$this->set_position();
@@ -188,6 +196,13 @@ public function set_global_fields()
188196

189197
}
190198

199+
public function set_theme_colors()
200+
{
201+
$colors = apply_filters( 'acfgb_theme_colors', $this->theme_colors);
202+
$this->theme_colors = $colors;
203+
204+
}
205+
191206
public function build_fields(){
192207
if (function_exists('acf_add_local_field_group')) {
193208

@@ -214,9 +229,9 @@ public function build_fields(){
214229
]
215230
])
216231
->addSelect('bg_color')
217-
->addChoices('green', 'orange', ['rose' => 'pink'], 'white')
232+
->addChoices($this->theme_colors)
218233
->addSelect('text_color')
219-
->addChoices('green', 'orange', ['rose' => 'pink'], 'white');
234+
->addChoices($this->theme_colors);
220235
}
221236

222237
if ($this->global_fields['block_id']){

src/lib/functions.php

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,6 @@ function my_acf_block_render_callback($block)
9494
}
9595

9696

97-
98-
/**
99-
* Modify
100-
*/
101-
function test()
102-
{
103-
wp_die('here');
97+
if (file_exists(get_template_directory() . "/acf-gutenberg/settings.php")) {
98+
include get_template_directory() . "/acf-gutenberg/settings.php";
10499
}
105-
//test();
106-
107-
108-
add_action( 'admin_menu', function (){
109-
add_options_page( 'My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', function (){
110-
echo '<div class="wrap">';
111-
echo '<p>Here is where the form would go if I actually had options.aaa</p>';
112-
echo '</div>';
113-
echo '<pre>';
114-
//print_r(Plugin::get_actions());
115-
echo '</pre>';
116-
echo '<pre>';
117-
print_r($GLOBALS['theme_blade_engine']);
118-
echo '</pre>';
119-
} );
120-
});

0 commit comments

Comments
 (0)