From 56fea899d4c5822546142e093f73f46d555395f4 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Wed, 15 Apr 2020 17:34:31 -0300 Subject: [PATCH] Adds partial edit link buttons to options on single items page. --- src/functions/customizer.php | 48 +++++++++++++++++++++++++++++------ src/tainacan/single-items.php | 10 ++++---- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/functions/customizer.php b/src/functions/customizer.php index a3c548e..e93a7ea 100644 --- a/src/functions/customizer.php +++ b/src/functions/customizer.php @@ -262,7 +262,7 @@ function tainacan_customize_register( $wp_customize ) { 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'default' => '3', - 'transport' => 'refresh' + 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'tainacan_single_item_metadata_columns_count_desktop', array( 'type' => 'number', @@ -277,6 +277,12 @@ function tainacan_customize_register( $wp_customize ) { 'step' => 1 ) ) ); + $wp_customize->selective_refresh->add_partial( 'tainacan_single_item_metadata_columns_count_desktop', + array( + 'selector' => '.single-item-collection--information .row', + 'render_callback' => '__return_false', + 'fallback_refresh' => true + ) ); $wp_customize->add_setting( 'tainacan_single_item_metadata_columns_count_wide', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', @@ -298,13 +304,13 @@ function tainacan_customize_register( $wp_customize ) { ) ); /** - * Adds options to display or not the thumbnail and share buttons on items page. + * Adds options to display or not the thumbnail on items page. */ $wp_customize->add_setting( 'tainacan_single_item_display_thumbnail', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'default' => true, - 'transport' => 'refresh' + 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'tainacan_single_item_display_thumbnail', array( 'type' => 'checkbox', @@ -313,11 +319,21 @@ function tainacan_customize_register( $wp_customize ) { 'label' => __( 'Display item thumbnail', 'tainacan-interface' ), 'description' => __( 'Toggle to show or not the item thumbnail, within the metadata list section.', 'tainacan-interface' ) ) ); + $wp_customize->selective_refresh->add_partial( 'tainacan_single_item_display_thumbnail', + array( + 'selector' => '.tainacan-item-thumbnail-container', + 'render_callback' => '__return_false', + 'fallback_refresh' => true + ) ); + + /** + * Adds options to display or not hare buttons on items page. + */ $wp_customize->add_setting( 'tainacan_single_item_display_share_buttons', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'default' => true, - 'transport' => 'refresh' + 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'tainacan_single_item_display_share_buttons', array( 'type' => 'checkbox', @@ -326,6 +342,12 @@ function tainacan_customize_register( $wp_customize ) { 'label' => __( 'Display share buttons', 'tainacan-interface' ), 'description' => __( 'Toggle to show or not the social icon share buttons, within the metadata list section or collection banner.', 'tainacan-interface' ) ) ); + $wp_customize->selective_refresh->add_partial( 'tainacan_single_item_display_share_buttons', + array( + 'selector' => '.tainacan-item-share-container', + 'render_callback' => '__return_false', + 'fallback_refresh' => true + ) ); /** * Adds option to display attachments and document as a gallery list. @@ -334,7 +356,7 @@ function tainacan_customize_register( $wp_customize ) { 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'default' => false, - 'transport' => 'refresh' + 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'tainacan_single_item_gallery_mode', array( 'type' => 'checkbox', @@ -343,7 +365,12 @@ function tainacan_customize_register( $wp_customize ) { 'label' => __( 'Show Document and Attachments grouped in one slider.', 'tainacan-interface' ), 'description' => __( 'Toggle to show the document and attachments in the same list, a carousel with the current item on top.', 'tainacan-interface' ) ) ); - + $wp_customize->selective_refresh->add_partial( 'tainacan_single_item_gallery_mode', + array( + 'selector' => '.single-item-collection--gallery, .single-item-collection--attachments', + 'render_callback' => '__return_false', + 'fallback_refresh' => true + ) ); /** * Adds option to display Collection banner on the item single page. @@ -352,7 +379,7 @@ function tainacan_customize_register( $wp_customize ) { 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'default' => false, - 'transport' => 'refresh' + 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'tainacan_single_item_collection_header', array( 'type' => 'checkbox', @@ -361,7 +388,12 @@ function tainacan_customize_register( $wp_customize ) { 'label' => __( 'Display a header of the related collection.', 'tainacan-interface' ), 'description' => __( 'Toggle to show a banner with name, thumbnail and color of the related collection.', 'tainacan-interface' ) ) ); - + $wp_customize->selective_refresh->add_partial( 'tainacan_single_item_collection_header', + array( + 'selector' => '.tainacan-single-item-heading', + 'render_callback' => '__return_false', + 'fallback_refresh' => true + ) ); /** * Adds section to control collection items page. --------------------------------------------------------- diff --git a/src/tainacan/single-items.php b/src/tainacan/single-items.php index 44a21bb..9dd0087 100644 --- a/src/tainacan/single-items.php +++ b/src/tainacan/single-items.php @@ -69,7 +69,7 @@ if (get_theme_mod('tainacan_single_item_collection_header', false)) { global $wp; if (get_theme_mod( 'tainacan_single_item_display_share_buttons', true )) : ?>
-
+ @@ -99,7 +99,7 @@ if (get_theme_mod('tainacan_single_item_collection_header', false)) {
-
+

@@ -111,7 +111,7 @@ if (get_theme_mod('tainacan_single_item_collection_header', false)) {
-
+
  • @@ -301,7 +301,7 @@ if (get_theme_mod('tainacan_single_item_collection_header', false)) {