|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Games Collector Gutenberg Integration |
|
4
|
|
|
* |
|
5
|
|
|
* @package GC\GamesCollector\Gutenberg |
|
6
|
|
|
* @since 1.3.0 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace GC\GamesCollector\Gutenberg; |
|
10
|
|
|
|
|
11
|
|
|
use GC\GamesCollector\Shortcode; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Enqueue the Gutenberg editor js and css. |
|
15
|
|
|
*/ |
|
16
|
|
|
function enqueue_block_editor_assets() { |
|
17
|
|
|
$js_file = plugin_dir_url( dirname( __FILE__, 2 ) ) . 'assets/js/editor.js'; |
|
18
|
|
|
wp_enqueue_script( 'games-collector-gberg-editor', $js_file, [ 'wp-i18n', 'wp-blocks', 'wp-element' ], '1.3.0' ); |
|
19
|
|
|
wp_enqueue_style( 'games-collector-gberg-editor', dirname( plugin_dir_url( __FILE__ ), 2 ) . '/assets/css/editor.css', [ 'wp-blocks' ], '1.3.0' ); |
|
20
|
|
|
wp_enqueue_style( 'games-collector', dirname( plugin_dir_url( __FILE__ ), 2 ) . '/assets/css/main.css', [], '1.3.0' ); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Register the Games Collector Gutenberg blocks. |
|
25
|
|
|
*/ |
|
26
|
|
|
function register_blocks() { |
|
27
|
|
|
// Bail if not using Gutenberg. |
|
28
|
|
|
if ( ! function_exists( 'register_block_type' ) ) { |
|
29
|
|
|
return; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
register_block_type( 'games-collector/add-all-games', [ |
|
33
|
|
|
'render_callback' => __NAMESPACE__ . '\\render_add_all_games', |
|
34
|
|
|
] ); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Piggyback off the shortcode for rendering the games list. |
|
39
|
|
|
* |
|
40
|
|
|
* @return string HTML for the games list. |
|
41
|
|
|
*/ |
|
42
|
|
|
function render_add_all_games() { |
|
43
|
|
|
return Shortcode\render_games(); |
|
44
|
|
|
} |
|
45
|
|
|
|