| Server IP : 37.27.51.148 / Your IP : 216.73.217.84 Web Server : nginx/1.14.1 System : Linux libra 4.18.0-553.51.1.el8_10.x86_64 #1 SMP Wed Apr 30 20:24:04 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.31 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/plugins/thrive-quiz-builder/tcb/blocks/tar-block/ |
Upload File : |
import { __ } from '@wordpress/i18n';
import { registerBlockType } from '@wordpress/blocks';
import { withSelect } from '@wordpress/data';
import tarLogo from './logo';
import previewBlock from './block-preview';
import renderAddBlock from './add-block';
import { maxNrOfPosts } from './utils';
/* global TCB_Post_Edit_Data */
/* global TAR_Block */
registerBlockType( 'thrive/architect-block', {
title: __( 'Thrive Architect Block', 'thrive-cb' ),
icon: tarLogo,
description: __(
'Add Thrive templates, symbols and blocks to your content!',
'thrive-cb'
),
category: 'thrive',
attributes: {
selectedBlock: {
type: 'number',
default: 0,
},
blockTitle: {
type: 'string',
default: '',
},
searchText: {
type: 'string',
default: '',
},
searchBlockSel: {
type: 'string',
default: '',
},
previewImage: {
type: 'boolean',
default: false,
},
},
example: {
attributes: {
previewImage: true,
},
},
edit: withSelect( function( select, props ) {
const searchTextSel = props.attributes.searchBlockSel,
query = {
per_page: maxNrOfPosts(),
search: searchTextSel,
tcb_symbols_tax_exclude: TCB_Post_Edit_Data.sections_tax_terms.map(
( term ) => term.term_id
),
};
return {
posts: select( 'core' ).getEntityRecords(
'postType',
'tcb_symbol',
query
),
};
} )( function( props ) {
if ( props.attributes.previewImage ) {
return [
wp.element.createElement( 'img', {
src: TAR_Block.block_preview,
} ),
];
}
if ( props.attributes.selectedBlock ) {
return previewBlock( props );
}
return renderAddBlock( props );
} ),
// How our block renders on the frontend
save: () => {
return null;
},
} );