-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblockparty-iframe.php
More file actions
88 lines (77 loc) · 3.21 KB
/
blockparty-iframe.php
File metadata and controls
88 lines (77 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* Plugin Name: Blockparty Iframe
* Description: Add a block to display an embedded frame in the WordPress editor.
* Version: 1.1.2
* Requires at least: 6.7
* Requires PHP: 8.1
* Author: Be API Technical team
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: blockparty-iframe
*
* @package CreateBlock
*/
namespace Blockparty\Iframe;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
define( 'BLOCKPARTY_IFRAME_VERSION', '1.1.2' );
define( 'BLOCKPARTY_IFRAME_URL', plugin_dir_url( __FILE__ ) );
define( 'BLOCKPARTY_IFRAME_DIR', plugin_dir_path( __FILE__ ) );
define( 'BLOCKPARTY_IFRAME_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
// Require vendor
if ( file_exists( BLOCKPARTY_IFRAME_DIR . '/vendor/autoload.php' ) ) {
require BLOCKPARTY_IFRAME_DIR . '/vendor/autoload.php';
}
/**
* Registers the block using a `blocks-manifest.php` file, which improves the performance of block type registration.
* Behind the scenes, it also registers all assets so they can be enqueued
* through the block editor in the corresponding context.
*
* @see https://make.wordpress.org/core/2025/03/13/more-efficient-block-type-registration-in-6-8/
* @see https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/
*/
function init() {
/**
* Registers the block(s) metadata from the `blocks-manifest.php` and registers the block type(s)
* based on the registered block metadata.
* Added in WordPress 6.8 to simplify the block metadata registration process added in WordPress 6.7.
*
* @see https://make.wordpress.org/core/2025/03/13/more-efficient-block-type-registration-in-6-8/
*/
if ( function_exists( 'wp_register_block_types_from_metadata_collection' ) ) {
wp_register_block_types_from_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
init_i18n();
return;
}
/**
* Registers the block(s) metadata from the `blocks-manifest.php` file.
* Added to WordPress 6.7 to improve the performance of block type registration.
*
* @see https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/
*/
if ( function_exists( 'wp_register_block_metadata_collection' ) ) {
wp_register_block_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
}
/**
* Registers the block type(s) in the `blocks-manifest.php` file.
*
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
$manifest_data = require __DIR__ . '/build/blocks-manifest.php';
foreach ( array_keys( $manifest_data ) as $block_type ) {
register_block_type( __DIR__ . "/build/{$block_type}" );
}
init_i18n();
}
add_action( 'init', __NAMESPACE__ . '\\init' );
/**
* Load the plugin translations.
*/
function init_i18n() {
// Load available translations.
load_plugin_textdomain( 'blockparty-iframe', false, dirname( BLOCKPARTY_IFRAME_PLUGIN_BASENAME ) . '/languages' );
// Load translations for JS
wp_set_script_translations( 'blockparty-iframe-editor-script', 'blockparty-iframe', BLOCKPARTY_IFRAME_DIR . '/languages' );
}