-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfeed-block.php
48 lines (45 loc) · 1.56 KB
/
feed-block.php
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
<?php
/**
* Plugin Name: Feed Loop Block
* Plugin URI: https://github.com/cr0ybot/feed-block
* Description: Advanced RSS & Atom feed block with configurable child blocks, similar to the Query Loop block.
* Requires at least: 6.2
* Requires PHP: 7.0
* Version: 0.5.0
* Author: Cory Hughart
* Author URI: https://coryhughart.com
* License: GPL-3.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: feed-block
*
* @package feed-block
*/
namespace FeedBlock;
// Import includes.
require_once __DIR__ . '/includes/util.php';
require_once __DIR__ . '/includes/feed.php';
require_once __DIR__ . '/includes/ajax.php';
require_once __DIR__ . '/includes/enqueue.php';
/**
* 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 register_blocks() {
foreach ( glob( plugin_dir_path( __FILE__ ) . 'build/blocks/*', GLOB_ONLYDIR ) as $block_dir ) {
// Extra args for specific blocks.
$block_args = array(
'feed-item-template' => array(
'skip_inner_blocks' => true,
),
);
$args = array();
if ( isset( $block_args[ basename( $block_dir ) ] ) ) {
$args = $block_args[ basename( $block_dir ) ];
}
register_block_type( $block_dir, $args );
}
}
add_action( 'init', __NAMESPACE__ . '\\register_blocks' );