You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.
Simple block, renders and saves the same content without any interactivity.
*/
import { categories } from '../components/categories';
// Import CSS.
// import './editor.scss';
// import './style.scss';
@return {?WPBlock} The block, if it has been successfully
registered; otherwise `undefined`.
*/
registerBlockType( 'cgb/block-nh-blocks', {
// Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
title: __( 'nh-blocks - Latest Block' ), // Block title.
icon: 'shield', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
category: 'text', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
keywords: [
__( 'nh-blocks — Post Block' ),
__( 'Posts by Category' ),
__( 'create-guten-block' ),
],
attributes: {
categories: {
type: 'array' },
selectCategory: { type: 'string' },
},
/**
* The edit function describes the structure of your block in the context of the editor.
* This represents what the editor will render when the block is used.
*
* The "edit" property must be a valid function.
*
* @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
*
* @param {Object} props Props.
* @returns {Mixed} JSX Component.
*/
edit: ( props ) => {
// Creates a <p class='wp-block-cgb-block-nh-blocks'></p>.
if ( ! props.attributes.categories ) {
wp.apiFetch( {
url: '/wp-json/wp/v2/categories',
} ).then( categories => {
props.setAttributes( { categories: categories } );
} );
}
console.log( props.attributes.categories );
return (
<InspectorControls>
<PanelBody>
<PanelRow>
<label>Set Filter</label>
</PanelRow>
<PanelRow>
<categories />
</PanelRow>
</PanelBody>
</InspectorControls>
);
},
/**
* The save function defines the way in which the different attributes should be combined
* into the final markup, which is then serialized by Gutenberg into post_content.
*
* The "save" property must be specified and must be a valid function.
*
* @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
*
* @param {Object} props Props.
* @returns {Mixed} JSX Frontend HTML.
*/
save: ( { className, attributes, setAttributes } ) => {
return null;
},
`
/**
*/
import { categories } from '../components/categories';
// Import CSS.
// import './editor.scss';
// import './style.scss';
const { __ } = wp.i18n; // Import __() from wp.i18n
const { registerBlockType } = wp.blocks; // Import registerBlockType() from wp.blocks
const { PlainText, RichText, InspectorControls } = wp.editor;
const { Fragment } = wp.element;
const { TextControl, ToggleControl, Panel, PanelBody, PanelRow, SelectControl, Dropdown, Button, CheckboxControl } = wp.components;
/**
*/
registerBlockType( 'cgb/block-nh-blocks', {
// Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
title: __( 'nh-blocks - Latest Block' ), // Block title.
icon: 'shield', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
category: 'text', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
keywords: [
__( 'nh-blocks — Post Block' ),
__( 'Posts by Category' ),
__( 'create-guten-block' ),
],
} );
`
`
const { Component } = wp.element;
export class categories extends Component {
constructor( props ) {
super( ...arguments );
this.props = props;
}
}
`
The text was updated successfully, but these errors were encountered: