-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterm-query.php
More file actions
61 lines (55 loc) · 1.98 KB
/
term-query.php
File metadata and controls
61 lines (55 loc) · 1.98 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
<?php
/**
* Plugin Name: Term Query Loop Block
* Plugin URI: https://github.com/cr0ybot/term-query
* Description: Query and display taxonomy terms as blocks.
* Requires at least: 6.7
* Requires PHP: 7.4
* Version: 0.7.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: term-query
* GitHub Plugin URI: https://github.com/cr0ybot/term-query
* Primary Branch: main
* Release Asset: true
*
* @package term-query
*/
namespace cr0ybot\Term_Query;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
define( 'TERM_QUERY_PLUGIN_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
define( 'TERM_QUERY_PLUGIN_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
define( 'TERM_QUERY_DIST_PATH', TERM_QUERY_PLUGIN_PATH . 'build/' );
define( 'TERM_QUERY_DIST_URI', TERM_QUERY_PLUGIN_URI . 'build/' );
define( 'TERM_QUERY_BLOCKS_PATH', TERM_QUERY_DIST_PATH . 'blocks/' );
// Glob import all includes.
foreach ( glob( plugin_dir_path( __FILE__ ) . 'includes/*.php' ) as $file ) {
require_once $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 register_blocks() {
// Extra args for specific blocks.
$block_args = array(
'term-template' => array(
'skip_inner_blocks' => true,
),
);
foreach ( glob( plugin_dir_path( __FILE__ ) . 'build/blocks/*', GLOB_ONLYDIR ) as $block_dir ) {
$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' );