0
0
Wordpressframework~10 mins

Why reusable content elements matter in Wordpress - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a reusable block in WordPress.

Wordpress
register_block_type('[1]', array('render_callback' => 'render_my_block'));
Drag options to blanks, or click blank then click option'
Amy-plugin/my-block
Bmy-block
Cplugin-block
Dblock/my-plugin
Attempts:
3 left
💡 Hint
Common Mistakes
Using a block name without a namespace
Using spaces in the block name
2fill in blank
medium

Complete the code to enqueue a script for your reusable block.

Wordpress
wp_enqueue_script('[1]', plugins_url('block.js', __FILE__), array('wp-blocks', 'wp-element'));
Drag options to blanks, or click blank then click option'
Amy-block-script
Bblock-script
Cscript-my-block
Denqueue-script
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic handle name
Forgetting to enqueue dependencies
3fill in blank
hard

Fix the error in the PHP code to register a reusable block category.

Wordpress
add_filter('block_categories_all', function($categories, $post) { return array_merge($categories, array(array('slug' => '[1]', 'title' => __('Custom Blocks')))); }, 10, 2);
Drag options to blanks, or click blank then click option'
AcustomBlocks
Bcustom-blocks
Ccustom blocks
Dcustom_blocks
Attempts:
3 left
💡 Hint
Common Mistakes
Using spaces in slug
Using underscores instead of hyphens
4fill in blank
hard

Fill both blanks to create a reusable block with attributes and save callback.

Wordpress
register_block_type('my-plugin/my-block', array('attributes' => array('content' => array('type' => '[1]')), 'render_callback' => '[2]'));
Drag options to blanks, or click blank then click option'
Astring
Brender_my_block
Carray
Dsave_my_block
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'array' as type for content
Confusing render and save callbacks
5fill in blank
hard

Fill all three blanks to create a reusable block with editor script, style, and save callback.

Wordpress
register_block_type('my-plugin/my-block', array('editor_script' => '[1]', 'style' => '[2]', 'render_callback' => '[3]'));
Drag options to blanks, or click blank then click option'
Amy-block-editor
Bmy-block-style
Crender_my_block
Dmy-block-script
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing script and style handles
Using incorrect callback function names