Change block icon and filtering keyword in Gutenberg blocks

dummy-blocks.php

<?php
/**
 * Plugin Name: Dummy Blocks
 * Plugin URI: https://github.com/sandeepjain2015/gutunburg-dummy-blocks.git
 * Plugin Description: Dummy Blocks is a plugin that allows you to add dummy blocks to your site.
 * Plugin Version: 1.0
 * Plugin Date: 2013-10-10
 * Plugin Author: Sandeep Jain
 * Plugin Author URI: https://sandeepjain.me/
 * 
 */

add_action( 'init', 'dummy_blocks_init' );

function dummy_blocks_init() {
	wp_enqueue_script(
		'dummy-block-editor-js',
		plugins_url( 'blocks/firstblock/index.js', __FILE__ ),
		array( 'wp-blocks', 'wp-i18n','wp-element' ),
		'3.5',
		true
	);
	register_block_type(
		'dummy-blocks/dummy-block',
		array(
			'editor_scripts' => '',
			'editor_styles'  => '',
		)
	);
}

index.js

var registerBlockType = wp.blocks.registerBlockType;
var __ = wp.i18n.__;
var el = wp.element.createElement;
registerBlockType(
    'dummyblock/firstblock',
    {
        title: __('First Block', 'dummy-blocks'),
        category: 'common',
        icon:{
            src:'format-audio',
            foreground:'white',
            background:'red'
        },
        keywords:[__('audio', 'dummy-blocks'),__('podcast', 'dummy-blocks')],
        attributes: {
            'class': {
                type: 'string',
                default: '',
            },
            'id': {
                type: 'string',
                default: '',
            },
            'style': {
                type: 'string',
                default: '',
            },
            'data-attribute': {
                type: 'string',

            },
            'data-value': {
                type: 'string',
            },
        },
        edit: function (props) {
            return el('p','first-block','edit code by react');
        },
        save: function (props) {
            return el('p','first-block','save code by react');
            
        },
    }
);

Leave a Comment

Your email address will not be published. Required fields are marked *