Skip to content

Commit

Permalink
added Skin option to change item title tag (resolves #89)
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-o committed Nov 24, 2023
1 parent 7e95a45 commit 66c14f2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
23 changes: 23 additions & 0 deletions classes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2304,8 +2304,31 @@ public function register_controls() {
'category' => 'items-style-' . $category_name . '-elements',
'alongside' => esc_html__( 'Display Title', 'visual-portfolio' ),
'name' => 'show_title',
'group' => 'items_style_title',
'default' => true,
);
$new_fields[] = array(
'type' => 'select',
'category' => 'items-style-' . $category_name . '-elements',
'label' => esc_html__( 'Title Tag', 'visual-portfolio' ),
'name' => 'title_tag',
'group' => 'items_style_title',
'default' => 'h2',
'options' => array(
'div' => '<div>',
'h1' => '<h1>',
'h2' => '<h2>',
'h3' => '<h3>',
'h4' => '<h4>',
'h5' => '<h5>',
'h6' => '<h6>',
),
'condition' => array(
array(
'control' => 'show_title',
),
),
);
}

if ( isset( $elements['categories'] ) && $elements['categories'] ) {
Expand Down
5 changes: 3 additions & 2 deletions templates/items-list/item-parts/title.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
return;
}

$title_tag = $opts['title_tag'] ?? 'h2';
$allow_links = isset( $allow_links ) ? $allow_links : false;
$link_data = array(
'href' => $allow_links ? $args['url'] : false,
Expand All @@ -28,10 +29,10 @@

?>

<h2 class="vp-portfolio__item-meta-title">
<<?php echo esc_attr( $title_tag ); ?> class="vp-portfolio__item-meta-title">
<?php
visual_portfolio()->include_template( 'global/link-start', $link_data );
echo wp_kses_post( $args['title'] );
visual_portfolio()->include_template( 'global/link-end', $link_data );
?>
</h2>
</<?php echo esc_attr( $title_tag ); ?>>

0 comments on commit 66c14f2

Please sign in to comment.