admin管理员组文章数量:1405565
I have tried to make this plugin : /
So I have :
/**
* WordPress dependencies
*/
import { registerBlockVariation } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
/**
* Register a parapgragh block variation with meta binding
*/
/**
* Register a paragraph block variation with meta binding
*/
registerBlockVariation( 'core/paragraph', {
name: 'show-my-data',
title: __( 'Show My Data', 'block-binding-shortcut' ),
description: __(
'Display custom meta data in a paragraph',
'block-binding-shortcut'
),
attributes: {
metadata: {
bindings: {
content: {
source: 'core/post-metadata',
args: {
key: 'my_custom_data'
},
},
},
},
},
isActive: ['metadata.bindings.content.args.key'],
scope: [ 'inserter', 'transform' ],
} );
and
<?php
/**
* Plugin Name: Preset Block Bindings
* Description: Using a block variation to preset block bindings.
* Requires at least: 6.1
* Requires PHP: 7.0
* Version: 1.0.2
* Author: The WordPress Contributors
* License: GPL-2.0-or-later
* License URI: .0.html
* Text Domain: preset-block-bindings
*
* @package block-developers-cookbook
*/
namespace BlockDevelopersCookbook;
add_action(
'init',
function() {
register_post_meta(
'post',
'my_custom_data',
array(
'show_in_rest' => true,
'single' => true,
'type' => 'string',
'auth_callback' => function() {
return current_user_can( 'edit_posts' );
},
'default' => 'This is a default value',
)
);
}
);
/**
* Register the block editor assets.
*/
add_action(
'enqueue_block_editor_assets',
function() {
$block_binding_shortcut_file = plugin_dir_path( __FILE__ ) . '/build/block-binding-shortcut.asset.php';
if ( file_exists( $block_binding_shortcut_file ) ) {
$assets = include $block_binding_shortcut_file;
wp_enqueue_script(
'block-binding-shortcut',
plugin_dir_url( __FILE__ ) . '/build/block-binding-shortcut.js',
$assets['dependencies'],
$assets['version'],
true
);
}
}
);
but on my wordpress nothing happens when I use this plugin. I do not see the text as described in the tutorial Anyone who can help me figure out what went wrong ?
本文标签: Block developer cookbook Plugin is not displaying anything
版权声明:本文标题:Block developer cookbook. Plugin is not displaying anything 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744342393a2601555.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论