Skip to content

Commit 7d31496

Browse files
committed
Add live in-widget-title
Normalize JS methods to be camelCase
1 parent 11c95c1 commit 7d31496

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

class-widget-form-wp-customize-control.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function render_content() {
3131
</div>
3232
<div class="widget-title">
3333
<h4 class="customize-control-title">
34-
<?php echo esc_html( $this->label ); ?>
34+
<?php echo esc_html( $this->label ); ?><span class="in-widget-title"></span>
3535
</h4>
3636
</div>
3737
</div>

widget-customizer.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,26 @@ var WidgetCustomizer = (function ($) {
1616
var control = this;
1717

1818
control.setting.bind( function( to ) {
19-
control.update_widget( to );
19+
control.updateWidget( to );
2020
});
2121

2222
control.container.find( '.widget-control-update' ).on( 'click', function (e) {
23-
control.update_widget();
23+
control.updateWidget();
2424
});
2525

2626
control.setting.previewer.channel.bind( 'synced', function () {
2727
control.container.removeClass( 'previewer-loading' );
2828
});
2929

30-
control.controlTabs();
30+
control.setupControlToggle();
31+
32+
control.setupWidgetTitle();
3133
},
3234

3335
/**
3436
* @param {object} instance_override When the model changes, the instance is sent this way
3537
*/
36-
update_widget: function ( instance_override ) {
38+
updateWidget: function ( instance_override ) {
3739
var control = this;
3840
var data = control.container.find(':input').serialize();
3941
control.container.addClass( 'widget-form-loading' );
@@ -72,7 +74,7 @@ var WidgetCustomizer = (function ($) {
7274
});
7375
},
7476

75-
controlTabs: function() {
77+
setupControlToggle: function() {
7678
var control = this;
7779
control.container.find('.widget-top').on( 'click', function (e) {
7880
// Copied from wpWidgets.init() in wp-admin/js/widgets.js
@@ -88,9 +90,27 @@ var WidgetCustomizer = (function ($) {
8890
}
8991
e.preventDefault();
9092
} );
93+
},
9194

92-
}
95+
setupWidgetTitle: function () {
96+
var control = this;
97+
control.setting.bind( function( to ) {
98+
control.updateInWidgetTitle();
99+
});
100+
control.updateInWidgetTitle();
101+
},
93102

103+
updateInWidgetTitle: function () {
104+
var control = this;
105+
var title = control.setting().title;
106+
var in_widget_title = control.container.find('.in-widget-title');
107+
if ( title ) {
108+
in_widget_title.text( ': ' + title );
109+
}
110+
else {
111+
in_widget_title.text( '' );
112+
}
113+
}
94114
});
95115

96116
// Note that 'widget_form' must match the Widget_Form_WP_Customize_Control::$type

0 commit comments

Comments
 (0)