WordPress Social Sharing Plugin – Social Warfare - Version 3.5.2

Version Description

(19 MAR 2019) = * Fixed tags for OG and Twitter Card. * Fixed source of Pinterest description when pinning from Save or Pinterest button. * Fixed empty 'via' being added to Pinterest description and Click to Tweet. * Updated addon registration and unregistration messages. * Updated icon font file and encoding.

Download this release

Release Info

Developer WarfarePlugins
Plugin Icon 128x128 WordPress Social Sharing Plugin – Social Warfare
Version 3.5.2
Comparing to
See all releases

Code changes from version 3.5.1 to 3.5.2

assets/fonts/sw-icon-font.woff CHANGED
Binary file
assets/js/admin-options-page.js CHANGED
@@ -4,7 +4,7 @@
4
 
5
  window.onload = function() {
6
  /*********************************************************
7
- Temporary patch for the custom color selects.
8
  *********************************************************/
9
  /*
10
  * Temp patch on the Visual Options colors.
@@ -13,17 +13,17 @@
13
  var panelSelector = "[name=default_colors],[name=hover_colors], [name=single_colors]";
14
  var floatSelector = "[name=float_default_colors], [name=float_hover_colors], [name=float_single_colors]";
15
 
16
- //* Hide the custom color inputs by default.
17
  jQuery("[name=custom_color],[name=custom_color_outlines],[name=float_custom_color],[name=float_custom_color_outlines]").parent().parent().hide();
18
 
19
- //* Show custom fields if they have already been selected.
20
  jQuery(panelSelector).each(function(index, select) {
21
  var value = jQuery(select).val();
22
  var customColor = jQuery("[name=custom_color]").parent().parent();
23
  var customOutlines = jQuery("[name=custom_color_outlines]").parent().parent();
24
 
25
  if (value.indexOf("custom") !== -1) {
26
- //* A custom value is set for this input.
27
  if (value.indexOf('outlines') > 0) {
28
  customOutlines.show();
29
  } else {
@@ -32,15 +32,14 @@
32
  }
33
  });
34
 
35
-
36
- //* Same, for floating button options.
37
  jQuery(floatSelector).each(function(index, select) {
38
  var value = jQuery(select).val();
39
  var customColor = jQuery("[name=float_custom_color]").parent().parent();
40
  var customOutlines = jQuery("[name=float_custom_color_outlines]").parent().parent();
41
 
42
  if (value.indexOf("custom") !== -1) {
43
- //* A custom value is set for this input.
44
  if (value.indexOf('outlines') > 0) {
45
  customOutlines.show();
46
  } else {
@@ -49,8 +48,7 @@
49
  }
50
  });
51
 
52
-
53
- //* Change handlers for style.
54
  jQuery(panelSelector).on("change", function(e) {
55
  var value = e.target.value;
56
  var customColor = jQuery("[name=custom_color]").parent().parent();
@@ -59,8 +57,7 @@
59
  handleCustomColors(e, panelSelector, customColor, customOutlines, value);
60
  });
61
 
62
-
63
- //* Same, for floating button options.
64
  jQuery(floatSelector).on("change", function(e) {
65
  var value = e.target.value;
66
  var customColor = jQuery("[name=float_custom_color]").parent().parent();
@@ -74,7 +71,7 @@
74
  }
75
 
76
  function handleCustomColors(event, selector, customColor, customOutlines) {
77
- //* Create a notice about the custom colors.
78
  var colorNotice = '<div id="color-notice"><p><span class="color-dismiss"></span><b>Note:</b> Custom colors will not show up in the preview, but will on your site.</p></div>';
79
  var visibility = {
80
  customColor: false,
@@ -83,7 +80,7 @@
83
 
84
  jQuery(selector).each(function(index, select) {
85
  var val = jQuery(select).val();
86
- //* Check to see if this or a sibling input has a custom_color selected.
87
  if (val.indexOf("custom") !== -1) {
88
  if (val.indexOf("outlines") > 0) {
89
  visibility.customOutlines = true;
@@ -93,7 +90,7 @@
93
  }
94
  });
95
 
96
- //* Hide or show the inputs based on results from above.
97
  visibility.customColor ? customColor.slideDown() : customColor.slideUp();
98
  visibility.customOutlines ? customOutlines.slideDown() : customOutlines.slideUp();
99
 
@@ -107,7 +104,6 @@
107
  jQuery("#color-notice").fadeOut("slow");
108
  }
109
  }
110
-
111
  }
112
 
113
 
@@ -118,14 +114,12 @@
118
  var range, selection;
119
 
120
  if (document.body.createTextRange) {
121
-
122
  range = document.body.createTextRange();
123
  range.moveToElementText(element);
124
  range.select();
125
 
126
- } else if (window.getSelection) {
127
-
128
- selection = window.getSelection();
129
  range = document.createRange();
130
 
131
  range.selectNodeContents(element);
@@ -221,7 +215,6 @@
221
  Checkboxes
222
  *********************************************************/
223
  function checkboxesInit() {
224
-
225
  jQuery('.sw-checkbox-toggle').on('click', function() {
226
  var status = jQuery(this).attr('status');
227
 
@@ -295,7 +288,7 @@
295
  data: data,
296
  success: function(response) {
297
  // Clear the loading screen
298
- clearLoadingScreen();
299
 
300
  // Reset the default options variable
301
  socialWarfare.defaultOptions = fetchAllOptions();
@@ -312,16 +305,15 @@
312
  jQuery('body').append('<div class="sw-loading-bg"><div class="sw-loading-message">Saving Changes</div></div>');
313
  }
314
 
315
- function clearLoadingScreen() {
316
- jQuery('.sw-loading-message').html('Success!').removeClass('sw-loading-message').addClass('sw-loading-complete');
 
317
 
318
  jQuery('.sw-loading-bg').delay(1000).fadeOut(1000);
319
 
320
  setTimeout(function() {
321
  jQuery('.sw-loading-bg').remove();
322
  }, 2000);
323
-
324
-
325
  }
326
 
327
  function updateCustomColor() {
@@ -333,7 +325,6 @@
333
  jQuery('style.swp_customColorStuff').remove();
334
 
335
  var colorCode = jQuery('input[name="custom_color"]').val();
336
-
337
  var customCSS = '';
338
 
339
  if (dColorSet == 'custom_color' || iColorSet == 'custom_color' || oColorSet == 'custom_color') {
@@ -396,7 +387,7 @@
396
  return;
397
  }
398
 
399
- //* Maps out the button themes.
400
  var defaults = {
401
  full_color: 'Full Color',
402
  light_gray: 'Light Gray',
@@ -410,7 +401,7 @@
410
  custom_color_outlines: 'Custom Color Outlines'
411
  };
412
 
413
- //* Defines which themes are available per style.
414
  var availableOptions = {
415
  flat_fresh: defaults,
416
  leaf: defaults,
@@ -532,11 +523,6 @@
532
 
533
  // Put together the new classes, remove the old ones, add the new ones, store the new ones for removal next time.
534
  var buttonsClass = 'swp_' + visualTheme + ' swp_default_' + dColorSet + ' swp_individual_' + iColorSet + ' swp_other_' + oColorSet;
535
- console.log('last class', socialWarfare.lastClass)
536
- console.log('updating to new style', visualTheme)
537
- console.log("class is ", $('.swp_social_panel').get().clasName);
538
-
539
- console.log('themeOptions', themeOptions)
540
 
541
  // Remove the previous theme.
542
  themeOptions.map(function(index, option) {
@@ -603,7 +589,7 @@
603
  var addons = adminWrapper.attr("swp-addons");
604
  var registeredAddons = adminWrapper.attr("swp-registrations");
605
 
606
- //* Toggle visibility of the registration input field for {key}.
607
  jQuery('.registration-wrapper.' + key).attr('registration', status);
608
 
609
  if (1 === parseInt(status)) {
@@ -615,7 +601,7 @@
615
  }
616
  }
617
 
618
- //* Removes a string from a given attribute.
619
  function removeAttrValue(el, attribute, removal) {
620
  var value = jQuery(el).attr(attribute);
621
  var startIndex = value.indexOf(removal);
@@ -627,7 +613,7 @@
627
  jQuery(el).attr(attribute, newValue);
628
  }
629
 
630
- //* Adds a string to a given attribute.
631
  function addAttrValue(el, attribute, addition) {
632
  var value = jQuery(el).attr(attribute);
633
  if (value.includes(addition)) return;
@@ -636,9 +622,9 @@
636
  }
637
 
638
  /*******************************************************
639
- Register the Plugin
640
  *******************************************************/
641
- function registerPlugin(key,item_id) {
642
  var registered = false;
643
  var data = {
644
  action: 'swp_register_plugin',
@@ -655,16 +641,22 @@
655
  // If the response was a failure...
656
  response = JSON.parse(response);
657
 
 
 
 
 
 
 
658
  if (!response.success) {
659
- alert('Failure: ' + response.data);
 
660
  } else {
661
  toggleRegistration('1' , key);
662
  registered = true;
663
  }
664
 
665
- window.location.reload(true);
666
- clearLoadingScreen();
667
-
668
  });
669
 
670
  return registered;
@@ -687,11 +679,11 @@
687
 
688
  // Ping the home server to create a registration log
689
  jQuery.post(ajaxurl, ajaxData, function(response) {
690
- // If the response was a failure...
691
- //
692
  response = JSON.parse(response);
 
693
  if (!response.success) {
694
- alert('Failure: ' + response.data);
 
695
  } else {
696
  // If the response was a success
697
  jQuery('input[name="'+key+'_license_key"]').val('');
@@ -699,9 +691,8 @@
699
  unregistered = true;
700
  }
701
 
702
- //* Passing in true forces reload from the server rather than cache.
703
- window.location.reload(true);
704
- clearLoadingScreen();
705
  });
706
 
707
 
@@ -711,14 +702,14 @@
711
  function handleRegistration() {
712
  jQuery('.register-plugin').on('click', function() {
713
  var key = jQuery(this).attr('swp-addon');
714
- var item_id = jQuery(this).attr('swp-item-id');
715
  registerPlugin(key,item_id);
716
  return false;
717
  });
718
 
719
  jQuery('.unregister-plugin').on('click', function() {
720
  var key = jQuery(this).attr('swp-addon');
721
- var item_id = jQuery(this).attr('swp-item-id');
722
  unregisterPlugin(key,item_id);
723
  return false;
724
  });
@@ -729,28 +720,27 @@
729
  *******************************************************/
730
  function sortableInit() {
731
  jQuery('.sw-buttons-sort.sw-active').sortable({
732
- connectWith: '.sw-buttons-sort.sw-inactive',
733
- update: function() {
734
- saveColorToggle();
735
- }
736
  });
737
 
738
  jQuery('.sw-buttons-sort.sw-inactive').sortable({
739
- connectWith: '.sw-buttons-sort.sw-active',
740
- update: function() {
741
- saveColorToggle();
742
- }
743
  });
744
  }
745
 
746
  function getSystemStatus() {
747
  jQuery('.sw-system-status').on('click', function(event) {
748
- // Block the default action
749
- event.preventDefault ? event.preventDefault() : (event.returnValue = false);
750
 
751
- jQuery('.system-status-wrapper').slideToggle();
752
 
753
- selectText(jQuery('.system-status-container').get(0));
754
  });
755
  }
756
 
@@ -761,35 +751,34 @@
761
  var customUploader;
762
 
763
  jQuery('.swp_upload_image_button').click(function(e) {
764
- e.preventDefault();
765
-
766
- var inputField = jQuery(this).attr('for');
767
 
768
- // If the uploader object has already been created, reopen the dialog
769
- if (customUploader) {
770
- customUploader.open();
771
 
772
- return;
773
- }
 
 
 
774
 
775
- // Extend the wp.media object
776
- customUploader = wp.media.frames.file_frame = wp.media({
777
- title: 'Choose Image',
778
- button: {
779
- text: 'Choose Image'
780
- },
781
- multiple: false
782
- });
783
 
784
- // When a file is selected, grab the URL and set it as the text field's value
785
- customUploader.on('select', function() {
786
- var attachment = customUploader.state().get('selection').first().toJSON();
787
 
788
- jQuery('input[name="' + inputField + '"').val(attachment.url);
789
- });
790
 
791
- // Open the uploader dialog
792
- customUploader.open();
793
  });
794
  }
795
 
@@ -817,9 +806,8 @@
817
 
818
  function update_ctt_preview() {
819
  var preview = jQuery("#ctt_preview");
820
- var textarea = jQuery("textarea[name=ctt_css]");
821
-
822
- jQuery(preview).text(jQuery(textarea).val());
823
  }
824
 
825
  // Addes a tooltip to a network icon, displaying the network's name.
@@ -829,13 +817,13 @@
829
  var network = jQuery(icon).data("network");
830
  var networkBounds = icon.getBoundingClientRect();
831
  var tooltipBounds = {};
832
- var knownMargin = 4; //* Paddig applied by CSS which must be accounted for.
833
  var css = {
834
  top: jQuery(icon).position().top - 50,
835
  left: jQuery(icon).position().left + knownMargin
836
  }
837
 
838
- //* Uppercase each part of a snake_cased name.
839
  if (network.indexOf("_") > 0) {
840
  var words = network.split("_").map(function(word) {
841
  return word[0].toUpperCase() + word.slice(1, word.length)
@@ -844,21 +832,20 @@
844
  network = words.join(" ");
845
  }
846
 
847
- //* Uppercase the first character of the name.
848
  network = network[0].toUpperCase() + network.slice(1, network.length);
849
 
850
  tooltip = jQuery('<span class="swp-icon-tooltip">' + network + '</span>').css(css).get(0);
851
  jQuery(this).parents(".sw-grid").first().append(tooltip);
852
 
853
- //* When tooltip is wider than icon, center tooltip over the icon.
854
  if (jQuery(tooltip).outerWidth() > jQuery(icon).outerWidth()) {
855
  var delta = jQuery(tooltip).outerWidth() - jQuery(icon).outerWidth();
856
  css.left = css.left - (delta / 2);
857
  jQuery(tooltip).css(css);
858
  }
859
 
860
-
861
- //* Give it a click listener to remove the tooltip after moving the mouse.
862
  jQuery(icon).on("mousedown", function(e) {
863
 
864
  jQuery("body").mousemove(function() {
@@ -895,6 +882,4 @@
895
  set_ctt_preview();
896
  addIconTooltips();
897
  });
898
-
899
-
900
  })(this, jQuery);
4
 
5
  window.onload = function() {
6
  /*********************************************************
7
+ Temporary patch for the custom color se lects.
8
  *********************************************************/
9
  /*
10
  * Temp patch on the Visual Options colors.
13
  var panelSelector = "[name=default_colors],[name=hover_colors], [name=single_colors]";
14
  var floatSelector = "[name=float_default_colors], [name=float_hover_colors], [name=float_single_colors]";
15
 
16
+ // Hide the custom color inputs by default.
17
  jQuery("[name=custom_color],[name=custom_color_outlines],[name=float_custom_color],[name=float_custom_color_outlines]").parent().parent().hide();
18
 
19
+ // Show custom fields if they have already been selected.
20
  jQuery(panelSelector).each(function(index, select) {
21
  var value = jQuery(select).val();
22
  var customColor = jQuery("[name=custom_color]").parent().parent();
23
  var customOutlines = jQuery("[name=custom_color_outlines]").parent().parent();
24
 
25
  if (value.indexOf("custom") !== -1) {
26
+ // A custom value is set for this input.
27
  if (value.indexOf('outlines') > 0) {
28
  customOutlines.show();
29
  } else {
32
  }
33
  });
34
 
35
+ // Same, for floating button options.
 
36
  jQuery(floatSelector).each(function(index, select) {
37
  var value = jQuery(select).val();
38
  var customColor = jQuery("[name=float_custom_color]").parent().parent();
39
  var customOutlines = jQuery("[name=float_custom_color_outlines]").parent().parent();
40
 
41
  if (value.indexOf("custom") !== -1) {
42
+ // A custom value is set for this input.
43
  if (value.indexOf('outlines') > 0) {
44
  customOutlines.show();
45
  } else {
48
  }
49
  });
50
 
51
+ // Change handlers for style.
 
52
  jQuery(panelSelector).on("change", function(e) {
53
  var value = e.target.value;
54
  var customColor = jQuery("[name=custom_color]").parent().parent();
57
  handleCustomColors(e, panelSelector, customColor, customOutlines, value);
58
  });
59
 
60
+ // Same, for floating button options.
 
61
  jQuery(floatSelector).on("change", function(e) {
62
  var value = e.target.value;
63
  var customColor = jQuery("[name=float_custom_color]").parent().parent();
71
  }
72
 
73
  function handleCustomColors(event, selector, customColor, customOutlines) {
74
+ // Create a notice about the custom colors.
75
  var colorNotice = '<div id="color-notice"><p><span class="color-dismiss"></span><b>Note:</b> Custom colors will not show up in the preview, but will on your site.</p></div>';
76
  var visibility = {
77
  customColor: false,
80
 
81
  jQuery(selector).each(function(index, select) {
82
  var val = jQuery(select).val();
83
+ // Check to see if this or a sibling input has a custom_color selected.
84
  if (val.indexOf("custom") !== -1) {
85
  if (val.indexOf("outlines") > 0) {
86
  visibility.customOutlines = true;
90
  }
91
  });
92
 
93
+ // Hide or show the inputs based on results from above.
94
  visibility.customColor ? customColor.slideDown() : customColor.slideUp();
95
  visibility.customOutlines ? customOutlines.slideDown() : customOutlines.slideUp();
96
 
104
  jQuery("#color-notice").fadeOut("slow");
105
  }
106
  }
 
107
  }
108
 
109
 
114
  var range, selection;
115
 
116
  if (document.body.createTextRange) {
 
117
  range = document.body.createTextRange();
118
  range.moveToElementText(element);
119
  range.select();
120
 
121
+ } else if (window.getSelection) {
122
+ selection = window.getSelection();
 
123
  range = document.createRange();
124
 
125
  range.selectNodeContents(element);
215
  Checkboxes
216
  *********************************************************/
217
  function checkboxesInit() {
 
218
  jQuery('.sw-checkbox-toggle').on('click', function() {
219
  var status = jQuery(this).attr('status');
220
 
288
  data: data,
289
  success: function(response) {
290
  // Clear the loading screen
291
+ clearLoadingScreen(true);
292
 
293
  // Reset the default options variable
294
  socialWarfare.defaultOptions = fetchAllOptions();
305
  jQuery('body').append('<div class="sw-loading-bg"><div class="sw-loading-message">Saving Changes</div></div>');
306
  }
307
 
308
+ function clearLoadingScreen(isSuccess) {
309
+ var message = (isSuccess) ? 'Success!' : '';
310
+ jQuery('.sw-loading-message').html(message).removeClass('sw-loading-message').addClass('sw-loading-complete');
311
 
312
  jQuery('.sw-loading-bg').delay(1000).fadeOut(1000);
313
 
314
  setTimeout(function() {
315
  jQuery('.sw-loading-bg').remove();
316
  }, 2000);
 
 
317
  }
318
 
319
  function updateCustomColor() {
325
  jQuery('style.swp_customColorStuff').remove();
326
 
327
  var colorCode = jQuery('input[name="custom_color"]').val();
 
328
  var customCSS = '';
329
 
330
  if (dColorSet == 'custom_color' || iColorSet == 'custom_color' || oColorSet == 'custom_color') {
387
  return;
388
  }
389
 
390
+ // Maps out the button themes.
391
  var defaults = {
392
  full_color: 'Full Color',
393
  light_gray: 'Light Gray',
401
  custom_color_outlines: 'Custom Color Outlines'
402
  };
403
 
404
+ // Defines which themes are available per style.
405
  var availableOptions = {
406
  flat_fresh: defaults,
407
  leaf: defaults,
523
 
524
  // Put together the new classes, remove the old ones, add the new ones, store the new ones for removal next time.
525
  var buttonsClass = 'swp_' + visualTheme + ' swp_default_' + dColorSet + ' swp_individual_' + iColorSet + ' swp_other_' + oColorSet;
 
 
 
 
 
526
 
527
  // Remove the previous theme.
528
  themeOptions.map(function(index, option) {
589
  var addons = adminWrapper.attr("swp-addons");
590
  var registeredAddons = adminWrapper.attr("swp-registrations");
591
 
592
+ // Toggle visibility of the registration input field for {key}.
593
  jQuery('.registration-wrapper.' + key).attr('registration', status);
594
 
595
  if (1 === parseInt(status)) {
601
  }
602
  }
603
 
604
+ // Removes a string from a given attribute.
605
  function removeAttrValue(el, attribute, removal) {
606
  var value = jQuery(el).attr(attribute);
607
  var startIndex = value.indexOf(removal);
613
  jQuery(el).attr(attribute, newValue);
614
  }
615
 
616
+ // Adds a string to a given attribute.
617
  function addAttrValue(el, attribute, addition) {
618
  var value = jQuery(el).attr(attribute);
619
  if (value.includes(addition)) return;
622
  }
623
 
624
  /*******************************************************
625
+ Register an addon.
626
  *******************************************************/
627
+ function registerPlugin(key, item_id) {
628
  var registered = false;
629
  var data = {
630
  action: 'swp_register_plugin',
641
  // If the response was a failure...
642
  response = JSON.parse(response);
643
 
644
+ if (typeof response != 'object') {
645
+ // bad response
646
+ throw 'Error making addon registration request. Passed in this data ', data, ' and got this response', response;
647
+ return;
648
+ }
649
+
650
  if (!response.success) {
651
+ var message = "This license key is not currently active. Please check the status of your key at https://warfareplugins.com/my-account/license-keys/";
652
+ alert(message)
653
  } else {
654
  toggleRegistration('1' , key);
655
  registered = true;
656
  }
657
 
658
+ clearLoadingScreen(registered);
659
+ window.location.reload(true);
 
660
  });
661
 
662
  return registered;
679
 
680
  // Ping the home server to create a registration log
681
  jQuery.post(ajaxurl, ajaxData, function(response) {
 
 
682
  response = JSON.parse(response);
683
+
684
  if (!response.success) {
685
+ var message = 'Sorry, we had trouble deactivating your key. Please let us know about this at https://warfareplugins.com/subit-ticket';
686
+ alert(message);
687
  } else {
688
  // If the response was a success
689
  jQuery('input[name="'+key+'_license_key"]').val('');
691
  unregistered = true;
692
  }
693
 
694
+ clearLoadingScreen(unregistered);
695
+ window.location.reload(true);
 
696
  });
697
 
698
 
702
  function handleRegistration() {
703
  jQuery('.register-plugin').on('click', function() {
704
  var key = jQuery(this).attr('swp-addon');
705
+ var item_id = jQuery(this).attr('swp-item-id').trim();
706
  registerPlugin(key,item_id);
707
  return false;
708
  });
709
 
710
  jQuery('.unregister-plugin').on('click', function() {
711
  var key = jQuery(this).attr('swp-addon');
712
+ var item_id = jQuery(this).attr('swp-item-id').trim();
713
  unregisterPlugin(key,item_id);
714
  return false;
715
  });
720
  *******************************************************/
721
  function sortableInit() {
722
  jQuery('.sw-buttons-sort.sw-active').sortable({
723
+ connectWith: '.sw-buttons-sort.sw-inactive',
724
+ update: function() {
725
+ saveColorToggle();
726
+ }
727
  });
728
 
729
  jQuery('.sw-buttons-sort.sw-inactive').sortable({
730
+ connectWith: '.sw-buttons-sort.sw-active',
731
+ update: function() {
732
+ saveColorToggle();
733
+ }
734
  });
735
  }
736
 
737
  function getSystemStatus() {
738
  jQuery('.sw-system-status').on('click', function(event) {
739
+ event.preventDefault();
 
740
 
741
+ jQuery('.system-status-wrapper').slideToggle();
742
 
743
+ selectText(jQuery('.system-status-container').get(0));
744
  });
745
  }
746
 
751
  var customUploader;
752
 
753
  jQuery('.swp_upload_image_button').click(function(e) {
754
+ e.preventDefault();
 
 
755
 
756
+ var inputField = jQuery(this).attr('for');
 
 
757
 
758
+ // If the uploader object has already been created, reopen the dialog
759
+ if (customUploader) {
760
+ customUploader.open();
761
+ return;
762
+ }
763
 
764
+ // Extend the wp.media object
765
+ customUploader = wp.media.frames.file_frame = wp.media({
766
+ title: 'Choose Image',
767
+ button: {
768
+ text: 'Choose Image'
769
+ },
770
+ multiple: false
771
+ });
772
 
773
+ // When a file is selected, grab the URL and set it as the text field's value
774
+ customUploader.on('select', function() {
775
+ var attachment = customUploader.state().get('selection').first().toJSON();
776
 
777
+ jQuery('input[name="' + inputField + '"').val(attachment.url);
778
+ });
779
 
780
+ // Open the uploader dialog
781
+ customUploader.open();
782
  });
783
  }
784
 
806
 
807
  function update_ctt_preview() {
808
  var preview = jQuery("#ctt_preview");
809
+ var textarea = jQuery("textarea[name=ctt_css]");
810
+ jQuery(preview).text(jQuery(textarea).val());
 
811
  }
812
 
813
  // Addes a tooltip to a network icon, displaying the network's name.
817
  var network = jQuery(icon).data("network");
818
  var networkBounds = icon.getBoundingClientRect();
819
  var tooltipBounds = {};
820
+ var knownMargin = 4; // Paddig applied by CSS which must be accounted for.
821
  var css = {
822
  top: jQuery(icon).position().top - 50,
823
  left: jQuery(icon).position().left + knownMargin
824
  }
825
 
826
+ // Uppercase each part of a snake_cased name.
827
  if (network.indexOf("_") > 0) {
828
  var words = network.split("_").map(function(word) {
829
  return word[0].toUpperCase() + word.slice(1, word.length)
832
  network = words.join(" ");
833
  }
834
 
835
+ // Uppercase the first character of the name.
836
  network = network[0].toUpperCase() + network.slice(1, network.length);
837
 
838
  tooltip = jQuery('<span class="swp-icon-tooltip">' + network + '</span>').css(css).get(0);
839
  jQuery(this).parents(".sw-grid").first().append(tooltip);
840
 
841
+ // When tooltip is wider than icon, center tooltip over the icon.
842
  if (jQuery(tooltip).outerWidth() > jQuery(icon).outerWidth()) {
843
  var delta = jQuery(tooltip).outerWidth() - jQuery(icon).outerWidth();
844
  css.left = css.left - (delta / 2);
845
  jQuery(tooltip).css(css);
846
  }
847
 
848
+ // Give it a click listener to remove the tooltip after moving the mouse.
 
849
  jQuery(icon).on("mousedown", function(e) {
850
 
851
  jQuery("body").mousemove(function() {
882
  set_ctt_preview();
883
  addIconTooltips();
884
  });
 
 
885
  })(this, jQuery);
assets/js/admin-options-page.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,o){"use strict";function t(e,o,t,s){var r={customColor:!1,customOutlines:!1};jQuery(o).each(function(e,o){var t=jQuery(o).val();-1!==t.indexOf("custom")&&(t.indexOf("outlines")>0?r.customOutlines=!0:r.customColor=!0)}),r.customColor?t.slideDown():t.slideUp(),r.customOutlines?s.slideDown():s.slideUp(),r.customColor||r.customOutlines?(jQuery("body").append('<div id="color-notice"><p><span class="color-dismiss"></span><b>Note:</b> Custom colors will not show up in the preview, but will on your site.</p></div>'),jQuery(".color-dismiss").on("click",function(){jQuery("#color-notice").fadeOut("slow")})):jQuery("#color-notice").length&&jQuery("#color-notice").fadeOut("slow")}function s(o){var t,s;document.body.createTextRange?(t=document.body.createTextRange(),t.moveToElementText(o),t.select()):e.getSelection&&(s=e.getSelection(),t=document.createRange(),t.selectNodeContents(o),s.removeAllRanges(),s.addRange(t))}function r(){var e={};return jQuery("form.sw-admin-settings-form input, form.sw-admin-settings-form select, form.sw-admin-settings-form textarea").each(function(){var o,t=jQuery(this),s=t.attr("name");o="checkbox"===t.attr("type")?t.prop("checked"):t.val(),e[s]=o}),e.order_of_icons={},jQuery(".sw-active i").each(function(){var o=jQuery(this).data("network");e.order_of_icons[o]=o}),e}function a(){var e=jQuery(".sw-top-menu").offset(),o=jQuery(".sw-top-menu").width();jQuery(".sw-top-menu").css({position:"fixed",left:e.left,top:e.top,width:o}),jQuery(".sw-admin-wrapper").css("padding-top","75px")}function n(){jQuery(".sw-tab-selector").on("click",function(e){e.preventDefault(),jQuery("html, body").animate({scrollTop:0},300);var o=jQuery(this).attr("data-link");jQuery(".sw-admin-tab").hide(),jQuery("#"+o).show(),jQuery(".sw-header-menu li").removeClass("sw-active-tab"),jQuery(this).parents("li").addClass("sw-active-tab"),"swp_styles"===o&&socialWarfare.activateHoverStates(),swpConditionalFields()})}function l(){jQuery(".sw-checkbox-toggle").on("click",function(){var e=jQuery(this).attr("status"),o=jQuery(this).attr("field");"on"===e?(jQuery(this).attr("status","off"),jQuery(o).prop("checked",!1)):(jQuery(this).attr("status","on"),jQuery(o).prop("checked",!0)),u(),swpConditionalFields()})}function i(){jQuery("form.sw-admin-settings-form input, form.sw-admin-settings-form select").on("change",function(){swpConditionalFields(),socialWarfare.newOptions=r(),u()}),socialWarfare.defaultOptions=r()}function u(){socialWarfare.newOptions=r(),JSON.stringify(socialWarfare.newOptions)!==JSON.stringify(socialWarfare.defaultOptions)?jQuery(".sw-save-settings").removeClass("sw-navy-button").addClass("sw-red-button"):jQuery(".sw-save-settings").removeClass("sw-red-button").addClass("sw-navy-button")}function c(){jQuery(".sw-save-settings").on("click",function(e){e.preventDefault?e.preventDefault():e.returnValue=!1,_();var o=r(),t={action:"swp_store_settings",security:swpAdminOptionsData.optionsNonce,settings:o};jQuery.post({url:ajaxurl,data:t,success:function(e){p(),socialWarfare.defaultOptions=r(),u()}})})}function _(){jQuery("body").append('<div class="sw-loading-bg"><div class="sw-loading-message">Saving Changes</div></div>')}function p(){jQuery(".sw-loading-message").html("Success!").removeClass("sw-loading-message").addClass("sw-loading-complete"),jQuery(".sw-loading-bg").delay(1e3).fadeOut(1e3),setTimeout(function(){jQuery(".sw-loading-bg").remove()},2e3)}function m(){var e=(jQuery('select[name="button_shape"]').val(),jQuery('select[name="default_colors"]').val()),o=jQuery('select[name="single_colors"]').val(),t=jQuery('select[name="hover_colors"]').val();jQuery("style.swp_customColorStuff").remove();var s=jQuery('input[name="custom_color"]').val(),r="";"custom_color"!=e&&"custom_color"!=o&&"custom_color"!=t||(r=".swp_social_panel.swp_default_customColor a, html body .swp_social_panel.swp_individual_customColor .nc_tweetContainer:hover a, body .swp_social_panel.swp_other_customColor:hover a {color:white} .swp_social_panel.swp_default_customColor .nc_tweetContainer, html body .swp_social_panel.swp_individual_customColor .nc_tweetContainer:hover, body .swp_social_panel.swp_other_customColor:hover .nc_tweetContainer {background-color:"+s+";border:1px solid "+s+";}"),"custom_color_outlines"!=e&&"custom_color_outlines"!=o&&"custom_color_outlines"!=t||(r=r+" .swp_social_panel.swp_default_custom_color_outlines a, html body .swp_social_panel.swp_individual_custom_color_outlines .nc_tweetContainer:hover a, body .swp_social_panel.swp_other_custom_color_outlines:hover a { color:"+s+"; } .swp_social_panel.swp_default_custom_color_outlines .nc_tweetContainer, html body .swp_social_panel.swp_individual_custom_color_outlines .nc_tweetContainer:hover, body .swp_social_panel.swp_other_custom_color_outlines:hover .nc_tweetContainer { background:transparent; border:1px solid "+s+"; }"),jQuery("head").append('<style type="text/css" class="swp_customColorStuff">'+r+"</style>")}function d(){function e(e){var o=jQuery('select[name="'+e+'"]').val();if(0===o.indexOf("custom")){return e.slice(0,e.indexOf("_"))+"_full_color"}return o}var t=e("button_shape"),s=e("default_colors"),r=e("single_colors"),a=e("hover_colors"),n="swp_"+t+" swp_default_"+s+" swp_individual_"+r+" swp_other_"+a;if(void 0===socialWarfare.lastClass){var l=o(".swp_social_panel");if(!l.length)return;socialWarfare.lastClass=l.get().className}var n="swp_"+t+" swp_default_"+s+" swp_individual_"+r+" swp_other_"+a;jQuery(".swp_social_panel").removeClass("swp_other_medium_gray"),jQuery(".swp_social_panel").removeClass(socialWarfare.lastClass).addClass(n),socialWarfare.lastClass=n}function y(){if(0!==jQuery('select[name="button_shape"]').length){var e={full_color:"Full Color",light_gray:"Light Gray",medium_gray:"Medium Gray",dark_gray:"Dark Gray",light_gray_outlines:"Light Gray Outlines",medium_gray_outlines:"Medium Gray Outlines",dark_gray_outlines:"Dark Gray Outlines",color_outlines:"Color Outlines",custom_color:"Custom Color",custom_color_outlines:"Custom Color Outlines"},t={flat_fresh:e,leaf:e,pill:e,three_dee:{full_color:"Full Color",light_gray:"Light Gray",medium_gray:"Medium Gray",dark_gray:"Dark Gray"},connected:e,shift:e,boxed:e,modern:{full_color:"Full Color",light_gray:"Light Gray",medium_gray:"Medium Gray",dark_gray:"Dark Gray",light_gray_outlines:"Light Gray Outlines",medium_gray_outlines:"Medium Gray Outlines",dark_gray_outlines:"Dark Gray Outlines",color_outlines:"Color Outlines",custom_color:"Custom Color",custom_color_outlines:"Custom Color Outlines"},dark:{light_gray_outlines:"Light Gray Outlines",medium_gray_outlines:"Medium Gray Outlines",dark_gray_outlines:"Dark Gray Outlines",color_outlines:"Color Outlines",custom_color:"Custom Color",custom_color_outlines:"Custom Color Outlines"}},s=jQuery('select[name="button_shape"]').val(),r=jQuery('select[name="default_colors"]').val(),a=jQuery('select[name="single_colors"]').val(),n=jQuery('select[name="hover_colors"]').val(),l=jQuery('select[name="button_shape"]').find("option").map(function(e,o){return o.value});jQuery('select[name="default_colors"] option, select[name="single_colors"] option, select[name="hover_colors"] option').remove(),jQuery.each(t[s],function(e,o){e===r?jQuery('select[name="default_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):jQuery('select[name="default_colors"]').append('<option value="'+e+'">'+o+"</option>"),e===a?jQuery('select[name="single_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):jQuery('select[name="single_colors"]').append('<option value="'+e+'">'+o+"</option>"),e===n?jQuery('select[name="hover_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):jQuery('select[name="hover_colors"]').append('<option value="'+e+'">'+o+"</option>"),"custom_color"==r||"custom_color_outlines"==r||"custom_color"==a||"custom_color_outlines"==a||"custom_color"==n||"custom_color_outlines"==n?(jQuery(".customColor_wrapper").slideDown(),m()):jQuery(".customColor_wrapper").slideUp()}),jQuery('select[name="default_colors"], select[name="single_colors"], select[name="hover_colors"]').on("change",d),jQuery('select[name="button_shape"]').on("change",function(){var e=jQuery('select[name="button_shape"]').val(),s=jQuery('select[name="default_colors"]').val(),r=jQuery('select[name="single_colors"]').val(),a=jQuery('select[name="hover_colors"]').val(),n=0,i=t[e],u=i.hasOwnProperty(s),c=i.hasOwnProperty(r),_=i.hasOwnProperty(a);jQuery('select[name="default_colors"] option, select[name="single_colors"] option, select[name="hover_colors"] option').remove(),jQuery.each(t[e],function(e,o){e===s||0==u&&0==n?jQuery('select[name="default_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):jQuery('select[name="default_colors"]').append('<option value="'+e+'">'+o+"</option>"),e===r||0==c&&0==n?jQuery('select[name="single_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):jQuery('select[name="single_colors"]').append('<option value="'+e+'">'+o+"</option>"),e===a||0==_&&0==n?jQuery('select[name="hover_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):jQuery('select[name="hover_colors"]').append('<option value="'+e+'">'+o+"</option>"),++n}),void 0===socialWarfare.lastClass&&(socialWarfare.lastClass="swp_flat_fresh swp_default_full_color swp_individual_full_color swp_other_full_color");var p="swp_"+e+" swp_default_"+s+" swp_individual_"+r+" swp_other_"+a;console.log("last class",socialWarfare.lastClass),console.log("updating to new style",e),console.log("class is ",o(".swp_social_panel").get().clasName),console.log("themeOptions",l),l.map(function(e,o){jQuery(".swp_social_panel").removeClass("swp_"+o.value)}),jQuery(".swp_social_panel").removeClass(socialWarfare.lastClass).addClass(p),socialWarfare.lastClass=p})}}function f(){jQuery('select[name="button_size"],select[name="button_alignment"]').on("change",function(){jQuery(".swp_social_panel").css({width:"100%"});var e,o=jQuery(".swp_social_panel").width(),t=jQuery('select[name="button_size"]').val(),s=jQuery('select[name="button_alignment"]').val();"full_width"==s&&1!=t||t>=1?(e=o/t,jQuery(".swp_social_panel").css("cssText","width:"+e+"px!important;"),jQuery(".swp_social_panel").css({transform:"scale("+t+")","transform-origin":"left"})):"full_width"!=s&&t<1&&(e=o/t,jQuery(".swp_social_panel").css({transform:"scale("+t+")","transform-origin":s})),socialWarfare.activateHoverStates()})}function w(){var e=jQuery('select[name="ctt_theme"]');e.on("change",function(){var e=jQuery('select[name="ctt_theme"]').val();jQuery(".swp_CTT").attr("class","swp_CTT").addClass(e)}),e.trigger("change")}function v(e,o){var t=jQuery(".sw-admin-wrapper");t.attr("swp-addons"),t.attr("swp-registrations");jQuery(".registration-wrapper."+o).attr("registration",e),1===parseInt(e)?(t.attr("sw-registered",e),jQuery(".sw-top-menu").attr("sw-registered",e),Q(t,"swp-registrations",o)):j(t,"swp-registrations",o)}function j(e,o,t){var s=jQuery(e).attr(o),r=s.indexOf(t);if(-1!==r){var a=r+t.length,n=s.slice(0,r)+s.slice(a);jQuery(e).attr(o,n)}}function Q(e,o,t){var s=jQuery(e).attr(o);s.includes(t)||jQuery(e).attr(o,s+t)}function g(o,t){var s=!1,r={action:"swp_register_plugin",security:swpAdminOptionsData.registerNonce,activity:"register",name_key:o,item_id:t,license_key:jQuery('input[name="'+o+'_license_key"]').val()};return _(),jQuery.post(ajaxurl,r,function(t){t=JSON.parse(t),t.success?(v("1",o),s=!0):alert("Failure: "+t.data),e.location.reload(!0),p()}),s}function h(o,t){var s=!1,r={action:"swp_unregister_plugin",security:swpAdminOptionsData.registerNonce,activity:"unregister",name_key:o,item_id:t};return _(),jQuery.post(ajaxurl,r,function(t){t=JSON.parse(t),t.success?(jQuery('input[name="'+o+'_license_key"]').val(""),v("0",o),s=!0):alert("Failure: "+t.data),e.location.reload(!0),p()}),s}function C(){jQuery(".register-plugin").on("click",function(){return g(jQuery(this).attr("swp-addon"),jQuery(this).attr("swp-item-id")),!1}),jQuery(".unregister-plugin").on("click",function(){return h(jQuery(this).attr("swp-addon"),jQuery(this).attr("swp-item-id")),!1})}function b(){jQuery(".sw-buttons-sort.sw-active").sortable({connectWith:".sw-buttons-sort.sw-inactive",update:function(){u()}}),jQuery(".sw-buttons-sort.sw-inactive").sortable({connectWith:".sw-buttons-sort.sw-active",update:function(){u()}})}function O(){jQuery(".sw-system-status").on("click",function(e){e.preventDefault?e.preventDefault():e.returnValue=!1,jQuery(".system-status-wrapper").slideToggle(),s(jQuery(".system-status-container").get(0))})}function k(){var e;jQuery(".swp_upload_image_button").click(function(o){o.preventDefault();var t=jQuery(this).attr("for");if(e)return void e.open();e=wp.media.frames.file_frame=wp.media({title:"Choose Image",button:{text:"Choose Image"},multiple:!1}),e.on("select",function(){var o=e.state().get("selection").first().toJSON();jQuery('input[name="'+t+'"').val(o.url)}),e.open()})}function x(){var e=jQuery("#ctt_preview"),o=jQuery("select[name=ctt_theme]");e.length||(e=jQuery('<style id="ctt_preview"></style>'),jQuery("head").append(e)),"none"===jQuery(o).val()&&W(),jQuery(o).on("change",function(e){"none"===e.target.value&&W()}),jQuery("textarea[name=ctt_css]").on("keyup",W)}function W(){var e=jQuery("#ctt_preview"),o=jQuery("textarea[name=ctt_css]");jQuery(e).text(jQuery(o).val())}function D(e){var o,t=e.target,s=jQuery(t).data("network"),r=(t.getBoundingClientRect(),{top:jQuery(t).position().top-50,left:jQuery(t).position().left+4});if(s.indexOf("_")>0){s=s.split("_").map(function(e){return e[0].toUpperCase()+e.slice(1,e.length)}).join(" ")}if(s=s[0].toUpperCase()+s.slice(1,s.length),o=jQuery('<span class="swp-icon-tooltip">'+s+"</span>").css(r).get(0),jQuery(this).parents(".sw-grid").first().append(o),jQuery(o).outerWidth()>jQuery(t).outerWidth()){var a=jQuery(o).outerWidth()-jQuery(t).outerWidth();r.left=r.left-a/2,jQuery(o).css(r)}jQuery(t).on("mousedown",function(e){jQuery("body").mousemove(function(){G(),jQuery("body").off("mousemove")})})}function G(e){jQuery(".swp-icon-tooltip").remove()}function S(){jQuery("[class*='sw-'][class*='-icon']").each(function(e,o){jQuery(o).hover(D,G)})}e.onload=function(){var e="[name=default_colors],[name=hover_colors], [name=single_colors]",o="[name=float_default_colors], [name=float_hover_colors], [name=float_single_colors]";jQuery("[name=custom_color],[name=custom_color_outlines],[name=float_custom_color],[name=float_custom_color_outlines]").parent().parent().hide(),jQuery(e).each(function(e,o){var t=jQuery(o).val(),s=jQuery("[name=custom_color]").parent().parent(),r=jQuery("[name=custom_color_outlines]").parent().parent();-1!==t.indexOf("custom")&&(t.indexOf("outlines")>0?r.show():s.show())}),jQuery(o).each(function(e,o){var t=jQuery(o).val(),s=jQuery("[name=float_custom_color]").parent().parent(),r=jQuery("[name=float_custom_color_outlines]").parent().parent();-1!==t.indexOf("custom")&&(t.indexOf("outlines")>0?r.show():s.show())}),jQuery(e).on("change",function(o){var s=(o.target.value,jQuery("[name=custom_color]").parent().parent()),r=jQuery("[name=custom_color_outlines]").parent().parent();t(o,e,s,r)}),jQuery(o).on("change",function(e){var s=(e.target.value,jQuery("[name=float_custom_color]").parent().parent()),r=jQuery("[name=float_custom_color_outlines]").parent().parent();s.hide(),r.hide(),t(e,o,s,r)})},jQuery(document).ready(function(){c(),i(),a(),n(),l(),y(),swpConditionalFields(),w(),f(),C(),b(),O(),k(),x(),S()})}(this,jQuery);
1
+ !function(e,t){"use strict";function o(e,t,o,s){var r={customColor:!1,customOutlines:!1};jQuery(t).each(function(e,t){var o=jQuery(t).val();-1!==o.indexOf("custom")&&(o.indexOf("outlines")>0?r.customOutlines=!0:r.customColor=!0)}),r.customColor?o.slideDown():o.slideUp(),r.customOutlines?s.slideDown():s.slideUp(),r.customColor||r.customOutlines?(jQuery("body").append('<div id="color-notice"><p><span class="color-dismiss"></span><b>Note:</b> Custom colors will not show up in the preview, but will on your site.</p></div>'),jQuery(".color-dismiss").on("click",function(){jQuery("#color-notice").fadeOut("slow")})):jQuery("#color-notice").length&&jQuery("#color-notice").fadeOut("slow")}function s(t){var o,s;document.body.createTextRange?(o=document.body.createTextRange(),o.moveToElementText(t),o.select()):e.getSelection&&(s=e.getSelection(),o=document.createRange(),o.selectNodeContents(t),s.removeAllRanges(),s.addRange(o))}function r(){var e={};return jQuery("form.sw-admin-settings-form input, form.sw-admin-settings-form select, form.sw-admin-settings-form textarea").each(function(){var t,o=jQuery(this),s=o.attr("name");t="checkbox"===o.attr("type")?o.prop("checked"):o.val(),e[s]=t}),e.order_of_icons={},jQuery(".sw-active i").each(function(){var t=jQuery(this).data("network");e.order_of_icons[t]=t}),e}function a(){var e=jQuery(".sw-top-menu").offset(),t=jQuery(".sw-top-menu").width();jQuery(".sw-top-menu").css({position:"fixed",left:e.left,top:e.top,width:t}),jQuery(".sw-admin-wrapper").css("padding-top","75px")}function n(){jQuery(".sw-tab-selector").on("click",function(e){e.preventDefault(),jQuery("html, body").animate({scrollTop:0},300);var t=jQuery(this).attr("data-link");jQuery(".sw-admin-tab").hide(),jQuery("#"+t).show(),jQuery(".sw-header-menu li").removeClass("sw-active-tab"),jQuery(this).parents("li").addClass("sw-active-tab"),"swp_styles"===t&&socialWarfare.activateHoverStates(),swpConditionalFields()})}function l(){jQuery(".sw-checkbox-toggle").on("click",function(){var e=jQuery(this).attr("status"),t=jQuery(this).attr("field");"on"===e?(jQuery(this).attr("status","off"),jQuery(t).prop("checked",!1)):(jQuery(this).attr("status","on"),jQuery(t).prop("checked",!0)),u(),swpConditionalFields()})}function i(){jQuery("form.sw-admin-settings-form input, form.sw-admin-settings-form select").on("change",function(){swpConditionalFields(),socialWarfare.newOptions=r(),u()}),socialWarfare.defaultOptions=r()}function u(){socialWarfare.newOptions=r(),JSON.stringify(socialWarfare.newOptions)!==JSON.stringify(socialWarfare.defaultOptions)?jQuery(".sw-save-settings").removeClass("sw-navy-button").addClass("sw-red-button"):jQuery(".sw-save-settings").removeClass("sw-red-button").addClass("sw-navy-button")}function c(){jQuery(".sw-save-settings").on("click",function(e){e.preventDefault?e.preventDefault():e.returnValue=!1,_();var t=r(),o={action:"swp_store_settings",security:swpAdminOptionsData.optionsNonce,settings:t};jQuery.post({url:ajaxurl,data:o,success:function(e){p(!0),socialWarfare.defaultOptions=r(),u()}})})}function _(){jQuery("body").append('<div class="sw-loading-bg"><div class="sw-loading-message">Saving Changes</div></div>')}function p(e){var t=e?"Success!":"";jQuery(".sw-loading-message").html(t).removeClass("sw-loading-message").addClass("sw-loading-complete"),jQuery(".sw-loading-bg").delay(1e3).fadeOut(1e3),setTimeout(function(){jQuery(".sw-loading-bg").remove()},2e3)}function m(){var e=(jQuery('select[name="button_shape"]').val(),jQuery('select[name="default_colors"]').val()),t=jQuery('select[name="single_colors"]').val(),o=jQuery('select[name="hover_colors"]').val();jQuery("style.swp_customColorStuff").remove();var s=jQuery('input[name="custom_color"]').val(),r="";"custom_color"!=e&&"custom_color"!=t&&"custom_color"!=o||(r=".swp_social_panel.swp_default_customColor a, html body .swp_social_panel.swp_individual_customColor .nc_tweetContainer:hover a, body .swp_social_panel.swp_other_customColor:hover a {color:white} .swp_social_panel.swp_default_customColor .nc_tweetContainer, html body .swp_social_panel.swp_individual_customColor .nc_tweetContainer:hover, body .swp_social_panel.swp_other_customColor:hover .nc_tweetContainer {background-color:"+s+";border:1px solid "+s+";}"),"custom_color_outlines"!=e&&"custom_color_outlines"!=t&&"custom_color_outlines"!=o||(r=r+" .swp_social_panel.swp_default_custom_color_outlines a, html body .swp_social_panel.swp_individual_custom_color_outlines .nc_tweetContainer:hover a, body .swp_social_panel.swp_other_custom_color_outlines:hover a { color:"+s+"; } .swp_social_panel.swp_default_custom_color_outlines .nc_tweetContainer, html body .swp_social_panel.swp_individual_custom_color_outlines .nc_tweetContainer:hover, body .swp_social_panel.swp_other_custom_color_outlines:hover .nc_tweetContainer { background:transparent; border:1px solid "+s+"; }"),jQuery("head").append('<style type="text/css" class="swp_customColorStuff">'+r+"</style>")}function y(){function e(e){var t=jQuery('select[name="'+e+'"]').val();if(0===t.indexOf("custom")){return e.slice(0,e.indexOf("_"))+"_full_color"}return t}var o=e("button_shape"),s=e("default_colors"),r=e("single_colors"),a=e("hover_colors"),n="swp_"+o+" swp_default_"+s+" swp_individual_"+r+" swp_other_"+a;if(void 0===socialWarfare.lastClass){var l=t(".swp_social_panel");if(!l.length)return;socialWarfare.lastClass=l.get().className}var n="swp_"+o+" swp_default_"+s+" swp_individual_"+r+" swp_other_"+a;jQuery(".swp_social_panel").removeClass("swp_other_medium_gray"),jQuery(".swp_social_panel").removeClass(socialWarfare.lastClass).addClass(n),socialWarfare.lastClass=n}function d(){if(0!==jQuery('select[name="button_shape"]').length){var e={full_color:"Full Color",light_gray:"Light Gray",medium_gray:"Medium Gray",dark_gray:"Dark Gray",light_gray_outlines:"Light Gray Outlines",medium_gray_outlines:"Medium Gray Outlines",dark_gray_outlines:"Dark Gray Outlines",color_outlines:"Color Outlines",custom_color:"Custom Color",custom_color_outlines:"Custom Color Outlines"},t={flat_fresh:e,leaf:e,pill:e,three_dee:{full_color:"Full Color",light_gray:"Light Gray",medium_gray:"Medium Gray",dark_gray:"Dark Gray"},connected:e,shift:e,boxed:e,modern:{full_color:"Full Color",light_gray:"Light Gray",medium_gray:"Medium Gray",dark_gray:"Dark Gray",light_gray_outlines:"Light Gray Outlines",medium_gray_outlines:"Medium Gray Outlines",dark_gray_outlines:"Dark Gray Outlines",color_outlines:"Color Outlines",custom_color:"Custom Color",custom_color_outlines:"Custom Color Outlines"},dark:{light_gray_outlines:"Light Gray Outlines",medium_gray_outlines:"Medium Gray Outlines",dark_gray_outlines:"Dark Gray Outlines",color_outlines:"Color Outlines",custom_color:"Custom Color",custom_color_outlines:"Custom Color Outlines"}},o=jQuery('select[name="button_shape"]').val(),s=jQuery('select[name="default_colors"]').val(),r=jQuery('select[name="single_colors"]').val(),a=jQuery('select[name="hover_colors"]').val(),n=jQuery('select[name="button_shape"]').find("option").map(function(e,t){return t.value});jQuery('select[name="default_colors"] option, select[name="single_colors"] option, select[name="hover_colors"] option').remove(),jQuery.each(t[o],function(e,t){e===s?jQuery('select[name="default_colors"]').append('<option value="'+e+'" selected>'+t+"</option>"):jQuery('select[name="default_colors"]').append('<option value="'+e+'">'+t+"</option>"),e===r?jQuery('select[name="single_colors"]').append('<option value="'+e+'" selected>'+t+"</option>"):jQuery('select[name="single_colors"]').append('<option value="'+e+'">'+t+"</option>"),e===a?jQuery('select[name="hover_colors"]').append('<option value="'+e+'" selected>'+t+"</option>"):jQuery('select[name="hover_colors"]').append('<option value="'+e+'">'+t+"</option>"),"custom_color"==s||"custom_color_outlines"==s||"custom_color"==r||"custom_color_outlines"==r||"custom_color"==a||"custom_color_outlines"==a?(jQuery(".customColor_wrapper").slideDown(),m()):jQuery(".customColor_wrapper").slideUp()}),jQuery('select[name="default_colors"], select[name="single_colors"], select[name="hover_colors"]').on("change",y),jQuery('select[name="button_shape"]').on("change",function(){var e=jQuery('select[name="button_shape"]').val(),o=jQuery('select[name="default_colors"]').val(),s=jQuery('select[name="single_colors"]').val(),r=jQuery('select[name="hover_colors"]').val(),a=0,l=t[e],i=l.hasOwnProperty(o),u=l.hasOwnProperty(s),c=l.hasOwnProperty(r);jQuery('select[name="default_colors"] option, select[name="single_colors"] option, select[name="hover_colors"] option').remove(),jQuery.each(t[e],function(e,t){e===o||0==i&&0==a?jQuery('select[name="default_colors"]').append('<option value="'+e+'" selected>'+t+"</option>"):jQuery('select[name="default_colors"]').append('<option value="'+e+'">'+t+"</option>"),e===s||0==u&&0==a?jQuery('select[name="single_colors"]').append('<option value="'+e+'" selected>'+t+"</option>"):jQuery('select[name="single_colors"]').append('<option value="'+e+'">'+t+"</option>"),e===r||0==c&&0==a?jQuery('select[name="hover_colors"]').append('<option value="'+e+'" selected>'+t+"</option>"):jQuery('select[name="hover_colors"]').append('<option value="'+e+'">'+t+"</option>"),++a}),void 0===socialWarfare.lastClass&&(socialWarfare.lastClass="swp_flat_fresh swp_default_full_color swp_individual_full_color swp_other_full_color");var _="swp_"+e+" swp_default_"+o+" swp_individual_"+s+" swp_other_"+r;n.map(function(e,t){jQuery(".swp_social_panel").removeClass("swp_"+t.value)}),jQuery(".swp_social_panel").removeClass(socialWarfare.lastClass).addClass(_),socialWarfare.lastClass=_})}}function f(){jQuery('select[name="button_size"],select[name="button_alignment"]').on("change",function(){jQuery(".swp_social_panel").css({width:"100%"});var e,t=jQuery(".swp_social_panel").width(),o=jQuery('select[name="button_size"]').val(),s=jQuery('select[name="button_alignment"]').val();"full_width"==s&&1!=o||o>=1?(e=t/o,jQuery(".swp_social_panel").css("cssText","width:"+e+"px!important;"),jQuery(".swp_social_panel").css({transform:"scale("+o+")","transform-origin":"left"})):"full_width"!=s&&o<1&&(e=t/o,jQuery(".swp_social_panel").css({transform:"scale("+o+")","transform-origin":s})),socialWarfare.activateHoverStates()})}function w(){var e=jQuery('select[name="ctt_theme"]');e.on("change",function(){var e=jQuery('select[name="ctt_theme"]').val();jQuery(".swp_CTT").attr("class","swp_CTT").addClass(e)}),e.trigger("change")}function v(e,t){var o=jQuery(".sw-admin-wrapper");o.attr("swp-addons"),o.attr("swp-registrations");jQuery(".registration-wrapper."+t).attr("registration",e),1===parseInt(e)?(o.attr("sw-registered",e),jQuery(".sw-top-menu").attr("sw-registered",e),Q(o,"swp-registrations",t)):j(o,"swp-registrations",t)}function j(e,t,o){var s=jQuery(e).attr(t),r=s.indexOf(o);if(-1!==r){var a=r+o.length,n=s.slice(0,r)+s.slice(a);jQuery(e).attr(t,n)}}function Q(e,t,o){var s=jQuery(e).attr(t);s.includes(o)||jQuery(e).attr(t,s+o)}function h(t,o){var s=!1,r={action:"swp_register_plugin",security:swpAdminOptionsData.registerNonce,activity:"register",name_key:t,item_id:o,license_key:jQuery('input[name="'+t+'_license_key"]').val()};return _(),jQuery.post(ajaxurl,r,function(o){if("object"!=typeof(o=JSON.parse(o)))throw o;if(o.success)v("1",t),s=!0;else{alert("This license key is not currently active. Please check the status of your key at https://warfareplugins.com/my-account/license-keys/")}p(s),e.location.reload(!0)}),s}function g(t,o){var s=!1,r={action:"swp_unregister_plugin",security:swpAdminOptionsData.registerNonce,activity:"unregister",name_key:t,item_id:o};return _(),jQuery.post(ajaxurl,r,function(o){if(o=JSON.parse(o),o.success)jQuery('input[name="'+t+'_license_key"]').val(""),v("0",t),s=!0;else{alert("Sorry, we had trouble deactivating your key. Please let us know about this at https://warfareplugins.com/subit-ticket")}p(s),e.location.reload(!0)}),s}function C(){jQuery(".register-plugin").on("click",function(){return h(jQuery(this).attr("swp-addon"),jQuery(this).attr("swp-item-id").trim()),!1}),jQuery(".unregister-plugin").on("click",function(){return g(jQuery(this).attr("swp-addon"),jQuery(this).attr("swp-item-id").trim()),!1})}function b(){jQuery(".sw-buttons-sort.sw-active").sortable({connectWith:".sw-buttons-sort.sw-inactive",update:function(){u()}}),jQuery(".sw-buttons-sort.sw-inactive").sortable({connectWith:".sw-buttons-sort.sw-active",update:function(){u()}})}function O(){jQuery(".sw-system-status").on("click",function(e){e.preventDefault(),jQuery(".system-status-wrapper").slideToggle(),s(jQuery(".system-status-container").get(0))})}function k(){var e;jQuery(".swp_upload_image_button").click(function(t){t.preventDefault();var o=jQuery(this).attr("for");if(e)return void e.open();e=wp.media.frames.file_frame=wp.media({title:"Choose Image",button:{text:"Choose Image"},multiple:!1}),e.on("select",function(){var t=e.state().get("selection").first().toJSON();jQuery('input[name="'+o+'"').val(t.url)}),e.open()})}function x(){var e=jQuery("#ctt_preview"),t=jQuery("select[name=ctt_theme]");e.length||(e=jQuery('<style id="ctt_preview"></style>'),jQuery("head").append(e)),"none"===jQuery(t).val()&&W(),jQuery(t).on("change",function(e){"none"===e.target.value&&W()}),jQuery("textarea[name=ctt_css]").on("keyup",W)}function W(){var e=jQuery("#ctt_preview"),t=jQuery("textarea[name=ctt_css]");jQuery(e).text(jQuery(t).val())}function G(e){var t,o=e.target,s=jQuery(o).data("network"),r=(o.getBoundingClientRect(),{top:jQuery(o).position().top-50,left:jQuery(o).position().left+4});if(s.indexOf("_")>0){s=s.split("_").map(function(e){return e[0].toUpperCase()+e.slice(1,e.length)}).join(" ")}if(s=s[0].toUpperCase()+s.slice(1,s.length),t=jQuery('<span class="swp-icon-tooltip">'+s+"</span>").css(r).get(0),jQuery(this).parents(".sw-grid").first().append(t),jQuery(t).outerWidth()>jQuery(o).outerWidth()){var a=jQuery(t).outerWidth()-jQuery(o).outerWidth();r.left=r.left-a/2,jQuery(t).css(r)}jQuery(o).on("mousedown",function(e){jQuery("body").mousemove(function(){D(),jQuery("body").off("mousemove")})})}function D(e){jQuery(".swp-icon-tooltip").remove()}function S(){jQuery("[class*='sw-'][class*='-icon']").each(function(e,t){jQuery(t).hover(G,D)})}e.onload=function(){var e="[name=default_colors],[name=hover_colors], [name=single_colors]",t="[name=float_default_colors], [name=float_hover_colors], [name=float_single_colors]";jQuery("[name=custom_color],[name=custom_color_outlines],[name=float_custom_color],[name=float_custom_color_outlines]").parent().parent().hide(),jQuery(e).each(function(e,t){var o=jQuery(t).val(),s=jQuery("[name=custom_color]").parent().parent(),r=jQuery("[name=custom_color_outlines]").parent().parent();-1!==o.indexOf("custom")&&(o.indexOf("outlines")>0?r.show():s.show())}),jQuery(t).each(function(e,t){var o=jQuery(t).val(),s=jQuery("[name=float_custom_color]").parent().parent(),r=jQuery("[name=float_custom_color_outlines]").parent().parent();-1!==o.indexOf("custom")&&(o.indexOf("outlines")>0?r.show():s.show())}),jQuery(e).on("change",function(t){var s=(t.target.value,jQuery("[name=custom_color]").parent().parent()),r=jQuery("[name=custom_color_outlines]").parent().parent();o(t,e,s,r)}),jQuery(t).on("change",function(e){var s=(e.target.value,jQuery("[name=float_custom_color]").parent().parent()),r=jQuery("[name=float_custom_color_outlines]").parent().parent();s.hide(),r.hide(),o(e,t,s,r)})},jQuery(document).ready(function(){c(),i(),a(),n(),l(),d(),swpConditionalFields(),w(),f(),C(),b(),O(),k(),x(),S()})}(this,jQuery);
assets/js/post-editor/src/block/style.scss CHANGED
@@ -18,8 +18,8 @@
18
  .swp-block-icon {
19
  margin: 0 28px 0 14px;
20
  font-size: 18px;
21
- width: 32px;
22
- height: 32px;
23
  }
24
  }
25
 
18
  .swp-block-icon {
19
  margin: 0 28px 0 14px;
20
  font-size: 18px;
21
+ width: 18px;
22
+ height: 18px;
23
  }
24
  }
25
 
assets/js/script.js CHANGED
@@ -952,7 +952,7 @@ window.socialWarfare = window.socialWarfare || {};
952
  * visitors pin the actual image being hovered.
953
  *
954
  */
955
- if ('undefined' !== typeof swpPinIt.image_source) {
956
 
957
  /**
958
  * By creating a temporary image and then using jQuery to fetch the
@@ -997,14 +997,15 @@ window.socialWarfare = window.socialWarfare || {};
997
  */
998
  if (typeof image.data("pin-description") != 'undefined') {
999
  pinDesc = image.data("pin-description");
1000
- } else if ('undefined' !== typeof swpPinIt.image_description) {
1001
  pinDesc = swpPinIt.image_description;
1002
  } else if (image.attr('title')) {
1003
  pinDesc = image.attr('title');
1004
  } else if (image.attr('alt')) {
1005
  pinDesc = image.attr('alt');
 
 
1006
  }
1007
-
1008
  shareLink = 'http://pinterest.com/pin/create/bookmarklet/?media=' + encodeURI(pinMedia) + '&url=' + encodeURI(document.URL) + '&is_video=false' + '&description=' + encodeURIComponent(pinDesc);
1009
 
1010
 
952
  * visitors pin the actual image being hovered.
953
  *
954
  */
955
+ if ('undefined' !== typeof swpPinIt.image_source && swpPinIt.image_source.length) {
956
 
957
  /**
958
  * By creating a temporary image and then using jQuery to fetch the
997
  */
998
  if (typeof image.data("pin-description") != 'undefined') {
999
  pinDesc = image.data("pin-description");
1000
+ } else if (typeof image.data("pin-description") == 'string' && swpPinIt.image_description.length) {
1001
  pinDesc = swpPinIt.image_description;
1002
  } else if (image.attr('title')) {
1003
  pinDesc = image.attr('title');
1004
  } else if (image.attr('alt')) {
1005
  pinDesc = image.attr('alt');
1006
+ } else if (typeof swpPinIt.post_title == 'string') {
1007
+ pinDesc = swpPinIt.post_title;
1008
  }
 
1009
  shareLink = 'http://pinterest.com/pin/create/bookmarklet/?media=' + encodeURI(pinMedia) + '&url=' + encodeURI(document.URL) + '&is_video=false' + '&description=' + encodeURIComponent(pinDesc);
1010
 
1011
 
assets/js/script.min.js CHANGED
@@ -1 +1 @@
1
- window.socialWarfare=window.socialWarfare||{},function(a,e){"use strict";if("function"!=typeof e){if("function"!=typeof jQuery)return void console.log("Social Warfare requires jQuery, or $ as an alias of jQuery. Please make sure your theme provides access to jQuery before activating Social Warfare.");var e=jQuery}socialWarfare.paddingTop=parseInt(e("body").css("padding-top")),socialWarfare.paddingBottom=parseInt(e("body").css("padding-bottom")),socialWarfare.initPlugin=function(){if(e("body").css({paddingTop:socialWarfare.paddingTop,paddingBottom:socialWarfare.paddingBottom}),socialWarfare.establishPanels(),socialWarfare.establishBreakpoint(),socialWarfare.panels.staticHorizontal||socialWarfare.panels.floatingSide||socialWarfare.panels.floatingHorizontal){socialWarfare.createFloatHorizontalPanel(),socialWarfare.positionFloatSidePanel(),socialWarfare.activateHoverStates(),socialWarfare.handleButtonClicks(),socialWarfare.updateFloatingButtons(),setTimeout(function(){socialWarfare.checkListeners(0,5)},2e3);var i=Date.now();e(a).scroll(function(){i+50-Date.now()<0&&(socialWarfare.updateFloatingButtons(),i=Date.now())})}};var i;socialWarfare.onWindowResize=function(){clearTimeout(i),i=setTimeout(socialWarfare.initPlugin,100)},socialWarfare.establishPanels=function(){return socialWarfare.panels={staticHorizontal:null,floatingSide:null,floatingHorizontal:null},socialWarfare.panels.staticHorizontal=e(".swp_social_panel").not(".swp_social_panelSide"),socialWarfare.panels.floatingSide=e(".swp_social_panelSide"),socialWarfare.panels},socialWarfare.activateHoverStates=function(){socialWarfare.trigger("pre_activate_buttons"),e(".swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer").on("mouseenter",function(){if(!e(this).hasClass("swp_nohover")){socialWarfare.resetStaticPanel();var a=e(this).find(".swp_share").outerWidth(),i=e(this).find("i.sw").outerWidth(),t=e(this).width(),o=1+(a+35)/t;e(this).find(".iconFiller").width(a+i+25+"px"),e(this).css("flex",o+" 1 0%")}}),e(".swp_social_panel:not(.swp_social_panelSide)").on("mouseleave",socialWarfare.resetStaticPanel)},socialWarfare.resetStaticPanel=function(){e(".swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer:not(.swp_nohover) .iconFiller").removeAttr("style"),e(".swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer:not(.swp_nohover)").removeAttr("style")},socialWarfare.handleButtonClicks=function(){e(".nc_tweet, a.swp_CTT").off("click"),e(".nc_tweet, a.swp_CTT").on("click",function(i){if(e(this).hasClass("noPop"))return i;if(void 0===e(this).data("link"))return i;i.preventDefault();var t,o,r,s,n,l,c=e(this).data("link").replace("’","'");t=270,o=500,e(this).is(".pinterest, .buffer_link, .flipboard")&&(t=550,o=775),e(this).hasClass("nc_tweet")?l=e(this).parents(".nc_tweetContainer").data("network"):e(this).hasClass("swp_CTT")&&(l="ctt"),r=a.screenY+(a.innerHeight-t)/2,s=a.screenX+(a.innerWidth-o)/2,n="height="+t+",width="+o+",top="+r+",left="+s,a.open(c,l,n),socialWarfare.trackClick(l)})},socialWarfare.createFloatHorizontalPanel=function(){if(socialWarfare.panels.staticHorizontal.length){var a=socialWarfare.panels.staticHorizontal.data("float"),i=socialWarfare.panels.staticHorizontal.data("float-mobile"),t=socialWarfare.panels.staticHorizontal.data("float-color"),o=e('<div class="nc_wrapper swp_floating_horizontal_wrapper" style="background-color:'+t+'"></div>'),r="";e(".nc_wrapper").length&&e(".nc_wrapper").remove(),e(".swp_floating_horizontal_wrapper").length&&e(".swp_floating_horizontal_wrapper").remove(),"top"!=a&&"bottom"!=a&&"top"!=i&&"bottom"!=i||(r=socialWarfare.isMobile()?i:a,o.addClass(r).hide().appendTo("body"),socialWarfare.panels.floatingHorizontal=socialWarfare.panels.staticHorizontal.first().clone(),socialWarfare.panels.floatingHorizontal.addClass("nc_floater").appendTo(o),socialWarfare.updateFloatingHorizontalDimensions(),e(".swp_social_panel .swp_count").css({transition:"padding .1s linear"}))}},socialWarfare.updateFloatingHorizontalDimensions=function(){if(socialWarfare.panels.staticHorizontal.length&&socialWarfare.panels.floatingHorizontal){var a="100%",e=0,i=socialWarfare.panels.staticHorizontal,t=i.parent();t.hasClass("swp-hidden-panel-wrap")&&(t=t.parent()),void 0!==i.offset().left&&(e=i.offset().left),void 0!==i.width()&&(a=i.width()),0==e&&(e=t.offset().left),100!=a&&0!=a||(a=t.width()),socialWarfare.panels.floatingHorizontal.css({width:a,left:e})}},socialWarfare.staticPanelIsVisible=function(){var i=!1,t=e(a).scrollTop();return e(".swp_social_panel").not(".swp_social_panelSide, .nc_floater").each(function(o){var r=e(this).offset();if(void 0!==socialWarfare.floatBeforeContent&&"1"!=socialWarfare.floatBeforeContent){var s=e(".swp-content-locator").parent();0===o&&s.length&&s.offset().top>t+e(a).height()&&(i=!0)}e(this).is(":visible")&&r.top+e(this).height()>t&&r.top<t+e(a).height()&&(i=!0)}),i},socialWarfare.updateFloatingButtons=function(){if(socialWarfare.panels.staticHorizontal.length)var a=socialWarfare.panels.staticHorizontal;else{if(!socialWarfare.panels.floatingSide.length)return;var a=socialWarfare.panels.floatingSide}var i=a.data("float");if(1==socialWarfare.isMobile())var i=a.data("float-mobile");return"none"==i?e(".nc_wrapper, .swp_floating_horizontal_wrapper, .swp_social_panelSide").hide():socialWarfare.isMobile()?(socialWarfare.toggleMobileButtons(),void socialWarfare.toggleFloatingHorizontalPanel()):("right"!=i&&"left"!=i||socialWarfare.toggleFloatingVerticalPanel(),void("bottom"!=i&&"top"!=i||socialWarfare.toggleFloatingHorizontalPanel()))},socialWarfare.toggleMobileButtons=function(){socialWarfare.panels.floatingSide.hide();var a=socialWarfare.staticPanelIsVisible()?"collapse":"visible";e(".nc_wrapper, .swp_floating_horizontal_wrapper").css("visibility",a)},socialWarfare.toggleFloatingVerticalPanel=function(){var a="",e=socialWarfare.panels.floatingSide.data("float"),i=socialWarfare.staticPanelIsVisible(),t="";if(socialWarfare.isMobile())return socialWarfare.panels.floatingSide.hide();socialWarfare.panels.floatingSide&&socialWarfare.panels.floatingSide.length||(i=!0),"slide"==socialWarfare.panels.floatingSide.data("transition")?(a=e,t=i?"-150px":"5px",socialWarfare.panels.floatingSide.css(a,t).show()):i?socialWarfare.panels.floatingSide.css("opacity",1).fadeOut(300).css("opacity",0):socialWarfare.panels.floatingSide.css("opacity",0).fadeIn(300).css("display","flex").css("opacity",1)},socialWarfare.hasReferencePanel=function(){return void 0!==socialWarfare.panels.staticHorizontal&&socialWarfare.panels.staticHorizontal.length>0},socialWarfare.toggleFloatingHorizontalPanel=function(){if(socialWarfare.hasReferencePanel()&&socialWarfare.panels.floatingHorizontal){var a=socialWarfare.panels.floatingHorizontal.first(),i=socialWarfare.isMobile()?e(a).data("float-mobile"):e(a).data("float"),t="bottom"==i?socialWarfare.paddingBottom:socialWarfare.paddingTop,o="padding-"+i;"off"!=i&&(socialWarfare.staticPanelIsVisible()?(e(".nc_wrapper, .swp_floating_horizontal_wrapper").hide(),socialWarfare.isMobile()&&e("#wpadminbar").length&&e("#wpadminbar").css("top",0)):(t+=50,e(".nc_wrapper, .swp_floating_horizontal_wrapper").show(),socialWarfare.isMobile()&&"top"==i&&e("#wpadminbar").length&&e("#wpadminbar").css("top",a.parent().height())),e("body").css(o,t))}},socialWarfare.positionFloatSidePanel=function(){var e,i,t,o=socialWarfare.panels.floatingSide;if(o&&o.length&&!o.hasClass("swp_side_top")&&!o.hasClass("swp_side_bottom")){if(e=o.outerHeight(),i=a.innerHeight,e>i)return o.css("top",0);t=(i-e)/2,o.css("top",t)}},e(a).on("load",function(){"undefined"!=typeof swpPinIt&&swpPinIt.enabled&&socialWarfare.enablePinterestSaveButtons(),a.clearCheckID=0}),socialWarfare.enablePinterestSaveButtons=function(){jQuery("img").on("mouseenter",function(){var a=socialWarfare.findPinterestBrowserSaveButtons();void 0!==a&&a&&socialWarfare.removePinterestBrowserSaveButtons(a)}),e(".swp-content-locator").parent().find("img").each(socialWarfare.renderPinterestSaveButton),e(".sw-pinit .sw-pinit-button").on("click",function(i){i.preventDefault(),a.open(e(this).attr("href"),"Pinterest","width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1"),socialWarfare.trackClick("pin_image")})},socialWarfare.renderPinterestSaveButton=function(){var a,i,t,o,r,s;if(a=e(this),!(void 0!=typeof swpPinIt.disableOnAnchors&&swpPinIt.disableOnAnchors&&e(a).parents().filter("a").length||a.outerHeight()<swpPinIt.minHeight||a.outerWidth()<swpPinIt.minWidth||a.hasClass("no_pin")||a.hasClass("no-pin"))){if(void 0!==swpPinIt.image_source){var n=new Image;n.src=swpPinIt.image_source,i=e(n).prop("src")}else a.data("media")?i=a.data("media"):e(this).data("lazy-src")?i=e(this).data("lazy-src"):a[0].src&&(i=a[0].src);i&&void 0!==i&&(void 0!==a.data("pin-description")?t=a.data("pin-description"):void 0!==swpPinIt.image_description?t=swpPinIt.image_description:a.attr("title")?t=a.attr("title"):a.attr("alt")&&(t=a.attr("alt")),s="http://pinterest.com/pin/create/bookmarklet/?media="+encodeURI(i)+"&url="+encodeURI(document.URL)+"&is_video=false&description="+encodeURIComponent(t),o=a.attr("class"),r=a.attr("style"),a.removeClass().attr("style","").wrap('<div class="sw-pinit" />'),a.after('<a href="'+s+'" class="sw-pinit-button sw-pinit-'+swpPinIt.vLocation+" sw-pinit-"+swpPinIt.hLocation+'">Save</a>'),a.parent(".sw-pinit").addClass(o).attr("style",r))}},socialWarfare.findPinterestBrowserSaveButtons=function(){var e,i,t,o,r,s;return e="rgb(189, 8, 28)",i="rgb(230, 0, 35)",t="8675309",o="14px 14px",r=null,document.querySelectorAll("span").forEach(function(n,l){s=a.getComputedStyle(n),s.backgroundColor!=e&&s.backgroundColor!=i||s.backgroundSize==o&&s.zIndex==t&&(r=n)}),r},socialWarfare.removePinterestBrowserSaveButtons=function(e){var i,t,o;i=e.nextSibling,void 0!==i&&"SPAN"==i.nodeName&&(t=a.getComputedStyle(i),o="24px",0===t.width.indexOf(o)&&0===t.height.indexOf(o)&&i.remove()),e.remove()},socialWarfare.fetchFacebookShares=function(){var a="https://graph.facebook.com/?fields=og_object{likes.summary(true).limit(0)},share&id="+swp_post_url,i=swp_post_recovery_url?"https://graph.facebook.com/?fields=og_object{likes.summary(true).limit(0)},share&id="+swp_post_recovery_url:"";e.when(e.get(a),e.get(i)).then(function(a,i){var t,o;t=socialWarfare.parseFacebookShares(a[0]),swp_post_recovery_url&&(t+=socialWarfare.parseFacebookShares(i[0]));var o={action:"swp_facebook_shares_update",post_id:swp_post_id,share_counts:t};e.post(swp_admin_ajax,o)})},socialWarfare.parseFacebookShares=function(a){var e=0;return void 0!==a.share&&(e+=parseInt(a.share.share_count),e+=parseInt(a.share.comment_count)),void 0!==a.og_object&&(e+=parseInt(a.og_object.likes.summary.total_count)),e},socialWarfare.trigger=function(i){e(a).trigger(e.Event(i))},socialWarfare.trackClick=function(a){!0===swpClickTracking&&("function"==typeof ga&&ga("send","event","social_media","swp_"+a+"_share"),"object"==typeof dataLayer&&dataLayer.push({event:"swp_"+a+"_share"}))},socialWarfare.checkListeners=function(a,i){if(!(a>i)){var t=e(".swp_social_panel");if(t.length>0&&t.find(".swp_pinterest"))return void socialWarfare.handleButtonClicks();setTimeout(function(){socialWarfare.checkListeners(++a,i)},2e3)}},socialWarfare.establishBreakpoint=function(){var a=e(".swp_social_panel");socialWarfare.breakpoint=1100,(a.length&&a.data("min-width")||0==a.data("min-width"))&&(socialWarfare.breakpoint=parseInt(a.data("min-width")))},socialWarfare.isMobile=function(){return e(a).width()<socialWarfare.breakpoint},e(document).ready(function(){socialWarfare.initPlugin(),socialWarfare.panels.floatingSide.hide(),e(a).resize(socialWarfare.onWindowResize)})}(this,jQuery);
1
+ window.socialWarfare=window.socialWarfare||{},function(a,e){"use strict";if("function"!=typeof e){if("function"!=typeof jQuery)return void console.log("Social Warfare requires jQuery, or $ as an alias of jQuery. Please make sure your theme provides access to jQuery before activating Social Warfare.");var e=jQuery}socialWarfare.paddingTop=parseInt(e("body").css("padding-top")),socialWarfare.paddingBottom=parseInt(e("body").css("padding-bottom")),socialWarfare.initPlugin=function(){if(e("body").css({paddingTop:socialWarfare.paddingTop,paddingBottom:socialWarfare.paddingBottom}),socialWarfare.establishPanels(),socialWarfare.establishBreakpoint(),socialWarfare.panels.staticHorizontal||socialWarfare.panels.floatingSide||socialWarfare.panels.floatingHorizontal){socialWarfare.createFloatHorizontalPanel(),socialWarfare.positionFloatSidePanel(),socialWarfare.activateHoverStates(),socialWarfare.handleButtonClicks(),socialWarfare.updateFloatingButtons(),setTimeout(function(){socialWarfare.checkListeners(0,5)},2e3);var t=Date.now();e(a).scroll(function(){t+50-Date.now()<0&&(socialWarfare.updateFloatingButtons(),t=Date.now())})}};var t;socialWarfare.onWindowResize=function(){clearTimeout(t),t=setTimeout(socialWarfare.initPlugin,100)},socialWarfare.establishPanels=function(){return socialWarfare.panels={staticHorizontal:null,floatingSide:null,floatingHorizontal:null},socialWarfare.panels.staticHorizontal=e(".swp_social_panel").not(".swp_social_panelSide"),socialWarfare.panels.floatingSide=e(".swp_social_panelSide"),socialWarfare.panels},socialWarfare.activateHoverStates=function(){socialWarfare.trigger("pre_activate_buttons"),e(".swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer").on("mouseenter",function(){if(!e(this).hasClass("swp_nohover")){socialWarfare.resetStaticPanel();var a=e(this).find(".swp_share").outerWidth(),t=e(this).find("i.sw").outerWidth(),i=e(this).width(),o=1+(a+35)/i;e(this).find(".iconFiller").width(a+t+25+"px"),e(this).css("flex",o+" 1 0%")}}),e(".swp_social_panel:not(.swp_social_panelSide)").on("mouseleave",socialWarfare.resetStaticPanel)},socialWarfare.resetStaticPanel=function(){e(".swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer:not(.swp_nohover) .iconFiller").removeAttr("style"),e(".swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer:not(.swp_nohover)").removeAttr("style")},socialWarfare.handleButtonClicks=function(){e(".nc_tweet, a.swp_CTT").off("click"),e(".nc_tweet, a.swp_CTT").on("click",function(t){if(e(this).hasClass("noPop"))return t;if(void 0===e(this).data("link"))return t;t.preventDefault();var i,o,r,s,n,l,c=e(this).data("link").replace("’","'");i=270,o=500,e(this).is(".pinterest, .buffer_link, .flipboard")&&(i=550,o=775),e(this).hasClass("nc_tweet")?l=e(this).parents(".nc_tweetContainer").data("network"):e(this).hasClass("swp_CTT")&&(l="ctt"),r=a.screenY+(a.innerHeight-i)/2,s=a.screenX+(a.innerWidth-o)/2,n="height="+i+",width="+o+",top="+r+",left="+s,a.open(c,l,n),socialWarfare.trackClick(l)})},socialWarfare.createFloatHorizontalPanel=function(){if(socialWarfare.panels.staticHorizontal.length){var a=socialWarfare.panels.staticHorizontal.data("float"),t=socialWarfare.panels.staticHorizontal.data("float-mobile"),i=socialWarfare.panels.staticHorizontal.data("float-color"),o=e('<div class="nc_wrapper swp_floating_horizontal_wrapper" style="background-color:'+i+'"></div>'),r="";e(".nc_wrapper").length&&e(".nc_wrapper").remove(),e(".swp_floating_horizontal_wrapper").length&&e(".swp_floating_horizontal_wrapper").remove(),"top"!=a&&"bottom"!=a&&"top"!=t&&"bottom"!=t||(r=socialWarfare.isMobile()?t:a,o.addClass(r).hide().appendTo("body"),socialWarfare.panels.floatingHorizontal=socialWarfare.panels.staticHorizontal.first().clone(),socialWarfare.panels.floatingHorizontal.addClass("nc_floater").appendTo(o),socialWarfare.updateFloatingHorizontalDimensions(),e(".swp_social_panel .swp_count").css({transition:"padding .1s linear"}))}},socialWarfare.updateFloatingHorizontalDimensions=function(){if(socialWarfare.panels.staticHorizontal.length&&socialWarfare.panels.floatingHorizontal){var a="100%",e=0,t=socialWarfare.panels.staticHorizontal,i=t.parent();i.hasClass("swp-hidden-panel-wrap")&&(i=i.parent()),void 0!==t.offset().left&&(e=t.offset().left),void 0!==t.width()&&(a=t.width()),0==e&&(e=i.offset().left),100!=a&&0!=a||(a=i.width()),socialWarfare.panels.floatingHorizontal.css({width:a,left:e})}},socialWarfare.staticPanelIsVisible=function(){var t=!1,i=e(a).scrollTop();return e(".swp_social_panel").not(".swp_social_panelSide, .nc_floater").each(function(o){var r=e(this).offset();if(void 0!==socialWarfare.floatBeforeContent&&"1"!=socialWarfare.floatBeforeContent){var s=e(".swp-content-locator").parent();0===o&&s.length&&s.offset().top>i+e(a).height()&&(t=!0)}e(this).is(":visible")&&r.top+e(this).height()>i&&r.top<i+e(a).height()&&(t=!0)}),t},socialWarfare.updateFloatingButtons=function(){if(socialWarfare.panels.staticHorizontal.length)var a=socialWarfare.panels.staticHorizontal;else{if(!socialWarfare.panels.floatingSide.length)return;var a=socialWarfare.panels.floatingSide}var t=a.data("float");if(1==socialWarfare.isMobile())var t=a.data("float-mobile");return"none"==t?e(".nc_wrapper, .swp_floating_horizontal_wrapper, .swp_social_panelSide").hide():socialWarfare.isMobile()?(socialWarfare.toggleMobileButtons(),void socialWarfare.toggleFloatingHorizontalPanel()):("right"!=t&&"left"!=t||socialWarfare.toggleFloatingVerticalPanel(),void("bottom"!=t&&"top"!=t||socialWarfare.toggleFloatingHorizontalPanel()))},socialWarfare.toggleMobileButtons=function(){socialWarfare.panels.floatingSide.hide();var a=socialWarfare.staticPanelIsVisible()?"collapse":"visible";e(".nc_wrapper, .swp_floating_horizontal_wrapper").css("visibility",a)},socialWarfare.toggleFloatingVerticalPanel=function(){var a="",e=socialWarfare.panels.floatingSide.data("float"),t=socialWarfare.staticPanelIsVisible(),i="";if(socialWarfare.isMobile())return socialWarfare.panels.floatingSide.hide();socialWarfare.panels.floatingSide&&socialWarfare.panels.floatingSide.length||(t=!0),"slide"==socialWarfare.panels.floatingSide.data("transition")?(a=e,i=t?"-150px":"5px",socialWarfare.panels.floatingSide.css(a,i).show()):t?socialWarfare.panels.floatingSide.css("opacity",1).fadeOut(300).css("opacity",0):socialWarfare.panels.floatingSide.css("opacity",0).fadeIn(300).css("display","flex").css("opacity",1)},socialWarfare.hasReferencePanel=function(){return void 0!==socialWarfare.panels.staticHorizontal&&socialWarfare.panels.staticHorizontal.length>0},socialWarfare.toggleFloatingHorizontalPanel=function(){if(socialWarfare.hasReferencePanel()&&socialWarfare.panels.floatingHorizontal){var a=socialWarfare.panels.floatingHorizontal.first(),t=socialWarfare.isMobile()?e(a).data("float-mobile"):e(a).data("float"),i="bottom"==t?socialWarfare.paddingBottom:socialWarfare.paddingTop,o="padding-"+t;"off"!=t&&(socialWarfare.staticPanelIsVisible()?(e(".nc_wrapper, .swp_floating_horizontal_wrapper").hide(),socialWarfare.isMobile()&&e("#wpadminbar").length&&e("#wpadminbar").css("top",0)):(i+=50,e(".nc_wrapper, .swp_floating_horizontal_wrapper").show(),socialWarfare.isMobile()&&"top"==t&&e("#wpadminbar").length&&e("#wpadminbar").css("top",a.parent().height())),e("body").css(o,i))}},socialWarfare.positionFloatSidePanel=function(){var e,t,i,o=socialWarfare.panels.floatingSide;if(o&&o.length&&!o.hasClass("swp_side_top")&&!o.hasClass("swp_side_bottom")){if(e=o.outerHeight(),t=a.innerHeight,e>t)return o.css("top",0);i=(t-e)/2,o.css("top",i)}},e(a).on("load",function(){"undefined"!=typeof swpPinIt&&swpPinIt.enabled&&socialWarfare.enablePinterestSaveButtons(),a.clearCheckID=0}),socialWarfare.enablePinterestSaveButtons=function(){jQuery("img").on("mouseenter",function(){var a=socialWarfare.findPinterestBrowserSaveButtons();void 0!==a&&a&&socialWarfare.removePinterestBrowserSaveButtons(a)}),e(".swp-content-locator").parent().find("img").each(socialWarfare.renderPinterestSaveButton),e(".sw-pinit .sw-pinit-button").on("click",function(t){t.preventDefault(),a.open(e(this).attr("href"),"Pinterest","width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1"),socialWarfare.trackClick("pin_image")})},socialWarfare.renderPinterestSaveButton=function(){var a,t,i,o,r,s;if(a=e(this),!(void 0!=typeof swpPinIt.disableOnAnchors&&swpPinIt.disableOnAnchors&&e(a).parents().filter("a").length||a.outerHeight()<swpPinIt.minHeight||a.outerWidth()<swpPinIt.minWidth||a.hasClass("no_pin")||a.hasClass("no-pin"))){if(void 0!==swpPinIt.image_source&&swpPinIt.image_source.length){var n=new Image;n.src=swpPinIt.image_source,t=e(n).prop("src")}else a.data("media")?t=a.data("media"):e(this).data("lazy-src")?t=e(this).data("lazy-src"):a[0].src&&(t=a[0].src);t&&void 0!==t&&(void 0!==a.data("pin-description")?i=a.data("pin-description"):"string"==typeof a.data("pin-description")&&swpPinIt.image_description.length?i=swpPinIt.image_description:a.attr("title")?i=a.attr("title"):a.attr("alt")?i=a.attr("alt"):"string"==typeof swpPinIt.post_title&&(i=swpPinIt.post_title),s="http://pinterest.com/pin/create/bookmarklet/?media="+encodeURI(t)+"&url="+encodeURI(document.URL)+"&is_video=false&description="+encodeURIComponent(i),o=a.attr("class"),r=a.attr("style"),a.removeClass().attr("style","").wrap('<div class="sw-pinit" />'),a.after('<a href="'+s+'" class="sw-pinit-button sw-pinit-'+swpPinIt.vLocation+" sw-pinit-"+swpPinIt.hLocation+'">Save</a>'),a.parent(".sw-pinit").addClass(o).attr("style",r))}},socialWarfare.findPinterestBrowserSaveButtons=function(){var e,t,i,o,r,s;return e="rgb(189, 8, 28)",t="rgb(230, 0, 35)",i="8675309",o="14px 14px",r=null,document.querySelectorAll("span").forEach(function(n,l){s=a.getComputedStyle(n),s.backgroundColor!=e&&s.backgroundColor!=t||s.backgroundSize==o&&s.zIndex==i&&(r=n)}),r},socialWarfare.removePinterestBrowserSaveButtons=function(e){var t,i,o;t=e.nextSibling,void 0!==t&&"SPAN"==t.nodeName&&(i=a.getComputedStyle(t),o="24px",0===i.width.indexOf(o)&&0===i.height.indexOf(o)&&t.remove()),e.remove()},socialWarfare.fetchFacebookShares=function(){var a="https://graph.facebook.com/?fields=og_object{likes.summary(true).limit(0)},share&id="+swp_post_url,t=swp_post_recovery_url?"https://graph.facebook.com/?fields=og_object{likes.summary(true).limit(0)},share&id="+swp_post_recovery_url:"";e.when(e.get(a),e.get(t)).then(function(a,t){var i,o;i=socialWarfare.parseFacebookShares(a[0]),swp_post_recovery_url&&(i+=socialWarfare.parseFacebookShares(t[0]));var o={action:"swp_facebook_shares_update",post_id:swp_post_id,share_counts:i};e.post(swp_admin_ajax,o)})},socialWarfare.parseFacebookShares=function(a){var e=0;return void 0!==a.share&&(e+=parseInt(a.share.share_count),e+=parseInt(a.share.comment_count)),void 0!==a.og_object&&(e+=parseInt(a.og_object.likes.summary.total_count)),e},socialWarfare.trigger=function(t){e(a).trigger(e.Event(t))},socialWarfare.trackClick=function(a){!0===swpClickTracking&&("function"==typeof ga&&ga("send","event","social_media","swp_"+a+"_share"),"object"==typeof dataLayer&&dataLayer.push({event:"swp_"+a+"_share"}))},socialWarfare.checkListeners=function(a,t){if(!(a>t)){var i=e(".swp_social_panel");if(i.length>0&&i.find(".swp_pinterest"))return void socialWarfare.handleButtonClicks();setTimeout(function(){socialWarfare.checkListeners(++a,t)},2e3)}},socialWarfare.establishBreakpoint=function(){var a=e(".swp_social_panel");socialWarfare.breakpoint=1100,(a.length&&a.data("min-width")||0==a.data("min-width"))&&(socialWarfare.breakpoint=parseInt(a.data("min-width")))},socialWarfare.isMobile=function(){return e(a).width()<socialWarfare.breakpoint},e(document).ready(function(){socialWarfare.initPlugin(),socialWarfare.panels.floatingSide.hide(),e(a).resize(socialWarfare.onWindowResize)})}(this,jQuery);
lib/Social_Warfare_Addon.php CHANGED
@@ -27,13 +27,9 @@ class Social_Warfare_Addon {
27
  endif;
28
  }
29
  if ( isset( $this->product_id ) && empty ( $this->store_url ) ) {
30
- // $message = "You provided `product_id` without a `store_url`. Please provide `store_url` as a top level domain, such as 'https://warfareplugins.com'.";
31
- // throw new Exception($message);
32
  $this->store_url = 'https://warfareplugins.com';
33
- }
34
-
35
- if ( isset( $this->product_id ) && empty ( $this->site_url ) ) {
36
- $this->store_url = SWP_Utility::get_site_url();
37
  }
38
  }
39
 
@@ -220,19 +216,17 @@ class Social_Warfare_Addon {
220
  *
221
  */
222
  public function unregister_plugin() {
 
223
  // Setup the variables needed for processing
224
  $options = get_option( 'social_warfare_settings' );
225
  $key = $_POST['name_key'];
226
  $item_id = $_POST['item_id'];
227
- $response = array();
228
 
229
  // Check to see if the license key is even in the options
230
  if ( !SWP_Utility::get_option( $key . '_license_key' ) ) :
231
-
232
  $response['success'] = true;
233
- echo json_encode($response);
234
- wp_die();
235
-
236
  endif;
237
 
238
  // Grab the license key so we can use it below
@@ -246,16 +240,22 @@ class Social_Warfare_Addon {
246
  'url' => $this->site_url,
247
  );
248
 
249
- //* wp_remote_retrieve_body encodes to JSON for us.
250
  $response = wp_remote_retrieve_body( wp_remote_post( $this->store_url, array( 'body' => $api_params, 'timeout' => 10 ) ) );
 
 
 
 
 
251
 
252
- $options = get_option( 'social_warfare_settings' );
253
- $options[$key.'_license_key'] = '';
254
- update_option( 'social_warfare_settings' , $options );
255
 
256
- echo $response;
 
 
 
 
257
 
258
- wp_die();
259
  }
260
 
261
  public function ajax_passthrough() {
27
  endif;
28
  }
29
  if ( isset( $this->product_id ) && empty ( $this->store_url ) ) {
 
 
30
  $this->store_url = 'https://warfareplugins.com';
31
+ $message = "You provided `product_id` without a `store_url`. Please provide `store_url` as a top level domain. Using default value " . $this->store_url;
32
+ error_log( $message );
 
 
33
  }
34
  }
35
 
216
  *
217
  */
218
  public function unregister_plugin() {
219
+
220
  // Setup the variables needed for processing
221
  $options = get_option( 'social_warfare_settings' );
222
  $key = $_POST['name_key'];
223
  $item_id = $_POST['item_id'];
224
+ $response = array('success' => false);
225
 
226
  // Check to see if the license key is even in the options
227
  if ( !SWP_Utility::get_option( $key . '_license_key' ) ) :
 
228
  $response['success'] = true;
229
+ wp_die(json_encode($response));
 
 
230
  endif;
231
 
232
  // Grab the license key so we can use it below
240
  'url' => $this->site_url,
241
  );
242
 
 
243
  $response = wp_remote_retrieve_body( wp_remote_post( $this->store_url, array( 'body' => $api_params, 'timeout' => 10 ) ) );
244
+ if ( empty( $response ) ) {
245
+ $response['success'] = false;
246
+ $response['message'] = 'Error making deactivation request to ' . $this->store_url;
247
+ wp_die( json_encode( $response ) );
248
+ }
249
 
250
+ $response = json_decode( $response );
 
 
251
 
252
+ if ( $response->license == 'deactivated' ) {
253
+ $options = get_option( 'social_warfare_settings' );
254
+ $options[$key.'_license_key'] = '';
255
+ update_option( 'social_warfare_settings' , $options );
256
+ }
257
 
258
+ wp_die(json_encode($response));
259
  }
260
 
261
  public function ajax_passthrough() {
lib/buttons-panel/SWP_Buttons_Panel.php CHANGED
@@ -453,7 +453,7 @@ class SWP_Buttons_Panel {
453
  * using any of the global or post type settings for the location.
454
  *
455
  */
456
- if ( !empty( $post_setting ) && 'default' != $post_setting ) {
457
  $this->location = $post_setting;
458
  return;
459
  }
453
  * using any of the global or post type settings for the location.
454
  *
455
  */
456
+ if ( is_singular() && !empty( $post_setting ) && 'default' != $post_setting ) {
457
  $this->location = $post_setting;
458
  return;
459
  }
lib/buttons-panel/SWP_Buttons_Panel_Loader.php CHANGED
@@ -5,7 +5,7 @@
5
  * Button placement options, as provided in the settings page,
6
  * are applied in the logic of this class. We also create the
7
  * content locator, and fallback panels for horizontal floating
8
- * panels.
9
  *
10
  * This used to be the SWP_Display class in /lib/frontend-output/
11
  *
5
  * Button placement options, as provided in the settings page,
6
  * are applied in the logic of this class. We also create the
7
  * content locator, and fallback panels for horizontal floating
8
+ * panels.
9
  *
10
  * This used to be the SWP_Display class in /lib/frontend-output/
11
  *
lib/buttons-panel/SWP_Buttons_Panel_Trait.php CHANGED
@@ -571,7 +571,7 @@ trait SWP_Buttons_Panel_Trait {
571
  */
572
  protected function get_order_of_icons() {
573
  global $swp_social_networks;
574
- $default_buttons = SWP_Utility::get_option( 'order_of_icons' );
575
  $sort_method = SWP_Utility::get_option( 'order_of_icons_method' );
576
  $order = array();
577
 
@@ -586,7 +586,7 @@ trait SWP_Buttons_Panel_Trait {
586
  *
587
  */
588
  if ( 'manual' === $sort_method || false === $sort_method ) {
589
- return $default_buttons;
590
  }
591
 
592
 
@@ -597,7 +597,7 @@ trait SWP_Buttons_Panel_Trait {
597
  *
598
  */
599
  if( empty( $this->shares ) || !is_array( $this->shares ) ) {
600
- return $default_buttons;
601
  }
602
 
603
 
@@ -609,13 +609,12 @@ trait SWP_Buttons_Panel_Trait {
609
  */
610
  arsort( $this->shares );
611
  foreach( $this->shares as $network => $share_count ) {
612
- if( $network !== 'total_shares' && in_array( $network, $default_buttons ) ) {
613
  $order[$network] = $network;
614
  }
615
  }
616
  $this->options['order_of_icons'] = $order;
617
  return $order;
618
-
619
  }
620
 
621
 
571
  */
572
  protected function get_order_of_icons() {
573
  global $swp_social_networks;
574
+ $active_networks = SWP_Utility::get_option( 'order_of_icons' );
575
  $sort_method = SWP_Utility::get_option( 'order_of_icons_method' );
576
  $order = array();
577
 
586
  *
587
  */
588
  if ( 'manual' === $sort_method || false === $sort_method ) {
589
+ return $active_networks;
590
  }
591
 
592
 
597
  *
598
  */
599
  if( empty( $this->shares ) || !is_array( $this->shares ) ) {
600
+ return $active_networks;
601
  }
602
 
603
 
609
  */
610
  arsort( $this->shares );
611
  foreach( $this->shares as $network => $share_count ) {
612
+ if( $network != 'total_shares' && in_array( $network, $active_networks ) ) {
613
  $order[$network] = $network;
614
  }
615
  }
616
  $this->options['order_of_icons'] = $order;
617
  return $order;
 
618
  }
619
 
620
 
lib/frontend-output/SWP_Shortcode.php CHANGED
@@ -95,7 +95,7 @@ class SWP_Shortcode {
95
  function click_to_tweet( $atts ) {
96
  global $post;
97
 
98
- // This is the Add Post editor for a new post, so no $post.
99
  if ( !is_object( $post ) ) {
100
  return $atts;
101
  }
@@ -147,7 +147,7 @@ class SWP_Shortcode {
147
  *
148
  */
149
  $via = '';
150
- if( false !== $twitter_handle ) {
151
  $via = '&via=' . $twitter_handle;
152
  }
153
 
95
  function click_to_tweet( $atts ) {
96
  global $post;
97
 
98
+ // This is the Add Post editor for a new post, so no $post.
99
  if ( !is_object( $post ) ) {
100
  return $atts;
101
  }
147
  *
148
  */
149
  $via = '';
150
+ if( !empty( $twitter_handle ) ) {
151
  $via = '&via=' . $twitter_handle;
152
  }
153
 
lib/options/SWP_Option_Abstract.php CHANGED
@@ -21,81 +21,81 @@ class SWP_Option_Abstract {
21
  use SWP_Debug_Trait;
22
 
23
 
24
- /**
25
- * Name
26
- *
27
- * The name of this option. This is a "pretty" name that the plugin user will see.
28
- *
29
- * @var string
30
- *
31
- */
32
  public $name;
33
 
34
 
35
  /**
36
- * Type
37
- *
38
- * The type property refers to the type of option this represents (e.g. input,
39
- * textarea, checkbox, etc.)
40
- *
41
- * @var string
42
- *
43
- */
44
  public $type;
45
 
46
 
47
  /**
48
- * Default
49
- *
50
- * The default property refers to the default value for this option. This is
51
- * what the option will be set to until the user changes it.
52
- *
53
- * @var mixed This var is dependant on what type of option is being generated.
54
- *
55
- */
56
  public $default;
57
 
58
 
59
  /**
60
- * Premium
61
- *
62
- * This property determines whether or not this option is a premium option. By
63
- * default this property is set to false. The set_premium() method can be called
64
- * to change this property. When called, the set_premium() method will accept a
65
- * string corresponding to the registration key of the premium plugin on which
66
- * this option relies. It will set the $premium_addon property to that string and
67
- * switch this property to true.
68
- *
69
- * @var bool
70
- *
71
- */
72
  public $premium = false;
73
 
74
- /**
75
- * Addon
76
- *
77
- * This propety is set iff $premium === true. The value of $addon is the
78
- * code for the corresponding addon. Permissable values are:
79
- *
80
- * pro
81
- *
82
- * @var string
83
- *
84
- */
85
- public $addon = '';
86
 
87
 
88
  /**
89
- * Priority
90
- *
91
- * The priority property is used to determine the order in which the options are
92
- * presented to the user. These options will be sorted prior to the rendering of
93
- * the HTML in ascending order. That is to say, an option with a priority of 10
94
- * will appear before an option with a priority of 20.
95
- *
96
- * @var integer
97
- *
98
- */
99
  public $priority;
100
 
101
 
@@ -109,12 +109,12 @@ class SWP_Option_Abstract {
109
  * @return none
110
  *
111
  */
112
- public function __construct( $name ) {
113
- $this->set_name( $name );
114
- $this->user_options = get_option( 'social_warfare_settings' );
115
 
116
- add_action('plugins_loaded', array( $this , 'load_social_networks' ) , 1000 );
117
- }
118
 
119
 
120
  /**
@@ -131,41 +131,41 @@ class SWP_Option_Abstract {
131
  }
132
 
133
 
134
- public function get_property( $property ) {
135
- if ( property_exists( __CLASS__, $property ) ) {
136
- return $this->$property;
137
- }
138
 
139
- $this->_throw("Property $property does not exist in " . __CLASS__ . "." );
140
- }
141
 
142
 
143
- public function get_all_networks() {
144
  return $this->networks;
145
- }
146
 
147
 
148
- public function get_user_icons() {
149
- // $options = get_option( 'social_warfare_settings' );
150
  $user_icons = SWP_Utility::get_option( 'order_of_icons' );
151
 
152
-
153
  if ( false === $user_icons ) {
154
  return array(
155
- 'google_plus' => 'google_plus',
156
- 'twitter' => 'twitter',
157
- 'facebook' => 'facebook',
158
- 'linkedin' => 'linkedin',
159
- 'pinterest' => 'pinterest'
160
- );
161
  }
162
 
163
- if ( is_array( $user_icons ) && array_key_exists( 'active', $user_icons) ) :
164
- return $user_icons['active'];
165
- endif;
 
166
 
167
- return $user_icons;
168
- }
169
 
170
 
171
  /**
@@ -176,74 +176,74 @@ class SWP_Option_Abstract {
176
  * @return object $this Allows method chaining.
177
  *
178
  */
179
- public function set_name( $name ) {
180
- if ( !is_string($name) ) {
181
- $this->_throw("Please provide a string for your object's name." );
182
- }
183
-
184
- $this->name = $name;
185
-
186
- return $this;
187
- }
188
-
189
-
190
- public function set_priority( $priority ) {
191
- if ( ! intval( $priority ) || $priority < 1) {
192
- $this->_throw("Requires an integer greater than 0.");
193
- }
194
-
195
- $this->priority = $priority;
196
-
197
- return $this;
198
- }
199
-
200
-
201
- /**
202
- * Creates a Javscript selector keyname based on the object's name.
203
- *
204
- * @param string $name The name to be converted to a key. Usually the objects name.
205
- * @return string $key A valid PHP and jQuery target keyname.
206
- */
207
- public function name_to_key( $name ) {
208
- if ( !is_string( $name ) ) :
209
- $this->_throw( 'Please provide a string to get a key.' );
210
- endif;
211
-
212
- //* Remove all non-word character symbols.
213
- $key = preg_replace( '#[^\w\s]#i', '', $name );
214
-
215
- //* Replace spaces with underscores.
216
- $key = preg_replace( '/\s+/', '_', $name );
217
-
218
-
219
- return strtolower( $key );
220
- }
221
-
222
-
223
- /**
224
- * Set the premium status of the object.
225
- *
226
- * Since there are going to be multiple addons, it's not sufficient to set premium to simply true or
227
- * false. Instead, it will be false by default. Unless this method is called and a string corresponding
228
- * the registration key of the corresponding premium addon is passed. Example: $SWP_Option->set_premium('pro');
229
- *
230
- * This will then set the premium property to true and place the registration key into the premium_addon property.
231
- *
232
- * This method does not need to be called unless it is a premium option.
233
- *
234
- * @since 3.0.0 | 02 MAR 2018 | Created
235
- * @param string String corresponding to the registration key of premium plugin if true.
236
- * @return $this Return the object to allow method chaining.
237
- *
238
- */
239
  public function set_premium( $premium_addon ) {
240
  if ( !is_string( $premium_addon ) ) {
241
- $addons = [ 'pro' ];
242
- $addon_string = PHP_EOL;
243
 
244
- foreach( $addons as $addon ) {
245
- $addon_string . $addon . PHP_EOL;
246
- }
247
  $this->_throw( "Please provide a string that is one of the following: " . var_export($addons ) );
248
  }
249
 
@@ -253,111 +253,111 @@ class SWP_Option_Abstract {
253
  }
254
 
255
 
256
- public function get_priority_map( $object) {
257
-
258
- return array_values( $this->object_to_array( $object ) );
259
- }
260
 
 
 
261
 
262
- public function object_to_array ( $object ) {
263
- if(!is_object($object) && !is_array($object)):
264
- return $object;
265
- endif;
266
 
267
- return array_map( [$this, 'object_to_array'], (array) $object);
268
- }
 
 
269
 
 
 
270
 
271
- /**
272
- * Sorts all core, premium, and third-party items by their designated priority.
273
- *
274
- * This is pretty hacky.
275
- * Ideally, the code would be pure as demonstrated in the andrewbaxter link below.
276
- * However, because we use objects with named keys to store our data, we can iterate
277
- * the objects as a numeric index. (E.g., $array[0] throws an error).
278
- * To resolve this, we have to
279
- */
280
- //* Logic: http://interactivepython.org/runestone/static/pythonds/SortSearch/TheQuickSort.html
281
- //* Code: http://andrewbaxter.net/quicksort.php
282
- public function sort_by_priority( $object ) {
283
 
284
- if (is_object($object)) {
285
- $array = $this->get_priority_map( $object) ; //get_object_vars($object);
286
- } else {
287
- $array = $object;
288
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
289
 
290
- $length = count( $array );
291
 
292
- if ( $length < 2 ) {
293
- return $array;
294
- }
295
 
296
- if ( $length === 2 ) :
297
- $first;
298
- $second;
299
- $index = 0;
300
 
301
- foreach( $array as $name => $object) {
302
- if ( $index === 2) break;
303
 
304
- if ( $index === 0) {
305
- $first = $object;
306
- } else {
307
- $second = $object;
308
- }
309
 
310
- $index++;
311
- }
312
 
313
- if ($first['priority'] > $second['priority']) {
314
- return [$second, $first];
315
- }
316
 
317
- return [$first, $second];
318
- endif;
319
 
320
- $left = $right = array();
321
 
322
- $pivot = $array[0];
323
 
324
- for ($i = 1; $i < $length; $i++) {
325
- $item = $array[$i];
326
 
327
- $item['priority'] < $pivot['priority'] ? $left[] = $item : $right[] = $item;
328
- }
329
 
330
- return array_merge( $this->sort_by_priority($left), [$pivot], $this->sort_by_priority($right) );
331
- }
332
 
333
 
334
- /**
335
- * Adds the SWP dependency attributes, if this object has a dependency set.
336
- *
337
- * @return string The HTML attributes if the object has dependency, or an empty string.
338
- */
339
- protected function render_dependency() {
340
- if ( !empty( $this->dependency) ) :
341
- return ' data-dep="' . $this->dependency->parent . '" data-dep_val=\'' . json_encode($this->dependency->values) . '\'';
342
- endif;
343
 
344
- return ' ';
345
- }
346
 
347
 
348
- /**
349
- * Adds the SWP premium attributes, if this object is premium.
350
- *
351
- * @return string The HTML attribute if the object has dependency, or an empty string.
352
- */
353
- protected function render_premium() {
354
- return;
355
- if ( isset( $this->premium ) ) :
356
- return ' premium="true" ';
357
- endif;
358
 
359
- return ' ';
360
- }
361
 
362
 
363
  /**
21
  use SWP_Debug_Trait;
22
 
23
 
24
+ /**
25
+ * Name
26
+ *
27
+ * The name of this option. This is a "pretty" name that the plugin user will see.
28
+ *
29
+ * @var string
30
+ *
31
+ */
32
  public $name;
33
 
34
 
35
  /**
36
+ * Type
37
+ *
38
+ * The type property refers to the type of option this represents (e.g. input,
39
+ * textarea, checkbox, etc.)
40
+ *
41
+ * @var string
42
+ *
43
+ */
44
  public $type;
45
 
46
 
47
  /**
48
+ * Default
49
+ *
50
+ * The default property refers to the default value for this option. This is
51
+ * what the option will be set to until the user changes it.
52
+ *
53
+ * @var mixed This var is dependant on what type of option is being generated.
54
+ *
55
+ */
56
  public $default;
57
 
58
 
59
  /**
60
+ * Premium
61
+ *
62
+ * This property determines whether or not this option is a premium option. By
63
+ * default this property is set to false. The set_premium() method can be called
64
+ * to change this property. When called, the set_premium() method will accept a
65
+ * string corresponding to the registration key of the premium plugin on which
66
+ * this option relies. It will set the $premium_addon property to that string and
67
+ * switch this property to true.
68
+ *
69
+ * @var bool
70
+ *
71
+ */
72
  public $premium = false;
73
 
74
+ /**
75
+ * Addon
76
+ *
77
+ * This propety is set iff $premium === true. The value of $addon is the
78
+ * code for the corresponding addon. Permissable values are:
79
+ *
80
+ * pro
81
+ *
82
+ * @var string
83
+ *
84
+ */
85
+ public $addon = '';
86
 
87
 
88
  /**
89
+ * Priority
90
+ *
91
+ * The priority property is used to determine the order in which the options are
92
+ * presented to the user. These options will be sorted prior to the rendering of
93
+ * the HTML in ascending order. That is to say, an option with a priority of 10
94
+ * will appear before an option with a priority of 20.
95
+ *
96
+ * @var integer
97
+ *
98
+ */
99
  public $priority;
100
 
101
 
109
  * @return none
110
  *
111
  */
112
+ public function __construct( $name ) {
113
+ $this->set_name( $name );
114
+ $this->user_options = get_option( 'social_warfare_settings' );
115
 
116
+ add_action('plugins_loaded', array( $this , 'load_social_networks' ) , 1000 );
117
+ }
118
 
119
 
120
  /**
131
  }
132
 
133
 
134
+ public function get_property( $property ) {
135
+ if ( property_exists( __CLASS__, $property ) ) {
136
+ return $this->$property;
137
+ }
138
 
139
+ $this->_throw("Property $property does not exist in " . __CLASS__ . "." );
140
+ }
141
 
142
 
143
+ public function get_all_networks() {
144
  return $this->networks;
145
+ }
146
 
147
 
148
+ public function get_user_icons() {
149
+ // $options = get_option( 'social_warfare_settings' );
150
  $user_icons = SWP_Utility::get_option( 'order_of_icons' );
151
 
 
152
  if ( false === $user_icons ) {
153
  return array(
154
+ 'google_plus' => 'google_plus',
155
+ 'twitter' => 'twitter',
156
+ 'facebook' => 'facebook',
157
+ 'linkedin' => 'linkedin',
158
+ 'pinterest' => 'pinterest'
159
+ );
160
  }
161
 
162
+ // For legacy code below 2.3.5
163
+ if ( is_array( $user_icons ) && array_key_exists( 'active', $user_icons) ) :
164
+ return $user_icons['active'];
165
+ endif;
166
 
167
+ return $user_icons;
168
+ }
169
 
170
 
171
  /**
176
  * @return object $this Allows method chaining.
177
  *
178
  */
179
+ public function set_name( $name ) {
180
+ if ( !is_string($name) ) {
181
+ $this->_throw("Please provide a string for your object's name." );
182
+ }
183
+
184
+ $this->name = $name;
185
+
186
+ return $this;
187
+ }
188
+
189
+
190
+ public function set_priority( $priority ) {
191
+ if ( ! intval( $priority ) || $priority < 1) {
192
+ $this->_throw("Requires an integer greater than 0.");
193
+ }
194
+
195
+ $this->priority = $priority;
196
+
197
+ return $this;
198
+ }
199
+
200
+
201
+ /**
202
+ * Creates a Javscript selector keyname based on the object's name.
203
+ *
204
+ * @param string $name The name to be converted to a key. Usually the objects name.
205
+ * @return string $key A valid PHP and jQuery target keyname.
206
+ */
207
+ public function name_to_key( $name ) {
208
+ if ( !is_string( $name ) ) :
209
+ $this->_throw( 'Please provide a string to get a key.' );
210
+ endif;
211
+
212
+ //* Remove all non-word character symbols.
213
+ $key = preg_replace( '#[^\w\s]#i', '', $name );
214
+
215
+ //* Replace spaces with underscores.
216
+ $key = preg_replace( '/\s+/', '_', $name );
217
+
218
+
219
+ return strtolower( $key );
220
+ }
221
+
222
+
223
+ /**
224
+ * Set the premium status of the object.
225
+ *
226
+ * Since there are going to be multiple addons, it's not sufficient to set premium to simply true or
227
+ * false. Instead, it will be false by default. Unless this method is called and a string corresponding
228
+ * the registration key of the corresponding premium addon is passed. Example: $SWP_Option->set_premium('pro');
229
+ *
230
+ * This will then set the premium property to true and place the registration key into the premium_addon property.
231
+ *
232
+ * This method does not need to be called unless it is a premium option.
233
+ *
234
+ * @since 3.0.0 | 02 MAR 2018 | Created
235
+ * @param string String corresponding to the registration key of premium plugin if true.
236
+ * @return $this Return the object to allow method chaining.
237
+ *
238
+ */
239
  public function set_premium( $premium_addon ) {
240
  if ( !is_string( $premium_addon ) ) {
241
+ $addons = [ 'pro' ];
242
+ $addon_string = PHP_EOL;
243
 
244
+ foreach( $addons as $addon ) {
245
+ $addon_string . $addon . PHP_EOL;
246
+ }
247
  $this->_throw( "Please provide a string that is one of the following: " . var_export($addons ) );
248
  }
249
 
253
  }
254
 
255
 
256
+ public function get_priority_map( $object) {
 
 
 
257
 
258
+ return array_values( $this->object_to_array( $object ) );
259
+ }
260
 
 
 
 
 
261
 
262
+ public function object_to_array ( $object ) {
263
+ if(!is_object($object) && !is_array($object)):
264
+ return $object;
265
+ endif;
266
 
267
+ return array_map( [$this, 'object_to_array'], (array) $object);
268
+ }
269
 
 
 
 
 
 
 
 
 
 
 
 
 
270
 
271
+ /**
272
+ * Sorts all core, premium, and third-party items by their designated priority.
273
+ *
274
+ * This is pretty hacky.
275
+ * Ideally, the code would be pure as demonstrated in the andrewbaxter link below.
276
+ * However, because we use objects with named keys to store our data, we can iterate
277
+ * the objects as a numeric index. (E.g., $array[0] throws an error).
278
+ * To resolve this, we have to
279
+ */
280
+ //* Logic: http://interactivepython.org/runestone/static/pythonds/SortSearch/TheQuickSort.html
281
+ //* Code: http://andrewbaxter.net/quicksort.php
282
+ public function sort_by_priority( $object ) {
283
+
284
+ if (is_object($object)) {
285
+ $array = $this->get_priority_map( $object) ; //get_object_vars($object);
286
+ } else {
287
+ $array = $object;
288
+ }
289
 
290
+ $length = count( $array );
291
 
292
+ if ( $length < 2 ) {
293
+ return $array;
294
+ }
295
 
296
+ if ( $length === 2 ) :
297
+ $first;
298
+ $second;
299
+ $index = 0;
300
 
301
+ foreach( $array as $name => $object) {
302
+ if ( $index === 2) break;
303
 
304
+ if ( $index === 0) {
305
+ $first = $object;
306
+ } else {
307
+ $second = $object;
308
+ }
309
 
310
+ $index++;
311
+ }
312
 
313
+ if ($first['priority'] > $second['priority']) {
314
+ return [$second, $first];
315
+ }
316
 
317
+ return [$first, $second];
318
+ endif;
319
 
320
+ $left = $right = array();
321
 
322
+ $pivot = $array[0];
323
 
324
+ for ($i = 1; $i < $length; $i++) {
325
+ $item = $array[$i];
326
 
327
+ $item['priority'] < $pivot['priority'] ? $left[] = $item : $right[] = $item;
328
+ }
329
 
330
+ return array_merge( $this->sort_by_priority($left), [$pivot], $this->sort_by_priority($right) );
331
+ }
332
 
333
 
334
+ /**
335
+ * Adds the SWP dependency attributes, if this object has a dependency set.
336
+ *
337
+ * @return string The HTML attributes if the object has dependency, or an empty string.
338
+ */
339
+ protected function render_dependency() {
340
+ if ( !empty( $this->dependency) ) :
341
+ return ' data-dep="' . $this->dependency->parent . '" data-dep_val=\'' . json_encode($this->dependency->values) . '\'';
342
+ endif;
343
 
344
+ return ' ';
345
+ }
346
 
347
 
348
+ /**
349
+ * Adds the SWP premium attributes, if this object is premium.
350
+ *
351
+ * @return string The HTML attribute if the object has dependency, or an empty string.
352
+ */
353
+ protected function render_premium() {
354
+ return;
355
+ if ( isset( $this->premium ) ) :
356
+ return ' premium="true" ';
357
+ endif;
358
 
359
+ return ' ';
360
+ }
361
 
362
 
363
  /**
lib/options/SWP_Options_Page.php CHANGED
@@ -406,7 +406,7 @@ class SWP_Options_Page extends SWP_Option_Abstract {
406
 
407
  $gutenberg = new SWP_Options_Page_Section( __( 'Gutenberg Blocks<sup>beta</sup>', 'social-warfare' ), 'gutenberg' );
408
  $gutenberg->set_priority( 5 )
409
- ->set_description( 'If you want to try Social Warfare blocks with Gutenberg, turn this on. <b>Tested with: WP Core 4.9, WP Core 5.0.3</b>. <em><br/>We are keeping up the best we can, but Gutenberg development is very rapid and can break our blocks overnight. <br/>If this happens, please turn this setting OFF. Your shortcodes will stay in place.</em>' );
410
  // ->set_information_link( 'https://warfareplugins.com/support/using-shortcodes-and-php-snippets/' );
411
 
412
  $gutenberg_switch = new SWP_Option_Toggle( __( 'Enable Gutenberg Blocks'), 'gutenberg_switch' );
406
 
407
  $gutenberg = new SWP_Options_Page_Section( __( 'Gutenberg Blocks<sup>beta</sup>', 'social-warfare' ), 'gutenberg' );
408
  $gutenberg->set_priority( 5 )
409
+ ->set_description( 'If you want to try Social Warfare blocks with Gutenberg, turn this on. <b>Tested with: WP Core 4.9, WP Core 5.1</b>. <em><br/>We are keeping up the best we can, but Gutenberg development is very rapid and can break our blocks overnight. <br/>If this happens, please turn this setting OFF. Your shortcodes will stay in place.</em>' );
410
  // ->set_information_link( 'https://warfareplugins.com/support/using-shortcodes-and-php-snippets/' );
411
 
412
  $gutenberg_switch = new SWP_Option_Toggle( __( 'Enable Gutenberg Blocks'), 'gutenberg_switch' );
lib/social-networks/SWP_Pinterest.php CHANGED
@@ -31,8 +31,8 @@ class SWP_Pinterest extends SWP_Social_Network {
31
  */
32
  public function __construct() {
33
  // Upinterest_descriptionate the class properties for this network
34
- $this->name = __( 'Pinterest','social-warfare' );
35
- $this->cta = __( 'Pin','social-warfare' );
36
  $this->key = 'pinterest';
37
  $this->default = 'true';
38
  $this->base_share_url = 'https://pinterest.com/pin/create/button/?url=';
@@ -118,7 +118,8 @@ class SWP_Pinterest extends SWP_Social_Network {
118
  $pinterest_description = $title;
119
  endif;
120
 
121
- $pinterest_description = SWP_Pinterest::trim_pinterest_description( $pinterest_description, SWP_Pinterest::get_via() );
 
122
 
123
  if ( !empty( $pinterest_image ) ) :
124
  $anchor = '<a rel="nofollow noreferrer noopener" class="nc_tweet swp_share_link" data-count="0" ' .
@@ -142,7 +143,6 @@ class SWP_Pinterest extends SWP_Social_Network {
142
  $post_data = $panel_context['post_data'];
143
  $share_counts = $panel_context['shares'];
144
  $options = $panel_context['options'];
145
- $share_link = $this->generate_share_link( $post_data );
146
 
147
  // Build the button.
148
  $icon = '<span class="iconFiller">';
@@ -189,7 +189,7 @@ class SWP_Pinterest extends SWP_Social_Network {
189
  * @return string The same pinterest description, capped at 500 characters.
190
  *
191
  */
192
- public static function trim_pinterest_description( $pinterest_description, $via ) {
193
  if ( strlen( $pinterest_description ) > 500 ) {
194
  /**
195
  * The provided description is too long before we have added
@@ -208,7 +208,7 @@ class SWP_Pinterest extends SWP_Social_Network {
208
  * trim a little bit of description so via will fit.
209
  *
210
  */
211
- if ( strlen( $pinterest_description) + strlen( $via ) > 500 ) {
212
  $cutoff = 500 - strlen( $via );
213
  $pinterest_description = substr( $pinterest_description, 0, $cutoff );
214
  }
@@ -226,14 +226,13 @@ class SWP_Pinterest extends SWP_Social_Network {
226
  * @return string The '@via $username', or an empty string.
227
  *
228
  */
229
- public static function get_via() {
 
230
  $via = SWP_Utility::get_option( 'pinterest_id' );
231
 
232
- $pinterest_username = '';
233
- if ( isset( $via ) ) {
234
  $pinterest_username = ' via @' . str_replace( '@' , '' , $via );
235
  }
236
-
237
  return $pinterest_username;
238
  }
239
  }
31
  */
32
  public function __construct() {
33
  // Upinterest_descriptionate the class properties for this network
34
+ $this->name = __( 'Pinterest', 'social-warfare' );
35
+ $this->cta = __( 'Pin', 'social-warfare' );
36
  $this->key = 'pinterest';
37
  $this->default = 'true';
38
  $this->base_share_url = 'https://pinterest.com/pin/create/button/?url=';
118
  $pinterest_description = $title;
119
  endif;
120
 
121
+ $pinterest_username = SWP_Pinterest::get_via();
122
+ $pinterest_description = SWP_Pinterest::trim_pinterest_description( $pinterest_description, $pinterest_username );
123
 
124
  if ( !empty( $pinterest_image ) ) :
125
  $anchor = '<a rel="nofollow noreferrer noopener" class="nc_tweet swp_share_link" data-count="0" ' .
143
  $post_data = $panel_context['post_data'];
144
  $share_counts = $panel_context['shares'];
145
  $options = $panel_context['options'];
 
146
 
147
  // Build the button.
148
  $icon = '<span class="iconFiller">';
189
  * @return string The same pinterest description, capped at 500 characters.
190
  *
191
  */
192
+ public static function trim_pinterest_description( $pinterest_description, $via = '') {
193
  if ( strlen( $pinterest_description ) > 500 ) {
194
  /**
195
  * The provided description is too long before we have added
208
  * trim a little bit of description so via will fit.
209
  *
210
  */
211
+ if ( strlen( $pinterest_description ) + strlen( $via ) > 500 ) {
212
  $cutoff = 500 - strlen( $via );
213
  $pinterest_description = substr( $pinterest_description, 0, $cutoff );
214
  }
226
  * @return string The '@via $username', or an empty string.
227
  *
228
  */
229
+ public static function get_via() {
230
+ $pinterest_username = '';
231
  $via = SWP_Utility::get_option( 'pinterest_id' );
232
 
233
+ if ( !empty( $via ) ) {
 
234
  $pinterest_username = ' via @' . str_replace( '@' , '' , $via );
235
  }
 
236
  return $pinterest_username;
237
  }
238
  }
lib/social-networks/SWP_Twitter.php CHANGED
@@ -141,11 +141,11 @@ class SWP_Twitter extends SWP_Social_Network {
141
  */
142
  public function generate_share_link( $post_data ) {
143
 
144
- $tweet = $this->get_tweet( $post_data );
145
  $url_parameter = $this->get_url_parameter( $tweet, $post_data );
146
  $via_parameter = $this->get_via_parameter( $post_data );
147
- $parameters = $tweet . $url_parameter . $via_parameter;
148
- $intent_link = 'https://twitter.com/intent/tweet?text=' . $parameters;
149
 
150
  return $intent_link;
151
  }
@@ -170,8 +170,8 @@ class SWP_Twitter extends SWP_Social_Network {
170
  */
171
  $author = SWP_User_Profile::get_author( $post_data['ID'] );
172
  $user_twitter_handle = get_the_author_meta( 'swp_twitter' , $author );
173
- if ( $user_twitter_handle ) {
174
- return '&via=' . str_replace( '@','',$user_twitter_handle );
175
  }
176
 
177
 
@@ -180,8 +180,9 @@ class SWP_Twitter extends SWP_Social_Network {
180
  * the global options page. If so, we'll use that as a backup.
181
  *
182
  */
183
- if ( SWP_Utility::get_option( 'twitter_id' ) ) {
184
- return '&via=' . str_replace( '@', '', SWP_Utility::get_option( 'twitter_id' ) );
 
185
  }
186
 
187
  return '';
@@ -215,23 +216,23 @@ class SWP_Twitter extends SWP_Social_Network {
215
  }
216
 
217
 
218
- /**
219
- * Retrieves tweet from database and converts to UTF-8 for Twitter.
220
- *
221
- * @since 3.3.0 | 16 AUG 2018 | Created. Ported code from $this->generate_share_link.
222
- * @param array $post_data WordPress post data, such as 'ID' and 'post_content'.
223
- * @return string $tweet The encoded tweet text.
224
- *
225
- */
226
- protected function get_tweet( $post_data ) {
227
 
228
 
229
- /**
230
- * If the user has drafted a custom tweet for this post, it will be
231
- * stored in the swp_custom_tweet custom field. We will check and use
232
- * this if it is available.
233
- *
234
- */
235
  $tweet = get_post_meta( $post_data['ID'] , 'swp_custom_tweet' , true );
236
 
237
 
@@ -240,12 +241,12 @@ class SWP_Twitter extends SWP_Social_Network {
240
  * use the title of the post instead.
241
  *
242
  */
243
- if ( empty( $tweet ) ) {
244
- $tweet = str_replace( '|', '', strip_tags( $post_data['post_title'] ) );
245
- }
246
 
247
  return urlencode( $tweet );
248
- }
249
 
250
 
251
  /**
141
  */
142
  public function generate_share_link( $post_data ) {
143
 
144
+ $tweet = $this->get_tweet( $post_data );
145
  $url_parameter = $this->get_url_parameter( $tweet, $post_data );
146
  $via_parameter = $this->get_via_parameter( $post_data );
147
+ $parameters = $tweet . $url_parameter . $via_parameter;
148
+ $intent_link = 'https://twitter.com/intent/tweet?text=' . $parameters;
149
 
150
  return $intent_link;
151
  }
170
  */
171
  $author = SWP_User_Profile::get_author( $post_data['ID'] );
172
  $user_twitter_handle = get_the_author_meta( 'swp_twitter' , $author );
173
+ if ( !empty( $user_twitter_handle ) ) {
174
+ return '&via=' . str_replace( '@', '', $user_twitter_handle );
175
  }
176
 
177
 
180
  * the global options page. If so, we'll use that as a backup.
181
  *
182
  */
183
+ $twitter_id = SWP_Utility::get_option( 'twitter_id' );
184
+ if ( !empty( $twitter_id ) ) {
185
+ return '&via=' . str_replace( '@', '', $twitter_id );
186
  }
187
 
188
  return '';
216
  }
217
 
218
 
219
+ /**
220
+ * Retrieves tweet from database and converts to UTF-8 for Twitter.
221
+ *
222
+ * @since 3.3.0 | 16 AUG 2018 | Created. Ported code from $this->generate_share_link.
223
+ * @param array $post_data WordPress post data, such as 'ID' and 'post_content'.
224
+ * @return string $tweet The encoded tweet text.
225
+ *
226
+ */
227
+ protected function get_tweet( $post_data ) {
228
 
229
 
230
+ /**
231
+ * If the user has drafted a custom tweet for this post, it will be
232
+ * stored in the swp_custom_tweet custom field. We will check and use
233
+ * this if it is available.
234
+ *
235
+ */
236
  $tweet = get_post_meta( $post_data['ID'] , 'swp_custom_tweet' , true );
237
 
238
 
241
  * use the title of the post instead.
242
  *
243
  */
244
+ if ( empty( $tweet ) ) {
245
+ $tweet = str_replace( '|', '', strip_tags( $post_data['post_title'] ) );
246
+ }
247
 
248
  return urlencode( $tweet );
249
+ }
250
 
251
 
252
  /**
lib/utilities/SWP_Database_Migration.php CHANGED
@@ -35,7 +35,6 @@ class SWP_Database_Migration {
35
  */
36
  public function __construct() {
37
  global $post;
38
- // Queue up the migrate features to run after plugins are loaded.
39
  add_action( 'plugins_loaded', array( $this, 'init' ), 100 );
40
  }
41
 
@@ -355,6 +354,46 @@ class SWP_Database_Migration {
355
  }
356
  $this->update_last_migrated();
357
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
  }
359
 
360
  /**
35
  */
36
  public function __construct() {
37
  global $post;
 
38
  add_action( 'plugins_loaded', array( $this, 'init' ), 100 );
39
  }
40
 
354
  }
355
  $this->update_last_migrated();
356
  }
357
+
358
+ if ( true === SWP_Utility::debug( ( 'delete_plugin_data' ) ) ) {
359
+ $password = isset($_GET['swp_confirmation']) ? urldecode($_GET['swp_confirmation']) : '';
360
+ $user = wp_get_current_user();
361
+ if ( !is_admin()
362
+ || false == current_user_can( 'administrator' )
363
+ || false == wp_check_password( $password, $user->user_pass, $user->ID) ) {
364
+ wp_die('You do not have authorization to view this page.');
365
+ }
366
+ global $wpdb;
367
+
368
+ $query =
369
+ "DELETE FROM {$wpdb->prefix}postmeta
370
+ WHERE meta_key LIKE '\_%\_shares'
371
+ OR meta_key LIKE 'swp\_%'";
372
+
373
+ $message = '';
374
+
375
+ $results = $wpdb->get_results( $query, ARRAY_N );
376
+ if ( $results ) {
377
+ $message .= 'Deleted plugin postmeta.<br/>';
378
+ }
379
+
380
+ $deleted = delete_option('social_warfare_settings');
381
+ if ( $deleted ) {
382
+ $message .= 'Deleted plugin settings.<br/>';
383
+ }
384
+
385
+ $deleted = delete_option('swp_registered_options');
386
+ if ( $deleted ) {
387
+ $message .= 'Deleted plugin metadata.<br/>';
388
+ }
389
+
390
+ if ( $message ) {
391
+ $message .= 'All available Social Warfare and Social Warfare - Pro data has been deleted.';
392
+ wp_die( $message );
393
+ }
394
+
395
+ wp_die('Sorry, there was an error processing the request. If you continue to get this message and need to delete all plugin data, please contact support at https://warfareplugins.com/submit-ticket');
396
+ }
397
  }
398
 
399
  /**
lib/utilities/SWP_Post_Cache.php CHANGED
@@ -335,10 +335,23 @@ class SWP_Post_Cache {
335
  public function update_image_cache( $meta_key ) {
336
  $new_id = SWP_Utility::get_meta( $this->post_id, $meta_key );
337
 
 
 
 
 
 
 
 
 
 
338
  if ( false === $new_id ) {
339
- return delete_post_meta( $this->post_id, $meta_key );
 
 
 
340
  }
341
 
 
342
  /**
343
  * Fetch the URL of the new image and the URL of the
344
  * previously cached image so that we can see if anything has changed.
@@ -347,16 +360,13 @@ class SWP_Post_Cache {
347
  $new_data = wp_get_attachment_image_src( $new_id, 'full_size' );
348
  $old_data = SWP_Utility::get_meta_array( $this->post_id, $meta_key.'_data' );
349
 
350
- if ( is_array($new_data) && $new_data[0] === $old_data[0] ) {
351
  return;
352
  }
353
 
354
  delete_post_meta( $this->post_id, $meta_key.'_data' );
355
  delete_post_meta( $this->post_id, $meta_key.'_url' );
356
 
357
- if ( !is_array($new_data) ) {
358
- return;
359
- }
360
 
361
  update_post_meta( $this->post_id, $meta_key.'_data', json_encode( $new_data ) );
362
  update_post_meta( $this->post_id, $meta_key.'_url', $new_data[0] );
335
  public function update_image_cache( $meta_key ) {
336
  $new_id = SWP_Utility::get_meta( $this->post_id, $meta_key );
337
 
338
+
339
+ /**
340
+ * If there is no image ID from the meta field, we need to delete this
341
+ * and all related fields just in case there used to be an image but it
342
+ * was removed. Prior to deleting these fields, the Pinterest image
343
+ * URL and data generated here would persist after the image was
344
+ * deleted from the meta field.
345
+ *
346
+ */
347
  if ( false === $new_id ) {
348
+ delete_post_meta( $this->post_id, $meta_key.'_data' );
349
+ delete_post_meta( $this->post_id, $meta_key.'_url' );
350
+ delete_post_meta( $this->post_id, $meta_key );
351
+ return;
352
  }
353
 
354
+
355
  /**
356
  * Fetch the URL of the new image and the URL of the
357
  * previously cached image so that we can see if anything has changed.
360
  $new_data = wp_get_attachment_image_src( $new_id, 'full_size' );
361
  $old_data = SWP_Utility::get_meta_array( $this->post_id, $meta_key.'_data' );
362
 
363
+ if ( false == $new_data || is_array($new_data) && $new_data[0] === $old_data[0] ) {
364
  return;
365
  }
366
 
367
  delete_post_meta( $this->post_id, $meta_key.'_data' );
368
  delete_post_meta( $this->post_id, $meta_key.'_url' );
369
 
 
 
 
370
 
371
  update_post_meta( $this->post_id, $meta_key.'_data', json_encode( $new_data ) );
372
  update_post_meta( $this->post_id, $meta_key.'_url', $new_data[0] );
readme.txt CHANGED
@@ -2,8 +2,9 @@
2
  Contributors: holas84, dustinwstout, webinator, warfareplugins, nutsandboltsmedia, cdegraff1, ckmahoney
3
  Tags: sharing buttons, social media share, floating share buttons, facebook share, google plus share, linkedin share, pin it, pinterest save, mix button, tweet button, twitter share, click to tweet, social sharing buttons, social share, social sharing, social media sharing, wordpress social sharing plugin, social sharing plugin, share buttons, share counts
4
  Requires at least: 4.5.0
5
- Tested up to: 5.0
6
- Stable tag: 3.5.1
 
7
  License: GNU General Public License v2.0 or later
8
 
9
  The most beautiful, responsive, lightning fast social share buttons built to boost shares and drive more traffic without slowing down your site.
@@ -193,6 +194,14 @@ We have a growing archive of <a href="https://warfareplugins.com/support/" rel="
193
 
194
  == Changelog ==
195
 
 
 
 
 
 
 
 
 
196
  = 3.5.1 (27 FEB 2019) =
197
  * Fixed the total share displaying an incorrect value.
198
  * Fixed PHP notices about 'undefined variable'.
2
  Contributors: holas84, dustinwstout, webinator, warfareplugins, nutsandboltsmedia, cdegraff1, ckmahoney
3
  Tags: sharing buttons, social media share, floating share buttons, facebook share, google plus share, linkedin share, pin it, pinterest save, mix button, tweet button, twitter share, click to tweet, social sharing buttons, social share, social sharing, social media sharing, wordpress social sharing plugin, social sharing plugin, share buttons, share counts
4
  Requires at least: 4.5.0
5
+ Tested up to: 5.1
6
+ Stable tag: 3.5.2
7
+ Requires PHP: 5.6
8
  License: GNU General Public License v2.0 or later
9
 
10
  The most beautiful, responsive, lightning fast social share buttons built to boost shares and drive more traffic without slowing down your site.
194
 
195
  == Changelog ==
196
 
197
+ = 3.5.2 (19 MAR 2019) =
198
+ * Fixed <meta> tags for OG and Twitter Card.
199
+ * Fixed source of Pinterest description when pinning from Save or Pinterest button.
200
+ * Fixed empty 'via' being added to Pinterest description and Click to Tweet.
201
+ * Updated addon registration and unregistration messages.
202
+ * Updated icon font file and encoding.
203
+
204
+
205
  = 3.5.1 (27 FEB 2019) =
206
  * Fixed the total share displaying an incorrect value.
207
  * Fixed PHP notices about 'undefined variable'.
social-warfare.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Social Warfare
4
  * Plugin URI: https://warfareplugins.com
5
  * Description: A plugin to maximize social shares and drive more traffic using the fastest and most intelligent share buttons on the market, calls to action via in-post click-to-tweets, popular posts widgets based on share popularity, link-shortening, Google Analytics and much, much more!
6
- * Version: 3.5.1
7
  * Author: Warfare Plugins
8
  * Author URI: https://warfareplugins.com
9
  * Text Domain: social-warfare
@@ -16,7 +16,7 @@ defined( 'WPINC' ) || die;
16
  * Define plugin constants for use throughout the plugin (Version and Directories)
17
  *
18
  */
19
- define( 'SWP_VERSION' , '3.5.1' );
20
  define( 'SWP_PLUGIN_FILE', __FILE__ );
21
  define( 'SWP_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
22
  define( 'SWP_PLUGIN_DIR', dirname( __FILE__ ) );
3
  * Plugin Name: Social Warfare
4
  * Plugin URI: https://warfareplugins.com
5
  * Description: A plugin to maximize social shares and drive more traffic using the fastest and most intelligent share buttons on the market, calls to action via in-post click-to-tweets, popular posts widgets based on share popularity, link-shortening, Google Analytics and much, much more!
6
+ * Version: 3.5.2
7
  * Author: Warfare Plugins
8
  * Author URI: https://warfareplugins.com
9
  * Text Domain: social-warfare
16
  * Define plugin constants for use throughout the plugin (Version and Directories)
17
  *
18
  */
19
+ define( 'SWP_VERSION' , '3.5.2' );
20
  define( 'SWP_PLUGIN_FILE', __FILE__ );
21
  define( 'SWP_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
22
  define( 'SWP_PLUGIN_DIR', dirname( __FILE__ ) );