Skip to content

Commit 37860de

Browse files
author
Mariusz Misiek
committed
customizer options for single directory entries
new customizer options to control if meta and sidebar should be displayed on sigle directory entry view
1 parent 000e3e7 commit 37860de

File tree

5 files changed

+65
-35
lines changed

5 files changed

+65
-35
lines changed

inc/customizer.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,6 +2266,26 @@ function cpschool_theme_customizer() {
22662266
)
22672267
);
22682268

2269+
// Section - Single Directory
2270+
Kirki::add_section(
2271+
'directory_entry',
2272+
array(
2273+
'title' => esc_html__( 'Directory Entry', 'cpschool' ),
2274+
'description' => esc_html__( 'Settings related to single directory entries.', 'cpschool' ),
2275+
'panel' => 'content_area',
2276+
)
2277+
);
2278+
2279+
cpschool_generate_content_common_settings(
2280+
'directory_entry',
2281+
'cp_school_directory',
2282+
array(
2283+
'sidebars' => array( 'sidebar-right' ),
2284+
'meta' => array(),
2285+
'navigation' => false,
2286+
)
2287+
);
2288+
22692289
// Section - Alerts
22702290
Kirki::add_section(
22712291
'alerts',

inc/customizer/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function cpschool_generate_content_common_settings( $section, $post_type, $optio
158158
}
159159

160160
// Post Navigation Settings.
161-
if( isset( $options['navigation'] ) ) {
161+
if( isset( $options['navigation'] ) && $options['navigation'] ) {
162162
Kirki::add_field( 'cpschool', array(
163163
'type' => 'toggle',
164164
'settings' => $section.'_navigation',

inc/hooks-wp.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,16 @@ function cpschool_custom_logo_remove_link( $html, $blog_id ) {
289289
*/
290290
function cpschool_custom_logo_image_attrs( $custom_logo_attr, $custom_logo_id, $blog_id ) {
291291

292-
$image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
292+
if ( ! $custom_logo_attr['alt'] && is_front_page() ) {
293+
$custom_logo_attr['alt'] = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
293294

294-
if ( empty( $image_alt ) ) {
295-
$image_alt = get_bloginfo( 'name', 'display' ) . ' logo';
295+
if ( $custom_logo_attr['alt'] ) {
296+
$custom_logo_attr['title'] = get_the_title( $custom_logo_id );
297+
}
298+
} else {
299+
$custom_logo_attr['alt'] = '';
300+
$custom_logo_attr['title'] = 'Home';
296301
}
297-
$custom_logo_attr['alt'] = $image_alt;
298-
299302
$custom_logo_attr['class'] = 'img-fluid';
300303

301304
return $custom_logo_attr;

inc/plugins/cp-directory-setup.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ function( $sources ) {
3838
add_filter(
3939
'cpschool_post_meta_disallowed_post_types',
4040
function( $disallowed_post_types ) {
41-
$disallowed_post_types[] = 'cp_school_directory';
41+
// Directory entries can now display meta data when enabled.
42+
if ( ! is_singular() || ! cpschool_get_content_theme_mod( 'meta', 'cp_school_directory', true ) ) {
43+
$disallowed_post_types[] = 'cp_school_directory';
44+
}
4245

4346
return $disallowed_post_types;
4447
}

inc/template-tags.php

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -306,34 +306,35 @@ function cpschool_get_post_meta( $post_id = null, $single = true ) {
306306
<?php
307307
}
308308

309-
// Categories.
310-
if ( in_array( 'tax-category', $post_meta, true ) && has_category() ) {
311-
?>
312-
<li class="post-categories list-inline-item">
313-
<span class="sr-only"><?php _e( 'Categories:', 'cpschool' ); ?></span>
314-
<span class="meta-icon" aria-hidden="true">
315-
<i class="cps-icon cps-icon-category"></i>
316-
</span>
317-
<span class="meta-text">
318-
<?php the_category( ', ' ); ?>
319-
</span>
320-
</li>
321-
<?php
322-
}
323-
324-
// Tags.
325-
if ( in_array( 'tax-post_tag', $post_meta, true ) && has_tag() ) {
326-
?>
327-
<li class="post-tags list-inline-item">
328-
<span class="sr-only"><?php _e( 'Tags:', 'cpschool' ); ?></span>
329-
<span class="meta-icon" aria-hidden="true">
330-
<i class="cps-icon cps-icon-tag"></i>
331-
</span>
332-
<span class="meta-text">
333-
<?php the_tags( '', ', ', '' ); ?>
334-
</span>
335-
</li>
336-
<?php
309+
// All enabled taxonomies
310+
foreach( $post_meta as $single_post_meta ) {
311+
// Categories.
312+
if( substr( $single_post_meta, 0, 4 ) === "tax-" ) {
313+
$taxonomy = substr( $single_post_meta, 4 );
314+
if ( has_term( '', $taxonomy ) ) {
315+
$icon = 'category';
316+
if( $taxonomy == 'category' ) {
317+
$data = get_the_category_list( ', ' );
318+
} elseif( $taxonomy == 'post_tag' ) {
319+
$data = get_the_tag_list( ', ' );
320+
$icon = 'tag';
321+
}
322+
else {
323+
$data = get_the_term_list( get_the_ID(), $taxonomy );
324+
}
325+
?>
326+
<li class="post-categories list-inline-item">
327+
<span class="sr-only"><?php _e( 'Categories:', 'cpschool' ); ?></span>
328+
<span class="meta-icon" aria-hidden="true">
329+
<i class="cps-icon cps-icon-<?php echo esc_attr( $icon ); ?>"></i>
330+
</span>
331+
<span class="meta-text">
332+
<?php echo $data; ?>
333+
</span>
334+
</li>
335+
<?php
336+
}
337+
}
337338
}
338339

339340
// Comments link.
@@ -545,6 +546,8 @@ function cpschool_get_active_sidebars() {
545546
// TODO Consider using "cpschool_get_content_theme_mod" function in here.
546547
elseif ( is_page() ) {
547548
$option_name = 'pages';
549+
} elseif ( is_singular( 'cp_school_directory' ) ) {
550+
$option_name = 'directory_entry';
548551
} elseif ( is_single() ) {
549552
$option_name = 'posts';
550553
}
@@ -756,6 +759,7 @@ function cpschool_get_content_theme_mod( $option_name, $post_type, $single ) {
756759
$option_prefix_map = array(
757760
'post' => 'posts',
758761
'page' => 'pages',
762+
'cp_school_directory' => 'directory_entry',
759763
);
760764
if ( isset( $option_prefix_map[ $post_type ] ) ) {
761765
$option_prefix = $option_prefix_map[ $post_type ];

0 commit comments

Comments
 (0)