FEATURE Handling custom anchors and changing block icon
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b813223fcd
commit
7b27f68053
|
|
@ -5,15 +5,22 @@
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"title": "Archives des notices biographiques",
|
"title": "Archives des notices biographiques",
|
||||||
"category": "carhop-blocks",
|
"category": "carhop-blocks",
|
||||||
"icon": "smiley",
|
"icon": "grid-view",
|
||||||
"description": "Archives des notices biographiques",
|
"description": "Archives des notices biographiques",
|
||||||
"supports": {
|
"supports": {
|
||||||
"html": false
|
"html": false,
|
||||||
|
"anchor": true
|
||||||
},
|
},
|
||||||
"textdomain": "carhop-blocks",
|
"textdomain": "carhop-blocks",
|
||||||
"editorScript": "file:./index.js",
|
"editorScript": "file:./index.js",
|
||||||
"editorStyle": "file:./index.css",
|
"editorStyle": "file:./index.css",
|
||||||
"style": "file:./style-index.css",
|
"style": "file:./style-index.css",
|
||||||
"render": "file:./render.php",
|
"render": "file:./render.php",
|
||||||
"viewScript": "file:./view.js"
|
"viewScript": "file:./view.js",
|
||||||
|
"attributes": {
|
||||||
|
"anchor": {
|
||||||
|
"type": "string",
|
||||||
|
"default": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import { registerBlockType } from "@wordpress/blocks";
|
import { registerBlockType } from "@wordpress/blocks";
|
||||||
import "./style.scss";
|
import "./style.scss";
|
||||||
import Edit from "./edit";
|
import Edit from "./edit";
|
||||||
|
import save from "./save";
|
||||||
import metadata from "./block.json";
|
import metadata from "./block.json";
|
||||||
registerBlockType(metadata.name, {
|
registerBlockType(metadata.name, {
|
||||||
edit: Edit,
|
edit: Edit,
|
||||||
|
save,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
$initialPostDisplayAmount = 10;
|
$initialPostDisplayAmount = 10;
|
||||||
|
|
||||||
|
$anchor = $attributes['anchor'] ?? false;
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'dbmob',
|
'post_type' => 'dbmob',
|
||||||
'posts_per_page' => $initialPostDisplayAmount,
|
'posts_per_page' => $initialPostDisplayAmount,
|
||||||
|
|
@ -9,7 +11,7 @@ $args = array(
|
||||||
$query = new WP_Query($args);
|
$query = new WP_Query($args);
|
||||||
$post_count = $query->found_posts;
|
$post_count = $query->found_posts;
|
||||||
?>
|
?>
|
||||||
<section <?php echo get_block_wrapper_attributes(array('class' => '')); ?>>
|
<section <?php echo get_block_wrapper_attributes(array('class' => '', 'id' => $anchor)); ?>>
|
||||||
<h2>Les notices rédigées par le CARHOP</h2>
|
<h2>Les notices rédigées par le CARHOP</h2>
|
||||||
|
|
||||||
<div class="notices-toolbar" data-post-type="dbmob">
|
<div class="notices-toolbar" data-post-type="dbmob">
|
||||||
|
|
|
||||||
10
plugins/carhop-blocks/src/dbmob-archives/save.js
Normal file
10
plugins/carhop-blocks/src/dbmob-archives/save.js
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { useBlockProps, RichText, InnerBlocks } from "@wordpress/block-editor";
|
||||||
|
import { __ } from "@wordpress/i18n";
|
||||||
|
|
||||||
|
export default function save({ attributes, setAttributes }) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<InnerBlocks.Content />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user