Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If you look at the top of setup.php you’ll see
- <?php
- namespace App;
- ?>
- This means that setup.php is in the App namespace. Whenever you pass callbacks to add_action or add_filter or whatever you must include the namespace. You can write the whole thing out, but in this context the easiest way is to use the __NAMESPACE__ magic constant. So something like this:
- <?php
- if( function_exists('acf_register_block_type') ) {
- add_action('acf/init', __NAMESPACE__.'\\register_acf_block_types');
- }
- ?>
- If you don’t anticipate needing to un-hook that action later, you can do what many of us do and pass an anonymous function as a callback instead:
- <?php
- if( function_exists('acf_register_block_type') ) {
- add_action('acf/init', function() {
- // register a testimonial block.
- acf_register_block_type(array(
- 'name' => 'testimonial',
- 'title' => __('Testimonial'),
- 'description' => __('A custom testimonial block.'),
- 'render_template' => 'app/Blocks/Testimonial/testimonial.php',
- 'category' => 'formatting',
- 'icon' => 'admin-comments',
- 'keywords' => array( 'testimonial', 'quote' ),
- ));
- });
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement