Version Description
- May 19, 2016 = Add front-end "edit" link to quickly edit widgets in the customizer
Download this release
Release Info
Developer | jonathanbardo |
Plugin | Contact Widgets |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 1.3.0
- assets/js/admin.js +5 -5
- assets/js/admin.min.js +1 -1
- assets/js/customize-preview-helper.js +9 -0
- assets/js/customize-preview-helper.min.js +1 -0
- contact-widgets.php +1 -1
- includes/class-base-widget.php +80 -0
- includes/class-contact.php +1 -21
- includes/class-social.php +3 -11
- readme.txt +4 -1
assets/js/admin.js
CHANGED
@@ -163,14 +163,14 @@
|
|
163 |
|
164 |
$( document ).ready( function ( $ ) {
|
165 |
|
166 |
-
// Sortable
|
167 |
-
$( document.body ).on( 'click.widgets-toggle', start_sortable );
|
168 |
-
|
169 |
-
$( document ).on( 'widget-updated', start_sortable );
|
170 |
-
|
171 |
// Social
|
172 |
$( document ).on( 'click', '.wpcw-widget-social .icons a', socialField.init );
|
173 |
|
|
|
|
|
|
|
|
|
|
|
174 |
} );
|
175 |
|
176 |
} )( jQuery );
|
163 |
|
164 |
$( document ).ready( function ( $ ) {
|
165 |
|
|
|
|
|
|
|
|
|
|
|
166 |
// Social
|
167 |
$( document ).on( 'click', '.wpcw-widget-social .icons a', socialField.init );
|
168 |
|
169 |
+
// Sortable
|
170 |
+
$( document ).on( 'wpcw.change', start_sortable );
|
171 |
+
$( document ).on( 'click.widgets-toggle', start_sortable );
|
172 |
+
$( document ).on( 'widget-updated', start_sortable );
|
173 |
+
|
174 |
} );
|
175 |
|
176 |
} )( jQuery );
|
assets/js/admin.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(a){function b(){var b=a(".wpcw-widget .form");b.sortable({items:"> *:not(.not-sortable)",handle:".wpcw-widget-sortable-handle",containment:"parent",placeholder:"sortable-placeholder",axis:"y",tolerance:"pointer",forcePlaceholderSize:!0,cursorAt:{top:40},stop:function(a,c){b.find(".customizer_update").val(c.item.index()).trigger("change")}})}a.fn.selectString=function(b){var c=a(this)[0],d=c.value.indexOf(b),e=d+b.length;if(c&&!(0>d))if(c.setSelectionRange)c.focus(),c.setSelectionRange(d,e);else if(c.createTextRange){var f=c.createTextRange();f.collapse(!0),f.moveEnd("character",e),f.moveStart("character",d),f.select()}else c.selectionStart&&(c.selectionStart=d,c.selectionEnd=e)};var c={$btn:null,$widget:null,$template:null,init:function(b){b.preventDefault();var d=c;return d.$btn=a(this),d.$widget=d.$btn.parents(".wpcw-widget"),d.$widget.find("."+d.$btn.data("key")).is(":animated")?!1:d.$btn.hasClass("inactive")?(d.$template=d.$widget.find(".default-fields"),d.$template=a(a.trim(d.$template.clone().html())),void d.add()):void d.remove()},add:function(){this.$btn.removeClass("inactive");var a=this.$btn.data();this.$template.addClass(a.key).find("label").prop("for",a.id),this.$template.find("input").prop("id",a.id).prop("name",a.name).prop("value",a.value),this.$template.find("label span.fa").prop("class",this.$btn.find("i").attr("class")),this.$template.find("label span.text").text(a.label),this.$template.hide().prependTo(this.$widget.find(".form")).stop(!0,!0).animate({height:"toggle",opacity:"toggle"},250),this.$template.find("input").selectString(a.select),this.update_customizer()},remove:function(){this.$btn.addClass("inactive"),this.$widget.find(".form ."+this.$btn.data("key")).stop(!0,!0).animate({height:"toggle",opacity:"toggle"},250,function(){a(this).remove()}),this.update_customizer()},update_customizer:function(){var a=this.$widget.find("div > div").length;this.$widget.find(".customizer_update").val(a).trigger("change")}};a(document).ready(function(a){a(document
|
1 |
+
!function(a){function b(){var b=a(".wpcw-widget .form");b.sortable({items:"> *:not(.not-sortable)",handle:".wpcw-widget-sortable-handle",containment:"parent",placeholder:"sortable-placeholder",axis:"y",tolerance:"pointer",forcePlaceholderSize:!0,cursorAt:{top:40},stop:function(a,c){b.find(".customizer_update").val(c.item.index()).trigger("change")}})}a.fn.selectString=function(b){var c=a(this)[0],d=c.value.indexOf(b),e=d+b.length;if(c&&!(0>d))if(c.setSelectionRange)c.focus(),c.setSelectionRange(d,e);else if(c.createTextRange){var f=c.createTextRange();f.collapse(!0),f.moveEnd("character",e),f.moveStart("character",d),f.select()}else c.selectionStart&&(c.selectionStart=d,c.selectionEnd=e)};var c={$btn:null,$widget:null,$template:null,init:function(b){b.preventDefault();var d=c;return d.$btn=a(this),d.$widget=d.$btn.parents(".wpcw-widget"),d.$widget.find("."+d.$btn.data("key")).is(":animated")?!1:d.$btn.hasClass("inactive")?(d.$template=d.$widget.find(".default-fields"),d.$template=a(a.trim(d.$template.clone().html())),void d.add()):void d.remove()},add:function(){this.$btn.removeClass("inactive");var a=this.$btn.data();this.$template.addClass(a.key).find("label").prop("for",a.id),this.$template.find("input").prop("id",a.id).prop("name",a.name).prop("value",a.value),this.$template.find("label span.fa").prop("class",this.$btn.find("i").attr("class")),this.$template.find("label span.text").text(a.label),this.$template.hide().prependTo(this.$widget.find(".form")).stop(!0,!0).animate({height:"toggle",opacity:"toggle"},250),this.$template.find("input").selectString(a.select),this.update_customizer()},remove:function(){this.$btn.addClass("inactive"),this.$widget.find(".form ."+this.$btn.data("key")).stop(!0,!0).animate({height:"toggle",opacity:"toggle"},250,function(){a(this).remove()}),this.update_customizer()},update_customizer:function(){var a=this.$widget.find("div > div").length;this.$widget.find(".customizer_update").val(a).trigger("change")}};a(document).ready(function(a){a(document).on("click",".wpcw-widget-social .icons a",c.init),a(document).on("wpcw.change",b),a(document).on("click.widgets-toggle",b),a(document).on("widget-updated",b)})}(jQuery);
|
assets/js/customize-preview-helper.js
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
( function ( $ ) {
|
2 |
+
|
3 |
+
$( document ).on( 'click', '.wpcw-widgets', function() {
|
4 |
+
|
5 |
+
wp.customize.WidgetCustomizerPreview.preview.send( 'focus-widget-control', $( this ).prop( 'id' ) );
|
6 |
+
|
7 |
+
});
|
8 |
+
|
9 |
+
} )( jQuery );
|
assets/js/customize-preview-helper.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(a){a(document).on("click",".wpcw-widgets",function(){wp.customize.WidgetCustomizerPreview.preview.send("focus-widget-control",a(this).prop("id"))})}(jQuery);
|
contact-widgets.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Contact Widgets
|
4 |
* Description: Beautifully display social media and contact information on your website with these simple widgets.
|
5 |
-
* Version: 1.
|
6 |
* Author: GoDaddy
|
7 |
* Author URI: https://godaddy.com
|
8 |
* Text Domain: contact-widgets
|
2 |
/**
|
3 |
* Plugin Name: Contact Widgets
|
4 |
* Description: Beautifully display social media and contact information on your website with these simple widgets.
|
5 |
+
* Version: 1.3.0
|
6 |
* Author: GoDaddy
|
7 |
* Author URI: https://godaddy.com
|
8 |
* Text Domain: contact-widgets
|
includes/class-base-widget.php
CHANGED
@@ -38,6 +38,32 @@ abstract class Base_Widget extends \WP_Widget {
|
|
38 |
'select_options' => [], // Only used if type=select & form_callback=render_form_select
|
39 |
];
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
/**
|
42 |
* Add common ressources needed for the form
|
43 |
*
|
@@ -50,6 +76,17 @@ abstract class Base_Widget extends \WP_Widget {
|
|
50 |
add_action( 'admin_footer', [ $this, 'enqueue_scripts' ] );
|
51 |
add_action( 'customize_controls_print_footer_scripts', [ $this, 'print_customizer_scripts' ] );
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
|
55 |
/**
|
@@ -417,6 +454,30 @@ abstract class Base_Widget extends \WP_Widget {
|
|
417 |
|
418 |
echo '</ul>';
|
419 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
echo $args['after_widget'];
|
421 |
|
422 |
}
|
@@ -475,4 +536,23 @@ abstract class Base_Widget extends \WP_Widget {
|
|
475 |
|
476 |
}
|
477 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
478 |
}
|
38 |
'select_options' => [], // Only used if type=select & form_callback=render_form_select
|
39 |
];
|
40 |
|
41 |
+
/**
|
42 |
+
* Widget base constructor
|
43 |
+
*
|
44 |
+
* @param string $id_base
|
45 |
+
* @param string $name
|
46 |
+
* @param array $widget_options
|
47 |
+
*/
|
48 |
+
public function __construct( $id_base, $name, array $widget_options ) {
|
49 |
+
|
50 |
+
parent::__construct( $id_base, $name, $widget_options );
|
51 |
+
|
52 |
+
if ( has_action( 'wp_enqueue_scripts', [ $this, 'front_end_enqueue_scripts' ] ) ) {
|
53 |
+
|
54 |
+
return;
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
// Enqueue style if widget is active (appears in a sidebar) or if in Customizer preview.
|
59 |
+
if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) {
|
60 |
+
|
61 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'front_end_enqueue_scripts' ] );
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
/**
|
68 |
* Add common ressources needed for the form
|
69 |
*
|
76 |
add_action( 'admin_footer', [ $this, 'enqueue_scripts' ] );
|
77 |
add_action( 'customize_controls_print_footer_scripts', [ $this, 'print_customizer_scripts' ] );
|
78 |
|
79 |
+
?>
|
80 |
+
<script>
|
81 |
+
( function ( $ ) {
|
82 |
+
|
83 |
+
// This let us know that we appended a new widget to reset sortables
|
84 |
+
$( document ).trigger( 'wpcw.change' );
|
85 |
+
|
86 |
+
} )( jQuery );
|
87 |
+
</script>
|
88 |
+
<?php
|
89 |
+
|
90 |
}
|
91 |
|
92 |
/**
|
454 |
|
455 |
echo '</ul>';
|
456 |
|
457 |
+
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
458 |
+
|
459 |
+
// admin-bar.php -> wp_admin_bar_customize_menu()
|
460 |
+
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
461 |
+
|
462 |
+
$edit_url = add_query_arg(
|
463 |
+
[
|
464 |
+
'autofocus' => [
|
465 |
+
'section' => 'sidebar-widgets-' . $args['id'],
|
466 |
+
'control' => 'widget_' . preg_replace( '/-(\d)/', '[$1]', $args['widget_id'] ),
|
467 |
+
],
|
468 |
+
'url' => urlencode( $current_url ),
|
469 |
+
],
|
470 |
+
wp_customize_url()
|
471 |
+
);
|
472 |
+
|
473 |
+
printf(
|
474 |
+
'<a class="post-edit-link" href="%s">%s</a>',
|
475 |
+
esc_url( $edit_url ),
|
476 |
+
__( 'Edit' )
|
477 |
+
);
|
478 |
+
|
479 |
+
}
|
480 |
+
|
481 |
echo $args['after_widget'];
|
482 |
|
483 |
}
|
536 |
|
537 |
}
|
538 |
|
539 |
+
/**
|
540 |
+
* Enqueue scripts and styles for front-end use
|
541 |
+
*
|
542 |
+
* @action wp_enqueue_scripts
|
543 |
+
*/
|
544 |
+
public function front_end_enqueue_scripts() {
|
545 |
+
|
546 |
+
$suffix = SCRIPT_DEBUG ? '' : '.min';
|
547 |
+
|
548 |
+
wp_enqueue_style( 'wpcw', \Contact_Widgets::$assets_url . "css/style{$suffix}.css", [], Plugin::$version );
|
549 |
+
|
550 |
+
if ( is_customize_preview() ) {
|
551 |
+
|
552 |
+
wp_enqueue_script( 'wpcw-helper', \Contact_Widgets::$assets_url . "js/customize-preview-helper{$suffix}.js", [], Plugin::$version );
|
553 |
+
|
554 |
+
}
|
555 |
+
|
556 |
+
}
|
557 |
+
|
558 |
}
|
includes/class-contact.php
CHANGED
@@ -16,7 +16,7 @@ final class Contact extends Base_Widget {
|
|
16 |
public function __construct() {
|
17 |
|
18 |
$widget_options = [
|
19 |
-
'classname' => 'wpcw-widget-contact',
|
20 |
'description' => __( 'Display your contact information.', 'contact-widgets' ),
|
21 |
'customize_selective_refresh' => true,
|
22 |
];
|
@@ -27,13 +27,6 @@ final class Contact extends Base_Widget {
|
|
27 |
$widget_options
|
28 |
);
|
29 |
|
30 |
-
// Enqueue style if widget is active (appears in a sidebar) or if in Customizer preview.
|
31 |
-
if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) {
|
32 |
-
|
33 |
-
add_action( 'wp_enqueue_scripts', [ $this, 'front_end_enqueue_scripts' ] );
|
34 |
-
|
35 |
-
}
|
36 |
-
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -135,19 +128,6 @@ final class Contact extends Base_Widget {
|
|
135 |
|
136 |
}
|
137 |
|
138 |
-
/**
|
139 |
-
* Enqueue scripts and styles for front-end use
|
140 |
-
*
|
141 |
-
* @action wp_enqueue_scripts
|
142 |
-
*/
|
143 |
-
public function front_end_enqueue_scripts() {
|
144 |
-
|
145 |
-
$suffix = SCRIPT_DEBUG ? '' : '.min';
|
146 |
-
|
147 |
-
wp_enqueue_style( 'wpcw', \Contact_Widgets::$assets_url . "css/style{$suffix}.css", [], Plugin::$version );
|
148 |
-
|
149 |
-
}
|
150 |
-
|
151 |
/**
|
152 |
* Initialize fields for use on front-end of forms
|
153 |
*
|
16 |
public function __construct() {
|
17 |
|
18 |
$widget_options = [
|
19 |
+
'classname' => 'wpcw-widgets wpcw-widget-contact',
|
20 |
'description' => __( 'Display your contact information.', 'contact-widgets' ),
|
21 |
'customize_selective_refresh' => true,
|
22 |
];
|
27 |
$widget_options
|
28 |
);
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
/**
|
128 |
|
129 |
}
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
/**
|
132 |
* Initialize fields for use on front-end of forms
|
133 |
*
|
includes/class-social.php
CHANGED
@@ -16,7 +16,7 @@ final class Social extends Base_Widget {
|
|
16 |
public function __construct() {
|
17 |
|
18 |
$widget_options = [
|
19 |
-
'classname' => 'wpcw-widget-social',
|
20 |
'description' => __( 'Display links to your social media profiles.', 'contact-widgets' ),
|
21 |
'customize_selective_refresh' => true,
|
22 |
];
|
@@ -27,13 +27,6 @@ final class Social extends Base_Widget {
|
|
27 |
$widget_options
|
28 |
);
|
29 |
|
30 |
-
// Enqueue style if widget is active (appears in a sidebar) or if in Customizer preview.
|
31 |
-
if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) {
|
32 |
-
|
33 |
-
add_action( 'wp_enqueue_scripts', [ $this, 'front_end_enqueue_scripts' ] );
|
34 |
-
|
35 |
-
}
|
36 |
-
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -186,10 +179,9 @@ final class Social extends Base_Widget {
|
|
186 |
*/
|
187 |
public function front_end_enqueue_scripts() {
|
188 |
|
189 |
-
$suffix = SCRIPT_DEBUG ? '' : '.min';
|
190 |
-
|
191 |
wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', [], '4.5.0' );
|
192 |
-
|
|
|
193 |
|
194 |
}
|
195 |
|
16 |
public function __construct() {
|
17 |
|
18 |
$widget_options = [
|
19 |
+
'classname' => 'wpcw-widgets wpcw-widget-social',
|
20 |
'description' => __( 'Display links to your social media profiles.', 'contact-widgets' ),
|
21 |
'customize_selective_refresh' => true,
|
22 |
];
|
27 |
$widget_options
|
28 |
);
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
/**
|
179 |
*/
|
180 |
public function front_end_enqueue_scripts() {
|
181 |
|
|
|
|
|
182 |
wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', [], '4.5.0' );
|
183 |
+
|
184 |
+
parent::front_end_enqueue_scripts();
|
185 |
|
186 |
}
|
187 |
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: godaddy, jonathanbardo, fjarrett
|
|
3 |
Tags: widget, contact, social, sharing, share button, share buttons, share links, social icons, social media, facebook, twitter, google plus, instagram
|
4 |
Requires at least: 4.4.2
|
5 |
Tested up to: 4.5
|
6 |
-
Stable tag: 1.
|
7 |
|
8 |
Beautifully display social media and contact information on your website with these simple widgets.
|
9 |
|
@@ -105,6 +105,9 @@ add_filter( 'wpcw_widget_social_custom_fields', function( $fields, $instance ) {
|
|
105 |
</pre>
|
106 |
|
107 |
== Changelog ==
|
|
|
|
|
|
|
108 |
= 1.2.0 - April 12, 2016 =
|
109 |
WordPress 4.5 compatibility
|
110 |
|
3 |
Tags: widget, contact, social, sharing, share button, share buttons, share links, social icons, social media, facebook, twitter, google plus, instagram
|
4 |
Requires at least: 4.4.2
|
5 |
Tested up to: 4.5
|
6 |
+
Stable tag: 1.3.0
|
7 |
|
8 |
Beautifully display social media and contact information on your website with these simple widgets.
|
9 |
|
105 |
</pre>
|
106 |
|
107 |
== Changelog ==
|
108 |
+
= 1.3.0 - May 19, 2016 =
|
109 |
+
Add front-end "edit" link to quickly edit widgets in the customizer
|
110 |
+
|
111 |
= 1.2.0 - April 12, 2016 =
|
112 |
WordPress 4.5 compatibility
|
113 |
|