controls['tag'] = [ 'tab' => 'content', 'label' => esc_html__( 'HTML tag', 'fluent-cart' ), 'type' => 'select', 'options' => [ 'h1' => 'h1', 'h2' => 'h2', 'h3' => 'h3', 'h4' => 'h4', 'h5' => 'h5', 'h6' => 'h6', ], 'inline' => true, 'placeholder' => 'h1', ]; $this->controls['prefix'] = [ 'tab' => 'content', 'label' => esc_html__( 'Prefix', 'fluent-cart' ), 'type' => 'text', 'inline' => true, ]; $this->controls['prefixBlock'] = [ 'tab' => 'content', 'label' => esc_html__( 'Prefix block', 'fluent-cart' ), 'type' => 'checkbox', 'inline' => true, 'required' => [ 'prefix', '!=', '' ], ]; $this->controls['suffix'] = [ 'tab' => 'content', 'label' => esc_html__( 'Suffix', 'fluent-cart' ), 'type' => 'text', 'inline' => true, ]; $this->controls['suffixBlock'] = [ 'tab' => 'content', 'label' => esc_html__( 'Suffix block', 'fluent-cart' ), 'type' => 'checkbox', 'inline' => true, 'required' => [ 'suffix', '!=', '' ], ]; $this->controls['linkToProduct'] = [ 'tab' => 'content', 'label' => esc_html__( 'Link to product', 'fluent-cart' ), 'type' => 'checkbox', ]; } public function render() { $settings = $this->settings; $prefix = ! empty( $settings['prefix'] ) ? $settings['prefix'] : false; $suffix = ! empty( $settings['suffix'] ) ? $settings['suffix'] : false; $link_to_product = isset( $settings['linkToProduct'] ); $output = ''; if ( $link_to_product ) { $output .= ''; } if ( $prefix ) { $this->set_attribute( 'prefix', 'class', [ 'post-prefix' ] ); $output .= isset( $settings['prefixBlock'] ) ? "
render_attributes( 'prefix' )}>{$prefix}
" : "render_attributes( 'prefix' )}>{$prefix}"; } $post = get_post( $this->post_id ); $output .= $post->post_title; if ( $suffix ) { $this->set_attribute( 'suffix', 'class', [ 'post-suffix' ] ); $output .= isset( $settings['suffixBlock'] ) ? "
render_attributes( 'suffix' )}>{$suffix}
" : "render_attributes( 'suffix' )}>{$suffix}"; } if ( $link_to_product ) { $output .= '
'; } // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- render_attributes() handles escaping, output is escaped echo "<" . esc_html($this->tag) . " {$this->render_attributes( '_root' )}>" . wp_kses_post($output) . "tag) . ">"; } public static function render_builder() { ?>