<?php /** * Plugin Name: hacklab-blocks * Description: blocos para utilização em diversos projetos. * Version: 0.1.0 * Requires at least: 5.8 * Requires PHP: 7.0 * Author: The WordPress Contributors * License: GPL-2.0-or-later * License URI: https://www.gnu.org/licenses/gpl-2.0.html * Text Domain: hacklab-blocks * Domain Path: /languages * * @package create-block */ define( 'HACKLAB_BLOCKS_PATH', plugin_dir_path(__FILE__) ); define( 'HACKLAB_BLOCKS_PATH_URL', plugin_dir_url(__FILE__) ); /** * Registers the block using the metadata loaded from the `block.json` file. * Behind the scenes, it registers also all assets so they can be enqueued * through the block editor in the corresponding context. * * @see https://developer.wordpress.org/reference/functions/register_block_type/ */ function hacklab_blocks_init() { if ( ! function_exists( 'register_block_type' ) ) { // Block editor is not available. return; } $plugin_folder = HACKLAB_BLOCKS_PATH; $blocos_ativos = array( 'sample-block' => null, 'story-list' => array( 'render_callback' => 'hacklabBlocks\\story_list_callback' ), 'flickr-album-gallery' => array( 'render_callback' => 'hacklabBlocks\\flickr_album_gallery_callback' ), 'video-playlist' => array( 'render_callback' => 'hacklabBlocks\\video_playlist_callback' ), 'featured-color' => array( 'render_callback' => 'hacklabBlocks\\featured_color_callback' ), 'post-with-image' => array( 'render_callback' => 'hacklabBlocks\\post_with_image_callback' ), 'hacklab-fetch-posts-api' => array( 'render_callback' => 'hacklabBlocks\\fetch_posts_api_callback' ), 'partners' => array( 'render_callback' => 'hacklabBlocks\\partners_callback' ), 'geo-information' => array( 'render_callback' => 'hacklabBlocks\\geo_information_callback', ), 'custom-taxonomy' => array( 'render_callback' => 'hacklabBlocks\\render_block_core_post_terms_2', ), 'post-meta' => array( 'render_callback' => 'hacklabBlocks\\post_meta_callback', ), 'filter-by-taxonomy' => array( 'render_callback' => 'hacklabBlocks\\filter_by_taxonomy_callback', ), 'custom-image-gallery-block' => null, 'featured-slider' => null, 'custom-columns' => null, 'theme-card' => null, 'themes-block' => null ); $blocos_ativos = apply_filters('hacklab_blocos_ativos',$blocos_ativos); foreach ($blocos_ativos as $block_name => $block_args ) { $args = array(); if ($block_args){ include $plugin_folder . '/blocks/' . $block_name . '/' . $block_name . '.php'; foreach ($block_args as $arg => $value) { $args[$arg] = $value; } } register_block_type($plugin_folder . 'blocks/' . $block_name . '/' , $args); } } add_action( 'init', 'hacklab_blocks_init' ); /** * Load plugin textdomain */ function hacklab_blocks_load_plugin_textdomain() { $path = dirname( plugin_basename( __FILE__ ) ) . '/languages'; load_plugin_textdomain( dirname( plugin_basename( __FILE__ ) ), false, $path ); } add_action( 'init', 'hacklab_blocks_load_plugin_textdomain' );