%3$s', $prefix_level, $wrapper_attributes, $prefix_content ); // Heading. $title_level = ! empty( $attributes['titleTag'] ) ? $attributes['titleTag'] : 'h2'; $wrapper_attributes = ''; if ( ! empty( $attributes['titleColor'] ) ) { $wrapper_attributes = 'style="color:' . $attributes['titleColor'] . '"'; } $wrapper_attributes .= 'class="gutenify-section-title-main"'; $title_content = ! empty( $attributes['titleContent'] ) ? $attributes['titleContent'] : ''; $title = sprintf( '<%1$s %2$s>%3$s', $title_level, $wrapper_attributes, $title_content ); // Suffix. $suffix_level = ! empty( $attributes['suffixTag'] ) ? $attributes['suffixTag'] : 'p'; $wrapper_attributes = ''; if ( ! empty( $attributes['suffixColor'] ) ) { $wrapper_attributes = 'style="color:' . $attributes['suffixColor'] . '"'; } $wrapper_attributes .= 'class="gutenify-section-title-suffix"'; $suffix_content = ! empty( $attributes['suffixContent'] ) ? $attributes['suffixContent'] : ''; $suffix = sprintf( '<%1$s %2$s>%3$s', $suffix_level, $wrapper_attributes, $suffix_content ); $block_client_id = ! empty( $attributes['blockClientId'] ) ? $attributes['blockClientId'] : 1; $output = '
'; $output .= '
'; if ( ! empty( $attributes['displayPrefix'] ) ) { $output .= $prefix; } $output .= $title; if ( ! empty( $attributes['displaySuffix'] ) ) { $output .= $suffix; } $output .= '
'; $output .= '
'; return $output; } /** * Registers the `gutenify/section-title` block on the server. */ function gutenify_register_block_section_title() { // Return early if this function does not exist. if ( ! function_exists( 'register_block_type' ) ) { return; } // Load attributes from block.json. ob_start(); include GUTENIFY_PLUGIN_DIR . 'src/blocks/section-title/block.json'; $metadata = json_decode( ob_get_clean(), true ); register_block_type( 'gutenify/section-title', array( 'render_callback' => 'gutenify_render_block_section_title', 'editor_script' => 'gutenify-editor', 'editor_style' => 'gutenify-editor', 'style' => 'gutenify-frontend', 'attributes' => $metadata['attributes'], ) ); } add_action( 'init', 'gutenify_register_block_section_title' );