rankmath testing
This commit is contained in:
parent
e524958c99
commit
7fa25fa3a8
|
|
@ -24,6 +24,10 @@
|
||||||
"relatedPostId": {
|
"relatedPostId": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"relatedPostPreviewGhostContent": {
|
||||||
|
"type": "string",
|
||||||
|
"default": ""
|
||||||
|
},
|
||||||
"postType": {
|
"postType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "questions"
|
"default": "questions"
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '548c237f02dcdec27f46');
|
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'f8adefcd282fd42751be');
|
||||||
|
|
|
||||||
|
|
@ -174,8 +174,25 @@ function Edit({
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
relatedPostId,
|
relatedPostId,
|
||||||
postType
|
postType,
|
||||||
|
relatedPostPreviewGhostContent
|
||||||
} = attributes;
|
} = attributes;
|
||||||
|
let currentRelatedPost = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => relatedPostId && postType ? select("core").getEntityRecord("postType", postType, relatedPostId) : null, [relatedPostId, postType]);
|
||||||
|
|
||||||
|
// console.log("relatedPostPreviewGhostContent", relatedPostPreviewGhostContent);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// if (currentRelatedPost?.content?.rendered) {
|
||||||
|
// setAttributes({
|
||||||
|
// relatedPostPreviewGhostContent: currentRelatedPost.content.rendered,
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// setAttributes({
|
||||||
|
// relatedPostPreviewGhostContent: null,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }, [currentRelatedPost]);
|
||||||
|
|
||||||
function parseBlockContentForTooltips(editorContent) {
|
function parseBlockContentForTooltips(editorContent) {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const doc = parser.parseFromString(editorContent, "text/html");
|
const doc = parser.parseFromString(editorContent, "text/html");
|
||||||
|
|
@ -198,7 +215,6 @@ function Edit({
|
||||||
});
|
});
|
||||||
return filteredTooltipWords;
|
return filteredTooltipWords;
|
||||||
}
|
}
|
||||||
let currentRelatedPost = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => relatedPostId && postType ? select("core").getEntityRecord("postType", postType, relatedPostId) : null, [relatedPostId, postType]);
|
|
||||||
(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_5__.useEffect)(() => {
|
(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_5__.useEffect)(() => {
|
||||||
if (currentRelatedPost) {
|
if (currentRelatedPost) {
|
||||||
const currentBlockTooltips = parseBlockContentForTooltips(currentRelatedPost.content.rendered);
|
const currentBlockTooltips = parseBlockContentForTooltips(currentRelatedPost.content.rendered);
|
||||||
|
|
@ -260,7 +276,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||||
foreground: "#DF1E1E"
|
foreground: "#DF1E1E"
|
||||||
},
|
},
|
||||||
edit: _edit__WEBPACK_IMPORTED_MODULE_3__["default"],
|
edit: _edit__WEBPACK_IMPORTED_MODULE_3__["default"],
|
||||||
save: _save__WEBPACK_IMPORTED_MODULE_4__["default"],
|
// save,
|
||||||
transforms: _transforms__WEBPACK_IMPORTED_MODULE_6__["default"]
|
transforms: _transforms__WEBPACK_IMPORTED_MODULE_6__["default"]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -289,7 +305,11 @@ function save({
|
||||||
attributes,
|
attributes,
|
||||||
setAttributes
|
setAttributes
|
||||||
}) {
|
}) {
|
||||||
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, "Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dignissimos reiciendis officiis molestias nostrum necessitatibus, explicabo culpa assumenda quod sit facere. Ullam vitae dignissimos quasi ea amet nisi rerum omnis saepe!"));
|
const {
|
||||||
|
relatedPostPreviewGhostContent
|
||||||
|
} = attributes;
|
||||||
|
if (!relatedPostPreviewGhostContent) return null;
|
||||||
|
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, relatedPostPreviewGhostContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
@ -444,7 +464,7 @@ module.exports = window["wp"]["i18n"];
|
||||||
\************************/
|
\************************/
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/post-content-container","version":"0.1.0","title":"Post Container","category":"homegrade-blocks","icon":{"background":"#fff","foreground":"#DF1E1E","src":"feedback"},"description":"Pour intégrer le contenu d\'une page ou d\'un post type","supports":{"anchor":true,"html":false},"textdomain":"homegrade-theme__bloks-texte-fonctionnel","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","render":"file:./render.php","attributes":{"relatedPostId":{"type":"number"},"postType":{"type":"string","default":"questions"},"anchor":{"type":"string"},"tooltipsWordsUsed":{"type":"array","default":[]}}}');
|
module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/post-content-container","version":"0.1.0","title":"Post Container","category":"homegrade-blocks","icon":{"background":"#fff","foreground":"#DF1E1E","src":"feedback"},"description":"Pour intégrer le contenu d\'une page ou d\'un post type","supports":{"anchor":true,"html":false},"textdomain":"homegrade-theme__bloks-texte-fonctionnel","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","render":"file:./render.php","attributes":{"relatedPostId":{"type":"number"},"relatedPostPreviewGhostContent":{"type":"string","default":""},"postType":{"type":"string","default":"questions"},"anchor":{"type":"string"},"tooltipsWordsUsed":{"type":"array","default":[]}}}');
|
||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -9,22 +9,21 @@ $anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_ht
|
||||||
$anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_html($attributes['anchor']) : ($relatedPostId ? "post-content-container-" . $relatedPostId : '');
|
$anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_html($attributes['anchor']) : ($relatedPostId ? "post-content-container-" . $relatedPostId : '');
|
||||||
$content = get_the_content(null, null, $relatedPost);
|
$content = get_the_content(null, null, $relatedPost);
|
||||||
|
|
||||||
// if ($relatedPost) {
|
if ($relatedPost) {
|
||||||
// // Temporarily set up the global post variable so the_content works as expected
|
// Temporarily set up the global post variable so the_content works as expected
|
||||||
// global $post;
|
global $post;
|
||||||
// $post = $relatedPost;
|
$post = $relatedPost;
|
||||||
// setup_postdata($post);
|
setup_postdata($post);
|
||||||
|
|
||||||
// ob_start();
|
ob_start();
|
||||||
// the_content();
|
the_content();
|
||||||
// $content = ob_get_clean();
|
$content = ob_get_clean();
|
||||||
// wp_reset_postdata();
|
wp_reset_postdata();
|
||||||
// }
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<section id="<?php echo $anchor ?>" class="post-content-container <?php echo $anchor ? "has-custom-anchor" : "" ?>">
|
<section id="<?php echo $anchor ?>" class="post-content-container <?php echo $anchor ? "has-custom-anchor" : "" ?>">
|
||||||
<h2 class="post-content-container__title"><?php echo $relatedPost->post_title ?></h2>
|
<h2 class="post-content-container__title"><?php echo $relatedPost->post_title ?></h2>
|
||||||
<!-- <?php echo $content; ?> -->
|
<?php echo $content; ?>
|
||||||
<?php echo $relatedPost->post_content ?>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -24,6 +24,10 @@
|
||||||
"relatedPostId": {
|
"relatedPostId": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"relatedPostPreviewGhostContent": {
|
||||||
|
"type": "string",
|
||||||
|
"default": ""
|
||||||
|
},
|
||||||
"postType": {
|
"postType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "questions"
|
"default": "questions"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,29 @@ import { decodeEntities } from "@wordpress/html-entities";
|
||||||
import OptionsSelectControl from "./OptionsSelectControl";
|
import OptionsSelectControl from "./OptionsSelectControl";
|
||||||
|
|
||||||
export default function Edit({ attributes, setAttributes }) {
|
export default function Edit({ attributes, setAttributes }) {
|
||||||
const { relatedPostId, postType } = attributes;
|
const { relatedPostId, postType, relatedPostPreviewGhostContent } =
|
||||||
|
attributes;
|
||||||
|
let currentRelatedPost = useSelect(
|
||||||
|
(select) =>
|
||||||
|
relatedPostId && postType
|
||||||
|
? select("core").getEntityRecord("postType", postType, relatedPostId)
|
||||||
|
: null,
|
||||||
|
[relatedPostId, postType],
|
||||||
|
);
|
||||||
|
|
||||||
|
// console.log("relatedPostPreviewGhostContent", relatedPostPreviewGhostContent);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// if (currentRelatedPost?.content?.rendered) {
|
||||||
|
// setAttributes({
|
||||||
|
// relatedPostPreviewGhostContent: currentRelatedPost.content.rendered,
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// setAttributes({
|
||||||
|
// relatedPostPreviewGhostContent: null,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }, [currentRelatedPost]);
|
||||||
|
|
||||||
function parseBlockContentForTooltips(editorContent) {
|
function parseBlockContentForTooltips(editorContent) {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
|
|
@ -41,14 +63,6 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
return filteredTooltipWords;
|
return filteredTooltipWords;
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentRelatedPost = useSelect(
|
|
||||||
(select) =>
|
|
||||||
relatedPostId && postType
|
|
||||||
? select("core").getEntityRecord("postType", postType, relatedPostId)
|
|
||||||
: null,
|
|
||||||
[relatedPostId, postType],
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentRelatedPost) {
|
if (currentRelatedPost) {
|
||||||
const currentBlockTooltips = parseBlockContentForTooltips(
|
const currentBlockTooltips = parseBlockContentForTooltips(
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,6 @@ registerBlockType(metadata.name, {
|
||||||
},
|
},
|
||||||
|
|
||||||
edit: Edit,
|
edit: Edit,
|
||||||
save,
|
// save,
|
||||||
transforms: transforms,
|
transforms: transforms,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,22 +9,21 @@ $anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_ht
|
||||||
$anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_html($attributes['anchor']) : ($relatedPostId ? "post-content-container-" . $relatedPostId : '');
|
$anchor = isset($attributes['anchor']) && !empty($attributes['anchor']) ? esc_html($attributes['anchor']) : ($relatedPostId ? "post-content-container-" . $relatedPostId : '');
|
||||||
$content = get_the_content(null, null, $relatedPost);
|
$content = get_the_content(null, null, $relatedPost);
|
||||||
|
|
||||||
// if ($relatedPost) {
|
if ($relatedPost) {
|
||||||
// // Temporarily set up the global post variable so the_content works as expected
|
// Temporarily set up the global post variable so the_content works as expected
|
||||||
// global $post;
|
global $post;
|
||||||
// $post = $relatedPost;
|
$post = $relatedPost;
|
||||||
// setup_postdata($post);
|
setup_postdata($post);
|
||||||
|
|
||||||
// ob_start();
|
ob_start();
|
||||||
// the_content();
|
the_content();
|
||||||
// $content = ob_get_clean();
|
$content = ob_get_clean();
|
||||||
// wp_reset_postdata();
|
wp_reset_postdata();
|
||||||
// }
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<section id="<?php echo $anchor ?>" class="post-content-container <?php echo $anchor ? "has-custom-anchor" : "" ?>">
|
<section id="<?php echo $anchor ?>" class="post-content-container <?php echo $anchor ? "has-custom-anchor" : "" ?>">
|
||||||
<h2 class="post-content-container__title"><?php echo $relatedPost->post_title ?></h2>
|
<h2 class="post-content-container__title"><?php echo $relatedPost->post_title ?></h2>
|
||||||
<!-- <?php echo $content; ?> -->
|
<?php echo $content; ?>
|
||||||
<?php echo $relatedPost->post_content ?>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -2,14 +2,8 @@ import { useBlockProps, RichText, InnerBlocks } from "@wordpress/block-editor";
|
||||||
import { __ } from "@wordpress/i18n";
|
import { __ } from "@wordpress/i18n";
|
||||||
|
|
||||||
export default function save({ attributes, setAttributes }) {
|
export default function save({ attributes, setAttributes }) {
|
||||||
return (
|
const { relatedPostPreviewGhostContent } = attributes;
|
||||||
<>
|
if (!relatedPostPreviewGhostContent) return null;
|
||||||
<p>
|
|
||||||
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dignissimos
|
return <>{relatedPostPreviewGhostContent}</>;
|
||||||
reiciendis officiis molestias nostrum necessitatibus, explicabo culpa
|
|
||||||
assumenda quod sit facere. Ullam vitae dignissimos quasi ea amet nisi
|
|
||||||
rerum omnis saepe!
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user