Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 0562821

Browse files
Merge pull request #411 from abaicus/development
Selective refresh for widgets
2 parents 86b69d0 + d90e562 commit 0562821

File tree

2 files changed

+45
-29
lines changed

2 files changed

+45
-29
lines changed

functions.php

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ function zerif_setup() {
7979

8080
/* woocommerce support */
8181
add_theme_support( 'woocommerce' );
82-
82+
83+
/* selective widget refresh */
84+
add_theme_support( 'customize-selective-refresh-widgets' );
85+
8386
/*******************************************/
8487
/************* Welcome screen *************/
8588
/*******************************************/
@@ -184,8 +187,8 @@ function zerif_widgets_init() {
184187
register_sidebar(array(
185188
'name' => __('About us section', 'zerif-lite'),
186189
'id' => 'sidebar-aboutus',
187-
'before_widget' => '',
188-
'after_widget' => '',
190+
'before_widget' => '<span id="%1$s">',
191+
'after_widget' => '</span>',
189192
'before_title' => '<h1 class="widget-title">',
190193
'after_title' => '</h1>',
191194
));
@@ -455,13 +458,13 @@ function zerif_register_widgets() {
455458

456459
/* Register sidebars */
457460
foreach ( $zerif_lite_sidebars as $zerif_lite_sidebar ):
458-
461+
$extra_class = '';
459462
if( $zerif_lite_sidebar == 'sidebar-ourfocus' ):
460463

461464
$zerif_lite_name = __('Our focus section widgets', 'zerif-lite');
462465

463466
elseif( $zerif_lite_sidebar == 'sidebar-testimonials' ):
464-
467+
$extra_class = 'feedback-box';
465468
$zerif_lite_name = __('Testimonials section widgets', 'zerif-lite');
466469

467470
elseif( $zerif_lite_sidebar == 'sidebar-ourteam' ):
@@ -478,8 +481,8 @@ function zerif_register_widgets() {
478481
array (
479482
'name' => $zerif_lite_name,
480483
'id' => $zerif_lite_sidebar,
481-
'before_widget' => '',
482-
'after_widget' => ''
484+
'before_widget' => '<span id="%1$s" class="'.$extra_class.'">',
485+
'after_widget' => '</span>',
483486
)
484487
);
485488

@@ -636,7 +639,10 @@ class zerif_ourfocus extends WP_Widget {
636639
public function __construct() {
637640
parent::__construct(
638641
'ctUp-ads-widget',
639-
__( 'Zerif - Our focus widget', 'zerif-lite' )
642+
__( 'Zerif - Our focus widget', 'zerif-lite' ),
643+
array (
644+
'customize_selective_refresh' => true,
645+
)
640646
);
641647
add_action('admin_enqueue_scripts', array($this, 'widget_scripts'));
642648
}
@@ -777,7 +783,10 @@ class zerif_testimonial_widget extends WP_Widget {
777783
public function __construct() {
778784
parent::__construct(
779785
'zerif_testim-widget',
780-
__( 'Zerif - Testimonial widget', 'zerif-lite' )
786+
__( 'Zerif - Testimonial widget', 'zerif-lite' ),
787+
array (
788+
'customize_selective_refresh' => true,
789+
)
781790
);
782791
add_action('admin_enqueue_scripts', array($this, 'widget_scripts'));
783792
}
@@ -796,9 +805,11 @@ function widget($args, $instance) {
796805
$zerif_accessibility = get_theme_mod('zerif_accessibility');
797806
// open link in a new tab when checkbox "accessibility" is not ticked
798807
$attribut_new_tab = (isset($zerif_accessibility) && ($zerif_accessibility != 1) ? ' target="_blank"' : '' );
799-
?>
800808

801-
<div class="feedback-box">
809+
echo $before_widget;
810+
811+
?>
812+
802813

803814
<!-- MESSAGE OF THE CLIENT -->
804815

@@ -862,10 +873,11 @@ function widget($args, $instance) {
862873
</div>
863874
<!-- / END CLIENT INFORMATION-->
864875

865-
</div> <!-- / END SINGLE FEEDBACK BOX-->
866876

867877
<?php
868878

879+
echo $after_widget;
880+
869881
}
870882

871883
function update($new_instance, $old_instance) {
@@ -924,17 +936,18 @@ function form($instance) {
924936
}
925937

926938
/****************************/
927-
928939
/****** clients widget ******/
929-
930940
/***************************/
931941

932942
class zerif_clients_widget extends WP_Widget{
933943

934944
public function __construct() {
935945
parent::__construct(
936946
'zerif_clients-widget',
937-
__( 'Zerif - Clients widget', 'zerif-lite' )
947+
__( 'Zerif - Clients widget', 'zerif-lite' ),
948+
array (
949+
'customize_selective_refresh' => true,
950+
)
938951
);
939952
add_action('admin_enqueue_scripts', array($this, 'widget_scripts'));
940953
}
@@ -1028,7 +1041,10 @@ class zerif_team_widget extends WP_Widget{
10281041
public function __construct() {
10291042
parent::__construct(
10301043
'zerif_team-widget',
1031-
__( 'Zerif - Team member widget', 'zerif-lite' )
1044+
__( 'Zerif - Team member widget', 'zerif-lite' ),
1045+
array (
1046+
'customize_selective_refresh' => true,
1047+
)
10321048
);
10331049
add_action('admin_enqueue_scripts', array($this, 'widget_scripts'));
10341050
}

style.css

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,28 +1846,28 @@ ul.nav > li.current_page_item.current > a:before {
18461846
-webkit-transition: all 0.2s ease-in-out;
18471847
transition: all 0.2s ease-in-out;
18481848
}
1849-
.focus-box:nth-child(4n+1) .service-icon:hover {
1849+
#focus span:nth-child(4n+1) .focus-box .service-icon:hover {
18501850
border: 10px solid #e96656;
18511851
}
1852-
.focus-box:nth-child(4n+2) .service-icon:hover{
1852+
#focus span:nth-child(4n+2) .focus-box .service-icon:hover{
18531853
border: 10px solid #34d293;
18541854
}
1855-
.focus-box:nth-child(4n+3) .service-icon:hover {
1855+
#focus span:nth-child(4n+3) .focus-box .service-icon:hover {
18561856
border: 10px solid #3ab0e2;
18571857
}
1858-
.focus-box:nth-child(4n+4) .service-icon:hover{
1858+
#focus span:nth-child(4n+4) .focus-box .service-icon:hover{
18591859
border: 10px solid #f7d861;
18601860
}
1861-
.focus-box:nth-child(4n+1) .red-border-bottom:before {
1861+
#focus span:nth-child(4n+1) .focus-box .red-border-bottom:before {
18621862
background: #e96656;
18631863
}
1864-
.focus-box:nth-child(4n+2) .red-border-bottom:before {
1864+
#focus span:nth-child(4n+2) .focus-box .red-border-bottom:before {
18651865
background: #34d293;
18661866
}
1867-
.focus-box:nth-child(4n+3) .red-border-bottom:before {
1867+
#focus span:nth-child(4n+3) .focus-box .red-border-bottom:before {
18681868
background: #3ab0e2;
18691869
}
1870-
.focus-box:nth-child(4n+4) .red-border-bottom:before {
1870+
#focus span:nth-child(4n+4) .focus-box .red-border-bottom:before {
18711871
background: #f7d861;
18721872
}
18731873
.focus-box h3 {
@@ -2330,7 +2330,7 @@ width: -webkit-calc(100% / 4);
23302330
.client-list div{
23312331
margin: 0;
23322332
}
2333-
.client-list div a{
2333+
.client-list div span{
23342334
margin-right: 24px;
23352335
}
23362336
.client-list div a:last-child{
@@ -2482,16 +2482,16 @@ width: -webkit-calc(100% / 4);
24822482
.team-member .social-icons ul li a:hover {
24832483
color: #e96656;
24842484
}
2485-
.our-team .row > div:nth-child(4n+1) .red-border-bottom:before{
2485+
.our-team .row > span:nth-child(4n+1) .red-border-bottom:before{
24862486
background: #e96656;
24872487
}
2488-
.our-team .row > div:nth-child(4n+2) .red-border-bottom:before{
2488+
.our-team .row > span:nth-child(4n+2) .red-border-bottom:before{
24892489
background: #34d293;
24902490
}
2491-
.our-team .row > div:nth-child(4n+3) .red-border-bottom:before{
2491+
.our-team .row > span:nth-child(4n+3) .red-border-bottom:before{
24922492
background: #3ab0e2;
24932493
}
2494-
.our-team .row > div:nth-child(4n+4) .red-border-bottom:before{
2494+
.our-team .row > span:nth-child(4n+4) .red-border-bottom:before{
24952495
background: #f7d861;
24962496
}
24972497

0 commit comments

Comments
 (0)