small fixes

ob_start() position
remove useless comments
This commit is contained in:
André Menrath 2021-08-04 17:34:01 +02:00
parent 917fdf9991
commit 745ce0fded
3 changed files with 8 additions and 36 deletions

File diff suppressed because one or more lines are too long

View File

@ -103,18 +103,6 @@ registerBlockType( 'cgb/block-mobilizon', {
* @param {Object} props Props. * @param {Object} props Props.
* @returns {Mixed} JSX Component. * @returns {Mixed} JSX Component.
*/ */
// edit: ( props ) => {
// // Creates a <p class='wp-block-cgb-block-mobilizon'></p>.
// return (
// <div className={ props.className }>
// <p>Mobilizon Gutenberg Block</p>
// </div>
// );
// },
edit: (props) => { edit: (props) => {
const { attributes, setAttributes } = props; const { attributes, setAttributes } = props;
async function updateAndValidateMobilizonActor(newtext) { async function updateAndValidateMobilizonActor(newtext) {
@ -154,6 +142,9 @@ registerBlockType( 'cgb/block-mobilizon', {
var helperText = "The group " + groupName + " does not exist on " + baseURL; var helperText = "The group " + groupName + " does not exist on " + baseURL;
setAttributes({ mobilizonInputFieldHelpText: helperText }); setAttributes({ mobilizonInputFieldHelpText: helperText });
} }
} else {
var helperText = baseURL + " is not a mobilizon instance";
setAttributes({ mobilizonInputFieldHelpText: helperText });
} }
} }
} }
@ -222,26 +213,6 @@ registerBlockType( 'cgb/block-mobilizon', {
</div> </div>
); );
}, },
/** /**
* The save function defines the way in which the different attributes should be combined * The save function defines the way in which the different attributes should be combined
* into the final markup, which is then serialized by Gutenberg into post_content. * into the final markup, which is then serialized by Gutenberg into post_content.

View File

@ -56,8 +56,9 @@ function mobilizon_query($baseURL, $query) {
return(wp_remote_post($endpoint, $args)); return(wp_remote_post($endpoint, $args));
} }
ob_start();
function block_render_callback($attributes, $content) { function block_render_callback($attributes, $content) {
ob_start();
// var_dump($attributes); // Debugging only // var_dump($attributes); // Debugging only
// Check if we are supposed to render anything at all // Check if we are supposed to render anything at all
if (array_key_exists("mobilizonInputFieldIsValid", $attributes) && $attributes["mobilizonInputFieldIsValid"]) { if (array_key_exists("mobilizonInputFieldIsValid", $attributes) && $attributes["mobilizonInputFieldIsValid"]) {
@ -201,7 +202,7 @@ function block_render_callback($attributes, $content) {
if (isset($event['physicalAddress'])) { if (isset($event['physicalAddress'])) {
$locality_description = $event['physicalAddress']['description']; $locality_description = $event['physicalAddress']['description'];
$locality_street = $event['physicalAddress']['street']; $locality_street = $event['physicalAddress']['street'];
$locality_city = $event['physicalAddress']['postalCode'] . $event['physicalAddress']['locality'];; $locality_city = $event['physicalAddress']['postalCode'] . ' ' . $event['physicalAddress']['locality'];;
} }
else { else {
$locality_street = ""; $locality_street = "";
@ -257,7 +258,7 @@ function block_render_callback($attributes, $content) {
</div> </div>
<h4>Website</h4> <h4>Website</h4>
<div class="eventMetaDataBlock"> <div class="eventMetaDataBlock">
<a href="'.$online_adress.' target="blank">'.$online_addres_host.'</a> <a href="'.$online_adress.'" target="blank">'.$online_addres_host.'</a>
</div> </div>
</aside> </aside>
<div class="event-description"> <div class="event-description">