diff --git a/plugins/carhop-blocks/src/see-also/block.json b/plugins/carhop-blocks/src/see-also/block.json new file mode 100644 index 0000000..17b972b --- /dev/null +++ b/plugins/carhop-blocks/src/see-also/block.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 3, + "name": "carhop-blocks/see-also", + "version": "0.1.0", + "title": "Voir aussi", + "category": "carhop-blocks", + "icon": "smiley", + "description": "Voir aussi", + "example": {}, + "supports": { + "html": false + }, + "textdomain": "carhop-blocks", + "editorScript": "file:./index.js", + "editorStyle": "file:./index.css", + "style": "file:./style-index.css", + "viewScript": "file:./view.js", + "render": "file:./render.php" +} \ No newline at end of file diff --git a/plugins/carhop-blocks/src/see-also/edit.js b/plugins/carhop-blocks/src/see-also/edit.js new file mode 100644 index 0000000..edce8c0 --- /dev/null +++ b/plugins/carhop-blocks/src/see-also/edit.js @@ -0,0 +1,16 @@ +import { __ } from "@wordpress/i18n"; +import { useBlockProps } from "@wordpress/block-editor"; +import ServerSideRender from "@wordpress/server-side-render"; + +import "./editor.scss"; + +export default function Edit(props) { + return ( +
+ +
+ ); +} diff --git a/plugins/carhop-blocks/src/see-also/editor.scss b/plugins/carhop-blocks/src/see-also/editor.scss new file mode 100644 index 0000000..e69de29 diff --git a/plugins/carhop-blocks/src/see-also/index.js b/plugins/carhop-blocks/src/see-also/index.js new file mode 100644 index 0000000..f9ce7f0 --- /dev/null +++ b/plugins/carhop-blocks/src/see-also/index.js @@ -0,0 +1,21 @@ +import { registerBlockType } from "@wordpress/blocks"; + +import "./style.scss"; + +import Edit from "./edit"; +import save from "./save"; +import metadata from "./block.json"; + +registerBlockType(metadata.name, { + icon: { + src: ( + + + + + ), + foreground: "#136f63", + }, + edit: Edit, + save, +}); diff --git a/plugins/carhop-blocks/src/see-also/render.php b/plugins/carhop-blocks/src/see-also/render.php new file mode 100644 index 0000000..e12a16a --- /dev/null +++ b/plugins/carhop-blocks/src/see-also/render.php @@ -0,0 +1,36 @@ + 'see-also alignfull']); +$title = $attributes['title'] ?? null; + +$current_post_ID = $attributes['currentPostID'] ?? get_the_ID(); +$current_tags = get_the_terms($current_post_ID, 'etiquettes'); + + +$relate_topic_posts = get_posts(array( + 'post_type' => array('analyses-etudes', 'expositions', 'outils-pedagogiques'), + 'tax_query' => array( + array( + 'taxonomy' => 'etiquettes', + 'field' => 'term_id', + 'terms' => wp_list_pluck($current_tags, 'term_id'), + ), + ), + 'posts_per_page' => 3, + 'post__not_in' => array($current_post_ID), +)); + +?> + +
> +
+
+

Suggestions

+

Voir aussi
sur ce sujet

+
+
+ + $post->ID, 'current_post_type' => $post->post_type)); ?> + +
+
+
\ No newline at end of file diff --git a/plugins/carhop-blocks/src/see-also/save.js b/plugins/carhop-blocks/src/see-also/save.js new file mode 100644 index 0000000..2e60d8d --- /dev/null +++ b/plugins/carhop-blocks/src/see-also/save.js @@ -0,0 +1,3 @@ +export default function save() { + return <>; +} diff --git a/plugins/carhop-blocks/src/see-also/style.scss b/plugins/carhop-blocks/src/see-also/style.scss new file mode 100644 index 0000000..e69de29 diff --git a/plugins/carhop-blocks/src/see-also/view.js b/plugins/carhop-blocks/src/see-also/view.js new file mode 100644 index 0000000..e69de29