← Back
Editing: list-posts.js
"use strict"; const { registerBlockType: customRegisterBlockTypef } = wp.blocks; const mygcel2 = wp.element.createElement; customRegisterBlockTypef( 'aiomatic-automatic-ai-content-writer/aiomatic-list', { title: 'AIomatic List Posts', icon: 'text', category: 'embed', attributes: { ruletype : { default: '', type: 'string', }, ruleid : { default: '', type: 'string', }, category : { default: '', type: 'string', }, posts : { default: '50', type: 'string', }, orderby : { default: 'title', type: 'string', }, order : { default: 'ASC', type: 'string', }, type : { default: 'any', type: 'string', } }, keywords: ['list', 'posts', 'aiomatic'], edit: (function( props ) { var ruletype = props.attributes.ruletype; var ruleid = props.attributes.ruleid; var category = props.attributes.category; var posts = props.attributes.posts; var orderby = props.attributes.orderby; var order = props.attributes.order; var type = props.attributes.type; function updateMessage( event ) { props.setAttributes( { ruletype: event.target.value} ); } function updateMessage2( event ) { props.setAttributes( { ruleid: event.target.value} ); } function updateMessage3( event ) { props.setAttributes( { category: event.target.value} ); } function updateMessage4( event ) { props.setAttributes( { posts: event.target.value} ); } function updateMessage5( event ) { props.setAttributes( { orderby: event.target.value} ); } function updateMessage6( event ) { props.setAttributes( { order: event.target.value} ); } function updateMessage7( event ) { props.setAttributes( { type: event.target.value} ); } return mygcel2( 'div', { className: 'coderevolution_gutenberg_div' }, mygcel2( 'h4', { className: 'coderevolution_gutenberg_title' }, 'AIomatic List Posts ', mygcel2( 'div', {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'} , mygcel2( 'div', {className:'bws_hidden_help_text'}, 'This block is used to list posts generated by this plugin. It is a simple way to list posts.' ) ) ), mygcel2( 'label', { className: 'coderevolution_gutenberg_label' }, 'Rule Type: ' ), mygcel2( 'div', {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'} , mygcel2( 'div', {className:'bws_hidden_help_text'}, 'Select the source of the posts that will be listed.' ) ), mygcel2( 'select', { value: ruletype, onChange: updateMessage, className: 'coderevolution_gutenberg_select' }, mygcel2( 'option', { value: 0}, 'Spintax to Posts' ), mygcel2( 'option', { value: ''}, 'Any' ) ), mygcel2( 'br' ), mygcel2( 'label', { className: 'coderevolution_gutenberg_label' }, 'Rule ID: ' ), mygcel2( 'div', {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'} , mygcel2( 'div', {className:'bws_hidden_help_text'}, 'Select the ID of the rule you wish to list posts from. To list all posts from a specific rule, leave this field blank.' ) ), mygcel2( 'input', { type:'number',min:0,placeholder:'Rule id to list', value: ruleid, onChange: updateMessage2, className: 'coderevolution_gutenberg_input' } ), mygcel2( 'br' ), mygcel2( 'label', { className: 'coderevolution_gutenberg_label' }, 'Category Slug: ' ), mygcel2( 'div', {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'} , mygcel2( 'div', {className:'bws_hidden_help_text'}, 'Select the post category slug from where you wish to list posts.' ) ), mygcel2( 'textarea', { rows:1,placeholder:'Category slug', value: category, onChange: updateMessage3, className: 'coderevolution_gutenberg_input' } ), mygcel2( 'br' ), mygcel2( 'label', { className: 'coderevolution_gutenberg_label' }, 'Posts Per Page: ' ), mygcel2( 'div', {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'} , mygcel2( 'div', {className:'bws_hidden_help_text'}, 'Select the number of posts to be shown at max.' ) ), mygcel2( 'input', { type:'number',min:1,placeholder:'10', value: posts, onChange: updateMessage4, className: 'coderevolution_gutenberg_input' } ), mygcel2( 'br' ), mygcel2( 'label', { className: 'coderevolution_gutenberg_label' }, 'Order By: ' ), mygcel2( 'div', {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'} , mygcel2( 'div', {className:'bws_hidden_help_text'}, 'Select how to order results.' ) ), mygcel2( 'select', { value: orderby, onChange: updateMessage5, className: 'coderevolution_gutenberg_select' }, mygcel2( 'option', { value: 'none'}, 'none' ), mygcel2( 'option', { value: 'date'}, 'date' ), mygcel2( 'option', { value: 'ID'}, 'ID' ), mygcel2( 'option', { value: 'author'}, 'author' ), mygcel2( 'option', { value: 'title'}, 'title' ), mygcel2( 'option', { value: 'name'}, 'name' ), mygcel2( 'option', { value: 'type'}, 'type' ), mygcel2( 'option', { value: 'modified'}, 'modified' ), mygcel2( 'option', { value: 'parent'}, 'parent' ), mygcel2( 'option', { value: 'rand'}, 'rand' ), mygcel2( 'option', { value: 'comment_count'}, 'comment_count' ), mygcel2( 'option', { value: 'relevance'}, 'relevance' ), mygcel2( 'option', { value: 'menu_order'}, 'menu_order' ) ), mygcel2( 'br' ), mygcel2( 'label', { className: 'coderevolution_gutenberg_label' }, 'Sort By: ' ), mygcel2( 'div', {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'} , mygcel2( 'div', {className:'bws_hidden_help_text'}, 'Select how to sort results.' ) ), mygcel2( 'select', { value: order, onChange: updateMessage6, className: 'coderevolution_gutenberg_select' }, mygcel2( 'option', { value: 'ASC'}, 'ASC' ), mygcel2( 'option', { value: 'DESC'}, 'DESC' ) ), mygcel2( 'br' ), mygcel2( 'label', { className: 'coderevolution_gutenberg_label' }, 'Post Type: ' ), mygcel2( 'div', {className:'bws_help_box bws_help_box_right dashicons dashicons-editor-help'} , mygcel2( 'div', {className:'bws_hidden_help_text'}, 'Select the post type to be listed. You can input a comma separated list of multiple post types (custom post types supported).' ) ), mygcel2( 'textarea', { rows:1,placeholder:'post', value: type, onChange: updateMessage7, className: 'coderevolution_gutenberg_input' } ) ); }), save: (function( props ) { return null; }), } );
Save File
Cancel