get('Version') ); wp_enqueue_script( 'blocksy/gutenberg-blocks', BLOCKSY_URL . '/static/bundle/blocks/blocks.js', $deps, $data['Version'], false ); }); $blocks = [ 'about-me', 'contact-info', 'quote', 'socials', 'search', 'share-box' ]; foreach ($blocks as $block) { $this->blocks[$block] = new \Blocksy\Editor\GutenbergBlock( $block, [ 'static' => false, ] ); } add_action('wp_ajax_blocksy_get_dynamic_block_view', function () { if ( ! current_user_can('edit_posts') || // phpcs:ignore WordPress.Security.NonceVerification.Missing ! isset($_POST['block']) || // phpcs:ignore WordPress.Security.NonceVerification.Missing ! isset($_POST['attributes']) ) { wp_send_json_error(); } // phpcs:ignore WordPress.Security.NonceVerification.Missing $block_name = sanitize_key($_POST['block']); if (! isset($this->blocks[$block_name])) { wp_send_json_error(); } $gutenberg_block = $this->blocks[$block_name]; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $attributes = json_decode(wp_unslash($_POST['attributes']), true); if (! is_array($attributes)) { $attributes = []; } wp_send_json_success([ 'content' => $gutenberg_block->render($attributes), ]); }); $this->init_blocks(); } public function init_blocks() { // Root Block new \Blocksy\Editor\Blocks\BlockWrapper(); new \Blocksy\Editor\Blocks\BreadCrumbs(); $this->query = new \Blocksy\Editor\Blocks\Query(); new \Blocksy\Editor\Blocks\TaxQuery(); new \Blocksy\Editor\Blocks\DynamicData(); } }