fixing problem whit return when no relatedPostId
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Antoine M 2024-12-17 17:14:02 +01:00
parent 29bfa6e9f0
commit ebcc7a6f08
5 changed files with 30 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,13 @@
<?php
$relatedPostId = isset($attributes['relatedPostId']) ? $attributes['relatedPostId'] : null;
if (!$relatedPostId) return;
$relatedPost = get_post($relatedPostId);
?>
<section id="questions-container-<?php echo $relatedPostId ?>" class="questions-container-block">
<h2 class="questions-container-block__title"><?php echo $relatedPost->post_title ?></h2>
<?php echo do_blocks($relatedPost->post_content) ?>
</section>

View File

@ -0,0 +1,14 @@
/*!***************************************************************************************************************************************************************************************************************************************************!*\
!*** css ../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!../../node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!../../node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/style.scss ***!
\***************************************************************************************************************************************************************************************************************************************************/
/**
* The following styles get applied both on the front of your site
* and in the editor.
*
* Replace them with your own styles or remove the file completely.
*/
.wp-block-homegrade-content-blocks-questions-container h2 {
font-weight: 800;
}
/*# sourceMappingURL=style-index.css.map*/

View File

@ -0,0 +1 @@
{"version":3,"file":"./style-index.css","mappings":";;;AAAA;;;;;EAAA;AAQC;EACC;AADF,C","sources":["webpack://multiblocks/./src/style.scss"],"sourcesContent":["/**\n * The following styles get applied both on the front of your site\n * and in the editor.\n *\n * Replace them with your own styles or remove the file completely.\n */\n\n.wp-block-homegrade-content-blocks-questions-container {\n\th2 {\n\t\tfont-weight: 800;\n\t}\n}\n"],"names":[],"sourceRoot":""}

View File

@ -1,5 +1,5 @@
<?php
$relatedPostId = $attributes['relatedPostId'] ?? null;
$relatedPostId = isset($attributes['relatedPostId']) ? $attributes['relatedPostId'] : null;
if (!$relatedPostId) return;
$relatedPost = get_post($relatedPostId);