From cd9c3390eb1695ca1239f4015d744281ff367093 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Thu, 6 Aug 2020 17:20:36 -0300 Subject: [PATCH] Adds option to hide core title from metadata list, as it already appears on the page title. --- src/functions/customizer.php | 23 ++++++++++++++++++++ src/template-parts/single-items-metadata.php | 1 + 2 files changed, 24 insertions(+) diff --git a/src/functions/customizer.php b/src/functions/customizer.php index 8a01e7c..8d3b086 100644 --- a/src/functions/customizer.php +++ b/src/functions/customizer.php @@ -638,6 +638,29 @@ function tainacan_customize_register( $wp_customize ) { 'render_callback' => '__return_false', 'fallback_refresh' => true ) ); + + /** + * Adds options to hide or no the core metadada in the metadada list. + */ + $wp_customize->add_setting( 'tainacan_single_item_hide_core_title_metadata', array( + 'type' => 'theme_mod', + 'capability' => 'edit_theme_options', + 'default' => false, + 'transport' => 'postMessage', + 'sanitize_callback' => 'tainacan_callback_sanitize_checkbox' + ) ); + $wp_customize->add_control( 'tainacan_single_item_hide_core_title_metadata', array( + 'type' => 'checkbox', + 'priority' => 2, // Within the section. + 'section' => 'tainacan_single_item_page', + 'label' => __( 'Hide core title from metadata list', 'tainacan-interface' ), + 'description' => __( 'Toggle to hide or not the core title from the metadada list, as it already appears on the page title.', 'tainacan-interface' ) + ) ); + $wp_customize->selective_refresh->add_partial( 'tainacan_single_item_hide_core_title_metadata', array( + 'selector' => '.metadata-type-core_title', + 'render_callback' => '__return_false', + 'fallback_refresh' => true + ) ); /** * Adds options to control single items page number of metadata columns. diff --git a/src/template-parts/single-items-metadata.php b/src/template-parts/single-items-metadata.php index 765e0a8..71d880d 100644 --- a/src/template-parts/single-items-metadata.php +++ b/src/template-parts/single-items-metadata.php @@ -60,6 +60,7 @@ 'after_title' => '', 'before_value' => '

', 'after_value' => '

', + 'exclude_title' => get_theme_mod('tainacan_single_item_hide_core_title_metadata', false) ); //$field = null; tainacan_the_metadata( $args );