Skip to content

Commit

Permalink
Add support for mode and post_types
Browse files Browse the repository at this point in the history
Closes #4
  • Loading branch information
MWDelaney authored Mar 26, 2019
1 parent e61fc7a commit f263b3c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sage-acf-gutenberg-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@

// Check whether ACF exists before continuing
foreach ($directories as $dir) {

// Sanity check whether the directory we're iterating over exists first
if (!file_exists(\locate_template($dir))) {
return;
}

// Iterate over the directories provided and look for templates
$template_directory = new \DirectoryIterator(\locate_template($dir));

Expand All @@ -54,6 +54,8 @@
'category' => 'Category',
'icon' => 'Icon',
'keywords' => 'Keywords',
'mode' => 'Mode',
'post_types' => 'PostTypes',
]);

if (empty($file_headers['title'])) {
Expand All @@ -72,9 +74,15 @@
'category' => $file_headers['category'],
'icon' => $file_headers['icon'],
'keywords' => explode(' ', $file_headers['keywords']),
'mode' => $file_headers['mode'],
'render_callback' => __NAMESPACE__.'\\sage_blocks_callback',
];

// If the PostTypes header is set in the template, restrict this block to thsoe types
if (!empty($file_headers['post_types'])) {
$data['post_types'] = explode(' ', $file_headers['post_types']);
}

// Register the block with ACF
\acf_register_block($data);
}
Expand Down

0 comments on commit f263b3c

Please sign in to comment.