PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.7.8
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.7.8
2.7.9 2.7.8 2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 All 30 releases
← All changes | admin/includes/class.gutenberg.snippet.php +12 -6 2.7.4 → 2.7.8 View file →
@@ -45,14 +45,10 @@
45 45 */
46 46 public function init() {
47 47 $this->shortcode_data = WINP_Helper::get_shortcode_data();
48 48
49 - if ( empty( $this->shortcode_data ) ) {
50 - return;
51 - }
52 -
53 49 // Register the block type and get the WP_Block_Type instance.
54 - $block_type = register_block_type( WINP_PLUGIN_DIR . '/admin/assets/gutenberg/build/block.json' );
50 + $block_type = $this->register_block();
55 51
56 52 /**
57 53 * Register snippets object, so it can be accessible within Gutenberg.
58 54 * The script handle is automatically generated by WordPress from the block name.
@@ -61,12 +57,22 @@
61 57 wp_localize_script(
62 58 $block_type->editor_script_handles[0],
63 59 'winp_snippets',
64 60 [
65 - 'data' => $this->prepared_snippets_data(),
61 + 'data' => $this->prepared_snippets_data(),
62 + 'createUrl' => admin_url( 'post-new.php?post_type=' . WINP_SNIPPETS_POST_TYPE ),
66 63 ]
67 64 );
68 65 }
66 + }
67 +
68 + /**
69 + * Register the block type.
70 + *
71 + * @return WP_Block_Type|false
72 + */
73 + protected function register_block() {
74 + return register_block_type( WINP_PLUGIN_DIR . '/admin/assets/gutenberg/build/block.json' );
69 75 }
70 76
71 77 /**
72 78 * Prepare snippets data for the block editor.