blocks->registerBlock( 'pro/recipe', [ 'render_callback' => [ $this, 'render' ] ] ); } /** * Render the block. * * @since 4.9.0 * * @param array $attributes The attributes for the block. * * @return string */ public function render( $attributes ) { $name = $attributes['name'] ?? ''; $description = $attributes['description'] ?? ''; $image = $attributes['image'] ?? ''; $nutrition = ! empty( $attributes['nutrition'] ) ? ( is_array( $attributes['nutrition'] ) ? $attributes['nutrition'] : json_decode( $attributes['nutrition'], true ) ) : ''; $ingredients = ! empty( $attributes['ingredients'] ) ? ( is_array( $attributes['ingredients'] ) ? $attributes['ingredients'] : json_decode( $attributes['ingredients'], true ) ) : []; $keywords = ! empty( $attributes['keywords'] ) ? ( is_array( $attributes['keywords'] ) ? $attributes['keywords'] : json_decode( $attributes['keywords'], true ) ) : ''; $timeRequired = ! empty( $attributes['timeRequired'] ) ? ( is_array( $attributes['timeRequired'] ) ? $attributes['timeRequired'] : json_decode( $attributes['timeRequired'], true ) ) : []; $instructions = ! empty( $attributes['instructions'] ) ? ( is_array( $attributes['instructions'] ) ? $attributes['instructions'] : json_decode( $attributes['instructions'], true ) ) : []; $rating = ! empty( $attributes['rating'] ) ? ( is_array( $attributes['rating'] ) ? $attributes['rating'] : json_decode( $attributes['rating'], true ) ) : []; $reviews = ! empty( $attributes['reviews'] ) ? ( is_array( $attributes['reviews'] ) ? $attributes['reviews'] : json_decode( $attributes['reviews'], true ) ) : []; $dishType = $attributes['dishType'] ?? ''; $cuisineType = $attributes['cuisineType'] ?? ''; $maximum = ! empty( $rating['maximum'] ) ? $rating['maximum'] : 5; $result = '
' . esc_html( aioseo()->tags->replaceTags( $description ) ) . '
' . esc_html( $instruction['text'] ) . '
'; if ( ! empty( $instruction['image'] ) ) { $result .= '