webdevstudios / wds-acf-blocks Goto Github PK
View Code? Open in Web Editor NEWA set of custom Gutenberg blocks built with Advanced Custom Fields Pro.
A set of custom Gutenberg blocks built with Advanced Custom Fields Pro.
Please remove all custom NPM Scripts in favor of @wordpress/scripts.
You can see an example in the WDS Block Starter repo
"scripts": {
"start": "wp-scripts start",
"dev": "wp-scripts start",
"watch": "wp-scripts start",
"build": "wp-scripts build",
"lint:css": "wp-scripts lint-style",
"lint:js": "wp-scripts lint-js",
"lint:php": "composer run lint",
"packages-update": "wp-scripts packages-update",
"postinstall": "wp-scripts build && composer install"
}
By default, a user is met with this terrible UX. All the fields are in the sidebar. @asharirfan can you write a blurb in the README (with screenshots) explaining to the user they should click the pencil icon?
Thanks
We should fix the following warnings that I am getting on PHP 8.0:
[04-Nov-2022 14:20:33 UTC] PHP Deprecated: Required parameter $defaults follows optional parameter $args in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/get-formatted-args.php on line 18
[04-Nov-2022 14:20:33 UTC] PHP Deprecated: Required parameter $args follows optional parameter $module_name in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/print-module.php on line 18
[04-Nov-2022 14:20:33 UTC] PHP Deprecated: Required parameter $abs_defaults follows optional parameter $abs_args in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/setup-block-defaults.php on line 23
[04-Nov-2022 14:20:34 UTC] PHP Deprecated: Required parameter $defaults follows optional parameter $args in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/get-formatted-args.php on line 18
[04-Nov-2022 14:20:34 UTC] PHP Deprecated: Required parameter $args follows optional parameter $module_name in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/print-module.php on line 18
[04-Nov-2022 14:20:34 UTC] PHP Deprecated: Required parameter $abs_defaults follows optional parameter $abs_args in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/setup-block-defaults.php on line 23
[04-Nov-2022 14:20:35 UTC] PHP Deprecated: Required parameter $defaults follows optional parameter $args in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/get-formatted-args.php on line 18
[04-Nov-2022 14:20:35 UTC] PHP Deprecated: Required parameter $args follows optional parameter $module_name in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/print-module.php on line 18
[04-Nov-2022 14:20:35 UTC] PHP Deprecated: Required parameter $abs_defaults follows optional parameter $abs_args in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/setup-block-defaults.php on line 23
[04-Nov-2022 14:20:35 UTC] PHP Deprecated: Required parameter $defaults follows optional parameter $args in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/get-formatted-args.php on line 18
[04-Nov-2022 14:20:35 UTC] PHP Deprecated: Required parameter $args follows optional parameter $module_name in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/print-module.php on line 18
[04-Nov-2022 14:20:35 UTC] PHP Deprecated: Required parameter $abs_defaults follows optional parameter $abs_args in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/setup-block-defaults.php on line 23
[04-Nov-2022 14:20:36 UTC] PHP Warning: Undefined variable $random_identifier in /Users/asharirfan/code/south-college-wds/app/public/wp-content/themes/south-college/searchform.php on line 13
[04-Nov-2022 14:20:36 UTC] PHP Warning: Undefined variable $random_identifier in /Users/asharirfan/code/south-college-wds/app/public/wp-content/themes/south-college/searchform.php on line 15
[04-Nov-2022 14:20:36 UTC] PHP Deprecated: Required parameter $defaults follows optional parameter $args in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/get-formatted-args.php on line 18
[04-Nov-2022 14:20:36 UTC] PHP Deprecated: Required parameter $args follows optional parameter $module_name in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/print-module.php on line 18
[04-Nov-2022 14:20:36 UTC] PHP Deprecated: Required parameter $abs_defaults follows optional parameter $abs_args in /Users/asharirfan/code/south-college-wds/app/public/wp-content/plugins/wds-acf-blocks/inc/helpers/setup-block-defaults.php on line 23
Please review the blocks in wd_s, and bring any changes forward into this repo.
I am getting the following errors in my debug.log
file when I try to add the ACF block to the editor.
[16-Sep-2020 12:09:09 UTC] PHP Notice: Undefined index: other_options in /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php on line 297
[16-Sep-2020 12:09:09 UTC] PHP Stack trace:
[16-Sep-2020 12:09:09 UTC] PHP 1. {main}() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-admin/admin-ajax.php:0
[16-Sep-2020 12:09:09 UTC] PHP 2. do_action() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-admin/admin-ajax.php:176
[16-Sep-2020 12:09:09 UTC] PHP 3. WP_Hook->do_action() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/plugin.php:478
[16-Sep-2020 12:09:09 UTC] PHP 4. WP_Hook->apply_filters() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/class-wp-hook.php:311
[16-Sep-2020 12:09:09 UTC] PHP 5. acf_ajax_fetch_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/class-wp-hook.php:287
[16-Sep-2020 12:09:09 UTC] PHP 6. acf_rendered_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:576
[16-Sep-2020 12:09:09 UTC] PHP 7. acf_render_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:303
[16-Sep-2020 12:09:09 UTC] PHP 8. wds_acf_blocks_acf_block_registration_callback() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:350
[16-Sep-2020 12:09:09 UTC] PHP 9. wds_acf_blocks_display_expired_block_message() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php:577
[16-Sep-2020 12:09:09 UTC] PHP 10. wds_acf_blocks_get_block_expired_class() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php:318
[16-Sep-2020 12:09:09 UTC] PHP Notice: Undefined index: other_options in /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php on line 297
[16-Sep-2020 12:09:09 UTC] PHP Stack trace:
[16-Sep-2020 12:09:09 UTC] PHP 1. {main}() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-admin/admin-ajax.php:0
[16-Sep-2020 12:09:09 UTC] PHP 2. do_action() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-admin/admin-ajax.php:176
[16-Sep-2020 12:09:09 UTC] PHP 3. WP_Hook->do_action() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/plugin.php:478
[16-Sep-2020 12:09:09 UTC] PHP 4. WP_Hook->apply_filters() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/class-wp-hook.php:311
[16-Sep-2020 12:09:09 UTC] PHP 5. acf_ajax_fetch_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/class-wp-hook.php:287
[16-Sep-2020 12:09:09 UTC] PHP 6. acf_rendered_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:576
[16-Sep-2020 12:09:09 UTC] PHP 7. acf_render_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:303
[16-Sep-2020 12:09:09 UTC] PHP 8. wds_acf_blocks_acf_block_registration_callback() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:350
[16-Sep-2020 12:09:09 UTC] PHP 9. include() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php:581
[16-Sep-2020 12:09:09 UTC] PHP 10. wds_acf_blocks_get_block_classes() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/template-parts/content-blocks/block-wds-accordion.php:14
[16-Sep-2020 12:09:09 UTC] PHP 11. wds_acf_blocks_get_block_expired_class() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php:278
[16-Sep-2020 12:09:09 UTC] PHP Notice: Undefined index: background_options in /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php on line 431
[16-Sep-2020 12:09:09 UTC] PHP Stack trace:
[16-Sep-2020 12:09:09 UTC] PHP 1. {main}() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-admin/admin-ajax.php:0
[16-Sep-2020 12:09:09 UTC] PHP 2. do_action() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-admin/admin-ajax.php:176
[16-Sep-2020 12:09:09 UTC] PHP 3. WP_Hook->do_action() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/plugin.php:478
[16-Sep-2020 12:09:09 UTC] PHP 4. WP_Hook->apply_filters() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/class-wp-hook.php:311
[16-Sep-2020 12:09:09 UTC] PHP 5. acf_ajax_fetch_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/class-wp-hook.php:287
[16-Sep-2020 12:09:09 UTC] PHP 6. acf_rendered_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:576
[16-Sep-2020 12:09:09 UTC] PHP 7. acf_render_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:303
[16-Sep-2020 12:09:09 UTC] PHP 8. wds_acf_blocks_acf_block_registration_callback() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:350
[16-Sep-2020 12:09:09 UTC] PHP 9. include() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php:581
[16-Sep-2020 12:09:09 UTC] PHP 10. wds_acf_blocks_display_block_options() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/template-parts/content-blocks/block-wds-accordion.php:21
[16-Sep-2020 12:09:09 UTC] PHP Notice: Undefined index: other_options in /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php on line 440
[16-Sep-2020 12:09:09 UTC] PHP Stack trace:
[16-Sep-2020 12:09:09 UTC] PHP 1. {main}() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-admin/admin-ajax.php:0
[16-Sep-2020 12:09:09 UTC] PHP 2. do_action() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-admin/admin-ajax.php:176
[16-Sep-2020 12:09:09 UTC] PHP 3. WP_Hook->do_action() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/plugin.php:478
[16-Sep-2020 12:09:09 UTC] PHP 4. WP_Hook->apply_filters() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/class-wp-hook.php:311
[16-Sep-2020 12:09:09 UTC] PHP 5. acf_ajax_fetch_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/class-wp-hook.php:287
[16-Sep-2020 12:09:09 UTC] PHP 6. acf_rendered_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:576
[16-Sep-2020 12:09:09 UTC] PHP 7. acf_render_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:303
[16-Sep-2020 12:09:09 UTC] PHP 8. wds_acf_blocks_acf_block_registration_callback() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:350
[16-Sep-2020 12:09:09 UTC] PHP 9. include() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php:581
[16-Sep-2020 12:09:09 UTC] PHP 10. wds_acf_blocks_display_block_options() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/template-parts/content-blocks/block-wds-accordion.php:21
[16-Sep-2020 12:09:09 UTC] PHP Notice: Undefined index: display_options in /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php on line 452
[16-Sep-2020 12:09:09 UTC] PHP Stack trace:
[16-Sep-2020 12:09:09 UTC] PHP 1. {main}() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-admin/admin-ajax.php:0
[16-Sep-2020 12:09:09 UTC] PHP 2. do_action() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-admin/admin-ajax.php:176
[16-Sep-2020 12:09:09 UTC] PHP 3. WP_Hook->do_action() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/plugin.php:478
[16-Sep-2020 12:09:09 UTC] PHP 4. WP_Hook->apply_filters() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/class-wp-hook.php:311
[16-Sep-2020 12:09:09 UTC] PHP 5. acf_ajax_fetch_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/class-wp-hook.php:287
[16-Sep-2020 12:09:09 UTC] PHP 6. acf_rendered_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:576
[16-Sep-2020 12:09:09 UTC] PHP 7. acf_render_block() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:303
[16-Sep-2020 12:09:09 UTC] PHP 8. wds_acf_blocks_acf_block_registration_callback() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:350
[16-Sep-2020 12:09:09 UTC] PHP 9. include() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php:581
[16-Sep-2020 12:09:09 UTC] PHP 10. wds_acf_blocks_display_block_options() /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/template-parts/content-blocks/block-wds-accordion.php:21
Please make sure this repo passes all current WDS Coding Standards via PHPCS, ESLint, Stylelint.
@asharirfan I have checked this plugin into version control. I ran npm install
. Now, I want to deploy my plugin.
I can't because /build
is ignore all my newly compiled files.
I will either have to:
/build
directory from my .gitignore
I don't think most users will have a CI/CD pipeline. We should probably allow the /build
directory. This will also help fix #18 if we check-in a build to this repo.
Thanks
@asharirfan I installed the plugin and activated and was greeted with a white screen of death.
On this line https://github.com/WebDevStudios/wds-acf-blocks/blob/main/inc/scripts.php#L22 can we run a conditional check for the /build/
diretory first?
If it's not there, can we tell the user to go run npm install
vs. getting a PHP error?
Thanks
Check if ACF 6.0 is available if not deactivate the plugin
Please write both user and developer facing documentation. Include screenshots and/or screencasts.
Hi,
Love the print_block function. Great for scaffolding or hardcoding some blocks in templates. What would the best practice be for enqueuing the block's css/js? When using a block normally, as you know, the css/js is enqueued. I was thinking of adding the css/js to the global css/scripts but that doesn't seem like the best solution. We would ideally want it to load only if the block is utilized.
I did modify the print_block function to enqueue but unsure if it's the best way to do it. It does the job but isn't my favorite. If this block is used in gutenberg, then the css / js is called twice. I was trying to think of a way to prevent that but I'm not sure of the block handles to prevent multiple enqueues of the same css/js.
function print_block( $block_name = '', $args = [] ) {
if ( ! $block_name ) {
return;
}
// extract args.
if ( ! empty( $args ) ) {
extract( $args ); //phpcs:ignore WordPress.PHP.DontExtract.extract_extract -- We can use it here since we know what to expect on the arguments.
}
wp_enqueue_style(
"$block_name-style",
get_theme_file_uri( "build/blocks/$block_name/style-script.css" ),
array(),
1.0
);
wp_enqueue_script(
"$block_name-script",
get_theme_file_path( "build/blocks/$block_name/script.js" ),
array(),
1.0
);
require get_template_directory() . '/src/blocks/' . $block_name . '/' . $block_name . '.php';
}
Any thoughts?
composer/installers
is now at version 2.0 but most of our other plugins specify ^1.5 - 1.5 was the last version anything WP related was added. In order to not create mass conflicts, we're likely going to have to do this on most of our plugins during the migration period to Composer 2 and PHP8:
"composer/installers":"^1.5 || ^2.0",
I am getting an undefined function error whenever I try to publish a post with the Recent Posts
block. I have tried searching for the function and it is not present in the repository.
Error details:
[09-Sep-2020 19:14:02 UTC] PHP Fatal error: Uncaught Error: Call to undefined function wds_acf_blocks_get_recent_posts_query_arguments() in /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/template-parts/content-blocks/block-wds-recent-posts.php:25
Stack trace:
#0 /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/inc/template-tags.php(581): include()
#1 /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php(350): wds_acf_blocks_acf_block_registration_callback(Array, '', false, 61)
#2 /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php(303): acf_render_block(Array, '', false, 61)
#3 /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-includes/class-wp-block.php(217): acf_rendered_block(Array, '', false)
#4 /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/gutenberg/lib/compat.php(431): WP_Block->rend in /Users/asharirfan/Documents/code/wds-acf-blocks/app/public/wp-content/plugins/wds-acf-blocks/template-parts/content-blocks/block-wds-recent-posts.php on line 25
@asharirfan Could you please add this to README?
https://github.com/WebDevStudios/wds-acf-blocks/blob/main/inc/hooks.php#L27
Release 1.0.0. π₯³
Create a command on wp-cli
to create a template for new blocks.
The plugin did not work when we were about to use it for VivaEve and I had to put back the functionality inside the theme to get it to work.
Had to use render_template
instead of the render_callback
function wds_acf_blocks_acf_block_registration_callback
to get the block's HTML output.
Please test these blocks with the latest version of the ACF Pro and the Gutenberg plugin.
Feel free to log any issues as Github issues (set the milestone to 1.0.0), so we can work through them.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.