Skip to content

Instantly share code, notes, and snippets.

@frantorres
Created October 22, 2022 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frantorres/c455b8f5f654ae46e512bd75fd725bfc to your computer and use it in GitHub Desktop.
Save frantorres/c455b8f5f654ae46e512bd75fd725bfc to your computer and use it in GitHub Desktop.
Añadir variación de bloque en Gutenberg.
'use strict';
(function () {
const {__, _x, _n, _nx} = wp.i18n;
wp.blocks.registerBlockVariation(
'core/paragraph',
{
name: 'paragraph-variation',
title: __('Variación de párrafo', '_s'),
icon: 'star-filled',
attributes: {
className: 'paragraph-variation'
},
}
);
})();
add_action( 'enqueue_block_editor_assets', '_s_loadVariationsScript' ); //Variations of blocks.
function _s_loadVariationsScript(){
wp_enqueue_script(
'_s-block-variations',
get_stylesheet_directory_uri() . '/block-variations.js',
array( 'wp-blocks', 'wp-i18n' )
);
wp_set_script_translations( '_s-block-variations', '_s', get_template_directory().'/languages' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment