Version Description
(08 JUN 2018) = * Fix for slow page loads on some sites. * Added notice to warn that StumbleUpon is being removed at the end of the month. * Fix for buttons not showing on mobile in some cases. * Removed calls to Google Plus' and LinkedIn's API's since they no longer offer share counts. * Fix for the Pinterest fallback image functionality. * Fix for admin settings page not saving in some instances. * Fix for the post_id parameter not working in the shortcodes. * Fix for the Buffer share button showing plusses instead of spaces. * Fix for Bitly Authentication occasionally not working. * Fix for some undefined index errors.
Download this release
Release Info
Developer | WarfarePlugins |
Plugin | WordPress Social Sharing Plugin – Social Warfare |
Version | 3.0.9 |
Comparing to | |
See all releases |
Code changes from version 3.0.8 to 3.0.9
- css/admin-options-page.css +31 -1
- css/admin-options-page.min.css +1 -1
- css/admin.css +48 -0
- css/admin.min.css +1 -1
- functions/Social_Warfare.php +10 -1
- functions/frontend-output/SWP_Buttons_Panel.php +48 -17
- functions/frontend-output/SWP_Display.php +23 -18
- functions/frontend-output/SWP_Script.php +1 -1
- functions/options/SWP_Option.php +4 -3
- functions/options/SWP_Options_Page.php +5 -0
- functions/options/SWP_Section_HTML.php +1 -1
- functions/social-networks/SWP_Google_Plus.php +1 -30
- functions/social-networks/SWP_Linkedin.php +25 -52
- functions/social-networks/SWP_Pinterest.php +33 -30
- functions/social-networks/SWP_Stumble_Upon.php +12 -1
- functions/utilities/SWP_CURL.php +29 -12
- functions/utilities/SWP_Database_Migration.php +33 -23
- functions/utilities/SWP_Notice.php +384 -0
- functions/utilities/SWP_Notice_Loader.php +32 -0
- functions/utilities/SWP_URL_Management.php +4 -4
- functions/utilities/share-cache.php +96 -50
- functions/utilities/share-count-function.php +29 -35
- functions/utilities/utility.php +22 -15
- js/admin-options-page.js +45 -9
- js/admin-options-page.min.js +1 -1
- js/admin.js +25 -0
- js/admin.min.js +1 -1
- js/script.js +25 -20
- readme.txt +14 -1
- social-warfare.php +2 -2
css/admin-options-page.css
CHANGED
@@ -833,10 +833,40 @@ p.sw-subtitle.sw-registration-text {
|
|
833 |
float: right;
|
834 |
}
|
835 |
|
836 |
-
.toplevel_page_social-warfare .notice-error,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
837 |
display: none;
|
838 |
}
|
839 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
840 |
.sw-grid-textarea {
|
841 |
border: rgb(221, 221, 221);
|
842 |
box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
|
833 |
float: right;
|
834 |
}
|
835 |
|
836 |
+
.toplevel_page_social-warfare .notice-error,
|
837 |
+
.toplevel_page_social-warfare .notice-warning,
|
838 |
+
.toplevel_page_social-warfare .notice-success,
|
839 |
+
.toplevel_page_social-warfare .notice-info,
|
840 |
+
.toplevel_page_social-warfare .is-dismissible,
|
841 |
+
.toplevel_page_social-warfare .update-nag,
|
842 |
+
.toplevel_page_social-warfare #notice-error,
|
843 |
+
.toplevel_page_social-warfare #notice-warning,
|
844 |
+
.toplevel_page_social-warfare #notice-success,
|
845 |
+
.toplevel_page_social-warfare #notice-info,
|
846 |
+
.toplevel_page_social-warfare #is-dismissible,
|
847 |
+
.toplevel_page_social-warfare #update-nag,
|
848 |
+
div.error {
|
849 |
display: none;
|
850 |
}
|
851 |
|
852 |
+
.toplevel_page_social-warfare .sw-admin-wrapper .notice-error,
|
853 |
+
.toplevel_page_social-warfare .sw-admin-wrapper .notice-warning,
|
854 |
+
.toplevel_page_social-warfare .sw-admin-wrapper .notice-success,
|
855 |
+
.toplevel_page_social-warfare .sw-admin-wrapper .notice-info,
|
856 |
+
.toplevel_page_social-warfare .sw-admin-wrapper .is-dismissible,
|
857 |
+
.toplevel_page_social-warfare .sw-admin-wrapper .update-nag,
|
858 |
+
.toplevel_page_social-warfare .sw-admin-wrapper #notice-error,
|
859 |
+
.toplevel_page_social-warfare .sw-admin-wrapper #notice-warning,
|
860 |
+
.toplevel_page_social-warfare .sw-admin-wrapper #notice-success,
|
861 |
+
.toplevel_page_social-warfare .sw-admin-wrapper #notice-info,
|
862 |
+
.toplevel_page_social-warfare .sw-admin-wrapper #is-dismissible,
|
863 |
+
.toplevel_page_social-warfare .sw-admin-wrapper #update-nag,
|
864 |
+
div.error {
|
865 |
+
display: block;
|
866 |
+
}
|
867 |
+
|
868 |
+
|
869 |
+
|
870 |
.sw-grid-textarea {
|
871 |
border: rgb(221, 221, 221);
|
872 |
box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
|
css/admin-options-page.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.sw-grid,.sw-grid-right{margin-bottom:2.127659574468%;padding-top:0}.sw-red-notice a,.swp_support_link{font-weight:700;text-decoration:none}.sw-grid{float:left}.sw-grid-right{float:right}.sw-col-140,.sw-col-220,.sw-col-300,.sw-col-380,.sw-col-460,.sw-col-540,.sw-col-60,.sw-col-620,.sw-col-700,.sw-col-780,.sw-col-860{margin-right:2.127659574468%}.sw-col-60{width:6.382978723404%}.sw-col-140{width:14.893617021277%}.sw-col-220{width:23.404255319149%}.sw-col-300{width:31.914893617021%}.sw-col-380{width:40.425531914894%}.sw-col-460{width:48.936170212766%}.sw-col-540{width:57.446808510638%}.sw-col-620{width:65.957446808511%}.sw-col-700{width:74.468085106383%}.sw-col-780{width:82.978723404255%}.sw-col-860{width:91.489361702128%}.sw-col-940{width:100%}.sw-fit,.sw-option-container :last-child{margin-left:0!important;margin-right:0!important}.sw-clearfix:after,.sw-clearfix:before{content:' ';display:table}.sw-clearfix:after{clear:both}.sw-clearfix{clear:both;width:100%}img{-ms-interpolation-mode:bicubic;border:0;height:auto;max-width:100%;vertical-align:middle}.sw-admin-divider{width:100%;height:1px;border-bottom:1px solid #CED3DC;margin:20px 0 40px}.sw-header-menu li,.sw-top-menu[sw-registered="0"] .sw-header-logo,.sw-top-menu[sw-registered="1"] .sw-header-logo-pro{height:75px;float:left}.sw-hidden{display:none!important}.swp_support_link{border:1px solid #ccc;font-size:18px;line-height:20px;-webkit-border-radius:50%;border-radius:50%;width:20px;display:block;float:right;text-align:center;color:#ccc;margin-right:20px;margin-top:4px;padding:2px}.swp_support_link:hover{color:#6BCCE9;border-color:#6BCCE9}.swp_support_link.swp_four_fourths{margin-left:20px;margin-top:13px}#screen-meta-links .screen-meta-toggle{display:none!important}#wpcontent,#wpwrap{background:#fff;padding-left:0}.sw-top-menu{border-bottom:1px solid #CED3DC;float:none;background:#fff;z-index:5;margin:0}.sw-top-menu[sw-registered="0"] .sw-header-logo-pro,.sw-top-menu[sw-registered="1"] .sw-header-logo{display:none}.sw-header-menu{height:75px;margin:0}.sw-header-menu li{margin:0 15px;font-size:16px;display:table}.sw-header-menu li a:focus,.sw-header-menu li:focus{outline:0;-webkit-box-shadow:none;box-shadow:none}.sw-header-menu li span{padding:0 5px 5px}.sw-header-menu li.sw-active-tab span,.sw-header-menu li:hover span{border-bottom:4px solid #30394f}.sw-header-menu li a{color:#30394f;text-decoration:none;display:table-cell;vertical-align:middle}.sw-top-menu .sw-grid{margin-bottom:0}.sw-admin-wrapper,.sw-header-wrapper{clear:both;margin:20px auto;padding:0 40px 20px;position:relative}.sw-header-wrapper{margin:0}.sw-tabs-container .sw-admin-tab{display:none}.sw-tabs-container .sw-admin-tab:nth-child(1){display:block}.sw-admin-wrapper[sw-registered="0"] .sw-option-container[premium="1"] .sw-checkbox-toggle[status=on] .sw-checkbox-on,.sw-checkbox-toggle[status=on] .sw-checkbox-off,.sw-checkbox-toggle[status=off] .sw-checkbox-on,.system-status-wrapper{display:none}.sw-admin-tab h2{font-size:26px;line-height:1.2;margin:0}.sw-admin-tab h2.sw-h-label{line-height:56px}p.sw-subtitle{font-size:16px;line-height:1.2;margin:10px 0 30px}p.sw-authenticate-label,p.sw-checkbox-label,p.sw-input-label,p.sw-select-label{font-size:16px;font-weight:700;padding-left:10%}.sw-select-label.sw-no-padding{padding-left:0}p.sw-short{margin:1em 0 0}p.sw-subtext-label{margin-top:-10px}.sw-admin-sidebar img{margin:5px 0 10px}.system-status-container{width:90%;height:250px;overflow:hidden;border:1px solid #CED3DC;padding:5%}h3.sw-buttons-toggle{width:100px;float:left;clear:left;margin:15px 0 30px;padding-left:10%}.sw-checkbox-toggle{width:150px;height:46px;background-color:#30394f;float:right;margin:5px 0;cursor:pointer;-webkit-border-radius:4px;border-radius:4px;overflow:hidden;position:relative}.sw-checkbox-off,.sw-checkbox-on{color:#fff;font-size:15px;text-align:center;line-height:46px;position:absolute;top:0;width:50%;height:100%}.sw-checkbox-toggle[status=on] .sw-checkbox-on{left:0;background-color:#71C069}.sw-admin-wrapper[sw-registered="0"] .sw-option-container[premium="1"] .sw-checkbox-toggle[status=on] .sw-checkbox-off{right:0;background-color:#ee464f;display:block}.sw-checkbox-toggle[status=off] .sw-checkbox-off{right:0;background-color:#ee464f}input.sw-admin-input{padding:15px;border:1px solid #ced3cd;-webkit-border-radius:4px;border-radius:4px;float:right;-webkit-box-shadow:none;box-shadow:none;margin:2px 0 1px;width:100%}.sw-grid select{width:100%;-webkit-box-shadow:none;box-shadow:none;border:1px solid #ced3cd;height:51px;padding:15px;margin:2px 1px 3px 0;-webkit-border-radius:4px;border-radius:4px}a.button.sw-blue-button,a.button.sw-green-button,a.button.sw-navy-button,a.button.sw-red-button{padding:15px 30px;height:auto;line-height:1;-webkit-border-radius:4px;border-radius:4px;float:right;margin:15px 0}a.button.sw-navy-button,a.button.sw-navy-button:focus{background:#30394f;color:#fff;border-color:#2a2d34;-webkit-box-shadow:none;box-shadow:none}a.button.sw-blue-button:hover,a.button.sw-navy-button:hover{background:#2a2d34;border-color:#2a2d34;color:#fff;-webkit-box-shadow:none;box-shadow:none}a.button.sw-blue-button,a.button.sw-blue-button:focus{background:#6bcce9;border-color:#6bcce9;color:#fff;-webkit-box-shadow:none;box-shadow:none}a.button.sw-green-button,a.button.sw-green-button:focus{background:#71C069;color:#fff;border-color:#71C069;-webkit-box-shadow:none;box-shadow:none}a.button.sw-red-button,a.button.sw-red-button:focus,a.button.sw-red-button:hover{background:#ee464f;color:#fff;border-color:#ee464f;-webkit-box-shadow:none;box-shadow:none}.sw-admin-tab a.button{margin:5px 0 15px}.sw-save-settings{width:100%;text-align:center}.sw-green-notice,.sw-red-notice{color:#fff;padding:15px;-webkit-border-radius:2px;border-radius:2px;margin:15px 0}.sw-loading-message,.sw-red-notice{background:#ee464f}.sw-green-notice,.sw-loading-complete{background:#71C069}.sw-loading-bg{width:100%;position:fixed;top:0;left:0;height:100%;background:rgba(0,0,0,.8);z-index:999999999999}.sw-green-notice:before,.sw-loading-complete:before,.sw-loading-message:before{font-family:Dashicons;font-size:26px;margin:0 15px 0 0;vertical-align:middle}.sw-red-notice:before{font-family:sw-icon-font;font-size:26px;margin:0 15px 0 0;vertical-align:middle;content:'E'}.sw-red-notice a{color:#fff;border-bottom:2px solid #fff}.sw-red-notice a:hover{color:#30394f;border-bottom:2px solid #30394f}.sw-loading-message:before{content:"\f158"}.sw-green-notice:before,.sw-loading-complete:before{content:"\f147"}.sw-admin-tab .two-thirds-advanced h2.sw-h-label{line-height:1.2;margin-bottom:15px}.sw-italic{font-style:italic}.sw-admin-hover-notice i:before,.sw-s{font-family:sw-icon-font;font-style:normal}p.sw-subtitle.sw-registration-text{padding:20px 0 0;font-size:120%;line-height:175%}.registration-wrapper[registration="0"] .swp_is_registered,.registration-wrapper[registration="1"] .swp_is_not_registered,.tweet-count-wrapper[registration=true] .swp_tweets_not_activated{display:none}.sw-tweet-count-demo{margin:20px 0}.sw-loading-complete,.sw-loading-message{position:fixed;top:50%;left:50%;-webkit-border-radius:3px;border-radius:3px;padding:25px;text-align:center;font-size:20px;color:#fff;width:240px;margin-top:-46px;margin-left:-120px}.sw-grid textarea{width:100%;height:120px}.sw-active,.sw-inactive{margin:0 0 5px;min-width:50px;min-height:40px;border:1px dashed #ced3dc;padding:0;-webkit-border-radius:4px;border-radius:4px;width:auto;height:auto;display:inline-block;max-width:520px}.sw-s{color:#fff;padding:5px 30px 4px;margin:7px 5px;-webkit-border-radius:2px;border-radius:2px;display:inline-block;font-size:15px;line-height:15px;cursor:pointer}.sw-twitter-icon:before{content:'s'}.sw-s.sw-twitter-icon{background-color:#429cd6;border-color:#3c87b2}.sw-google_plus-icon:before{content:'h'}.sw-s.sw-google_plus-icon{background-color:#df4b37;border-color:#c44133}.sw-facebook-icon:before{content:'j'}.sw-s.sw-facebook-icon{background-color:#3a589e;border-color:#2e4675}.sw-pinterest-icon:before{content:'b'}.sw-s.sw-pinterest-icon{background-color:#cd2029;border-color:#aa1b29}.sw-linkedin-icon:before{content:'f'}.sw-s.sw-linkedin-icon{background-color:#0d77b7;border-color:#0c6591}.sw-tumblr-icon:before{content:'r'}.sw-s.sw-tumblr-icon{background-color:#39475d;border-color:#27313f}.sw-stumbleupon-icon:before{content:'q'}.sw-s.sw-stumbleupon-icon{background-color:#ef5025;border-color:#d34427}.sw-reddit-icon:before{content:'a'}.sw-s.sw-reddit-icon{background-color:#f04b23;border-color:#d33f27}.sw-yummly-icon:before{content:'x'}.sw-s.sw-yummly-icon{background-color:#e26426;border-color:#b65027}.sw-whatsapp-icon:before{content:'y'}.sw-s.sw-whatsapp-icon{background-color:#71c169;border-color:#28b04b}.sw-pocket-icon:before{content:'B'}.sw-s.sw-pocket-icon{background-color:#ef4056;border-color:#ce3d55}.sw-buffer-icon:before{content:'z'}.sw-s.sw-buffer-icon{background-color:#323b43;border-color:#59626a}.sw-email-icon:before{content:'k'}.sw-s.sw-email-icon{background-color:#6bcce9;border-color:#6bcce9}.sw-hacker_news-icon:before{content:'D'}.sw-s.sw-hacker_news-icon{background-color:#f16522;border-color:#d85623}.sw-flipboard-icon:before{content:'C'}.sw-s.sw-flipboard-icon{background-color:#e02828;border-color:#bf2626}@media screen and (max-width:1350px){.sw-header-menu li{font-size:12px;margin:0 10px}}@media screen and (max-width:1080px){.sw-header-logo{display:none}}.sw-admin-wrapper[sw-registered="0"] [premium="1"]{display:none!important}.sw-admin-wrapper[sw-registered="0"] [premium="1"] .sw-premium-blocker,.sw-admin-wrapper[sw-registered="0"] i[premium-button="1"],.sw-admin-wrapper[sw-registered="1"] .sw-premium-buttons,.sw-admin-wrapper[swp-addons*=pro] [premium],.sw-admin-wrapper[swp-addons*=affiliatewp] [premium],.sw-admin-wrapper[swp-addons*=enhanced_shortcodes] [premium],.sw-admin-wrapper[swp-addons*=advanced_display] [premium]{display:none}.sw-admin-wrapper[sw-registered="0"] .sw-option-container{position:relative}.sw-admin-wrapper[sw-registered="0"] [premium="1"] .sw-premium-blocker:not(.no-icon):before{font-family:sw-icon-font;content:'E';font-size:24px;float:right;margin:20px 20px 0 0}.sw-admin-wrapper[swp-addons*=pro][swp-registrations*=pro] [premium],.sw-admin-wrapper[swp-addons*=affiliatewp][swp-registrations*=affiliatewp] [premium],.sw-admin-wrapper[swp-addons*=enhanced_shortcodes][swp-registrations*=enhanced_shortcodes] [premium],.sw-admin-wrapper[swp-addons*=advanced_display][swp-registrations*=advanced_display] [premium]{display:inherit}.swp_upload_image_field,.toplevel_page_social-warfare #is-dismissible,.toplevel_page_social-warfare #notice-error,.toplevel_page_social-warfare #notice-info,.toplevel_page_social-warfare #notice-success,.toplevel_page_social-warfare #notice-warning,.toplevel_page_social-warfare #update-nag,.toplevel_page_social-warfare .is-dismissible,.toplevel_page_social-warfare .notice-error,.toplevel_page_social-warfare .notice-info,.toplevel_page_social-warfare .notice-success,.toplevel_page_social-warfare .notice-warning,.toplevel_page_social-warfare .update-nag,div.error{display:none}.ui-tooltip.sw-admin-hover-notice{background:#ee464f;color:#fff;-webkit-border-radius:2px;border-radius:2px;margin:15px 0;border:0;-webkit-box-shadow:none;box-shadow:none;max-width:none;padding:20px}.sw-admin-hover-notice i:before{font-size:26px;margin:0 15px 0 0;vertical-align:middle;content:'E';float:left}.sw-admin-image-preview{max-height:50px;float:right}.sw-grid-textarea{border:#ddd;box-shadow:inset 0 1px 2px rgba(0,0,0,.07);height:120px;width:97%}#color-notice{position:fixed;bottom:15px;margin:0 auto;left:25%;right:25%;background:rgba(255,225,255,.37);background-color:#ced3dc;color:#30394f;padding:20px;border-radius:4px;text-align:left;width:650px}#color-notice p{font-size:16px;padding:0;margin:0}#color-notice .color-dismiss{float:right;color:#fff;font-weight:600}#color-notice .color-dismiss:before{content:'x';background:#30394f;border-radius:50%;width:26px;display:block;text-align:center;height:26px;line-height:22px;font-size:22px;cursor:pointer;padding:0;opacity:.4}
|
1 |
+
.sw-grid{float:left;margin-bottom:2.127659574468%;padding-top:0}.sw-grid-right{float:right;margin-bottom:2.127659574468%;padding-top:0}.sw-col-60,.sw-col-140,.sw-col-220,.sw-col-300,.sw-col-380,.sw-col-460,.sw-col-540,.sw-col-620,.sw-col-700,.sw-col-780,.sw-col-860{margin-right:2.127659574468%}.sw-col-60{width:6.382978723404%}.sw-col-140{width:14.893617021277%}.sw-col-220{width:23.404255319149%}.sw-col-300{width:31.914893617021%}.sw-col-380{width:40.425531914894%}.sw-col-460{width:48.936170212766%}.sw-col-540{width:57.446808510638%}.sw-col-620{width:65.957446808511%}.sw-col-700{width:74.468085106383%}.sw-col-780{width:82.978723404255%}.sw-col-860{width:91.489361702128%}.sw-col-940{width:100%}.sw-fit{margin-left:0!important;margin-right:0!important}.sw-option-container *:last-child{margin-left:0!important;margin-right:0!important}.sw-clearfix:after,.sw-clearfix:before{content:' ';display:table}.sw-clearfix:after{clear:both}.sw-clearfix{clear:both;width:100%}img{-ms-interpolation-mode:bicubic;border:0;height:auto;max-width:100%;vertical-align:middle}.sw-admin-divider{width:100%;height:1px;border-bottom:1px solid #CED3DC;margin:20px 0 40px 0}.sw-hidden{display:none!important}.swp_support_link{border:1px solid #ccc;font-size:18px;line-height:20px;text-decoration:none;-webkit-border-radius:50%;border-radius:50%;width:20px;display:block;float:right;text-align:center;color:#ccc;margin-right:20px;margin-top:4px;padding:2px;font-weight:bold}.swp_support_link:hover{color:#6BCCE9;border-color:#6BCCE9}.swp_support_link.swp_four_fourths{margin-left:20px;margin-top:13px}#screen-meta-links .screen-meta-toggle{display:none!important}#wpwrap,#wpcontent{background:#fff;padding-left:0}.sw-top-menu{border-bottom:1px solid #CED3DC;float:none;background:#fff;z-index:5;margin:0}.sw-top-menu[sw-registered="0"] .sw-header-logo{height:75px;float:left}.sw-top-menu[sw-registered="1"] .sw-header-logo-pro{height:75px;float:left}.sw-top-menu[sw-registered="1"] .sw-header-logo{display:none}.sw-top-menu[sw-registered="0"] .sw-header-logo-pro{display:none}.sw-header-menu{height:75px;margin:0}.sw-header-menu li{float:left;margin:0 15px;font-size:16px;display:table;height:75px}.sw-header-menu li:focus,.sw-header-menu li a:focus{outline:none;-webkit-box-shadow:none;box-shadow:none}.sw-header-menu li span{padding:0 5px 5px 5px}.sw-header-menu li.sw-active-tab span,.sw-header-menu li:hover span{border-bottom:4px solid #30394f}.sw-header-menu li a{color:#30394f;text-decoration:none;display:table-cell;vertical-align:middle}.sw-top-menu .sw-grid{margin-bottom:0}.sw-admin-wrapper,.sw-header-wrapper{clear:both;margin:20px auto 20px auto;padding:0 40px 20px 40px;position:relative}.sw-header-wrapper{margin:0}.sw-tabs-container .sw-admin-tab{display:none}.sw-tabs-container .sw-admin-tab:nth-child(1){display:block}.sw-admin-tab h2{font-size:26px;line-height:1.2;margin:0}.sw-admin-tab h2.sw-h-label{line-height:56px}p.sw-subtitle{font-size:16px;line-height:1.2;margin:10px 0 30px 0}p.sw-checkbox-label,p.sw-input-label,p.sw-select-label,p.sw-authenticate-label{font-size:16px;font-weight:bold;padding-left:10%}.sw-select-label.sw-no-padding{padding-left:0}p.sw-short{margin:1em 0 0 0}p.sw-subtext-label{margin-top:-10px}.sw-admin-sidebar img{margin:5px 0 10px 0}.system-status-wrapper{display:none}.system-status-container{width:90%;height:250px;overflow:hidden;border:1px solid #CED3DC;padding:5%}h3.sw-buttons-toggle{width:100px;float:left;clear:left;margin:15px 0 30px 0;padding-left:10%}.sw-checkbox-toggle{width:150px;height:46px;background-color:#30394f;float:right;margin:5px 0;cursor:pointer;-webkit-border-radius:4px;border-radius:4px;overflow:hidden;position:relative}.sw-checkbox-on,.sw-checkbox-off{color:white;font-size:15px;text-align:center;line-height:46px;position:absolute;top:0;width:50%;height:100%}.sw-checkbox-toggle[status="on"] .sw-checkbox-on{left:0;background-color:#71C069}.sw-checkbox-toggle[status="on"] .sw-checkbox-off,.sw-checkbox-toggle[status="off"] .sw-checkbox-on{display:none}.sw-admin-wrapper[sw-registered="0"] .sw-option-container[premium="1"] .sw-checkbox-toggle[status="on"] .sw-checkbox-on{display:none}.sw-admin-wrapper[sw-registered="0"] .sw-option-container[premium="1"] .sw-checkbox-toggle[status="on"] .sw-checkbox-off{right:0;background-color:#ee464f;display:block}.sw-checkbox-toggle[status="off"] .sw-checkbox-off{right:0;background-color:#ee464f}input.sw-admin-input{padding:15px;border:1px solid #ced3cd;-webkit-border-radius:4px;border-radius:4px;float:right;-webkit-box-shadow:none;box-shadow:none;margin:2px 0 1px 0;width:100%}.sw-grid select{width:100%;-webkit-box-shadow:none;box-shadow:none;border:1px solid #ced3cd;height:51px;padding:15px;margin:2px 1px 3px 0;-webkit-border-radius:4px;border-radius:4px}a.button.sw-navy-button,a.button.sw-blue-button,a.button.sw-green-button,a.button.sw-red-button{padding:15px 30px;height:auto;line-height:1;-webkit-border-radius:4px;border-radius:4px;-webkit-box-shadow:none;box-shadow:none;float:right;margin:15px 0}a.button.sw-navy-button,a.button.sw-navy-button:focus{background:#30394f;color:#fff;border-color:#2a2d34;-webkit-box-shadow:none;box-shadow:none}a.button.sw-navy-button:hover,a.button.sw-blue-button:hover{background:#2a2d34;border-color:#2a2d34;color:#fff;-webkit-box-shadow:none;box-shadow:none}a.button.sw-blue-button,a.button.sw-blue-button:focus{background:#6bcce9;border-color:#6bcce9;color:#fff;-webkit-box-shadow:none;box-shadow:none}a.button.sw-green-button,a.button.sw-green-button:focus{background:#71C069;color:#fff;border-color:#71C069;-webkit-box-shadow:none;box-shadow:none}a.button.sw-red-button,a.button.sw-red-button:focus,a.button.sw-red-button:hover{background:#ee464f;color:#fff;border-color:#ee464f;-webkit-box-shadow:none;box-shadow:none}.sw-admin-tab a.button{margin:5px 0 15px 0}.sw-save-settings{width:100%;text-align:center}.sw-red-notice,.sw-green-notice{color:#fff;padding:15px;-webkit-border-radius:2px;border-radius:2px;margin:15px 0}.sw-red-notice,.sw-loading-message{background:#ee464f}.sw-green-notice,.sw-loading-complete{background:#71C069}.sw-loading-bg{width:100%;position:fixed;top:0;left:0;height:100%;background:rgba(0,0,0,0.8);z-index:999999999999}.sw-loading-message:before,.sw-green-notice:before,.sw-loading-complete:before{font-family:'Dashicons';font-size:26px;margin:0 15px 0 0;vertical-align:middle}.sw-red-notice:before,.sw-red-notice:before{font-family:'sw-icon-font';font-size:26px;margin:0 15px 0 0;vertical-align:middle;content:'E'}.sw-red-notice a{color:#fff;font-weight:bold;text-decoration:none;border-bottom:2px solid #fff}.sw-red-notice a:hover{color:#30394f;border-bottom:2px solid #30394f}.sw-loading-message:before{content:"\f158"}.sw-green-notice:before,.sw-loading-complete:before{content:"\f147"}.sw-admin-tab .two-thirds-advanced h2.sw-h-label{line-height:1.2;margin-bottom:15px}.sw-italic{font-style:italic}p.sw-subtitle.sw-registration-text{padding:20px 0 0 0;font-size:120%;line-height:175%}.registration-wrapper[registration="1"] .swp_is_not_registered{display:none}.registration-wrapper[registration="0"] .swp_is_registered{display:none}.tweet-count-wrapper[registration="true"] .swp_tweets_not_activated{display:none}.sw-tweet-count-demo{margin:20px 0}.sw-loading-message,.sw-loading-complete{position:fixed;top:50%;left:50%;-webkit-border-radius:3px;border-radius:3px;padding:25px;text-align:center;font-size:20px;color:white;width:240px;margin-top:-46px;margin-left:-120px}.sw-grid textarea{width:100%;height:120px}.sw-active,.sw-inactive{margin:0 0 5px 0;min-width:50px;min-height:40px;border:1px dashed #ced3dc;padding:0;-webkit-border-radius:4px;border-radius:4px;width:auto;height:auto;display:inline-block;max-width:520px}.sw-s{font-family:'sw-icon-font';color:#fff;padding:5px 30px 4px;margin:7px 5px 7px;-webkit-border-radius:2px;border-radius:2px;display:inline-block;font-style:normal;font-size:15px;line-height:15px;cursor:pointer}.sw-twitter-icon:before{content:'s'}.sw-s.sw-twitter-icon{background-color:#429cd6;border-color:#3c87b2}.sw-google_plus-icon:before{content:'h'}.sw-s.sw-google_plus-icon{background-color:#df4b37;border-color:#c44133}.sw-facebook-icon:before{content:'j'}.sw-s.sw-facebook-icon{background-color:#3a589e;border-color:#2e4675}.sw-pinterest-icon:before{content:'b'}.sw-s.sw-pinterest-icon{background-color:#cd2029;border-color:#aa1b29}.sw-linkedin-icon:before{content:'f'}.sw-s.sw-linkedin-icon{background-color:#0d77b7;border-color:#0c6591}.sw-tumblr-icon:before{content:'r'}.sw-s.sw-tumblr-icon{background-color:#39475d;border-color:#27313f}.sw-stumbleupon-icon:before{content:'q'}.sw-s.sw-stumbleupon-icon{background-color:#ef5025;border-color:#d34427}.sw-reddit-icon:before{content:'a'}.sw-s.sw-reddit-icon{background-color:#f04b23;border-color:#d33f27}.sw-yummly-icon:before{content:'x'}.sw-s.sw-yummly-icon{background-color:#e26426;border-color:#b65027}.sw-whatsapp-icon:before{content:'y'}.sw-s.sw-whatsapp-icon{background-color:#71c169;border-color:#28b04b}.sw-pocket-icon:before{content:'B'}.sw-s.sw-pocket-icon{background-color:#ef4056;border-color:#ce3d55}.sw-buffer-icon:before{content:'z'}.sw-s.sw-buffer-icon{background-color:#323b43;border-color:#59626a}.sw-email-icon:before{content:'k'}.sw-s.sw-email-icon{background-color:#6bcce9;border-color:#6bcce9}.sw-hacker_news-icon:before{content:'D'}.sw-s.sw-hacker_news-icon{background-color:#f16522;border-color:#d85623}.sw-flipboard-icon:before{content:'C'}.sw-s.sw-flipboard-icon{background-color:#e02828;border-color:#bf2626}@media screen and (max-width:1350px){.sw-header-menu li{font-size:12px;margin:0 10px}}@media screen and (max-width:1080px){.sw-header-logo{display:none}}.sw-admin-wrapper[sw-registered="0"] [premium="1"]{display:none!important}.sw-admin-wrapper[sw-registered="0"] .sw-option-container{position:relative}.sw-admin-wrapper[sw-registered="0"] [premium="1"] .sw-premium-blocker{display:none}.sw-admin-wrapper[sw-registered="0"] [premium="1"] .sw-premium-blocker:not(.no-icon):before{font-family:'sw-icon-font';content:'E';font-size:24px;float:right;margin:20px 20px 0 0}.sw-admin-wrapper[sw-registered="0"] i[premium-button="1"]{display:none}.sw-admin-wrapper[sw-registered="1"] .sw-premium-buttons{display:none}.sw-admin-wrapper[swp-addons*="pro"] [premium],.sw-admin-wrapper[swp-addons*="affiliatewp"] [premium],.sw-admin-wrapper[swp-addons*="enhanced_shortcodes"] [premium],.sw-admin-wrapper[swp-addons*="advanced_display"] [premium]{display:none}.sw-admin-wrapper[swp-addons*="pro"][swp-registrations*="pro"] [premium],.sw-admin-wrapper[swp-addons*="affiliatewp"][swp-registrations*="affiliatewp"] [premium],.sw-admin-wrapper[swp-addons*="enhanced_shortcodes"][swp-registrations*="enhanced_shortcodes"] [premium],.sw-admin-wrapper[swp-addons*="advanced_display"][swp-registrations*="advanced_display"] [premium]{display:inherit}.ui-tooltip.sw-admin-hover-notice{background:#ee464f;color:#fff;padding:15px;-webkit-border-radius:2px;border-radius:2px;margin:15px 0;border:0;-webkit-box-shadow:none;box-shadow:none;max-width:none;padding:20px}.sw-admin-hover-notice i:before{font-family:'sw-icon-font';font-size:26px;margin:0 15px 0 0;vertical-align:middle;content:'E';float:left;font-style:normal}.swp_upload_image_field{display:none}.sw-admin-image-preview{max-height:50px;float:right}.toplevel_page_social-warfare .notice-error,.toplevel_page_social-warfare .notice-warning,.toplevel_page_social-warfare .notice-success,.toplevel_page_social-warfare .notice-info,.toplevel_page_social-warfare .is-dismissible,.toplevel_page_social-warfare .update-nag,.toplevel_page_social-warfare #notice-error,.toplevel_page_social-warfare #notice-warning,.toplevel_page_social-warfare #notice-success,.toplevel_page_social-warfare #notice-info,.toplevel_page_social-warfare #is-dismissible,.toplevel_page_social-warfare #update-nag,div.error{display:none}.toplevel_page_social-warfare .sw-admin-wrapper .notice-error,.toplevel_page_social-warfare .sw-admin-wrapper .notice-warning,.toplevel_page_social-warfare .sw-admin-wrapper .notice-success,.toplevel_page_social-warfare .sw-admin-wrapper .notice-info,.toplevel_page_social-warfare .sw-admin-wrapper .is-dismissible,.toplevel_page_social-warfare .sw-admin-wrapper .update-nag,.toplevel_page_social-warfare .sw-admin-wrapper #notice-error,.toplevel_page_social-warfare .sw-admin-wrapper #notice-warning,.toplevel_page_social-warfare .sw-admin-wrapper #notice-success,.toplevel_page_social-warfare .sw-admin-wrapper #notice-info,.toplevel_page_social-warfare .sw-admin-wrapper #is-dismissible,.toplevel_page_social-warfare .sw-admin-wrapper #update-nag,div.error{display:block}.sw-grid-textarea{border:rgb(221,221,221);box-shadow:inset 0 1px 2px rgba(0,0,0,.07);height:120px;width:97%}#color-notice{position:fixed;bottom:15px;margin:0 auto;left:25%;right:25%;background:rgba( 255,225,255,.37 );background-color:#ced3dc;color:#30394f;padding:20px;border-radius:4px;text-align:left;width:650px}#color-notice p{font-size:16px;padding:0;margin:0}#color-notice .color-dismiss{float:right;color:#fff;font-weight:600}#color-notice .color-dismiss:before{content:'x';background:#30394f;border-radius:50%;width:26px;display:block;text-align:center;height:26px;line-height:22px;font-size:22px;cursor:pointer;padding:0;opacity:.4}
|
css/admin.css
CHANGED
@@ -212,3 +212,51 @@
|
|
212 |
border-top: 1px solid #CED3DC;
|
213 |
padding-top: 40px;
|
214 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
border-top: 1px solid #CED3DC;
|
213 |
padding-top: 40px;
|
214 |
}
|
215 |
+
|
216 |
+
.swp-notice-wrapper {
|
217 |
+
max-width: 73%;
|
218 |
+
margin-top: -15px;
|
219 |
+
margin-bottom: 15px;
|
220 |
+
}
|
221 |
+
|
222 |
+
.swp-notice {
|
223 |
+
padding: 10px 15px;
|
224 |
+
padding: 20px;
|
225 |
+
}
|
226 |
+
|
227 |
+
.swp-actions {
|
228 |
+
display: flex;
|
229 |
+
align-items: center;
|
230 |
+
}
|
231 |
+
|
232 |
+
.swp-notice a {
|
233 |
+
cursor: hover;
|
234 |
+
text-decoration: underline;
|
235 |
+
margin: 0 10px;
|
236 |
+
}
|
237 |
+
|
238 |
+
.swp-dismiss-notice.notice.notice-info {
|
239 |
+
font-size: 15px;
|
240 |
+
line-height: 25px;
|
241 |
+
}
|
242 |
+
|
243 |
+
.swp-dismiss-notice.notice.notice-info {
|
244 |
+
border-left-color: #D34250;
|
245 |
+
padding: 20px;
|
246 |
+
margin: 15px 0 15px;
|
247 |
+
}
|
248 |
+
|
249 |
+
.swp-dismiss-notice.notice.notice-info p {
|
250 |
+
font-size: 15px;
|
251 |
+
line-height: 25px;
|
252 |
+
padding: 0;
|
253 |
+
margin: 0 0 20px;
|
254 |
+
}
|
255 |
+
|
256 |
+
a.swp-notice-cta {
|
257 |
+
cursor: pointer;
|
258 |
+
text-decoration: underline;
|
259 |
+
font-size: 15px;
|
260 |
+
line-height: 30px;
|
261 |
+
margin-right: 50px;
|
262 |
+
}
|
css/admin.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.notAvailable{opacity
|
1 |
+
.notAvailable{opacity:0.3}.swp_CountDown{background-color:#CCC;display:inline-block;float:right;padding:5px 15px;-webkit-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;color:#FFF;font-weight:bold;margin-top:-27px}.swp_CountDown.swp_blue{background-color:#30394F}.swp_CountDown.swp_red{background-color:#EE464F}#social_warfare textarea.large-text{width:100%}#social_warfare ul.swpmb-media-list.ui-sortable{display:block;width:100%;-webkit-background-size:cover;background-size:cover;background-position-x:center;background-repeat:no-repeat;background-color:#ccc;-webkit-border-radius:4px;border-radius:4px;padding:0}#social_warfare .swp_og_imageWrapper ul.swpmb-media-list{background-image:url('../images/img-placeholder-og.jpg')}#social_warfare .swp_pinterest_imageWrapper ul.swpmb-media-list{background-image:url('../images/img-placeholder-pin.jpg')}.swpmb-field.swpmb-textarea-wrapper.swp_og_title,.swpmb-field.swpmb-textarea-wrapper.swp_og_description,.swpmb-field.swpmb-textarea-wrapper.swp_pinterest_descriptionWrapper,.swpmb-field.swpmb-textarea-wrapper.swp_customTweetWrapper{width:63%;float:left}.swpmb-field.swpmb-select-wrapper.swp_pin_browser_extensionWrapper,.swpmb-field.swpmb-select-wrapper.swp_pin_browser_extension_locationWrapper,.swpmb-field.swpmb-select-wrapper.swp_post_locationWrapper,.swpmb-field.swpmb-select-wrapper.swp_float_locationWrapper{width:32%;float:left;min-width:320px}.swpmb-field.swpmb-select-wrapper.swp_pin_browser_extensionWrapper select,.swpmb-field.swpmb-select-wrapper.swp_pin_browser_extension_locationWrapper select,.swpmb-field.swpmb-select-wrapper.swp_post_locationWrapper select,.swpmb-field.swpmb-select-wrapper.swp_float_locationWrapper select{width:90%}.swpmb-field.swpmb-image_advanced-wrapper.swp_og_imageWrapper,.swpmb-field.swpmb-image_advanced-wrapper.swp_pinterest_imageWrapper{width:30%;float:left;margin-right:3%}#social_warfare .swpmb-label,#social_warfare .swpmb-input{width:100%}#social_warfare .swpmb-field{margin-top:10px}#social_warfare .swpmb-image-item,#social_warfare .swpmb-media-preview,#social_warfare .swpmb-media-content .centered,#social_warfare .swpmb-media-content img{width:100%;height:auto;max-height:none;-webkit-transform:none;-ms-transform:none;transform:none}.wp-core-ui #social_warfare a.swpmb-add-media.button{display:block;background:#30394f;color:#fff;font-size:12px;line-height:1;text-align:center;vertical-align:middle;padding:15px 25px;margin:0;-webkit-box-shadow:none;box-shadow:none;border:none;height:auto}.wp-core-ui #social_warfare a.swpmb-add-media.button:hover{background:#EE464F}#social_warfare .swpmb-media-content img{-webkit-transform:translate(0%,0%);-ms-transform:translate(0%,0%);transform:translate(0%,0%)}#social_warfare .swpmb-media-content{overflow:visible}#social_warfare .swpmb-media-preview:before{padding-top:0}#social_warfare .swpmb-media-content{position:inherit}#social_warfare .swpmb-divider-wrapper hr{border:none!important}#social_warfare .swpmb-label label{font-weight:bold;color:#30394f;font-size:18px}#social_warfare .swpmb-divider-wrapper{max-height:1px;clear:both}#social_warfare .swpmb-label{margin-bottom:10px}#social_warfare h2.hndle span:before{content:'p';margin-right:10px;font-family:"sw-icon-font";vertical-align:middle}#social_warfare .dashicons,#social_warfare .sw{vertical-align:middle;margin-right:10px;font-size:18px}#social_warfare .sw-premium-blocker{position:absolute;width:100%;height:100%;top:0;left:0}#social_warfare .sw-premium-blocker:not(.no-icon):before{font-family:'sw-icon-font';content:'E';font-size:24px;float:right;margin:10px 40px 0 0}.ui-tooltip.sw-admin-hover-notice{background:#ee464f;color:#fff;padding:15px;-webkit-border-radius:2px;border-radius:2px;margin:15px 0;border:0;-webkit-box-shadow:none;box-shadow:none;max-width:none;padding:20px}.sw-admin-hover-notice i:before{font-family:'sw-icon-font';font-size:26px;margin:0 15px 0 0;vertical-align:middle;content:'E';float:left;font-style:normal}[class$=title_wrapper] ~ [class$=title_wrapper]{border-top:1px solid #CED3DC;padding-top:40px}.swp-notice-wrapper{max-width:73%;margin-top:-15px;margin-bottom:15px}.swp-notice{padding:10px 15px;padding:20px}.swp-actions{display:flex;align-items:center}.swp-notice a{cursor:hover;text-decoration:underline;margin:0 10px}.swp-dismiss-notice.notice.notice-info{font-size:15px;line-height:25px}.swp-dismiss-notice.notice.notice-info{border-left-color:#D34250;padding:20px;margin:15px 0 15px}.swp-dismiss-notice.notice.notice-info p{font-size:15px;line-height:25px;padding:0;margin:0 0 20px}a.swp-notice-cta{cursor:pointer;text-decoration:underline;font-size:15px;line-height:30px;margin-right:50px}
|
functions/Social_Warfare.php
CHANGED
@@ -152,6 +152,7 @@ class Social_Warfare {
|
|
152 |
*/
|
153 |
new SWP_Database_Migration();
|
154 |
|
|
|
155 |
/**
|
156 |
* The Options Page Class
|
157 |
*
|
@@ -224,6 +225,12 @@ class Social_Warfare {
|
|
224 |
*
|
225 |
*/
|
226 |
new SWP_User_Profile();
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
}
|
228 |
|
229 |
|
@@ -258,7 +265,9 @@ class Social_Warfare {
|
|
258 |
'Permalink',
|
259 |
'Plugin_Updater',
|
260 |
'Database_Migration',
|
261 |
-
'URL_Management'
|
|
|
|
|
262 |
];
|
263 |
$this->load_files( '/functions/utilities/', $utilities);
|
264 |
|
152 |
*/
|
153 |
new SWP_Database_Migration();
|
154 |
|
155 |
+
|
156 |
/**
|
157 |
* The Options Page Class
|
158 |
*
|
225 |
*
|
226 |
*/
|
227 |
new SWP_User_Profile();
|
228 |
+
|
229 |
+
/**
|
230 |
+
*
|
231 |
+
* Instantiates all of our notices.
|
232 |
+
*/
|
233 |
+
new SWP_Notice_Loader();
|
234 |
}
|
235 |
|
236 |
|
265 |
'Permalink',
|
266 |
'Plugin_Updater',
|
267 |
'Database_Migration',
|
268 |
+
'URL_Management',
|
269 |
+
'Notice',
|
270 |
+
'Notice_Loader'
|
271 |
];
|
272 |
$this->load_files( '/functions/utilities/', $utilities);
|
273 |
|
functions/frontend-output/SWP_Buttons_Panel.php
CHANGED
@@ -96,7 +96,7 @@ class SWP_Buttons_Panel {
|
|
96 |
public function __construct( $args = array(), $shortcode = false ) {
|
97 |
global $swp_social_networks, $post;
|
98 |
$this->networks = $swp_social_networks;
|
99 |
-
|
100 |
|
101 |
//* Access the $post once while we have it. Values may be overwritten.
|
102 |
$this->post_data = [
|
@@ -111,9 +111,9 @@ class SWP_Buttons_Panel {
|
|
111 |
$this->content = isset( $args['content'] ) ? $args['content'] : '';
|
112 |
$this->is_shortcode = $shortcode;
|
113 |
$this->localize_options( $args );
|
114 |
-
|
115 |
$this->shares = get_social_warfare_shares( $this->post_data['ID'] );
|
116 |
-
|
117 |
$this->establish_permalink();
|
118 |
$this->establish_active_buttons();
|
119 |
|
@@ -158,6 +158,8 @@ class SWP_Buttons_Panel {
|
|
158 |
$this->options[$this->options] = $value;
|
159 |
return $this;
|
160 |
}
|
|
|
|
|
161 |
/**
|
162 |
* Set multiple options
|
163 |
*
|
@@ -173,6 +175,8 @@ class SWP_Buttons_Panel {
|
|
173 |
array_merge( $this->options , $options );
|
174 |
return $this;
|
175 |
}
|
|
|
|
|
176 |
/**
|
177 |
* Set the post ID for this buttons panel.
|
178 |
*
|
@@ -190,11 +194,29 @@ class SWP_Buttons_Panel {
|
|
190 |
if ( isset( $this->args['postID'] ) ) :
|
191 |
$this->post_data['ID'] = $this->args['postID'];
|
192 |
endif;
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
endif;
|
197 |
}
|
|
|
|
|
198 |
/**
|
199 |
* Establish the post content
|
200 |
*
|
@@ -211,6 +233,8 @@ class SWP_Buttons_Panel {
|
|
211 |
$this->content = $args['content'];
|
212 |
endif;
|
213 |
}
|
|
|
|
|
214 |
/**
|
215 |
* Establish Location
|
216 |
*
|
@@ -263,7 +287,6 @@ class SWP_Buttons_Panel {
|
|
263 |
* for that type from the global options.
|
264 |
*
|
265 |
*/
|
266 |
-
|
267 |
// If we are on the home page
|
268 |
if( is_front_page() ):
|
269 |
$home = $this->options['location_home'];
|
@@ -412,6 +435,9 @@ class SWP_Buttons_Panel {
|
|
412 |
endif;
|
413 |
echo $html;
|
414 |
endif;
|
|
|
|
|
|
|
415 |
return $html;
|
416 |
}
|
417 |
|
@@ -471,7 +497,7 @@ class SWP_Buttons_Panel {
|
|
471 |
if( 'off' === $post_setting) :
|
472 |
return 'none';
|
473 |
endif;
|
474 |
-
|
475 |
$post_on = true;
|
476 |
};
|
477 |
|
@@ -586,8 +612,12 @@ class SWP_Buttons_Panel {
|
|
586 |
if ( $echo ) :
|
587 |
echo $html;
|
588 |
endif;
|
|
|
|
|
|
|
589 |
return $html;
|
590 |
endif;
|
|
|
591 |
}
|
592 |
|
593 |
|
@@ -735,12 +765,11 @@ class SWP_Buttons_Panel {
|
|
735 |
}
|
736 |
|
737 |
|
738 |
-
//* TODO: This has not been refactored.
|
739 |
protected function handle_timestamp() {
|
740 |
-
if ( swp_is_cache_fresh( $this->post_data['ID'] ) == false && isset($this->options['cache_method']) && 'legacy' === $this->options['cache_method'] ) :
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
}
|
745 |
|
746 |
|
@@ -767,9 +796,11 @@ class SWP_Buttons_Panel {
|
|
767 |
$this->content = $content;
|
768 |
|
769 |
if ( isset( $this->args['echo']) && true === $this->args['echo'] ) {
|
770 |
-
|
771 |
-
|
772 |
-
|
|
|
|
|
773 |
echo $this->content;
|
774 |
}
|
775 |
|
@@ -801,7 +832,7 @@ class SWP_Buttons_Panel {
|
|
801 |
return;
|
802 |
}
|
803 |
|
804 |
-
|
805 |
|
806 |
return $this->do_print();
|
807 |
}
|
96 |
public function __construct( $args = array(), $shortcode = false ) {
|
97 |
global $swp_social_networks, $post;
|
98 |
$this->networks = $swp_social_networks;
|
99 |
+
$this->args = $args;
|
100 |
|
101 |
//* Access the $post once while we have it. Values may be overwritten.
|
102 |
$this->post_data = [
|
111 |
$this->content = isset( $args['content'] ) ? $args['content'] : '';
|
112 |
$this->is_shortcode = $shortcode;
|
113 |
$this->localize_options( $args );
|
114 |
+
$this->establish_post_id();
|
115 |
$this->shares = get_social_warfare_shares( $this->post_data['ID'] );
|
116 |
+
$this->establish_location();
|
117 |
$this->establish_permalink();
|
118 |
$this->establish_active_buttons();
|
119 |
|
158 |
$this->options[$this->options] = $value;
|
159 |
return $this;
|
160 |
}
|
161 |
+
|
162 |
+
|
163 |
/**
|
164 |
* Set multiple options
|
165 |
*
|
175 |
array_merge( $this->options , $options );
|
176 |
return $this;
|
177 |
}
|
178 |
+
|
179 |
+
|
180 |
/**
|
181 |
* Set the post ID for this buttons panel.
|
182 |
*
|
194 |
if ( isset( $this->args['postID'] ) ) :
|
195 |
$this->post_data['ID'] = $this->args['postID'];
|
196 |
endif;
|
197 |
+
|
198 |
+
// Current argument.
|
199 |
+
if ( isset( $this->args['post_id'] ) ) :
|
200 |
+
$this->post_data['ID'] = $this->args['post_id'];
|
201 |
+
endif;
|
202 |
+
|
203 |
+
if ( isset ( $this->args['id'] ) ) :
|
204 |
+
$post = get_post( $this->args['id'] );
|
205 |
+
$post_data = [
|
206 |
+
'ID' => $post->ID,
|
207 |
+
'post_type' => $post->post_type,
|
208 |
+
'permalink' => get_the_permalink( $post->ID ),
|
209 |
+
'post_title' => $post->post_title,
|
210 |
+
'post_status' => $post->post_status,
|
211 |
+
'post_content' => $post->post_content
|
212 |
+
];
|
213 |
+
|
214 |
+
$this->post_data = array_merge( $this->post_data, $post_data );
|
215 |
+
|
216 |
endif;
|
217 |
}
|
218 |
+
|
219 |
+
|
220 |
/**
|
221 |
* Establish the post content
|
222 |
*
|
233 |
$this->content = $args['content'];
|
234 |
endif;
|
235 |
}
|
236 |
+
|
237 |
+
|
238 |
/**
|
239 |
* Establish Location
|
240 |
*
|
287 |
* for that type from the global options.
|
288 |
*
|
289 |
*/
|
|
|
290 |
// If we are on the home page
|
291 |
if( is_front_page() ):
|
292 |
$home = $this->options['location_home'];
|
435 |
endif;
|
436 |
echo $html;
|
437 |
endif;
|
438 |
+
|
439 |
+
$this->handle_timestamp();
|
440 |
+
|
441 |
return $html;
|
442 |
}
|
443 |
|
497 |
if( 'off' === $post_setting) :
|
498 |
return 'none';
|
499 |
endif;
|
500 |
+
|
501 |
$post_on = true;
|
502 |
};
|
503 |
|
612 |
if ( $echo ) :
|
613 |
echo $html;
|
614 |
endif;
|
615 |
+
|
616 |
+
$this->handle_timestamp();
|
617 |
+
|
618 |
return $html;
|
619 |
endif;
|
620 |
+
|
621 |
}
|
622 |
|
623 |
|
765 |
}
|
766 |
|
767 |
|
|
|
768 |
protected function handle_timestamp() {
|
769 |
+
if ( swp_is_cache_fresh( $this->post_data['ID'] ) == false && isset( $this->options['cache_method'] ) && 'legacy' === $this->options['cache_method'] ) :
|
770 |
+
delete_post_meta( $this->post_data['ID'], 'swp_cache_timestamp' );
|
771 |
+
update_post_meta( $this->post_data['ID'], 'swp_cache_timestamp', floor( ( (date( 'U' ) / 60) / 60) ) );
|
772 |
+
endif;
|
773 |
}
|
774 |
|
775 |
|
796 |
$this->content = $content;
|
797 |
|
798 |
if ( isset( $this->args['echo']) && true === $this->args['echo'] ) {
|
799 |
+
|
800 |
+
if( true == _swp_is_debug('buttons_output')):
|
801 |
+
echo 'Echoing, not returning. In SWP_Buttons_Panel on line ' . __LINE__;
|
802 |
+
endif;
|
803 |
+
|
804 |
echo $this->content;
|
805 |
}
|
806 |
|
832 |
return;
|
833 |
}
|
834 |
|
835 |
+
$this->handle_timestamp();
|
836 |
|
837 |
return $this->do_print();
|
838 |
}
|
functions/frontend-output/SWP_Display.php
CHANGED
@@ -11,7 +11,6 @@
|
|
11 |
*/
|
12 |
class SWP_Display {
|
13 |
public $already_print;
|
14 |
-
// public $Button;
|
15 |
|
16 |
public function __construct() {
|
17 |
/**
|
@@ -34,6 +33,8 @@ class SWP_Display {
|
|
34 |
add_action('template_redirect', [$this, 'activate_buttons'] );
|
35 |
add_action( 'wp_footer', [$this, 'floating_buttons'] );
|
36 |
}
|
|
|
|
|
37 |
/**
|
38 |
* A function to add the buttons
|
39 |
*
|
@@ -75,25 +76,28 @@ class SWP_Display {
|
|
75 |
|
76 |
|
77 |
/**
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
95 |
}
|
96 |
|
|
|
97 |
function floating_buttons() {
|
98 |
|
99 |
$side_panel = new SWP_Buttons_Panel( ['content' => "" ]);
|
@@ -109,6 +113,7 @@ class SWP_Display {
|
|
109 |
return;
|
110 |
}
|
111 |
|
|
|
112 |
/**
|
113 |
* The main social_warfare function used to create the buttons.
|
114 |
*
|
11 |
*/
|
12 |
class SWP_Display {
|
13 |
public $already_print;
|
|
|
14 |
|
15 |
public function __construct() {
|
16 |
/**
|
33 |
add_action('template_redirect', [$this, 'activate_buttons'] );
|
34 |
add_action( 'wp_footer', [$this, 'floating_buttons'] );
|
35 |
}
|
36 |
+
|
37 |
+
|
38 |
/**
|
39 |
* A function to add the buttons
|
40 |
*
|
76 |
|
77 |
|
78 |
/**
|
79 |
+
* A wrapper function for adding the buttons, content, or excerpt.
|
80 |
+
*
|
81 |
+
* @since 1.0.0
|
82 |
+
* @param string $content The content.
|
83 |
+
* @return String $content The modified content
|
84 |
+
*
|
85 |
+
*/
|
86 |
+
public function social_warfare_wrapper( $content ) {
|
87 |
+
global $post;
|
88 |
+
|
89 |
+
// Ensure it's not an embedded post
|
90 |
+
if (true === is_singular() && $post->ID !== get_queried_object_id()) {
|
91 |
+
return $content;
|
92 |
+
}
|
93 |
+
|
94 |
+
// Pass the content to the buttons constructor to place them inside.
|
95 |
+
$buttons_panel = new SWP_Buttons_Panel( ['content' => $content ]);
|
96 |
+
|
97 |
+
return $buttons_panel->the_buttons( $content );
|
98 |
}
|
99 |
|
100 |
+
|
101 |
function floating_buttons() {
|
102 |
|
103 |
$side_panel = new SWP_Buttons_Panel( ['content' => "" ]);
|
113 |
return;
|
114 |
}
|
115 |
|
116 |
+
|
117 |
/**
|
118 |
* The main social_warfare function used to create the buttons.
|
119 |
*
|
functions/frontend-output/SWP_Script.php
CHANGED
@@ -167,7 +167,7 @@ class SWP_Script {
|
|
167 |
*
|
168 |
*/
|
169 |
public function click_tracking( $info ) {
|
170 |
-
if ( $info['swp_user_options']['click_tracking'] ) {
|
171 |
$info['footer_output'] .= 'var swpClickTracking = true;';
|
172 |
} else {
|
173 |
$info['footer_output'] .= 'var swpClickTracking = false;';
|
167 |
*
|
168 |
*/
|
169 |
public function click_tracking( $info ) {
|
170 |
+
if ( isset( $info['swp_user_options']['click_tracking'] ) && true === $info['swp_user_options']['click_tracking'] ) {
|
171 |
$info['footer_output'] .= 'var swpClickTracking = true;';
|
172 |
} else {
|
173 |
$info['footer_output'] .= 'var swpClickTracking = false;';
|
functions/options/SWP_Option.php
CHANGED
@@ -146,17 +146,18 @@ class SWP_Option extends SWP_Abstract {
|
|
146 |
*/
|
147 |
public function set_default( $value ) {
|
148 |
|
149 |
-
|
150 |
|
151 |
// Add this to our global list of defaults
|
152 |
add_filter('swp_options_page_defaults' , array( $this , 'register_default' ) );
|
153 |
|
154 |
global $swp_user_options;
|
|
|
155 |
if( !isset( $swp_user_options[$this->key] ) ):
|
156 |
-
|
157 |
endif;
|
158 |
|
159 |
-
|
160 |
}
|
161 |
|
162 |
|
146 |
*/
|
147 |
public function set_default( $value ) {
|
148 |
|
149 |
+
$this->default = $value;
|
150 |
|
151 |
// Add this to our global list of defaults
|
152 |
add_filter('swp_options_page_defaults' , array( $this , 'register_default' ) );
|
153 |
|
154 |
global $swp_user_options;
|
155 |
+
|
156 |
if( !isset( $swp_user_options[$this->key] ) ):
|
157 |
+
$swp_user_options[$this->key] = $this->default;
|
158 |
endif;
|
159 |
|
160 |
+
return $this;
|
161 |
}
|
162 |
|
163 |
|
functions/options/SWP_Options_Page.php
CHANGED
@@ -707,8 +707,13 @@ class SWP_Options_Page extends SWP_Abstract {
|
|
707 |
$sidebar = new SWP_Section_HTML( 'Sidebar' );
|
708 |
$tab_map = $this->sort_by_priority( $this->tabs );
|
709 |
$registered = false;
|
|
|
710 |
|
711 |
$container = '<div class="sw-admin-wrapper" sw-registered="'. $this->registered .'" swp-addons="' . $active_addons . '" swp-registrations="' . $registered_addons . '">';
|
|
|
|
|
|
|
|
|
712 |
$container .= '<form class="sw-admin-settings-form">';
|
713 |
$container .= '<div class="sw-tabs-container sw-grid sw-col-700">';
|
714 |
|
707 |
$sidebar = new SWP_Section_HTML( 'Sidebar' );
|
708 |
$tab_map = $this->sort_by_priority( $this->tabs );
|
709 |
$registered = false;
|
710 |
+
$notices = apply_filters( 'swp_admin_notices', '' );
|
711 |
|
712 |
$container = '<div class="sw-admin-wrapper" sw-registered="'. $this->registered .'" swp-addons="' . $active_addons . '" swp-registrations="' . $registered_addons . '">';
|
713 |
+
$container .= '<div class="swp-notice-wrapper">';
|
714 |
+
$container .= $notices;
|
715 |
+
$container .= '</div>';
|
716 |
+
|
717 |
$container .= '<form class="sw-admin-settings-form">';
|
718 |
$container .= '<div class="sw-tabs-container sw-grid sw-col-700">';
|
719 |
|
functions/options/SWP_Section_HTML.php
CHANGED
@@ -209,7 +209,7 @@ class SWP_Section_HTML extends SWP_Option {
|
|
209 |
public function do_bitly_authentication_button() {
|
210 |
$link = "https://bitly.com/oauth/authorize?client_id=96c9b292c5503211b68cf4ab53f6e2f4b6d0defb&state=" . admin_url( 'admin-ajax.php' ) . "&redirect_uri=https://warfareplugins.com/bitly_oauth.php";
|
211 |
|
212 |
-
if (
|
213 |
$text = __( 'Connected', 'social-warfare' );
|
214 |
$color = 'sw-green-button';
|
215 |
else:
|
209 |
public function do_bitly_authentication_button() {
|
210 |
$link = "https://bitly.com/oauth/authorize?client_id=96c9b292c5503211b68cf4ab53f6e2f4b6d0defb&state=" . admin_url( 'admin-ajax.php' ) . "&redirect_uri=https://warfareplugins.com/bitly_oauth.php";
|
211 |
|
212 |
+
if ( swp_get_option('bitly_access_token') ):
|
213 |
$text = __( 'Connected', 'social-warfare' );
|
214 |
$color = 'sw-green-button';
|
215 |
else:
|
functions/social-networks/SWP_Google_Plus.php
CHANGED
@@ -11,6 +11,7 @@
|
|
11 |
* @since 1.0.0 | Unknown | Created
|
12 |
* @since 2.2.4 | 02 MAY 2017 | Refactored functions & updated docblocking
|
13 |
* @since 3.0.0 | 05 APR 2018 | Rebuilt into a class-based system.
|
|
|
14 |
*
|
15 |
*/
|
16 |
class SWP_Google_Plus extends SWP_Social_Network {
|
@@ -42,34 +43,4 @@ class SWP_Google_Plus extends SWP_Social_Network {
|
|
42 |
|
43 |
$this->init_social_network();
|
44 |
}
|
45 |
-
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Generate the API Share Count Request URL
|
49 |
-
*
|
50 |
-
* @since 3.0.0 | 07 APR 2018 | Created
|
51 |
-
* @access public
|
52 |
-
* @param string $url The permalink of the page or post for which to fetch share counts
|
53 |
-
* @return string $request_url The complete URL to be used to access share counts via the API
|
54 |
-
*
|
55 |
-
*/
|
56 |
-
public function get_api_link( $url ) {
|
57 |
-
return $url;
|
58 |
-
}
|
59 |
-
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Parse the response to get the share count
|
63 |
-
*
|
64 |
-
* @since 3.0.0 | 07 APR 2018 | Created
|
65 |
-
* @access public
|
66 |
-
* @param string $response The raw response returned from the API request
|
67 |
-
* @return int $total_activity The number of shares reported from the API
|
68 |
-
*
|
69 |
-
*/
|
70 |
-
public function parse_api_response( $response ) {
|
71 |
-
$response = json_decode( $response, true );
|
72 |
-
return isset( $response[0]['result']['metadata']['globalCounts']['count'] )?intval( $response[0]['result']['metadata']['globalCounts']['count'] ):0;
|
73 |
-
}
|
74 |
-
|
75 |
}
|
11 |
* @since 1.0.0 | Unknown | Created
|
12 |
* @since 2.2.4 | 02 MAY 2017 | Refactored functions & updated docblocking
|
13 |
* @since 3.0.0 | 05 APR 2018 | Rebuilt into a class-based system.
|
14 |
+
* @since 3.0.9 | 04 JUN 2018 | Removed deprecated API request (share counts)
|
15 |
*
|
16 |
*/
|
17 |
class SWP_Google_Plus extends SWP_Social_Network {
|
43 |
|
44 |
$this->init_social_network();
|
45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
functions/social-networks/SWP_Linkedin.php
CHANGED
@@ -1,58 +1,31 @@
|
|
1 |
<?php
|
2 |
|
3 |
class SWP_Linkedin extends SWP_Social_Network {
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Generate the API Share Count Request URL
|
34 |
-
*
|
35 |
-
* @since 1.0.0
|
36 |
-
* @access public
|
37 |
-
* @param string $url The permalink of the page or post for which to fetch share counts
|
38 |
-
* @return string $request_url The complete URL to be used to access share counts via the API
|
39 |
-
*/
|
40 |
-
function get_api_link( $url ) {
|
41 |
-
$request_url = 'https://www.linkedin.com/countserv/count/share?url=' . $url . '&format=json';
|
42 |
-
return $request_url;
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Parse the response to get the share count
|
48 |
-
*
|
49 |
-
* @since 1.0.0
|
50 |
-
* @access public
|
51 |
-
* @param string $response The raw response returned from the API request
|
52 |
-
* @return int $total_activity The number of shares reported from the API
|
53 |
-
*/
|
54 |
-
public function parse_api_response( $response ) {
|
55 |
-
$response = json_decode( $response, true );
|
56 |
-
return isset( $response['count'] )?intval( $response['count'] ):0;
|
57 |
-
}
|
58 |
}
|
1 |
<?php
|
2 |
|
3 |
class SWP_Linkedin extends SWP_Social_Network {
|
4 |
+
/**
|
5 |
+
* The Magic __construct Method
|
6 |
+
*
|
7 |
+
* This method is used to instantiate the social network object. It does three things.
|
8 |
+
* First it sets the object properties for each network. Then it adds this object to
|
9 |
+
* the globally accessible swp_social_networks array. Finally, it fetches the active
|
10 |
+
* state (does the user have this button turned on?) so that it can be accessed directly
|
11 |
+
* within the object.
|
12 |
+
*
|
13 |
+
* @since 3.0.0 | 06 APR 2018 | Created
|
14 |
+
* @since 3.0.9 | 04 JUN 2018 | Removed deprecated API request (share counts)
|
15 |
+
* @param none
|
16 |
+
* @return none
|
17 |
+
* @access public
|
18 |
+
*
|
19 |
+
*/
|
20 |
+
public function __construct() {
|
21 |
|
22 |
+
// Update the class properties for this network
|
23 |
+
$this->name = __( 'LinkedIn','social-warfare' );
|
24 |
+
$this->cta = __( 'Share','social-warfare' );
|
25 |
+
$this->key = 'linkedin';
|
26 |
+
$this->default = 'true';
|
27 |
+
$this->base_share_url = 'https://www.linkedin.com/cws/share?url=';
|
28 |
|
29 |
+
$this->init_social_network();
|
30 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
functions/social-networks/SWP_Pinterest.php
CHANGED
@@ -74,6 +74,7 @@ class SWP_Pinterest extends SWP_Social_Network {
|
|
74 |
* @since 1.0.0
|
75 |
* @since 3.0.0 | 01 MAY 2018 | Re-wrote the function to a class method.
|
76 |
* @since 3.0.6 | 14 MAY 2018 | Appended $pinterest_username to $pinterest_description.
|
|
|
77 |
* @access public
|
78 |
* @return array $panel_context Array of
|
79 |
* ['post_data'] => metadata about the post;
|
@@ -82,15 +83,24 @@ class SWP_Pinterest extends SWP_Social_Network {
|
|
82 |
* @param bool $echo If true, this will immediately echo its code rather than save it for later.
|
83 |
*
|
84 |
*/
|
85 |
-
public function render_HTML( $panel_context
|
86 |
global $swp_user_options;
|
87 |
$post_id = $panel_context['post_data']['ID'];
|
88 |
-
|
89 |
$post_url = urlencode( urldecode( SWP_URL_Management::process_url( $panel_context['post_data']['permalink'] , 'pinterest' , $post_id ) ) );
|
90 |
|
91 |
$options = $swp_user_options;
|
92 |
-
$
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
if ( !empty( $options['pinterest_id'] ) ) :
|
96 |
$pinterest_username = ' via @' . str_replace( '@' , '' , $options['pinterest_id'] );
|
@@ -99,12 +109,11 @@ class SWP_Pinterest extends SWP_Social_Network {
|
|
99 |
endif;
|
100 |
|
101 |
$title = str_replace( '|', '', strip_tags( $panel_context['post_data']['post_title'] ) );
|
102 |
-
|
103 |
$pinterest_description = get_post_meta( $post_id , 'swp_pinterest_description' , true );
|
104 |
|
105 |
-
if( is_array( $pinterest_description ) && !empty( $pinterest_description )
|
106 |
$pinterest_description = $pinterest_description[0];
|
107 |
-
delete_post_meta( $post_id , 'swp_pinterest_description' );
|
108 |
update_post_meta( $post_id , 'swp_pinterest_description' , $pinterest_description );
|
109 |
}
|
110 |
|
@@ -114,39 +123,30 @@ class SWP_Pinterest extends SWP_Social_Network {
|
|
114 |
|
115 |
$pinterest_description .= $pinterest_username;
|
116 |
|
117 |
-
if ( $pinterest_image
|
118 |
$anchor = '<a rel="nofollow" class="nc_tweet" data-count="0" ' .
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
else :
|
125 |
$anchor = '<a rel="nofollow" class="nc_tweet noPop" ' .
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
endif;
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
if ( isset($options['advanced_pinterest_fallback']) && $options['advanced_pinterest_fallback'] == 'featured'):
|
137 |
-
$thumbnail_url = wp_get_attachment_url( get_post_thumbnail_id( $panel_context['postID'] ) );
|
138 |
-
if( !empty( $thumbnail_url ) ):
|
139 |
-
$array['imageURL'] = $thumbnail_url;
|
140 |
-
endif;
|
141 |
-
|
142 |
-
endif;
|
143 |
-
|
144 |
//* Begin parent class method.
|
145 |
|
146 |
$post_data = $panel_context['post_data'];
|
147 |
$share_counts = $panel_context['shares'];
|
148 |
$options = $panel_context['options'];
|
149 |
$share_link = $this->generate_share_link( $post_data );
|
|
|
150 |
// Build the button.
|
151 |
$icon = '<span class="iconFiller">';
|
152 |
$icon.= '<span class="spaceManWilly">';
|
@@ -154,11 +154,13 @@ class SWP_Pinterest extends SWP_Social_Network {
|
|
154 |
$icon.= '<span class="swp_share">' . $this->cta . '</span>';
|
155 |
$icon .= '</span>';
|
156 |
$icon .= '</span>';
|
|
|
157 |
if ( true === $this->are_shares_shown( $share_counts , $options ) ) :
|
158 |
$icon .= '<span class="swp_count">' . swp_kilomega( $share_counts[$this->key] ) . '</span>';
|
159 |
else :
|
160 |
$icon = '<span class="swp_count swp_hide">' . $icon . '</span>';
|
161 |
endif;
|
|
|
162 |
// Build the wrapper.
|
163 |
$html = '<div class="nc_tweetContainer swp_'.$this->key.'" data-network="'.$this->key.'">';
|
164 |
$html .= $anchor;
|
@@ -166,9 +168,10 @@ class SWP_Pinterest extends SWP_Social_Network {
|
|
166 |
$html .= $icon;
|
167 |
$html.= '</a>';
|
168 |
$html.= '</div>';
|
169 |
-
// Store these buttons so that we don't have to generate them for each set
|
170 |
|
|
|
171 |
$this->html = $html;
|
|
|
172 |
if ( $echo ) :
|
173 |
echo $html;
|
174 |
endif;
|
74 |
* @since 1.0.0
|
75 |
* @since 3.0.0 | 01 MAY 2018 | Re-wrote the function to a class method.
|
76 |
* @since 3.0.6 | 14 MAY 2018 | Appended $pinterest_username to $pinterest_description.
|
77 |
+
* @since 3.0.9 | 04 JUN 2018 | Updated the check for pinterest image.
|
78 |
* @access public
|
79 |
* @return array $panel_context Array of
|
80 |
* ['post_data'] => metadata about the post;
|
83 |
* @param bool $echo If true, this will immediately echo its code rather than save it for later.
|
84 |
*
|
85 |
*/
|
86 |
+
public function render_HTML( $panel_context, $echo = false ) {
|
87 |
global $swp_user_options;
|
88 |
$post_id = $panel_context['post_data']['ID'];
|
|
|
89 |
$post_url = urlencode( urldecode( SWP_URL_Management::process_url( $panel_context['post_data']['permalink'] , 'pinterest' , $post_id ) ) );
|
90 |
|
91 |
$options = $swp_user_options;
|
92 |
+
$metabox_pinterest_image = get_post_meta( $post_id , 'swp_pinterest_image_url' , true );
|
93 |
+
|
94 |
+
if ( !empty( $metabox_pinterest_image ) ) :
|
95 |
+
$pinterest_image = $metabox_pinterest_image;
|
96 |
+
|
97 |
+
elseif ( isset($options['pinterest_fallback']) && $options['pinterest_fallback'] == 'featured' ):
|
98 |
+
$pinterest_image = wp_get_attachment_url( get_post_thumbnail_id( $post_id ) );
|
99 |
+
|
100 |
+
else :
|
101 |
+
$pinterest_image = '';
|
102 |
+
|
103 |
+
endif;
|
104 |
|
105 |
if ( !empty( $options['pinterest_id'] ) ) :
|
106 |
$pinterest_username = ' via @' . str_replace( '@' , '' , $options['pinterest_id'] );
|
109 |
endif;
|
110 |
|
111 |
$title = str_replace( '|', '', strip_tags( $panel_context['post_data']['post_title'] ) );
|
|
|
112 |
$pinterest_description = get_post_meta( $post_id , 'swp_pinterest_description' , true );
|
113 |
|
114 |
+
if( is_array( $pinterest_description ) && !empty( $pinterest_description ) ) {
|
115 |
$pinterest_description = $pinterest_description[0];
|
116 |
+
// delete_post_meta( $post_id , 'swp_pinterest_description' );
|
117 |
update_post_meta( $post_id , 'swp_pinterest_description' , $pinterest_description );
|
118 |
}
|
119 |
|
123 |
|
124 |
$pinterest_description .= $pinterest_username;
|
125 |
|
126 |
+
if ( !empty( $pinterest_image ) ) :
|
127 |
$anchor = '<a rel="nofollow" class="nc_tweet" data-count="0" ' .
|
128 |
+
'data-link="https://pinterest.com/pin/create/button/' .
|
129 |
+
'?url=' . $panel_context['post_data']['permalink'] .
|
130 |
+
'&media=' . urlencode( $pinterest_image ) .
|
131 |
+
'&description=' . urlencode( $pinterest_description ) .
|
132 |
+
'">';
|
133 |
else :
|
134 |
$anchor = '<a rel="nofollow" class="nc_tweet noPop" ' .
|
135 |
+
'onClick="var e=document.createElement(\'script\');
|
136 |
+
e.setAttribute(\'type\',\'text/javascript\');
|
137 |
+
e.setAttribute(\'charset\',\'UTF-8\');
|
138 |
+
e.setAttribute(\'src\',\'//assets.pinterest.com/js/pinmarklet.js?r=\'+Math.random()*99999999);
|
139 |
+
document.body.appendChild(e);
|
140 |
+
" >';
|
141 |
endif;
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
//* Begin parent class method.
|
144 |
|
145 |
$post_data = $panel_context['post_data'];
|
146 |
$share_counts = $panel_context['shares'];
|
147 |
$options = $panel_context['options'];
|
148 |
$share_link = $this->generate_share_link( $post_data );
|
149 |
+
|
150 |
// Build the button.
|
151 |
$icon = '<span class="iconFiller">';
|
152 |
$icon.= '<span class="spaceManWilly">';
|
154 |
$icon.= '<span class="swp_share">' . $this->cta . '</span>';
|
155 |
$icon .= '</span>';
|
156 |
$icon .= '</span>';
|
157 |
+
|
158 |
if ( true === $this->are_shares_shown( $share_counts , $options ) ) :
|
159 |
$icon .= '<span class="swp_count">' . swp_kilomega( $share_counts[$this->key] ) . '</span>';
|
160 |
else :
|
161 |
$icon = '<span class="swp_count swp_hide">' . $icon . '</span>';
|
162 |
endif;
|
163 |
+
|
164 |
// Build the wrapper.
|
165 |
$html = '<div class="nc_tweetContainer swp_'.$this->key.'" data-network="'.$this->key.'">';
|
166 |
$html .= $anchor;
|
168 |
$html .= $icon;
|
169 |
$html.= '</a>';
|
170 |
$html.= '</div>';
|
|
|
171 |
|
172 |
+
// Store these buttons so that we don't have to generate them for each set
|
173 |
$this->html = $html;
|
174 |
+
|
175 |
if ( $echo ) :
|
176 |
echo $html;
|
177 |
endif;
|
functions/social-networks/SWP_Stumble_Upon.php
CHANGED
@@ -40,7 +40,18 @@ class SWP_Stumble_Upon extends SWP_Social_Network {
|
|
40 |
$this->default = 'false';
|
41 |
$this->base_share_url = 'http://www.stumbleupon.com/submit?url=';
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
|
46 |
|
40 |
$this->default = 'false';
|
41 |
$this->base_share_url = 'http://www.stumbleupon.com/submit?url=';
|
42 |
|
43 |
+
$today = date("Y-m-d H:i:s");
|
44 |
+
$expiry = "2018-06-30 00:00:00";
|
45 |
+
|
46 |
+
if ( $today < $expiry ) :
|
47 |
+
$this->init_social_network();
|
48 |
+
else :
|
49 |
+
$options = get_option('social_warfare_settings');
|
50 |
+
if ( isset( $options['order_of_icons']['stumbleupon'] ) ) :
|
51 |
+
unset( $options['order_of_icons']['stumbleupon'] );
|
52 |
+
update_option( 'social_warfare_settings', $options );
|
53 |
+
endif;
|
54 |
+
endif;
|
55 |
}
|
56 |
|
57 |
|
functions/utilities/SWP_CURL.php
CHANGED
@@ -14,6 +14,11 @@ class SWP_CURL {
|
|
14 |
|
15 |
public static function fetch_shares_via_curl_multi( $data, $options = array() ) {
|
16 |
|
|
|
|
|
|
|
|
|
|
|
17 |
// array of curl handles
|
18 |
$curly = array();
|
19 |
// data to be returned
|
@@ -26,9 +31,7 @@ class SWP_CURL {
|
|
26 |
// then add them to the multi-handle
|
27 |
if( is_array( $data ) ):
|
28 |
foreach ( $data as $id => $d ) :
|
29 |
-
|
30 |
if ( $d !== 0 || $id == 'google_plus' ) :
|
31 |
-
|
32 |
$curly[ $id ] = curl_init();
|
33 |
|
34 |
if ( $id == 'google_plus' ) :
|
@@ -70,8 +73,12 @@ class SWP_CURL {
|
|
70 |
endforeach;
|
71 |
endif;
|
72 |
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
75 |
do {
|
76 |
curl_multi_exec( $mh, $running );
|
77 |
} while ($running > 0);
|
@@ -82,16 +89,24 @@ class SWP_CURL {
|
|
82 |
curl_multi_remove_handle( $mh, $c );
|
83 |
}
|
84 |
|
85 |
-
|
86 |
-
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
-
|
|
|
95 |
}
|
96 |
|
97 |
public static function file_get_contents_curl( $url ) {
|
@@ -110,9 +125,11 @@ class SWP_CURL {
|
|
110 |
$cont = @curl_exec( $ch );
|
111 |
$curl_errno = curl_errno( $ch );
|
112 |
curl_close( $ch );
|
|
|
113 |
if ( $curl_errno > 0 ) {
|
114 |
return false;
|
115 |
}
|
|
|
116 |
return $cont;
|
117 |
}
|
118 |
}
|
14 |
|
15 |
public static function fetch_shares_via_curl_multi( $data, $options = array() ) {
|
16 |
|
17 |
+
if ( _swp_is_debug( 'is_cache_fresh' ) ) :
|
18 |
+
$started = time();
|
19 |
+
echo "Starting multi curl request at : " . $started;
|
20 |
+
endif;
|
21 |
+
|
22 |
// array of curl handles
|
23 |
$curly = array();
|
24 |
// data to be returned
|
31 |
// then add them to the multi-handle
|
32 |
if( is_array( $data ) ):
|
33 |
foreach ( $data as $id => $d ) :
|
|
|
34 |
if ( $d !== 0 || $id == 'google_plus' ) :
|
|
|
35 |
$curly[ $id ] = curl_init();
|
36 |
|
37 |
if ( $id == 'google_plus' ) :
|
73 |
endforeach;
|
74 |
endif;
|
75 |
|
76 |
+
if (_swp_is_debug( 'is_cache_fresh' ) ) :
|
77 |
+
echo "<br>About to execute the multi curl. Current time: " . time();
|
78 |
+
endif;
|
79 |
+
|
80 |
+
// execute the handles
|
81 |
+
$running = null;
|
82 |
do {
|
83 |
curl_multi_exec( $mh, $running );
|
84 |
} while ($running > 0);
|
89 |
curl_multi_remove_handle( $mh, $c );
|
90 |
}
|
91 |
|
92 |
+
// all done
|
93 |
+
curl_multi_close( $mh );
|
94 |
|
95 |
+
if( true == _swp_is_debug('show_share_data') ) :
|
96 |
+
echo "<pre>";
|
97 |
+
var_dump($result);
|
98 |
+
echo "</pre>";
|
99 |
+
endif;
|
100 |
+
|
101 |
+
if ( _swp_is_debug( 'is_cache_fresh' ) ) :
|
102 |
+
$done = time();
|
103 |
+
$duration = $done - $started;
|
104 |
+
echo "<br>Finishing the multi curl request at " . $done;
|
105 |
+
echo "<br>Total time for request was " . $duration . " seconds.";
|
106 |
+
endif;
|
107 |
|
108 |
+
|
109 |
+
return $result;
|
110 |
}
|
111 |
|
112 |
public static function file_get_contents_curl( $url ) {
|
125 |
$cont = @curl_exec( $ch );
|
126 |
$curl_errno = curl_errno( $ch );
|
127 |
curl_close( $ch );
|
128 |
+
|
129 |
if ( $curl_errno > 0 ) {
|
130 |
return false;
|
131 |
}
|
132 |
+
|
133 |
return $cont;
|
134 |
}
|
135 |
}
|
functions/utilities/SWP_Database_Migration.php
CHANGED
@@ -48,22 +48,28 @@ class SWP_Database_Migration {
|
|
48 |
if ( !$this->post_meta_is_migrated() ) {
|
49 |
$this->update_post_meta();
|
50 |
$this->update_hidden_post_meta();
|
51 |
-
|
52 |
}
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
if ( true === _swp_is_debug('initialize_db') ) {
|
60 |
$this->initialize_db();
|
61 |
}
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
|
68 |
if ( true === _swp_is_Debug('get_last_migrated') ) {
|
69 |
$this->get_last_migrated( true );
|
@@ -112,12 +118,12 @@ class SWP_Database_Migration {
|
|
112 |
* @return bool True if the old option still exists; false otherwise.
|
113 |
*/
|
114 |
public function post_meta_is_migrated() {
|
115 |
-
if( $this->last_migrated
|
116 |
-
return
|
117 |
}
|
118 |
|
119 |
-
|
120 |
-
|
121 |
|
122 |
return count( $old_metadata ) === 0;
|
123 |
}
|
@@ -158,7 +164,13 @@ class SWP_Database_Migration {
|
|
158 |
public function update_hidden_post_meta() {
|
159 |
global $wpdb;
|
160 |
|
161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
|
163 |
$hidden_map = [
|
164 |
'_googlePlus_shares' => '_google_plus_shares',
|
@@ -231,8 +243,6 @@ class SWP_Database_Migration {
|
|
231 |
$results = $wpdb->query( $q2 );
|
232 |
}
|
233 |
|
234 |
-
$this->update_last_migrated();
|
235 |
-
|
236 |
}
|
237 |
|
238 |
|
@@ -389,7 +399,7 @@ class SWP_Database_Migration {
|
|
389 |
'sideCustomColor' => 'single_custom_color',
|
390 |
'floatBgColor' => 'float_background_color',
|
391 |
'orderOfIconsSelect' => 'order_of_icons_method',
|
392 |
-
|
393 |
];
|
394 |
|
395 |
$value_map = [
|
@@ -446,18 +456,18 @@ class SWP_Database_Migration {
|
|
446 |
$migrations['custom_color'] = $new_value;
|
447 |
$migrations['custom_color_outlines'] = $new_value;
|
448 |
|
449 |
-
|
450 |
-
|
451 |
$migrations['float_custom_color'] = $new_value;
|
452 |
$migrations['float_custom_color_outlines'] = $new_value;
|
453 |
endif;
|
454 |
endif;
|
455 |
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
|
462 |
if ( array_key_exists( $old, $map) ) :
|
463 |
//* We specified an update to the key.
|
48 |
if ( !$this->post_meta_is_migrated() ) {
|
49 |
$this->update_post_meta();
|
50 |
$this->update_hidden_post_meta();
|
51 |
+
$this->update_last_migrated();
|
52 |
}
|
53 |
|
54 |
+
if ( true === _swp_is_debug('get_user_options') ) :
|
55 |
+
echo "<pre>";
|
56 |
+
var_export( get_option( 'social_warfare_settings', array() ) );
|
57 |
+
echo "</pre>";
|
58 |
+
wp_die();
|
59 |
+
endif;
|
60 |
|
61 |
+
if ( true === _swp_is_debug('migrate_db') ) {
|
62 |
+
$this->migrate();
|
63 |
+
}
|
64 |
|
65 |
if ( true === _swp_is_debug('initialize_db') ) {
|
66 |
$this->initialize_db();
|
67 |
}
|
68 |
|
69 |
+
if ( true === _swp_is_debug('migrate_post_meta') ) {
|
70 |
+
$this->update_post_meta();
|
71 |
+
$this->update_hidden_post_meta();
|
72 |
+
}
|
73 |
|
74 |
if ( true === _swp_is_Debug('get_last_migrated') ) {
|
75 |
$this->get_last_migrated( true );
|
118 |
* @return bool True if the old option still exists; false otherwise.
|
119 |
*/
|
120 |
public function post_meta_is_migrated() {
|
121 |
+
if( $this->last_migrated !== $this->get_last_migrated() ) {
|
122 |
+
return false;
|
123 |
}
|
124 |
|
125 |
+
//* Fetch posts with 2.3.5 metadata.
|
126 |
+
$old_metadata = get_posts( ['meta_key' => 'nc_postLocation', 'numberposts' => 1] );
|
127 |
|
128 |
return count( $old_metadata ) === 0;
|
129 |
}
|
164 |
public function update_hidden_post_meta() {
|
165 |
global $wpdb;
|
166 |
|
167 |
+
try {
|
168 |
+
set_time_limit(300);
|
169 |
+
} catch (Exception $e) {
|
170 |
+
if ( function_exists( 'error_log' ) ) :
|
171 |
+
error_log($e->getMessage());
|
172 |
+
endif;
|
173 |
+
}
|
174 |
|
175 |
$hidden_map = [
|
176 |
'_googlePlus_shares' => '_google_plus_shares',
|
243 |
$results = $wpdb->query( $q2 );
|
244 |
}
|
245 |
|
|
|
|
|
246 |
}
|
247 |
|
248 |
|
399 |
'sideCustomColor' => 'single_custom_color',
|
400 |
'floatBgColor' => 'float_background_color',
|
401 |
'orderOfIconsSelect' => 'order_of_icons_method',
|
402 |
+
'newOrderOfIcons' => 'order_of_icons',
|
403 |
];
|
404 |
|
405 |
$value_map = [
|
456 |
$migrations['custom_color'] = $new_value;
|
457 |
$migrations['custom_color_outlines'] = $new_value;
|
458 |
|
459 |
+
// If the float style source is set to inherit the style from the static buttons.
|
460 |
+
if ( $options['floatStyleSource'] == true ) :
|
461 |
$migrations['float_custom_color'] = $new_value;
|
462 |
$migrations['float_custom_color_outlines'] = $new_value;
|
463 |
endif;
|
464 |
endif;
|
465 |
|
466 |
+
// Only if the source is set to not inherit them from the static buttons.
|
467 |
+
if ( $old === 'sideCustomColor' ) :
|
468 |
+
$migrations['float_custom_color'] = $new_value;
|
469 |
+
$migrations['float_custom_color_outlines'] = $new_value;
|
470 |
+
endif;
|
471 |
|
472 |
if ( array_key_exists( $old, $map) ) :
|
473 |
//* We specified an update to the key.
|
functions/utilities/SWP_Notice.php
ADDED
@@ -0,0 +1,384 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SWP_Notice
|
5 |
+
*
|
6 |
+
* A class to control the creation and display of admin notices throughout the
|
7 |
+
* WordPress dashboard and on the Social Warfare settings page. This class also
|
8 |
+
* creates the framework and functionality for both permanently and temporarily
|
9 |
+
* dismissing these notices. It also allows for creating start dates, end dates,
|
10 |
+
* and various types of calls-to-actions used to dismiss these notices.
|
11 |
+
*
|
12 |
+
* @package SocialWarfare\Utilities
|
13 |
+
* @copyright Copyright (c) 2018, Warfare Plugins, LLC
|
14 |
+
* @license GPL-3.0+
|
15 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
16 |
+
* @access public
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
class SWP_Notice {
|
20 |
+
|
21 |
+
|
22 |
+
/**
|
23 |
+
* The Magic __construct method
|
24 |
+
*
|
25 |
+
* This method will initialize our notice object and then add the necessary hooks to
|
26 |
+
* allow it to be displayed and to be dismissed via admin-ajax.php.
|
27 |
+
*
|
28 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
29 |
+
* @param string $key A unique key for this notice.
|
30 |
+
* @param string $message The message for this notice
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
public function __construct( $key, $message ) {
|
34 |
+
$this->set_key( $key );
|
35 |
+
$this->init();
|
36 |
+
$this->set_message( $message );
|
37 |
+
$this->actions = array();
|
38 |
+
|
39 |
+
// Add hooks to display our admin notices in the dashbaord and on our settings page.
|
40 |
+
add_action( 'admin_notices', array( $this, 'print_HTML' ) );
|
41 |
+
add_action( 'swp_admin_notices', array( $this, 'get_HTML' ) );
|
42 |
+
|
43 |
+
// Add a hook for permanently dismissing a notice via admin-ajax.php
|
44 |
+
add_action( 'wp_ajax_dismiss', array( $this, 'dismiss' ) );
|
45 |
+
add_action( 'wp_ajax_nopriv_dismiss', array( $this, 'dismiss' ) );
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Initialize the basics of this property.
|
52 |
+
*
|
53 |
+
* This method checks for the dismissed_notices options array in the database.
|
54 |
+
* If it doesn't exist, it creates it as an empty array. It then stores that
|
55 |
+
* array in a local property to control the display or non-display of this
|
56 |
+
* notice. It then finds the attributes for this specific notice and stores it
|
57 |
+
* in the local $data property.
|
58 |
+
*
|
59 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
60 |
+
* @access public
|
61 |
+
* @param null
|
62 |
+
* @return null
|
63 |
+
*
|
64 |
+
*/
|
65 |
+
public function init() {
|
66 |
+
$notices = get_option( 'social_warfare_dismissed_notices', false );
|
67 |
+
|
68 |
+
if ( false === $notices ) {
|
69 |
+
update_option( 'social_warfare_dismissed_notices', array() );
|
70 |
+
$notices = array();
|
71 |
+
}
|
72 |
+
|
73 |
+
$this->notices = $notices;
|
74 |
+
|
75 |
+
if ( isset( $notices[$this->key] ) ) :
|
76 |
+
$this->data = $notices[$this->key];
|
77 |
+
endif;
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
/**
|
82 |
+
* A method to determine if this notice should be displayed.
|
83 |
+
*
|
84 |
+
* This method lets the class now if this notice should be displayed or not. It checks
|
85 |
+
* thing like the start date, the end date, the dimissal status if it was temporarily
|
86 |
+
* dismissed versus permanently dismissed and so on.
|
87 |
+
*
|
88 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
89 |
+
* @access public
|
90 |
+
* @param null
|
91 |
+
* @return bool Default true.
|
92 |
+
*
|
93 |
+
*/
|
94 |
+
public function should_display_notice() {
|
95 |
+
$now = new DateTime();
|
96 |
+
$now = $now->format('Y-m-d H:i:s');
|
97 |
+
|
98 |
+
// If the start date has not been reached.
|
99 |
+
if ( isset( $this->start_date ) && $now < $this->start_date ) {
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
|
103 |
+
// If the end date has been reached.
|
104 |
+
if( isset( $this->end_date ) && $now > $this->end_date ) {
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
|
108 |
+
//* No dismissal has happened yet.
|
109 |
+
if ( empty( $this->data['timestamp']) ) :
|
110 |
+
return true;
|
111 |
+
endif;
|
112 |
+
|
113 |
+
//* They have dismissed a permadismiss.
|
114 |
+
if ( isset( $this->data['timestamp'] ) && $this->data['timeframe'] == 0) {
|
115 |
+
return false;
|
116 |
+
}
|
117 |
+
|
118 |
+
//* They have dismissed with a temp CTA.
|
119 |
+
if ( isset( $this->data['timeframe'] ) && $this->data['timeframe'] > 0 ) {
|
120 |
+
|
121 |
+
$expiry = $this->data['timestamp'];
|
122 |
+
|
123 |
+
return $now > $expiry;
|
124 |
+
}
|
125 |
+
|
126 |
+
return true;
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Processes notice dismissals via ajax.
|
132 |
+
*
|
133 |
+
* This is the method that is added to the Wordpress admin-ajax hooks.
|
134 |
+
*
|
135 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
136 |
+
* @access public
|
137 |
+
* @param null
|
138 |
+
* @return null The response from update_option is echoed.
|
139 |
+
*
|
140 |
+
*/
|
141 |
+
public function dismiss() {
|
142 |
+
$key = $_POST['key'];
|
143 |
+
$timeframe = $_POST['timeframe'];
|
144 |
+
$now = new DateTime();
|
145 |
+
|
146 |
+
if ( 0 < $timeframe ) {
|
147 |
+
$timestamp = $now->modify("+$timeframe days")->format('Y-m-d H:i:s');
|
148 |
+
} else {
|
149 |
+
$timestamp = $now->format('Y-m-d H:i:s');
|
150 |
+
}
|
151 |
+
|
152 |
+
$this->notices[$key]['timestamp'] = $timestamp;
|
153 |
+
$this->notices[$key]['timeframe'] = $timeframe;
|
154 |
+
|
155 |
+
echo json_encode( update_option( 'social_warfare_dismissed_notices', $this->notices ) );
|
156 |
+
wp_die();
|
157 |
+
}
|
158 |
+
|
159 |
+
|
160 |
+
/**
|
161 |
+
* A method to allow you to set the message text for this notice.
|
162 |
+
*
|
163 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
164 |
+
* @access public
|
165 |
+
* @param string $message A string of text for the notices message.
|
166 |
+
* @return object $this Allows for method chaining.
|
167 |
+
*
|
168 |
+
*/
|
169 |
+
public function set_message( $message ) {
|
170 |
+
if ( !is_string( $message ) ) :
|
171 |
+
throw("Please provide a string for your database key.");
|
172 |
+
endif;
|
173 |
+
|
174 |
+
$this->message = $message;
|
175 |
+
|
176 |
+
return $this;
|
177 |
+
}
|
178 |
+
|
179 |
+
|
180 |
+
/**
|
181 |
+
* A method to allow you to set the unique key for this notice.
|
182 |
+
*
|
183 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
184 |
+
* @access protected
|
185 |
+
* @param string $key A string representing this notices unique key.
|
186 |
+
* @return object $this Allows for method chaining.
|
187 |
+
*
|
188 |
+
*/
|
189 |
+
protected function set_key( $key ) {
|
190 |
+
if ( !is_string ( $key ) ) :
|
191 |
+
throw("Please provide a string for your database key.");
|
192 |
+
endif;
|
193 |
+
|
194 |
+
$this->key = $key;
|
195 |
+
|
196 |
+
return $this;
|
197 |
+
}
|
198 |
+
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Set a start date.
|
202 |
+
*
|
203 |
+
* This will allow us to schedule messages to be displayed at a specific date in the
|
204 |
+
* future. For example, before the StumbleUpon service goes away, we may want to post
|
205 |
+
* a notice letting folks know that it WILL BE going away. The day that they actually
|
206 |
+
* go away could be the start date for a notice that says that they HAVE gone away.
|
207 |
+
*
|
208 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
209 |
+
* @access public
|
210 |
+
* @param string $start_date A str date formatted to 'Y-m-d H:i:s'
|
211 |
+
* @return $this Allows for method chaining
|
212 |
+
* @TODO Add a type check, if possible, for a properly formatted date string.
|
213 |
+
*
|
214 |
+
*/
|
215 |
+
public function set_start_date( $start_date ) {
|
216 |
+
if ( $this->is_date( $start_date ) ) :
|
217 |
+
$this->start_date = $start_date;
|
218 |
+
endif;
|
219 |
+
|
220 |
+
return $this;
|
221 |
+
}
|
222 |
+
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Set an end date.
|
226 |
+
*
|
227 |
+
* This will allow us to schedule messages to stop being displayed at a specific date
|
228 |
+
* in the future. For example, before the StumbleUpon service goes away, we may want
|
229 |
+
* to post a notice letting folks know that it WILL BE going away. The day that they
|
230 |
+
* actually go away could be the end date for that notice and the start date for a
|
231 |
+
* notice that says that they HAVE gone away. Additionally, we may only want to notify
|
232 |
+
* people about StumbleUpon having gone away for 60 days after it happens. After that,
|
233 |
+
* we can just assume that they've probably heard from somewhere else and not worry
|
234 |
+
* about showing a notice message.
|
235 |
+
*
|
236 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
237 |
+
* @access public
|
238 |
+
* @param string $end_date A str date formatted to 'Y-m-d H:i:s'
|
239 |
+
* @return $this Allows for method chaining
|
240 |
+
* @TODO Add a type check, if possible, for a properly formatted date string.
|
241 |
+
*
|
242 |
+
*/
|
243 |
+
public function set_end_date( $end_date ) {
|
244 |
+
if ( $this->is_date( $end_date ) ) :
|
245 |
+
$this->end_date = $end_date;
|
246 |
+
endif;
|
247 |
+
|
248 |
+
return $this;
|
249 |
+
}
|
250 |
+
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Creates the interactive CTA for the notice.
|
254 |
+
*
|
255 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
256 |
+
* @access public
|
257 |
+
* @param string $action Optional. The message to be displayed. Default "Thanks, I understand."
|
258 |
+
* @param string $link Optional. The outbound link.
|
259 |
+
* @param string $class Optional. The CSS classname to assign to the CTA.
|
260 |
+
* @param string $timeframe
|
261 |
+
* @return $this Allows for method chaining.
|
262 |
+
*
|
263 |
+
*/
|
264 |
+
public function add_cta( $action = '', $link = '', $class = '' , $timeframe = 0 ) {
|
265 |
+
if ( '' === $action ) :
|
266 |
+
$action = "Thanks, I understand.";
|
267 |
+
endif;
|
268 |
+
|
269 |
+
if ( !empty( $link ) ) :
|
270 |
+
$link = ' href="' . $link . '" target="_blank"';
|
271 |
+
endif;
|
272 |
+
|
273 |
+
$cta = array();
|
274 |
+
$cta['action'] = $action;
|
275 |
+
$cta['link'] = $link;
|
276 |
+
$cta['class'] = $class;
|
277 |
+
$cta['timeframe'] = $timeframe;
|
278 |
+
|
279 |
+
$this->actions[] = $cta;
|
280 |
+
|
281 |
+
return $this;
|
282 |
+
}
|
283 |
+
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Render out the HTML.
|
287 |
+
*
|
288 |
+
* Ideally, everything before this method will create a beautiful data-oriented
|
289 |
+
* object. The only HTML that should be compiled should be inside this method.
|
290 |
+
*
|
291 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
292 |
+
* @access public
|
293 |
+
* @param null
|
294 |
+
* @return string The compiled HTML of the dashboard notice.
|
295 |
+
*
|
296 |
+
*/
|
297 |
+
public function render_HTML() {
|
298 |
+
if ( empty( $this->actions) ) :
|
299 |
+
$this->add_cta();
|
300 |
+
endif;
|
301 |
+
|
302 |
+
$html = '<div class="swp-dismiss-notice notice notice-info " data-key="' . $this->key . '">';
|
303 |
+
$html .= '<p>' . $this->message . ' - Warfare Plugins Team</p>';
|
304 |
+
$html .= '<div class="swp-actions">';
|
305 |
+
|
306 |
+
foreach( $this->actions as $cta) {
|
307 |
+
$html .= '<a class="swp-notice-cta ' . $cta['class'] . '" ' . $cta['link'] . ' data-timeframe="'.$cta['timeframe'].'">';
|
308 |
+
$html .= $cta['action'];
|
309 |
+
$html .= "</a>";
|
310 |
+
}
|
311 |
+
|
312 |
+
$html .= '</div>';
|
313 |
+
$html .= '</div>';
|
314 |
+
|
315 |
+
$this->html = $html;
|
316 |
+
|
317 |
+
return $this;
|
318 |
+
}
|
319 |
+
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Gets (returns) the HTML for this notice.
|
323 |
+
*
|
324 |
+
* We have two separate methods for this. One for returning the HTML, and
|
325 |
+
* one for echoing the html. This one returns it.
|
326 |
+
*
|
327 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
328 |
+
* @access public
|
329 |
+
* @param string $notices The string of notices to be modified.
|
330 |
+
* @return string The modified string of notices' html.
|
331 |
+
*
|
332 |
+
*/
|
333 |
+
public function get_HTML( $notices = '' ) {
|
334 |
+
|
335 |
+
if ( !$this->should_display_notice() ) :
|
336 |
+
return $notices;
|
337 |
+
endif;
|
338 |
+
|
339 |
+
if ( empty( $this->html ) ) :
|
340 |
+
$this->render_HTML();
|
341 |
+
endif;
|
342 |
+
|
343 |
+
return $notices .= $this->html;
|
344 |
+
}
|
345 |
+
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Echos the HTML for this notice.
|
349 |
+
*
|
350 |
+
* We have two separate methods for this. One for returning the HTML, and
|
351 |
+
* one for echoing the html. This one echos it.
|
352 |
+
*
|
353 |
+
* @since 3.0.9 | 07 JUN 2018 | Created
|
354 |
+
* @access public
|
355 |
+
* @param string $notices The string of notices to be modified.
|
356 |
+
* @return string The modified string of notices' html.
|
357 |
+
*
|
358 |
+
*/
|
359 |
+
public function print_HTML() {
|
360 |
+
if ( !$this->should_display_notice() ) :
|
361 |
+
return;
|
362 |
+
endif;
|
363 |
+
|
364 |
+
if ( empty( $this->html ) ) :
|
365 |
+
$this->render_HTML();
|
366 |
+
endif;
|
367 |
+
|
368 |
+
echo $this->html;
|
369 |
+
|
370 |
+
return $this;
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Checks whether a string is formatted as our default Date format.
|
375 |
+
*
|
376 |
+
* @since 3.0.9 | 08 JUN 2018 | Created
|
377 |
+
* @param string $string The datetime string in question.
|
378 |
+
* @return bool True iff the string is of the format 'Y-m-d h:i:s'.
|
379 |
+
*
|
380 |
+
*/
|
381 |
+
private function is_date( $string ) {
|
382 |
+
return DateTime::createFromFormat( 'Y-m-d h:i:s', $string ) !== false;
|
383 |
+
}
|
384 |
+
}
|
functions/utilities/SWP_Notice_Loader.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* SWP_Notice_Loader
|
5 |
+
*
|
6 |
+
* This is where we define all the messages, CTAs, and scheudling for each notice.
|
7 |
+
* It is fine to bloat the method with as many notices as necessary.
|
8 |
+
*
|
9 |
+
* @since 3.0.9 | 09 JUN 2018 | Created the class.
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
class SWP_Notice_Loader {
|
13 |
+
public function __construct() {
|
14 |
+
$this->do_notices();
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Creates and instantiates the notices.
|
19 |
+
*
|
20 |
+
*
|
21 |
+
* @since 3.0.9 | 09 JUN 2018 | Created the method.
|
22 |
+
* @param void
|
23 |
+
* @return void
|
24 |
+
*/
|
25 |
+
public function do_notices() {
|
26 |
+
$message = 'As of June 30th, 2018, StumbleUpon will no longer exist as a sharing platform. Instead, they are moving in with Mix. ';
|
27 |
+
$message .= 'While this is exciting for Mix, <b>share counts will not be transferred, and Mix is not providing a share button or API. </b>';
|
28 |
+
$message .= 'You can read more about it <a href="http://help.stumbleupon.com/customer/en/portal/articles/2908172-transitioning-from-stumbleupon-to-mix" target="_blank">here</a>.';
|
29 |
+
|
30 |
+
$notice = new SWP_Notice( 'stumble_upon_closed', $message, 'notice-info' );
|
31 |
+
}
|
32 |
+
}
|
functions/utilities/SWP_URL_Management.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* networks. This class will shorten them via Bitly or add Google Analytics tracking
|
8 |
* parameters if the user has either of these options enabled and configured.
|
9 |
*
|
10 |
-
* @since 3.0.0 | 14 FEB 2018 | Added check for is_attachment() to
|
11 |
* @since 3.0.0 | 04 APR 2018 | Converted to class-based, object-oriented system.
|
12 |
*
|
13 |
*/
|
@@ -56,14 +56,14 @@ class SWP_URL_Management {
|
|
56 |
$url = $array['url'];
|
57 |
$network = $array['network'];
|
58 |
|
59 |
-
if( ( 'pinterest' === $network && isset( $swp_user_options['utm_on_pins']) && true === $swp_user_options['utm_on_pins']) || $network !== 'pinterest' ):
|
60 |
|
61 |
if ( true === is_attachment() ) :
|
62 |
return $array;
|
63 |
endif;
|
64 |
|
65 |
// Check if Analytics have been enabled or not
|
66 |
-
if ( true ==
|
67 |
$url_string = 'utm_source=' . $network . '&utm_medium=' . $options['analytics_medium'] . '&utm_campaign=' . $options['analytics_campaign'] . '';
|
68 |
|
69 |
if ( strpos( $url,'?' ) !== false ) :
|
@@ -125,7 +125,7 @@ class SWP_URL_Management {
|
|
125 |
$access_token = $options['bitly_access_token'];
|
126 |
|
127 |
// If Google Analytics is Activated....
|
128 |
-
if (
|
129 |
|
130 |
// If the link has already been shortened....
|
131 |
$existingURL = get_post_meta( $postID,'bitly_link_' . $network,true );
|
7 |
* networks. This class will shorten them via Bitly or add Google Analytics tracking
|
8 |
* parameters if the user has either of these options enabled and configured.
|
9 |
*
|
10 |
+
* @since 3.0.0 | 14 FEB 2018 | Added check for is_attachment() to swp_google_analytics
|
11 |
* @since 3.0.0 | 04 APR 2018 | Converted to class-based, object-oriented system.
|
12 |
*
|
13 |
*/
|
56 |
$url = $array['url'];
|
57 |
$network = $array['network'];
|
58 |
|
59 |
+
if( ( 'pinterest' === $network && isset( $swp_user_options['utm_on_pins']) && true === $swp_user_options['utm_on_pins']) || $network !== 'pinterest' ) :
|
60 |
|
61 |
if ( true === is_attachment() ) :
|
62 |
return $array;
|
63 |
endif;
|
64 |
|
65 |
// Check if Analytics have been enabled or not
|
66 |
+
if ( true == swp_get_option('google_analytics') ) :
|
67 |
$url_string = 'utm_source=' . $network . '&utm_medium=' . $options['analytics_medium'] . '&utm_campaign=' . $options['analytics_campaign'] . '';
|
68 |
|
69 |
if ( strpos( $url,'?' ) !== false ) :
|
125 |
$access_token = $options['bitly_access_token'];
|
126 |
|
127 |
// If Google Analytics is Activated....
|
128 |
+
if ( swp_get_option('google_analytics') == true ) :
|
129 |
|
130 |
// If the link has already been shortened....
|
131 |
$existingURL = get_post_meta( $postID,'bitly_link_' . $network,true );
|
functions/utilities/share-cache.php
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
* Control the cache rebuild processes for share counts
|
5 |
*
|
@@ -13,7 +12,6 @@
|
|
13 |
|
14 |
defined( 'WPINC' ) || die;
|
15 |
|
16 |
-
|
17 |
/**
|
18 |
* Register custom query vars.
|
19 |
*
|
@@ -36,17 +34,20 @@ add_filter( 'query_vars', 'swp_add_query_vars' );
|
|
36 |
* @param array $request The current query request.
|
37 |
* @return array $request The modified query request.
|
38 |
*/
|
39 |
-
add_filter( 'request', 'swp_alter_the_query' );
|
40 |
function swp_alter_the_query( $request ) {
|
41 |
$dummy_query = new WP_Query(); // the query isn't run if we don't pass any query vars
|
42 |
$dummy_query->parse_query( $request );
|
43 |
-
|
|
|
44 |
unset($request['swp_cache']);
|
45 |
-
|
|
|
46 |
return $request;
|
47 |
}
|
|
|
|
|
|
|
48 |
|
49 |
-
add_filter( 'swp_meta_tags', 'swp_cache_rebuild_rel_canonical', 7 );
|
50 |
/**
|
51 |
* Use a rel canonical so search engines know this is not a real page.
|
52 |
*
|
@@ -55,12 +56,14 @@ add_filter( 'swp_meta_tags', 'swp_cache_rebuild_rel_canonical', 7 );
|
|
55 |
* @return array $info Meta tag info.
|
56 |
*/
|
57 |
function swp_cache_rebuild_rel_canonical( $info ) {
|
58 |
-
if ( 'rebuild' === $_GET['swp_cache'] )
|
59 |
$info['header_output'] .= '<link rel="canonical" href="' . get_permalink() . '">';
|
60 |
-
|
61 |
|
62 |
return $info;
|
63 |
}
|
|
|
|
|
64 |
|
65 |
/**
|
66 |
* Cache checking function
|
@@ -77,6 +80,10 @@ function swp_is_cache_fresh( $post_id, $output = false, $ajax = false ) {
|
|
77 |
|
78 |
// Bail early if it's a crawl bot. If so, ONLY SERVE CACHED RESULTS FOR MAXIMUM SPEED.
|
79 |
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/bot|crawl|slurp|spider/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) {
|
|
|
|
|
|
|
|
|
80 |
return true;
|
81 |
}
|
82 |
|
@@ -85,23 +92,37 @@ function swp_is_cache_fresh( $post_id, $output = false, $ajax = false ) {
|
|
85 |
$fresh_cache = false;
|
86 |
|
87 |
// Bail if output isn't being forced and legacy caching isn't enabled.
|
88 |
-
if (
|
|
|
89 |
if ( empty( $_GET['swp_cache'] ) && empty( $_POST['swp_cache'] ) ) {
|
90 |
$fresh_cache = true;
|
91 |
}
|
92 |
|
|
|
|
|
|
|
|
|
93 |
return $fresh_cache;
|
94 |
}
|
95 |
|
96 |
if( isset( $_POST['swp_cache'] ) && 'rebuild' === $_POST['swp_cache'] ) {
|
|
|
|
|
|
|
|
|
|
|
97 |
return false;
|
98 |
}
|
99 |
|
100 |
// Always be TRUE if we're not on a single.php otherwise we could end up
|
101 |
// Rebuilding multiple page caches which will cost a lot of time.
|
102 |
-
if ( ! is_singular() && ! $ajax )
|
|
|
|
|
|
|
|
|
103 |
return true;
|
104 |
-
|
105 |
|
106 |
$post_age = floor( date( 'U' ) - get_post_time( 'U' , false , $post_id ) );
|
107 |
|
@@ -116,19 +137,26 @@ function swp_is_cache_fresh( $post_id, $output = false, $ajax = false ) {
|
|
116 |
$time = floor( ( ( date( 'U' ) / 60 ) / 60 ) );
|
117 |
$last_checked = get_post_meta( $post_id, 'swp_cache_timestamp', true );
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
if ( $last_checked > ( $time - $hours ) && $last_checked > 390000 ) {
|
120 |
$fresh_cache = true;
|
121 |
} else {
|
122 |
$fresh_cache = false;
|
123 |
}
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
|
129 |
return $fresh_cache;
|
130 |
}
|
131 |
|
|
|
132 |
add_action( 'wp_ajax_swp_cache_trigger', 'swp_cache_rebuild' );
|
133 |
add_action( 'wp_ajax_nopriv_swp_cache_trigger', 'swp_cache_rebuild' );
|
134 |
|
@@ -196,6 +224,7 @@ function swp_cache_rebuild() {
|
|
196 |
wp_die();
|
197 |
}
|
198 |
|
|
|
199 |
/**
|
200 |
* A function to reset the cache timestamp with the current time
|
201 |
*
|
@@ -209,6 +238,7 @@ function swp_cache_reset_timestamp($post_id) {
|
|
209 |
update_post_meta( $post_id , 'swp_cache_timestamp' , floor( ( ( date( 'U' ) / 60 ) / 60 ) ) );
|
210 |
}
|
211 |
|
|
|
212 |
/**
|
213 |
* A function to delete the current timestamp
|
214 |
*
|
@@ -218,6 +248,8 @@ function swp_cache_reset_timestamp($post_id) {
|
|
218 |
function swp_cache_delete_timestamp() {
|
219 |
delete_post_meta( get_the_ID() , 'swp_cache_timestamp' );
|
220 |
}
|
|
|
|
|
221 |
add_action( 'save_post', 'swp_cache_delete_timestamp' );
|
222 |
add_action( 'save_post', 'swp_cache_store_autoloads' );
|
223 |
add_action( 'save_post', 'swp_clear_bitly_cache' );
|
@@ -225,6 +257,7 @@ add_action( 'publish_post', 'swp_cache_delete_timestamp' );
|
|
225 |
add_action( 'publish_post', 'swp_cache_store_autoloads' );
|
226 |
add_action( 'publish_post', 'swp_clear_bitly_cache' );
|
227 |
|
|
|
228 |
/**
|
229 |
* A function to clear Bitly's cache when the post is UPDATED. This way if they change the permalink, it will fetch new links.
|
230 |
*
|
@@ -241,6 +274,7 @@ function swp_clear_bitly_cache() {
|
|
241 |
delete_post_meta( get_the_ID() ,'bitly_link' );
|
242 |
}
|
243 |
|
|
|
244 |
/**
|
245 |
* A function to store all the fields for autoloading
|
246 |
*
|
@@ -252,6 +286,8 @@ function swp_cache_store_autoloads() {
|
|
252 |
swp_cache_rebuild_pin_image($post_id);
|
253 |
swp_cache_rebuild_og_image($post_id);
|
254 |
}
|
|
|
|
|
255 |
/**
|
256 |
* Open Graph Image
|
257 |
*
|
@@ -265,9 +301,9 @@ function swp_cache_store_autoloads() {
|
|
265 |
* @return void
|
266 |
*/
|
267 |
function swp_cache_rebuild_og_image($post_id) {
|
268 |
-
|
269 |
-
// Check if an OG image has been declared
|
270 |
$image_id = get_post_meta( $post_id , 'swp_og_image' , true );
|
|
|
271 |
if ( $image_id ):
|
272 |
|
273 |
$cur_image_url = get_post_meta( $post_id , 'swp_open_graph_image_url' , true );
|
@@ -288,6 +324,8 @@ function swp_cache_rebuild_og_image($post_id) {
|
|
288 |
delete_post_meta( $post_id,'swp_open_graph_image_url' );
|
289 |
endif;
|
290 |
}
|
|
|
|
|
291 |
/**
|
292 |
* Pinterest Image
|
293 |
*
|
@@ -301,9 +339,9 @@ function swp_cache_rebuild_og_image($post_id) {
|
|
301 |
* @return void
|
302 |
*/
|
303 |
function swp_cache_rebuild_pin_image($post_id) {
|
304 |
-
|
305 |
// Check if a custom pinterest image has been declared
|
306 |
$pin_image_id = get_post_meta( $post_id , 'swp_pinterest_image' , true );
|
|
|
307 |
if ( false !== $pin_image_id ) :
|
308 |
$pin_image_url = wp_get_attachment_url( $pin_image_id );
|
309 |
$cur_image_url = get_post_meta( $post_id , 'swp_pinterest_image_url' , true );
|
@@ -313,20 +351,19 @@ function swp_cache_rebuild_pin_image($post_id) {
|
|
313 |
delete_post_meta( $post_id,'swp_pinterest_image_url' );
|
314 |
update_post_meta( $post_id,'swp_pinterest_image_url' , $pin_image_url );
|
315 |
endif;
|
|
|
316 |
else:
|
317 |
delete_post_meta( $post_id , 'swp_pinterest_image_url' );
|
318 |
endif;
|
319 |
}
|
320 |
|
|
|
321 |
/**
|
322 |
* Update Facebook share counts.
|
323 |
*
|
324 |
* @since 2.1.0
|
325 |
* @return void
|
326 |
*/
|
327 |
-
|
328 |
-
add_action( 'wp_ajax_swp_facebook_shares_update', 'swp_facebook_shares_update' );
|
329 |
-
add_action( 'wp_ajax_nopriv_swp_facebook_shares_update', 'swp_facebook_shares_update' );
|
330 |
function swp_facebook_shares_update() {
|
331 |
$post_id = $_POST['post_id'];
|
332 |
$activity = $_POST['activity'];
|
@@ -342,8 +379,9 @@ function swp_facebook_shares_update() {
|
|
342 |
|
343 |
wp_die();
|
344 |
}
|
|
|
|
|
345 |
|
346 |
-
add_filter( 'swp_footer_scripts' , 'swp_output_cache_trigger' );
|
347 |
|
348 |
/**
|
349 |
* Trigger cache rebuild.
|
@@ -354,7 +392,6 @@ add_filter( 'swp_footer_scripts' , 'swp_output_cache_trigger' );
|
|
354 |
* @return array $info A modified array of footer script information.
|
355 |
*/
|
356 |
function swp_output_cache_trigger( $info ) {
|
357 |
-
|
358 |
// Make sure the post is published, otherwise don't attempt to update counts
|
359 |
if('publish' == get_post_status($info['postID']) ):
|
360 |
|
@@ -381,7 +418,7 @@ function swp_output_cache_trigger( $info ) {
|
|
381 |
});
|
382 |
}
|
383 |
|
384 |
-
|
385 |
$info['footer_output'] .= ob_get_clean();
|
386 |
return $info;
|
387 |
}
|
@@ -397,72 +434,81 @@ function swp_output_cache_trigger( $info ) {
|
|
397 |
}
|
398 |
|
399 |
// Trigger the cache rebuild.
|
400 |
-
if ( ( isset($_GET['swp_cache']) && 'rebuild' === $_GET['swp_cache'] ) || false === swp_is_cache_fresh( get_the_ID(), true ) )
|
401 |
ob_start();
|
402 |
|
403 |
?>
|
404 |
var within_timelimit;
|
405 |
swp_admin_ajax = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
|
406 |
var swp_buttons_exist = (document.getElementsByClassName( 'swp_social_panel' ).length > 0);
|
|
|
407 |
if ( swp_buttons_exist ) {
|
408 |
document.addEventListener('DOMContentLoaded', function() {
|
409 |
var swp_check_for_js = setInterval( function() {
|
410 |
if( 'undefined' !== typeof socialWarfarePlugin) {
|
411 |
clearInterval(swp_check_for_js);
|
|
|
412 |
<?php if( isset($_GET['swp_cache']) && 'rebuild' === $_GET['swp_cache'] ): ?>
|
|
|
413 |
var swp_cache_data = {
|
414 |
'action': 'swp_cache_trigger',
|
415 |
'post_id': <?php echo $info['postID']; ?>,
|
416 |
'timestamp': <?php echo time(); ?>,
|
417 |
'force':true
|
418 |
};
|
|
|
419 |
<?php else: ?>
|
|
|
420 |
var swp_cache_data = {
|
421 |
'action': 'swp_cache_trigger',
|
422 |
'post_id': <?php echo $info['postID']; ?>,
|
423 |
'timestamp': <?php echo time(); ?>
|
424 |
};
|
|
|
425 |
<?php endif; ?>
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
|
|
449 |
}
|
450 |
} , 250 );
|
451 |
});
|
|
|
452 |
swp_post_id='<?php echo $info['postID']; ?>';
|
453 |
swp_post_url='<?php echo get_permalink(); ?>';
|
454 |
swp_post_recovery_url = '<?php echo $alternateURL; ?>';
|
455 |
|
456 |
-
//
|
457 |
}
|
458 |
<?php
|
459 |
$info['footer_output'] .= ob_get_clean();
|
460 |
-
|
461 |
-
|
462 |
endif;
|
463 |
|
464 |
return $info;
|
465 |
}
|
|
|
|
|
466 |
|
467 |
/**
|
468 |
* A function to remove fields that we no longer use
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Control the cache rebuild processes for share counts
|
4 |
*
|
12 |
|
13 |
defined( 'WPINC' ) || die;
|
14 |
|
|
|
15 |
/**
|
16 |
* Register custom query vars.
|
17 |
*
|
34 |
* @param array $request The current query request.
|
35 |
* @return array $request The modified query request.
|
36 |
*/
|
|
|
37 |
function swp_alter_the_query( $request ) {
|
38 |
$dummy_query = new WP_Query(); // the query isn't run if we don't pass any query vars
|
39 |
$dummy_query->parse_query( $request );
|
40 |
+
|
41 |
+
if(isset($request['swp_cache'])) :
|
42 |
unset($request['swp_cache']);
|
43 |
+
endif;
|
44 |
+
|
45 |
return $request;
|
46 |
}
|
47 |
+
add_filter( 'request', 'swp_alter_the_query' );
|
48 |
+
|
49 |
+
|
50 |
|
|
|
51 |
/**
|
52 |
* Use a rel canonical so search engines know this is not a real page.
|
53 |
*
|
56 |
* @return array $info Meta tag info.
|
57 |
*/
|
58 |
function swp_cache_rebuild_rel_canonical( $info ) {
|
59 |
+
if ( 'rebuild' === $_GET['swp_cache'] ) :
|
60 |
$info['header_output'] .= '<link rel="canonical" href="' . get_permalink() . '">';
|
61 |
+
endif;
|
62 |
|
63 |
return $info;
|
64 |
}
|
65 |
+
add_filter( 'swp_meta_tags', 'swp_cache_rebuild_rel_canonical', 7 );
|
66 |
+
|
67 |
|
68 |
/**
|
69 |
* Cache checking function
|
80 |
|
81 |
// Bail early if it's a crawl bot. If so, ONLY SERVE CACHED RESULTS FOR MAXIMUM SPEED.
|
82 |
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/bot|crawl|slurp|spider/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) {
|
83 |
+
if ( _swp_is_debug( 'is_cache_fresh' ) ) :
|
84 |
+
echo "The cache is fresh: " . (int) $fresh_cache . ' on line number ' . __LINE__;
|
85 |
+
endif;
|
86 |
+
|
87 |
return true;
|
88 |
}
|
89 |
|
92 |
$fresh_cache = false;
|
93 |
|
94 |
// Bail if output isn't being forced and legacy caching isn't enabled.
|
95 |
+
if ( !$output && isset( $options['cache_method'] ) && 'legacy' !== $options['cache_method'] ) {
|
96 |
+
|
97 |
if ( empty( $_GET['swp_cache'] ) && empty( $_POST['swp_cache'] ) ) {
|
98 |
$fresh_cache = true;
|
99 |
}
|
100 |
|
101 |
+
if ( _swp_is_debug( 'is_cache_fresh' ) ) {
|
102 |
+
echo "The cache is fresh: " . (int) $fresh_cache . ' on line number ' . __LINE__;
|
103 |
+
}
|
104 |
+
|
105 |
return $fresh_cache;
|
106 |
}
|
107 |
|
108 |
if( isset( $_POST['swp_cache'] ) && 'rebuild' === $_POST['swp_cache'] ) {
|
109 |
+
|
110 |
+
if ( _swp_is_debug( 'is_cache_fresh' ) ) :
|
111 |
+
echo "The cache is fresh: " . (int) $fresh_cache . ' on line number ' . __LINE__;
|
112 |
+
endif;
|
113 |
+
|
114 |
return false;
|
115 |
}
|
116 |
|
117 |
// Always be TRUE if we're not on a single.php otherwise we could end up
|
118 |
// Rebuilding multiple page caches which will cost a lot of time.
|
119 |
+
if ( ! is_singular() && ! $ajax ) :
|
120 |
+
if ( _swp_is_debug( 'is_cache_fresh' ) ) :
|
121 |
+
echo "The cache is fresh: " . (int) $fresh_cache . ' on line number ' . __LINE__;
|
122 |
+
endif;
|
123 |
+
|
124 |
return true;
|
125 |
+
endif;
|
126 |
|
127 |
$post_age = floor( date( 'U' ) - get_post_time( 'U' , false , $post_id ) );
|
128 |
|
137 |
$time = floor( ( ( date( 'U' ) / 60 ) / 60 ) );
|
138 |
$last_checked = get_post_meta( $post_id, 'swp_cache_timestamp', true );
|
139 |
|
140 |
+
if ( _swp_is_debug( 'is_cache_fresh' ) ) :
|
141 |
+
echo "<br/>Time: ", var_dump($time);
|
142 |
+
echo "<br/>Last_checked: ", var_dump($last_checked);
|
143 |
+
echo "<br/>Hours: ", var_dump($hours);
|
144 |
+
endif;
|
145 |
+
|
146 |
if ( $last_checked > ( $time - $hours ) && $last_checked > 390000 ) {
|
147 |
$fresh_cache = true;
|
148 |
} else {
|
149 |
$fresh_cache = false;
|
150 |
}
|
151 |
|
152 |
+
if ( _swp_is_debug( 'is_cache_fresh' ) ) :
|
153 |
+
echo "The cache is fresh: " . (int) $fresh_cache . ' on line number ' . __LINE__;
|
154 |
+
endif;
|
155 |
|
156 |
return $fresh_cache;
|
157 |
}
|
158 |
|
159 |
+
|
160 |
add_action( 'wp_ajax_swp_cache_trigger', 'swp_cache_rebuild' );
|
161 |
add_action( 'wp_ajax_nopriv_swp_cache_trigger', 'swp_cache_rebuild' );
|
162 |
|
224 |
wp_die();
|
225 |
}
|
226 |
|
227 |
+
|
228 |
/**
|
229 |
* A function to reset the cache timestamp with the current time
|
230 |
*
|
238 |
update_post_meta( $post_id , 'swp_cache_timestamp' , floor( ( ( date( 'U' ) / 60 ) / 60 ) ) );
|
239 |
}
|
240 |
|
241 |
+
|
242 |
/**
|
243 |
* A function to delete the current timestamp
|
244 |
*
|
248 |
function swp_cache_delete_timestamp() {
|
249 |
delete_post_meta( get_the_ID() , 'swp_cache_timestamp' );
|
250 |
}
|
251 |
+
|
252 |
+
|
253 |
add_action( 'save_post', 'swp_cache_delete_timestamp' );
|
254 |
add_action( 'save_post', 'swp_cache_store_autoloads' );
|
255 |
add_action( 'save_post', 'swp_clear_bitly_cache' );
|
257 |
add_action( 'publish_post', 'swp_cache_store_autoloads' );
|
258 |
add_action( 'publish_post', 'swp_clear_bitly_cache' );
|
259 |
|
260 |
+
|
261 |
/**
|
262 |
* A function to clear Bitly's cache when the post is UPDATED. This way if they change the permalink, it will fetch new links.
|
263 |
*
|
274 |
delete_post_meta( get_the_ID() ,'bitly_link' );
|
275 |
}
|
276 |
|
277 |
+
|
278 |
/**
|
279 |
* A function to store all the fields for autoloading
|
280 |
*
|
286 |
swp_cache_rebuild_pin_image($post_id);
|
287 |
swp_cache_rebuild_og_image($post_id);
|
288 |
}
|
289 |
+
|
290 |
+
|
291 |
/**
|
292 |
* Open Graph Image
|
293 |
*
|
301 |
* @return void
|
302 |
*/
|
303 |
function swp_cache_rebuild_og_image($post_id) {
|
304 |
+
// Check if an OG image has been declared
|
|
|
305 |
$image_id = get_post_meta( $post_id , 'swp_og_image' , true );
|
306 |
+
|
307 |
if ( $image_id ):
|
308 |
|
309 |
$cur_image_url = get_post_meta( $post_id , 'swp_open_graph_image_url' , true );
|
324 |
delete_post_meta( $post_id,'swp_open_graph_image_url' );
|
325 |
endif;
|
326 |
}
|
327 |
+
|
328 |
+
|
329 |
/**
|
330 |
* Pinterest Image
|
331 |
*
|
339 |
* @return void
|
340 |
*/
|
341 |
function swp_cache_rebuild_pin_image($post_id) {
|
|
|
342 |
// Check if a custom pinterest image has been declared
|
343 |
$pin_image_id = get_post_meta( $post_id , 'swp_pinterest_image' , true );
|
344 |
+
|
345 |
if ( false !== $pin_image_id ) :
|
346 |
$pin_image_url = wp_get_attachment_url( $pin_image_id );
|
347 |
$cur_image_url = get_post_meta( $post_id , 'swp_pinterest_image_url' , true );
|
351 |
delete_post_meta( $post_id,'swp_pinterest_image_url' );
|
352 |
update_post_meta( $post_id,'swp_pinterest_image_url' , $pin_image_url );
|
353 |
endif;
|
354 |
+
|
355 |
else:
|
356 |
delete_post_meta( $post_id , 'swp_pinterest_image_url' );
|
357 |
endif;
|
358 |
}
|
359 |
|
360 |
+
|
361 |
/**
|
362 |
* Update Facebook share counts.
|
363 |
*
|
364 |
* @since 2.1.0
|
365 |
* @return void
|
366 |
*/
|
|
|
|
|
|
|
367 |
function swp_facebook_shares_update() {
|
368 |
$post_id = $_POST['post_id'];
|
369 |
$activity = $_POST['activity'];
|
379 |
|
380 |
wp_die();
|
381 |
}
|
382 |
+
add_action( 'wp_ajax_swp_facebook_shares_update', 'swp_facebook_shares_update' );
|
383 |
+
add_action( 'wp_ajax_nopriv_swp_facebook_shares_update', 'swp_facebook_shares_update' );
|
384 |
|
|
|
385 |
|
386 |
/**
|
387 |
* Trigger cache rebuild.
|
392 |
* @return array $info A modified array of footer script information.
|
393 |
*/
|
394 |
function swp_output_cache_trigger( $info ) {
|
|
|
395 |
// Make sure the post is published, otherwise don't attempt to update counts
|
396 |
if('publish' == get_post_status($info['postID']) ):
|
397 |
|
418 |
});
|
419 |
}
|
420 |
|
421 |
+
<?php
|
422 |
$info['footer_output'] .= ob_get_clean();
|
423 |
return $info;
|
424 |
}
|
434 |
}
|
435 |
|
436 |
// Trigger the cache rebuild.
|
437 |
+
if ( ( isset($_GET['swp_cache']) && 'rebuild' === $_GET['swp_cache'] ) || false === swp_is_cache_fresh( get_the_ID(), true ) ) :
|
438 |
ob_start();
|
439 |
|
440 |
?>
|
441 |
var within_timelimit;
|
442 |
swp_admin_ajax = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
|
443 |
var swp_buttons_exist = (document.getElementsByClassName( 'swp_social_panel' ).length > 0);
|
444 |
+
|
445 |
if ( swp_buttons_exist ) {
|
446 |
document.addEventListener('DOMContentLoaded', function() {
|
447 |
var swp_check_for_js = setInterval( function() {
|
448 |
if( 'undefined' !== typeof socialWarfarePlugin) {
|
449 |
clearInterval(swp_check_for_js);
|
450 |
+
|
451 |
<?php if( isset($_GET['swp_cache']) && 'rebuild' === $_GET['swp_cache'] ): ?>
|
452 |
+
|
453 |
var swp_cache_data = {
|
454 |
'action': 'swp_cache_trigger',
|
455 |
'post_id': <?php echo $info['postID']; ?>,
|
456 |
'timestamp': <?php echo time(); ?>,
|
457 |
'force':true
|
458 |
};
|
459 |
+
|
460 |
<?php else: ?>
|
461 |
+
|
462 |
var swp_cache_data = {
|
463 |
'action': 'swp_cache_trigger',
|
464 |
'post_id': <?php echo $info['postID']; ?>,
|
465 |
'timestamp': <?php echo time(); ?>
|
466 |
};
|
467 |
+
|
468 |
<?php endif; ?>
|
469 |
+
|
470 |
+
// if ( !swp_cache_data.timestamp ) { // error handling}
|
471 |
+
console.log( "Server Timestamp is " + swp_cache_data.timestamp );
|
472 |
+
var browser_date = Date.now();
|
473 |
+
if ( !browser_date )
|
474 |
+
browser_date = new Date().getTime();
|
475 |
+
browser_date = Math.floor( browser_date / 1000 );
|
476 |
+
console.log( "Browser Timestamp is " + browser_date );
|
477 |
+
var elapsed_time = ( browser_date - swp_cache_data.timestamp );
|
478 |
+
if ( elapsed_time > 60 ) {
|
479 |
+
console.log( "Elapsed time since server timestamp is greater than 60 seconds -- " + elapsed_time + "seconds" );
|
480 |
+
within_timelimit = false;
|
481 |
+
} else {
|
482 |
+
console.log( "Elapsed time since server timestamp is less than 60 seconds -- " + elapsed_time + "seconds" );
|
483 |
+
within_timelimit = true;
|
484 |
+
}
|
485 |
+
|
486 |
+
if ( within_timelimit === true ) {
|
487 |
+
jQuery.post( swp_admin_ajax, swp_cache_data, function( response ) {
|
488 |
+
console.log(response);
|
489 |
+
});
|
490 |
+
|
491 |
+
socialWarfarePlugin.fetchShares();
|
492 |
+
}
|
493 |
}
|
494 |
} , 250 );
|
495 |
});
|
496 |
+
|
497 |
swp_post_id='<?php echo $info['postID']; ?>';
|
498 |
swp_post_url='<?php echo get_permalink(); ?>';
|
499 |
swp_post_recovery_url = '<?php echo $alternateURL; ?>';
|
500 |
|
501 |
+
//socialWarfarePlugin.fetchShares();
|
502 |
}
|
503 |
<?php
|
504 |
$info['footer_output'] .= ob_get_clean();
|
505 |
+
endif;
|
|
|
506 |
endif;
|
507 |
|
508 |
return $info;
|
509 |
}
|
510 |
+
add_filter( 'swp_footer_scripts' , 'swp_output_cache_trigger' );
|
511 |
+
|
512 |
|
513 |
/**
|
514 |
* A function to remove fields that we no longer use
|
functions/utilities/share-count-function.php
CHANGED
@@ -18,7 +18,6 @@ function get_social_warfare_shares( $postID ) {
|
|
18 |
return false;
|
19 |
endif;
|
20 |
|
21 |
-
|
22 |
// Set the initial options
|
23 |
$options = $swp_user_options;
|
24 |
$url = apply_filters( 'swp_url_filter_function', get_permalink( $postID ) );
|
@@ -39,10 +38,8 @@ function get_social_warfare_shares( $postID ) {
|
|
39 |
// Queue up the networks that are available
|
40 |
$networks = $options['order_of_icons'];
|
41 |
|
42 |
-
|
43 |
-
|
44 |
if ( !is_array( $networks ) || count ( $networks ) === 0 ) :
|
45 |
-
|
46 |
endif;
|
47 |
|
48 |
$icons_array = array(
|
@@ -51,25 +48,24 @@ function get_social_warfare_shares( $postID ) {
|
|
51 |
|
52 |
foreach ( $networks as $network ) :
|
53 |
|
54 |
-
|
55 |
|
56 |
-
|
57 |
-
|
58 |
$shares[$network] = get_post_meta( $postID,'_' . $network . '_shares',true );
|
59 |
|
60 |
-
|
61 |
-
|
62 |
$old_shares[$network] = get_post_meta( $postID,'_' . $network . '_shares',true );
|
63 |
$api_links[$network] = $swp_social_networks[$network]->get_api_link( $url );
|
64 |
-
|
65 |
|
66 |
-
|
67 |
|
68 |
endforeach;
|
69 |
|
70 |
// Recover Shares From Previously Used URL Patterns
|
71 |
if ( true == $options['recover_shares'] && false == $fresh_cache ) :
|
72 |
-
|
73 |
$alternateURL = SWP_Permalink::get_alt_permalink( $postID );
|
74 |
$alternateURL = apply_filters( 'swp_recovery_filter', $alternateURL );
|
75 |
|
@@ -77,15 +73,14 @@ function get_social_warfare_shares( $postID ) {
|
|
77 |
$altURLs = apply_filters('swp_additional_url_to_check', $altURLs );
|
78 |
|
79 |
// Debug the Alternate URL being checked
|
80 |
-
if ( _swp_is_debug( 'recovery' ) )
|
81 |
echo $alternateURL;
|
82 |
echo $altURLs;
|
83 |
-
|
84 |
|
85 |
foreach ( $networks as $network ) :
|
86 |
|
87 |
if( isset( $swp_social_networks[$network] ) ):
|
88 |
-
|
89 |
$old_share_links[$network] = $swp_social_networks[$network]->get_api_link( $alternateURL );
|
90 |
|
91 |
if( !empty($altURLs) ):
|
@@ -100,12 +95,10 @@ function get_social_warfare_shares( $postID ) {
|
|
100 |
if ( $fresh_cache == true ) :
|
101 |
if ( get_post_meta( $postID,'_total_shares',true ) ) :
|
102 |
$shares['total_shares'] = get_post_meta( $postID, '_total_shares', true );
|
103 |
-
|
104 |
else :
|
105 |
$shares['total_shares'] = 0;
|
106 |
endif;
|
107 |
else :
|
108 |
-
|
109 |
// Fetch all the share counts asyncrounously
|
110 |
$raw_shares_array = SWP_CURL::fetch_shares_via_curl_multi( $api_links );
|
111 |
|
@@ -113,26 +106,28 @@ function get_social_warfare_shares( $postID ) {
|
|
113 |
$old_raw_shares_array = SWP_CURL::fetch_shares_via_curl_multi( $old_share_links );
|
114 |
endif;
|
115 |
|
|
|
|
|
|
|
116 |
foreach ( $networks as $network ) :
|
117 |
|
118 |
if( isset( $swp_social_networks[$network] ) ):
|
119 |
-
|
120 |
-
if ( ! isset( $raw_shares_array[$network] ) ) {
|
121 |
$raw_shares_array[$network] = 0;
|
122 |
-
|
123 |
|
124 |
-
if ( ! isset( $old_raw_shares_array[$network] ) )
|
125 |
$old_raw_shares_array[$network] = 0;
|
126 |
-
|
127 |
|
128 |
-
|
129 |
|
130 |
if ( $options['recover_shares'] == true ) :
|
131 |
|
132 |
$recovered_shares[$network] = $swp_social_networks[$network]->parse_api_response( $old_raw_shares_array[$network] );
|
133 |
|
134 |
-
if( !empty($altURLs) ):
|
135 |
-
|
136 |
$altURLs_recovered_shares[$network] = $swp_social_networks[$network]->parse_api_response( $altURLs_raw_shares_array[$network] );
|
137 |
endif;
|
138 |
|
@@ -143,29 +138,29 @@ function get_social_warfare_shares( $postID ) {
|
|
143 |
if( !empty($altURLs) ):
|
144 |
$shares[$network] = $shares[$network] + $altURLs_recovered_shares[$network];
|
145 |
endif;
|
146 |
-
|
|
|
147 |
|
148 |
if ( $shares[$network] < $old_shares[$network] && false === _swp_is_debug('force_new_shares') ) :
|
149 |
-
|
150 |
|
151 |
elseif($shares[$network] > 0) :
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
endif;
|
156 |
|
157 |
if (is_numeric( $shares[$network] ) ):
|
158 |
-
|
159 |
-
|
160 |
endif;
|
161 |
-
endif;
|
162 |
|
163 |
-
|
|
|
164 |
endif;
|
165 |
|
166 |
/**
|
167 |
* Update the Cache and Return the Share Counts
|
168 |
*/
|
|
|
169 |
if ( $fresh_cache != true ) :
|
170 |
|
171 |
// Clean out the previously used custom meta fields
|
@@ -178,5 +173,4 @@ function get_social_warfare_shares( $postID ) {
|
|
178 |
|
179 |
// Return the share counts
|
180 |
return $shares;
|
181 |
-
|
182 |
}
|
18 |
return false;
|
19 |
endif;
|
20 |
|
|
|
21 |
// Set the initial options
|
22 |
$options = $swp_user_options;
|
23 |
$url = apply_filters( 'swp_url_filter_function', get_permalink( $postID ) );
|
38 |
// Queue up the networks that are available
|
39 |
$networks = $options['order_of_icons'];
|
40 |
|
|
|
|
|
41 |
if ( !is_array( $networks ) || count ( $networks ) === 0 ) :
|
42 |
+
return $shares;
|
43 |
endif;
|
44 |
|
45 |
$icons_array = array(
|
48 |
|
49 |
foreach ( $networks as $network ) :
|
50 |
|
51 |
+
if( isset( $swp_social_networks[$network] ) ):
|
52 |
|
53 |
+
// Check if we can used the cached share numbers
|
54 |
+
if ( $fresh_cache == true ) :
|
55 |
$shares[$network] = get_post_meta( $postID,'_' . $network . '_shares',true );
|
56 |
|
57 |
+
// If cache is expired, fetch new and update the cache
|
58 |
+
else :
|
59 |
$old_shares[$network] = get_post_meta( $postID,'_' . $network . '_shares',true );
|
60 |
$api_links[$network] = $swp_social_networks[$network]->get_api_link( $url );
|
61 |
+
endif;
|
62 |
|
63 |
+
endif;
|
64 |
|
65 |
endforeach;
|
66 |
|
67 |
// Recover Shares From Previously Used URL Patterns
|
68 |
if ( true == $options['recover_shares'] && false == $fresh_cache ) :
|
|
|
69 |
$alternateURL = SWP_Permalink::get_alt_permalink( $postID );
|
70 |
$alternateURL = apply_filters( 'swp_recovery_filter', $alternateURL );
|
71 |
|
73 |
$altURLs = apply_filters('swp_additional_url_to_check', $altURLs );
|
74 |
|
75 |
// Debug the Alternate URL being checked
|
76 |
+
if ( _swp_is_debug( 'recovery' ) ) :
|
77 |
echo $alternateURL;
|
78 |
echo $altURLs;
|
79 |
+
endif;
|
80 |
|
81 |
foreach ( $networks as $network ) :
|
82 |
|
83 |
if( isset( $swp_social_networks[$network] ) ):
|
|
|
84 |
$old_share_links[$network] = $swp_social_networks[$network]->get_api_link( $alternateURL );
|
85 |
|
86 |
if( !empty($altURLs) ):
|
95 |
if ( $fresh_cache == true ) :
|
96 |
if ( get_post_meta( $postID,'_total_shares',true ) ) :
|
97 |
$shares['total_shares'] = get_post_meta( $postID, '_total_shares', true );
|
|
|
98 |
else :
|
99 |
$shares['total_shares'] = 0;
|
100 |
endif;
|
101 |
else :
|
|
|
102 |
// Fetch all the share counts asyncrounously
|
103 |
$raw_shares_array = SWP_CURL::fetch_shares_via_curl_multi( $api_links );
|
104 |
|
106 |
$old_raw_shares_array = SWP_CURL::fetch_shares_via_curl_multi( $old_share_links );
|
107 |
endif;
|
108 |
|
109 |
+
//* Need to reset the timestamp so we don't fetch shares again on the same request.
|
110 |
+
swp_cache_reset_timestamp( $postID );
|
111 |
+
|
112 |
foreach ( $networks as $network ) :
|
113 |
|
114 |
if( isset( $swp_social_networks[$network] ) ):
|
115 |
+
if ( ! isset( $raw_shares_array[$network] ) ) :
|
|
|
116 |
$raw_shares_array[$network] = 0;
|
117 |
+
endif;
|
118 |
|
119 |
+
if ( ! isset( $old_raw_shares_array[$network] ) ) :
|
120 |
$old_raw_shares_array[$network] = 0;
|
121 |
+
endif;
|
122 |
|
123 |
+
$shares[$network] = $swp_social_networks[$network]->parse_api_response($raw_shares_array[$network]);
|
124 |
|
125 |
if ( $options['recover_shares'] == true ) :
|
126 |
|
127 |
$recovered_shares[$network] = $swp_social_networks[$network]->parse_api_response( $old_raw_shares_array[$network] );
|
128 |
|
129 |
+
if( !empty($altURLs) ) :
|
130 |
+
$altURLs_raw_shares_array = SWP_CURL::fetch_shares_via_curl_multi( $altURLs_share_links );
|
131 |
$altURLs_recovered_shares[$network] = $swp_social_networks[$network]->parse_api_response( $altURLs_raw_shares_array[$network] );
|
132 |
endif;
|
133 |
|
138 |
if( !empty($altURLs) ):
|
139 |
$shares[$network] = $shares[$network] + $altURLs_recovered_shares[$network];
|
140 |
endif;
|
141 |
+
|
142 |
+
endif; //* End 'recover_shares'
|
143 |
|
144 |
if ( $shares[$network] < $old_shares[$network] && false === _swp_is_debug('force_new_shares') ) :
|
145 |
+
$shares[$network] = $old_shares[$network];
|
146 |
|
147 |
elseif($shares[$network] > 0) :
|
148 |
+
delete_post_meta( $postID,'_' . $network . '_shares' );
|
149 |
+
update_post_meta( $postID,'_' . $network . '_shares',$shares[$network] );
|
|
|
150 |
endif;
|
151 |
|
152 |
if (is_numeric( $shares[$network] ) ):
|
153 |
+
$shares['total_shares'] += $shares[$network];
|
|
|
154 |
endif;
|
|
|
155 |
|
156 |
+
endif;
|
157 |
+
endforeach;
|
158 |
endif;
|
159 |
|
160 |
/**
|
161 |
* Update the Cache and Return the Share Counts
|
162 |
*/
|
163 |
+
|
164 |
if ( $fresh_cache != true ) :
|
165 |
|
166 |
// Clean out the previously used custom meta fields
|
173 |
|
174 |
// Return the share counts
|
175 |
return $shares;
|
|
|
176 |
}
|
functions/utilities/utility.php
CHANGED
@@ -40,28 +40,28 @@
|
|
40 |
*
|
41 |
*/
|
42 |
function swp_get_option( $key, $options = null ){
|
43 |
-
|
44 |
|
45 |
if ( null === $options ) {
|
46 |
$options = $swp_user_options;
|
47 |
}
|
48 |
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
return $defaults[$key];
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
}
|
66 |
|
67 |
add_action( 'wp_ajax_swp_store_settings', 'swp_store_the_settings' );
|
@@ -70,6 +70,7 @@ add_action( 'wp_ajax_swp_store_settings', 'swp_store_the_settings' );
|
|
70 |
*
|
71 |
* @since unknown
|
72 |
* @return void
|
|
|
73 |
*/
|
74 |
function swp_store_the_settings() {
|
75 |
global $swp_user_options;
|
@@ -103,8 +104,8 @@ function swp_store_the_settings() {
|
|
103 |
}
|
104 |
}
|
105 |
|
106 |
-
|
107 |
-
echo json_encode($options);
|
108 |
|
109 |
die;
|
110 |
}
|
@@ -555,3 +556,9 @@ function swp_snake_case( $string ) {
|
|
555 |
$snake_case = str_replace( ' ' , '_' , strtolower($string) );
|
556 |
return $snake_case;
|
557 |
}
|
|
|
|
|
|
|
|
|
|
|
|
40 |
*
|
41 |
*/
|
42 |
function swp_get_option( $key, $options = null ){
|
43 |
+
global $swp_user_options;
|
44 |
|
45 |
if ( null === $options ) {
|
46 |
$options = $swp_user_options;
|
47 |
}
|
48 |
|
49 |
+
$defaults = array();
|
50 |
+
$defaults = apply_filters('swp_options_page_defaults' , $defaults );
|
51 |
|
52 |
+
// If the options exists, return it.
|
53 |
+
if( !empty( $options[$key] ) ):
|
54 |
+
return $options[$key];
|
55 |
|
56 |
+
// Else check if we have a default to use:
|
57 |
+
elseif( !empty($defaults[$key]) ):
|
58 |
+
// init_default( $key );
|
59 |
return $defaults[$key];
|
60 |
|
61 |
+
// If neither, just return false.
|
62 |
+
else:
|
63 |
+
return false;
|
64 |
+
endif;
|
65 |
}
|
66 |
|
67 |
add_action( 'wp_ajax_swp_store_settings', 'swp_store_the_settings' );
|
70 |
*
|
71 |
* @since unknown
|
72 |
* @return void
|
73 |
+
* @since 3.0.9 | 31 MAY 2018 | Added call to wp_cache_delete to make sure settings save
|
74 |
*/
|
75 |
function swp_store_the_settings() {
|
76 |
global $swp_user_options;
|
104 |
}
|
105 |
}
|
106 |
|
107 |
+
wp_cache_delete ( 'social_warfare_settings', 'options' );
|
108 |
+
echo json_encode(swp_update_options( $options ));
|
109 |
|
110 |
die;
|
111 |
}
|
556 |
$snake_case = str_replace( ' ' , '_' , strtolower($string) );
|
557 |
return $snake_case;
|
558 |
}
|
559 |
+
|
560 |
+
add_action( 'wp_ajax_swp_fetch_user_options', 'swp_fetch_user_options' );
|
561 |
+
function swp_fetch_user_options() {
|
562 |
+
echo json_encode( get_option( 'social_warfare_settings', [] ) );
|
563 |
+
wp_die();
|
564 |
+
}
|
js/admin-options-page.js
CHANGED
@@ -73,8 +73,6 @@
|
|
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 visible = false;
|
77 |
-
var value = event.target.value;
|
78 |
var visibility = {
|
79 |
customColor: false,
|
80 |
customOutlines: false
|
@@ -96,7 +94,6 @@
|
|
96 |
visibility.customOutlines ? customOutlines.slideDown() : customOutlines.slideUp();
|
97 |
|
98 |
if (visibility.customColor || visibility.customOutlines) {
|
99 |
-
console.log(colorNotice);
|
100 |
$("body").append(colorNotice);
|
101 |
$(".color-dismiss").on("click", function() {
|
102 |
$("#color-notice").fadeOut("slow");
|
@@ -109,6 +106,38 @@
|
|
109 |
|
110 |
}
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
/*********************************************************
|
113 |
A Function send the array of setting to ajax.php
|
114 |
*********************************************************/
|
@@ -289,15 +318,21 @@
|
|
289 |
};
|
290 |
|
291 |
// Send the POST request
|
292 |
-
$.post(
|
293 |
-
|
294 |
-
|
|
|
|
|
|
|
295 |
|
296 |
-
|
297 |
-
|
|
|
|
|
|
|
298 |
|
299 |
-
saveColorToggle();
|
300 |
});
|
|
|
301 |
});
|
302 |
}
|
303 |
|
@@ -798,6 +833,7 @@
|
|
798 |
getSystemStatus();
|
799 |
customUploaderInit();
|
800 |
set_ctt_preview();
|
|
|
801 |
});
|
802 |
|
803 |
|
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,
|
78 |
customOutlines: false
|
94 |
visibility.customOutlines ? customOutlines.slideDown() : customOutlines.slideUp();
|
95 |
|
96 |
if (visibility.customColor || visibility.customOutlines) {
|
|
|
97 |
$("body").append(colorNotice);
|
98 |
$(".color-dismiss").on("click", function() {
|
99 |
$("#color-notice").fadeOut("slow");
|
106 |
|
107 |
}
|
108 |
|
109 |
+
function createNotice(message, parentElement) {
|
110 |
+
var notice = document.createElement("div");
|
111 |
+
var style = "background-color: #ced3dc; color: #30394f; padding: 5px 10px; font-size: 16px !important;";
|
112 |
+
|
113 |
+
var dismiss = document.createElement("span");
|
114 |
+
dismiss.textContent = "Dismiss this notice";
|
115 |
+
|
116 |
+
dismiss.addEventListener("click", function(e) {
|
117 |
+
jQuery(e.target.parentNode).slideUp();
|
118 |
+
});
|
119 |
+
|
120 |
+
notice.style = style;
|
121 |
+
notice.innerHTML = message;
|
122 |
+
notice.appendChild(dismiss)
|
123 |
+
|
124 |
+
parentElement.appendChild(notice);
|
125 |
+
}
|
126 |
+
|
127 |
+
function createStumbleUponNotice() {
|
128 |
+
var message = '<h3><u>Big news</u></h3>';
|
129 |
+
message += '<p>As of June 30th, 2018, StumbleUpon will no longer exist as a sharing platform.<br/>Instead, they are moving in with Mix.</p>';
|
130 |
+
message += '<p>While this is exciting for Mix, <b>share counts will not be transferred, and Mix is not providing a share button or API.</b>';
|
131 |
+
message += '<br/>You can read more about it <a href="http://help.stumbleupon.com/customer/en/portal/articles/2908172-transitioning-from-stumbleupon-to-mix" target="_blank">here</a>.</p>';
|
132 |
+
|
133 |
+
var parent = document.querySelector(".social_networks_description_wrapper");
|
134 |
+
|
135 |
+
if (typeof parent !== 'undefined') {
|
136 |
+
createNotice(message, parent)
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
/*********************************************************
|
142 |
A Function send the array of setting to ajax.php
|
143 |
*********************************************************/
|
318 |
};
|
319 |
|
320 |
// Send the POST request
|
321 |
+
$.post({
|
322 |
+
url: ajaxurl,
|
323 |
+
data: data,
|
324 |
+
success: function(response) {
|
325 |
+
// Clear the loading screen
|
326 |
+
clearLoadingScreen();
|
327 |
|
328 |
+
// Reset the default options variable
|
329 |
+
socialWarfarePlugin.defaultOptions = fetchAllOptions();
|
330 |
+
|
331 |
+
saveColorToggle();
|
332 |
+
}
|
333 |
|
|
|
334 |
});
|
335 |
+
|
336 |
});
|
337 |
}
|
338 |
|
833 |
getSystemStatus();
|
834 |
customUploaderInit();
|
835 |
set_ctt_preview();
|
836 |
+
// createStumbleUponNotice();
|
837 |
});
|
838 |
|
839 |
|
js/admin-options-page.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(m,f,i){m.onload=function(){var F="[name=default_colors],[name=hover_colors], [name=single_colors]";var E="[name=float_default_colors], [name=float_hover_colors], [name=float_single_colors]";f("[name=custom_color],[name=custom_color_outlines],[name=float_custom_color],[name=float_custom_color_outlines]").parent().parent().hide();f(F).each(function(J,H){var K=f(H).val();var I=f("[name=custom_color]").parent().parent();var G=f("[name=custom_color_outlines]").parent().parent();if(K.indexOf("custom")!==-1){if(K.indexOf("outlines")>0){G.show()}else{I.show()}}});f(E).each(function(J,H){var K=f(H).val();var I=f("[name=float_custom_color]").parent().parent();var G=f("[name=float_custom_color_outlines]").parent().parent();if(K.indexOf("custom")!==-1){K.indexOf("outlines")>0?G.show():I.show()}});f(F).on("change",function(J){var I=J.target.value;var H=f("[name=custom_color]").parent().parent();var G=f("[name=custom_color_outlines]").parent().parent();p(J,F,H,G,I)});f(E).on("change",function(J){var I=J.target.value;var H=f("[name=float_custom_color]").parent().parent();var G=f("[name=float_custom_color_outlines]").parent().parent();H.hide();G.hide();p(J,E,H,G,I)})};function p(J,F,H,E){var I='<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>';var L=false;var K=J.target.value;var G={customColor:false,customOutlines:false};f(F).each(function(N,M){var O=f(M).val();if(O.indexOf("custom")!==-1){if(O.indexOf("outlines")>0){G.customOutlines=true}else{G.customColor=true}}});G.customColor?H.slideDown():H.slideUp();G.customOutlines?E.slideDown():E.slideUp();if(G.customColor||G.customOutlines){console.log(I);f("body").append(I);f(".color-dismiss").on("click",function(){f("#color-notice").fadeOut("slow")})}else{if(f("#color-notice")){f(I).fadeOut("slow")}}}function C(F){var E,G;if(document.body.createTextRange){E=document.body.createTextRange();E.moveToElementText(F);E.select()}else{if(m.getSelection){G=m.getSelection();E=document.createRange();E.selectNodeContents(F);G.removeAllRanges();G.addRange(E)}}}function r(){var E={};f("form.sw-admin-settings-form input, form.sw-admin-settings-form select, form.sw-admin-settings-form textarea").each(function(){var G=f(this);var F=G.attr("name");var H;if("checkbox"===G.attr("type")){H=G.prop("checked")}else{H=G.val()}E[F]=H});E.order_of_icons={};f(".sw-active i").each(function(){var F=f(this).data("network");E.order_of_icons[F]=F});return E}function k(){var F=f(".sw-top-menu").offset();var E=f(".sw-top-menu").width();f(".sw-top-menu").css({position:"fixed",left:F.left,top:F.top,width:E});f(".sw-admin-wrapper").css("padding-top","75px")}function w(){f(".sw-tab-selector").on("click",function(F){F.preventDefault();f("html, body").animate({scrollTop:0},300);var E=f(this).attr("data-link");f(".sw-admin-tab").hide();f("#"+E).show();f(".sw-header-menu li").removeClass("sw-active-tab");f(this).parents("li").addClass("sw-active-tab");if("swp_styles"===E){socialWarfarePlugin.activateHoverStates()}swpConditionalFields()})}function q(){f(".sw-checkbox-toggle").on("click",function(){var E=f(this).attr("status");var F=f(this).attr("field");if("on"===E){f(this).attr("status","off");f(F).prop("checked",false)}else{f(this).attr("status","on");f(F).prop("checked",true)}D();swpConditionalFields()})}function b(){f("form.sw-admin-settings-form input, form.sw-admin-settings-form select").on("change",function(){swpConditionalFields();socialWarfarePlugin.newOptions=r();D()});socialWarfarePlugin.defaultOptions=r()}function D(){socialWarfarePlugin.newOptions=r();if(JSON.stringify(socialWarfarePlugin.newOptions)!==JSON.stringify(socialWarfarePlugin.defaultOptions)){f(".sw-save-settings").removeClass("sw-navy-button").addClass("sw-red-button")}else{f(".sw-save-settings").removeClass("sw-red-button").addClass("sw-navy-button")}}function l(){f(".sw-save-settings").on("click",function(F){F.preventDefault?F.preventDefault():(F.returnValue=false);v();var E=r();var G={action:"swp_store_settings",security:swpAdminOptionsData.optionsNonce,settings:E};f.post(ajaxurl,G,function(H){g();socialWarfarePlugin.defaultOptions=r();D()})})}function v(){f("body").append('<div class="sw-loading-bg"><div class="sw-loading-message">Saving Changes</div></div>')}function g(){f(".sw-loading-message").html("Success!").removeClass("sw-loading-message").addClass("sw-loading-complete");f(".sw-loading-bg").delay(1000).fadeOut(1000);setTimeout(function(){f(".sw-loading-bg").remove()},2000)}function a(){var J=f('select[name="button_shape"]').val();var G=f('select[name="default_colors"]').val();var E=f('select[name="single_colors"]').val();var H=f('select[name="hover_colors"]').val();f("style.swp_customColorStuff").remove();var F=f('input[name="custom_color"]').val();var I="";if(G=="custom_color"||E=="custom_color"||H=="custom_color"){I=".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:"+F+";border:1px solid "+F+";}"}if(G=="custom_color_outlines"||E=="custom_color_outlines"||H=="custom_color_outlines"){I=I+" .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:"+F+"; } .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 "+F+"; }"}f("head").append('<style type="text/css" class="swp_customColorStuff">'+I+"</style>")}function x(){var J=F("button_shape");var G=F("default_colors");var E=F("single_colors");var H=F("hover_colors");function F(K){var M=f('select[name="'+K+'"]').val();if(M.indexOf("custom")===0){var L=K.slice(0,K.indexOf("_"));return L+"_full_color"}return M}var I="swp_"+J+" swp_default_"+G+" swp_individual_"+E+" swp_other_"+H;if("undefined"===typeof socialWarfarePlugin.lastClass){socialWarfarePlugin.lastClass="swp_flat_fresh swp_default_full_color swp_individual_full_color swp_other_full_color"}var I="swp_"+J+" swp_default_"+G+" swp_individual_"+E+" swp_other_"+H;f(".swp_social_panel").removeClass("swp_other_medium_gray");f(".swp_social_panel").removeClass(socialWarfarePlugin.lastClass).addClass(I);socialWarfarePlugin.lastClass=I}function A(){var I={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"};var G={flat_fresh:I,leaf:I,pill:I,three_dee:{full_color:"Full Color",light_gray:"Light Gray",medium_gray:"Medium Gray",dark_gray:"Dark Gray"},connected:I,shift:I,boxed:I};if(0===f('select[name="button_shape"]').length){return}var J=f('select[name="button_shape"]').val();var F=f('select[name="default_colors"]').val();var E=f('select[name="single_colors"]').val();var H=f('select[name="hover_colors"]').val();f('select[name="default_colors"] option, select[name="single_colors"] option, select[name="hover_colors"] option').remove();f.each(G[J],function(K,L){if(K===F){f('select[name="default_colors"]').append('<option value="'+K+'" selected>'+L+"</option>")}else{f('select[name="default_colors"]').append('<option value="'+K+'">'+L+"</option>")}if(K===E){f('select[name="single_colors"]').append('<option value="'+K+'" selected>'+L+"</option>")}else{f('select[name="single_colors"]').append('<option value="'+K+'">'+L+"</option>")}if(K===H){f('select[name="hover_colors"]').append('<option value="'+K+'" selected>'+L+"</option>")}else{f('select[name="hover_colors"]').append('<option value="'+K+'">'+L+"</option>")}if(F=="custom_color"||F=="custom_color_outlines"||E=="custom_color"||E=="custom_color_outlines"||H=="custom_color"||H=="custom_color_outlines"){f(".customColor_wrapper").slideDown();a()}else{f(".customColor_wrapper").slideUp()}});f('select[name="default_colors"], select[name="single_colors"], select[name="hover_colors"]').on("change",x);f('select[name="button_shape"]').on("change",function(){var T=f('select[name="button_shape"]').val();var K=f('select[name="default_colors"]').val();var M=f('select[name="single_colors"]').val();var R=f('select[name="hover_colors"]').val();var O=0;var P=G[T];var Q=P.hasOwnProperty(K);var N=P.hasOwnProperty(M);var L=P.hasOwnProperty(R);f('select[name="default_colors"] option, select[name="single_colors"] option, select[name="hover_colors"] option').remove();f.each(G[T],function(U,V){if(U===K||(Q==false&&O==0)){f('select[name="default_colors"]').append('<option value="'+U+'" selected>'+V+"</option>")}else{f('select[name="default_colors"]').append('<option value="'+U+'">'+V+"</option>")}if(U===M||(N==false&&O==0)){f('select[name="single_colors"]').append('<option value="'+U+'" selected>'+V+"</option>")}else{f('select[name="single_colors"]').append('<option value="'+U+'">'+V+"</option>")}if(U===R||(L==false&&O==0)){f('select[name="hover_colors"]').append('<option value="'+U+'" selected>'+V+"</option>")}else{f('select[name="hover_colors"]').append('<option value="'+U+'">'+V+"</option>")}++O});if("undefined"===typeof socialWarfarePlugin.lastClass){socialWarfarePlugin.lastClass="swp_flat_fresh swp_default_full_color swp_individual_full_color swp_other_full_color"}var S="swp_"+T+" swp_default_"+K+" swp_individual_"+M+" swp_other_"+R;f(".swp_social_panel").removeClass(socialWarfarePlugin.lastClass).addClass(S);socialWarfarePlugin.lastClass=S})}function B(){f('select[name="button_size"],select[name="button_alignment"]').on("change",function(){f(".swp_social_panel").css({width:"100%"});var E=f(".swp_social_panel").width();var G=f('select[name="button_size"]').val();var H=f('select[name="button_alignment"]').val();var F;if((H=="full_width"&&G!=1)||G>=1){F=E/G;f(".swp_social_panel").css("cssText","width:"+F+"px!important;");f(".swp_social_panel").css({transform:"scale("+G+")","transform-origin":"left"})}else{if(H!="full_width"&&G<1){F=E/G;f(".swp_social_panel").css({transform:"scale("+G+")","transform-origin":H})}}socialWarfarePlugin.activateHoverStates()})}function o(){var E=f('select[name="ctt_theme"]');E.on("change",function(){var F=f('select[name="ctt_theme"]').val();f(".swp_CTT").attr("class","swp_CTT").addClass(F)});E.trigger("change")}function z(F,G){var E=f(".sw-admin-wrapper");var H=E.attr("swp-addons");var I=E.attr("swp-registrations");f(".registration-wrapper."+G).attr("registration",F);if(1===parseInt(F)){E.attr("sw-registered",F);f(".sw-top-menu").attr("sw-registered",F);t(E,"swp-registrations",G)}else{y(E,"swp-registrations",G)}}function y(G,H,F){var I=f(G).attr(H);var K=I.indexOf(F);if(K===-1){return}var E=K+F.length;var J=I.slice(0,K)+I.slice(E);f(G).attr(H,J)}function t(F,G,E){var H=f(F).attr(G);if(H.includes(E)){return}f(F).attr(G,H+E)}function u(F,E){var H=false;var G={action:"swp_register_plugin",security:swpAdminOptionsData.registerNonce,activity:"register",name_key:F,item_id:E,license_key:f('input[name="'+F+'_license_key"]').val()};v();f.post(ajaxurl,G,function(I){I=JSON.parse(I);if(!I.success){alert("Failure: "+I.data)}else{z("1",F);H=true}m.location.reload(true);g()});return H}function j(H,G){var F=false;var E={action:"swp_unregister_plugin",security:swpAdminOptionsData.registerNonce,activity:"unregister",name_key:H,item_id:G,};v();f.post(ajaxurl,E,function(I){I=JSON.parse(I);if(!I.success){alert("Failure: "+I.data)}else{f('input[name="'+H+'_license_key"]').val("");z("0",H);F=true}m.location.reload(true);g()});return F}function d(){f(".register-plugin").on("click",function(){var F=f(this).attr("swp-addon");var E=f(this).attr("swp-item-id");u(F,E);return false});f(".unregister-plugin").on("click",function(){var F=f(this).attr("swp-addon");var E=f(this).attr("swp-item-id");j(F,E);return false})}function c(){f(".sw-buttons-sort.sw-active").sortable({connectWith:".sw-buttons-sort.sw-inactive",update:function(){D()}});f(".sw-buttons-sort.sw-inactive").sortable({connectWith:".sw-buttons-sort.sw-active",update:function(){D()}})}function e(){f(".sw-system-status").on("click",function(E){E.preventDefault?E.preventDefault():(E.returnValue=false);f(".system-status-wrapper").slideToggle();C(f(".system-status-container").get(0))})}function s(){var E;f(".swp_upload_image_button").click(function(G){G.preventDefault();var F=f(this).attr("for");if(E){E.open();return}E=wp.media.frames.file_frame=wp.media({title:"Choose Image",button:{text:"Choose Image"},multiple:false});E.on("select",function(){var H=E.state().get("selection").first().toJSON();f('input[name="'+F+'"').val(H.url)});E.open()})}function h(){var F=f("#ctt_preview");var E=f("select[name=ctt_theme]");if(!F.length){F=f('<style id="ctt_preview"></style>');f("head").append(F)}if(f(E).val()==="none"){n()}f(E).on("change",function(G){if(G.target.value==="none"){n()}});f("textarea[name=ctt_css]").on("keyup",n)}function n(){var F=f("#ctt_preview");var E=f("textarea[name=ctt_css]");f(F).text(f(E).val())}f(document).ready(function(){l();b();k();w();q();A();swpConditionalFields();o();B();d();c();e();s();h()})})(this,jQuery);
|
1 |
+
!function(e,t,o){"use strict";function s(e,o,s,a){var n='<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>',l={customColor:!1,customOutlines:!1};t(o).each(function(e,o){var s=t(o).val();-1!==s.indexOf("custom")&&(s.indexOf("outlines")>0?l.customOutlines=!0:l.customColor=!0)}),l.customColor?s.slideDown():s.slideUp(),l.customOutlines?a.slideDown():a.slideUp(),l.customColor||l.customOutlines?(t("body").append(n),t(".color-dismiss").on("click",function(){t("#color-notice").fadeOut("slow")})):t("#color-notice")&&t(n).fadeOut("slow")}function a(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 n(){var e={};return t("form.sw-admin-settings-form input, form.sw-admin-settings-form select, form.sw-admin-settings-form textarea").each(function(){var o,s=t(this),a=s.attr("name");o="checkbox"===s.attr("type")?s.prop("checked"):s.val(),e[a]=o}),e.order_of_icons={},t(".sw-active i").each(function(){var o=t(this).data("network");e.order_of_icons[o]=o}),e}function l(){var e=t(".sw-top-menu").offset(),o=t(".sw-top-menu").width();t(".sw-top-menu").css({position:"fixed",left:e.left,top:e.top,width:o}),t(".sw-admin-wrapper").css("padding-top","75px")}function i(){t(".sw-tab-selector").on("click",function(e){e.preventDefault(),t("html, body").animate({scrollTop:0},300);var o=t(this).attr("data-link");t(".sw-admin-tab").hide(),t("#"+o).show(),t(".sw-header-menu li").removeClass("sw-active-tab"),t(this).parents("li").addClass("sw-active-tab"),"swp_styles"===o&&socialWarfarePlugin.activateHoverStates(),swpConditionalFields()})}function r(){t(".sw-checkbox-toggle").on("click",function(){var e=t(this).attr("status"),o=t(this).attr("field");"on"===e?(t(this).attr("status","off"),t(o).prop("checked",!1)):(t(this).attr("status","on"),t(o).prop("checked",!0)),u(),swpConditionalFields()})}function c(){t("form.sw-admin-settings-form input, form.sw-admin-settings-form select").on("change",function(){swpConditionalFields(),socialWarfarePlugin.newOptions=n(),u()}),socialWarfarePlugin.defaultOptions=n()}function u(){socialWarfarePlugin.newOptions=n(),JSON.stringify(socialWarfarePlugin.newOptions)!==JSON.stringify(socialWarfarePlugin.defaultOptions)?t(".sw-save-settings").removeClass("sw-navy-button").addClass("sw-red-button"):t(".sw-save-settings").removeClass("sw-red-button").addClass("sw-navy-button")}function _(){t(".sw-save-settings").on("click",function(e){e.preventDefault?e.preventDefault():e.returnValue=!1,p();var o=n(),s={action:"swp_store_settings",security:swpAdminOptionsData.optionsNonce,settings:o};t.post({url:ajaxurl,data:s,success:function(e){d(),socialWarfarePlugin.defaultOptions=n(),u()}})})}function p(){t("body").append('<div class="sw-loading-bg"><div class="sw-loading-message">Saving Changes</div></div>')}function d(){t(".sw-loading-message").html("Success!").removeClass("sw-loading-message").addClass("sw-loading-complete"),t(".sw-loading-bg").delay(1e3).fadeOut(1e3),setTimeout(function(){t(".sw-loading-bg").remove()},2e3)}function m(){var e=(t('select[name="button_shape"]').val(),t('select[name="default_colors"]').val()),o=t('select[name="single_colors"]').val(),s=t('select[name="hover_colors"]').val();t("style.swp_customColorStuff").remove();var a=t('input[name="custom_color"]').val(),n="";"custom_color"!=e&&"custom_color"!=o&&"custom_color"!=s||(n=".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:"+a+";border:1px solid "+a+";}"),"custom_color_outlines"!=e&&"custom_color_outlines"!=o&&"custom_color_outlines"!=s||(n=n+" .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:"+a+"; } .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 "+a+"; }"),t("head").append('<style type="text/css" class="swp_customColorStuff">'+n+"</style>")}function f(){function e(e){var o=t('select[name="'+e+'"]').val();if(0===o.indexOf("custom")){return e.slice(0,e.indexOf("_"))+"_full_color"}return o}var o=e("button_shape"),s=e("default_colors"),a=e("single_colors"),n=e("hover_colors"),l="swp_"+o+" swp_default_"+s+" swp_individual_"+a+" swp_other_"+n;void 0===socialWarfarePlugin.lastClass&&(socialWarfarePlugin.lastClass="swp_flat_fresh swp_default_full_color swp_individual_full_color swp_other_full_color");var l="swp_"+o+" swp_default_"+s+" swp_individual_"+a+" swp_other_"+n;t(".swp_social_panel").removeClass("swp_other_medium_gray"),t(".swp_social_panel").removeClass(socialWarfarePlugin.lastClass).addClass(l),socialWarfarePlugin.lastClass=l}function w(){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"},o={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};if(0!==t('select[name="button_shape"]').length){var s=t('select[name="button_shape"]').val(),a=t('select[name="default_colors"]').val(),n=t('select[name="single_colors"]').val(),l=t('select[name="hover_colors"]').val();t('select[name="default_colors"] option, select[name="single_colors"] option, select[name="hover_colors"] option').remove(),t.each(o[s],function(e,o){e===a?t('select[name="default_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):t('select[name="default_colors"]').append('<option value="'+e+'">'+o+"</option>"),e===n?t('select[name="single_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):t('select[name="single_colors"]').append('<option value="'+e+'">'+o+"</option>"),e===l?t('select[name="hover_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):t('select[name="hover_colors"]').append('<option value="'+e+'">'+o+"</option>"),"custom_color"==a||"custom_color_outlines"==a||"custom_color"==n||"custom_color_outlines"==n||"custom_color"==l||"custom_color_outlines"==l?(t(".customColor_wrapper").slideDown(),m()):t(".customColor_wrapper").slideUp()}),t('select[name="default_colors"], select[name="single_colors"], select[name="hover_colors"]').on("change",f),t('select[name="button_shape"]').on("change",function(){var e=t('select[name="button_shape"]').val(),s=t('select[name="default_colors"]').val(),a=t('select[name="single_colors"]').val(),n=t('select[name="hover_colors"]').val(),l=0,i=o[e],r=i.hasOwnProperty(s),c=i.hasOwnProperty(a),u=i.hasOwnProperty(n);t('select[name="default_colors"] option, select[name="single_colors"] option, select[name="hover_colors"] option').remove(),t.each(o[e],function(e,o){e===s||0==r&&0==l?t('select[name="default_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):t('select[name="default_colors"]').append('<option value="'+e+'">'+o+"</option>"),e===a||0==c&&0==l?t('select[name="single_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):t('select[name="single_colors"]').append('<option value="'+e+'">'+o+"</option>"),e===n||0==u&&0==l?t('select[name="hover_colors"]').append('<option value="'+e+'" selected>'+o+"</option>"):t('select[name="hover_colors"]').append('<option value="'+e+'">'+o+"</option>"),++l}),void 0===socialWarfarePlugin.lastClass&&(socialWarfarePlugin.lastClass="swp_flat_fresh swp_default_full_color swp_individual_full_color swp_other_full_color");var _="swp_"+e+" swp_default_"+s+" swp_individual_"+a+" swp_other_"+n;t(".swp_social_panel").removeClass(socialWarfarePlugin.lastClass).addClass(_),socialWarfarePlugin.lastClass=_})}}function v(){t('select[name="button_size"],select[name="button_alignment"]').on("change",function(){t(".swp_social_panel").css({width:"100%"});var e,o=t(".swp_social_panel").width(),s=t('select[name="button_size"]').val(),a=t('select[name="button_alignment"]').val();"full_width"==a&&1!=s||s>=1?(e=o/s,t(".swp_social_panel").css("cssText","width:"+e+"px!important;"),t(".swp_social_panel").css({transform:"scale("+s+")","transform-origin":"left"})):"full_width"!=a&&s<1&&(e=o/s,t(".swp_social_panel").css({transform:"scale("+s+")","transform-origin":a})),socialWarfarePlugin.activateHoverStates()})}function g(){var e=t('select[name="ctt_theme"]');e.on("change",function(){var e=t('select[name="ctt_theme"]').val();t(".swp_CTT").attr("class","swp_CTT").addClass(e)}),e.trigger("change")}function h(e,o){var s=t(".sw-admin-wrapper");s.attr("swp-addons"),s.attr("swp-registrations");t(".registration-wrapper."+o).attr("registration",e),1===parseInt(e)?(s.attr("sw-registered",e),t(".sw-top-menu").attr("sw-registered",e),C(s,"swp-registrations",o)):y(s,"swp-registrations",o)}function y(e,o,s){var a=t(e).attr(o),n=a.indexOf(s);if(-1!==n){var l=n+s.length,i=a.slice(0,n)+a.slice(l);t(e).attr(o,i)}}function C(e,o,s){var a=t(e).attr(o);a.includes(s)||t(e).attr(o,a+s)}function b(o,s){var a=!1,n={action:"swp_register_plugin",security:swpAdminOptionsData.registerNonce,activity:"register",name_key:o,item_id:s,license_key:t('input[name="'+o+'_license_key"]').val()};return p(),t.post(ajaxurl,n,function(t){t=JSON.parse(t),t.success?(h("1",o),a=!0):alert("Failure: "+t.data),e.location.reload(!0),d()}),a}function O(o,s){var a=!1,n={action:"swp_unregister_plugin",security:swpAdminOptionsData.registerNonce,activity:"unregister",name_key:o,item_id:s};return p(),t.post(ajaxurl,n,function(s){s=JSON.parse(s),s.success?(t('input[name="'+o+'_license_key"]').val(""),h("0",o),a=!0):alert("Failure: "+s.data),e.location.reload(!0),d()}),a}function x(){t(".register-plugin").on("click",function(){return b(t(this).attr("swp-addon"),t(this).attr("swp-item-id")),!1}),t(".unregister-plugin").on("click",function(){return O(t(this).attr("swp-addon"),t(this).attr("swp-item-id")),!1})}function k(){t(".sw-buttons-sort.sw-active").sortable({connectWith:".sw-buttons-sort.sw-inactive",update:function(){u()}}),t(".sw-buttons-sort.sw-inactive").sortable({connectWith:".sw-buttons-sort.sw-active",update:function(){u()}})}function P(){t(".sw-system-status").on("click",function(e){e.preventDefault?e.preventDefault():e.returnValue=!1,t(".system-status-wrapper").slideToggle(),a(t(".system-status-container").get(0))})}function W(){var e;t(".swp_upload_image_button").click(function(o){o.preventDefault();var s=t(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();t('input[name="'+s+'"').val(o.url)}),e.open()})}function D(){var e=t("#ctt_preview"),o=t("select[name=ctt_theme]");e.length||(e=t('<style id="ctt_preview"></style>'),t("head").append(e)),"none"===t(o).val()&&S(),t(o).on("change",function(e){"none"===e.target.value&&S()}),t("textarea[name=ctt_css]").on("keyup",S)}function S(){var e=t("#ctt_preview"),o=t("textarea[name=ctt_css]");t(e).text(t(o).val())}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]";t("[name=custom_color],[name=custom_color_outlines],[name=float_custom_color],[name=float_custom_color_outlines]").parent().parent().hide(),t(e).each(function(e,o){var s=t(o).val(),a=t("[name=custom_color]").parent().parent(),n=t("[name=custom_color_outlines]").parent().parent();-1!==s.indexOf("custom")&&(s.indexOf("outlines")>0?n.show():a.show())}),t(o).each(function(e,o){var s=t(o).val(),a=t("[name=float_custom_color]").parent().parent(),n=t("[name=float_custom_color_outlines]").parent().parent();-1!==s.indexOf("custom")&&(s.indexOf("outlines")>0?n.show():a.show())}),t(e).on("change",function(o){var a=(o.target.value,t("[name=custom_color]").parent().parent()),n=t("[name=custom_color_outlines]").parent().parent();s(o,e,a,n)}),t(o).on("change",function(e){var a=(e.target.value,t("[name=float_custom_color]").parent().parent()),n=t("[name=float_custom_color_outlines]").parent().parent();a.hide(),n.hide(),s(e,o,a,n)})},t(document).ready(function(){_(),c(),l(),i(),r(),w(),swpConditionalFields(),g(),v(),x(),k(),P(),W(),D()})}(this,jQuery);
|
js/admin.js
CHANGED
@@ -211,7 +211,31 @@ if (window.location.href.indexOf("widgets.php") > -1 ) {
|
|
211 |
}
|
212 |
}
|
213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
jQuery( document ).ready( function() {
|
|
|
|
|
215 |
if ( jQuery( '#social_warfare.postbox' ).length ) {
|
216 |
|
217 |
// Add the CountDown Box for the Social Media Title
|
@@ -238,6 +262,7 @@ if (window.location.href.indexOf("widgets.php") > -1 ) {
|
|
238 |
twitterRemaining();
|
239 |
});
|
240 |
|
|
|
241 |
// Setup an initilazation loop
|
242 |
var swpPostInit = setInterval( function() {
|
243 |
|
211 |
}
|
212 |
}
|
213 |
|
214 |
+
function noticeClickHandlers() {
|
215 |
+
jQuery(".swp-notice-cta").on("click", function(e) {
|
216 |
+
e.preventDefault();
|
217 |
+
var parent = jQuery(this).parents(".swp-dismiss-notice");
|
218 |
+
|
219 |
+
jQuery.post({
|
220 |
+
url: ajaxurl,
|
221 |
+
data: {
|
222 |
+
action: 'dismiss',
|
223 |
+
key: parent.data("key"),
|
224 |
+
timeframe: this.dataset.timeframe
|
225 |
+
},
|
226 |
+
success: function(result) {
|
227 |
+
result = JSON.parse(result)
|
228 |
+
if (result) {
|
229 |
+
parent.slideUp(500);
|
230 |
+
}
|
231 |
+
}
|
232 |
+
});
|
233 |
+
});
|
234 |
+
}
|
235 |
+
|
236 |
jQuery( document ).ready( function() {
|
237 |
+
noticeClickHandlers();
|
238 |
+
|
239 |
if ( jQuery( '#social_warfare.postbox' ).length ) {
|
240 |
|
241 |
// Add the CountDown Box for the Social Media Title
|
262 |
twitterRemaining();
|
263 |
});
|
264 |
|
265 |
+
|
266 |
// Setup an initilazation loop
|
267 |
var swpPostInit = setInterval( function() {
|
268 |
|
js/admin.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function swpConditionalFields(){function e(e){return jQuery('select[name="'+e+'"]').val()}function s(e){return"true"===e&&(e=!0),"false"===e&&(e=!1),e}jQuery("[data-dep]").each(function(){var e=jQuery(this).data("dep"),a=JSON.parse(JSON.stringify(jQuery(this).data("dep_val")));if(-1===window.location.href.indexOf("page=social-warfare"))var
|
1 |
+
function swpConditionalFields(){function e(e){return jQuery('select[name="'+e+'"]').val()}function s(e){return"true"===e&&(e=!0),"false"===e&&(e=!1),e}jQuery("[data-dep]").each(function(){var e=jQuery(this).data("dep"),a=JSON.parse(JSON.stringify(jQuery(this).data("dep_val")));if(-1===window.location.href.indexOf("page=social-warfare"))var t=jQuery(this).parents(".widgets-holder-wrap").find('[data-swp-name="'+e+'"]');else var t=jQuery('[name="'+e+'"]')[0];var r;void 0===t&&void 0===(t=jQuery('[name="'+e+'"]')[0])&&(t=jQuery("[fieldjQuery="+e+"]")[0]),r="checkbox"==jQuery(t).attr("type")?jQuery(t).prop("checked"):jQuery(t).val(),r=s(r),-1!==window.location.href.indexOf("page=social-warfare")?-1!==jQuery.inArray(r,a)&&jQuery(t).parent(".sw-grid").is(":visible")?jQuery(this).show():jQuery(this).hide():-1!==jQuery.inArray(r,a)||r===a?jQuery(this).show():jQuery(this).hide()}),!1===function(e){return jQuery('[name="'+e+'"]').prop("checked")}("float_style_source")&&"custom_color"===e("float_default_colors")||"custom_color_outlines"===e("float_default_colors")||"custom_color"===e("float_single_colors")||"custom_color_outlines"===e("float_single_colors")||"custom_color"===e("float_hover_colors")||"custom_color_outlines"===e("float_hover_colors")?jQuery(".sideCustomColor_wrapper").slideDown():jQuery(".sideCustomColor_wrapper").slideUp()}var socialWarfareAdmin=socialWarfareAdmin||{},swpWidget,widgetSubmit;if(window.location.href.indexOf("widgets.php")>-1)var widgetFinder=setInterval(function(){void 0!==swpWidget&&clearInterval(widgetFinder),swpWidget=jQuery("#widgets-right [id*=_swp_popular_posts_widget], [id*=_swp_popular_posts_widget].open")[0],widgetSubmit=jQuery(swpWidget).find("[idjQuery=savewidget]")[0],jQuery(swpWidget).on("click",swpConditionalFields),jQuery(widgetSubmit).on("click",function(){setTimeout(swpConditionalFields,600)})},50);!function(e,s,a){"use strict";function t(){var e=s("#social_warfare textarea#swp_og_title").val(),a=60-e.length;e.length>0&&a>=0?s("#social_warfare .swp_og_title .swp_CountDown").removeClass("swp_red").addClass("swp_blue"):e.length>0&&a<0?s("#social_warfare .swp_og_title .swp_CountDown").removeClass("swp_blue").addClass("swp_red"):s("#social_warfare .swp_og_title .swp_CountDown").removeClass("swp_blue").removeClass("swp_red"),s("#social_warfare .swp_og_title .counterNumber").html(a)}function r(){var e=s("#social_warfare textarea#swp_og_description").val(),a=160-e.length;e.length>0&&a>=0?s("#social_warfare .swp_og_description .swp_CountDown").removeClass("swp_red").addClass("swp_blue"):e.length>0&&a<0?s("#social_warfare .swp_og_description .swp_CountDown").removeClass("swp_blue").addClass("swp_red"):s("#social_warfare .swp_og_description .swp_CountDown").removeClass("swp_blue").removeClass("swp_red"),s("#social_warfare .swp_og_description .counterNumber").html(a)}function o(){var e,a=s("#social_warfare textarea#swp_custom_tweet").val(),t=s("#social_warfare .twitterIDWrapper label").html();a.indexOf("http")>-1||a.indexOf("https")>-1?(e=0,s(".tweetLinkSection").css({"text-decoration":"line-through"})):(e=23,s(".tweetLinkSection").css({"text-decoration":"none"}));var r;r=void 0===t?280-socialWarfareAdmin.linkLength(a)-e:280-socialWarfareAdmin.linkLength(a)-e-t.length-6,a.length>0&&r>=0?s("#social_warfare .swp_customTweetWrapper .swp_CountDown").removeClass("swp_red").addClass("swp_blue"):a.length>0&&r<0?s("#social_warfare .swp_customTweetWrapper .swp_CountDown").removeClass("swp_blue").addClass("swp_red"):s("#social_warfare .swp_customTweetWrapper .swp_CountDown").removeClass("swp_blue").removeClass("swp_red"),s("#social_warfare .swp_customTweetWrapper .counterNumber").html(r)}function i(){s(".swp-notice-cta").on("click",function(e){e.preventDefault();var a=s(this).parents(".swp-dismiss-notice");s.post({url:ajaxurl,data:{action:"dismiss",key:a.data("key"),timeframe:this.dataset.timeframe},success:function(e){(e=JSON.parse(e))&&a.slideUp(500)}})})}socialWarfareAdmin.linkLength=function(e){for(var s="",a=0;a<23;a++)s+="o";return e.replace(/(http:\/\/[\S]*)/g,s).length},s(document).ready(function(){if(i(),s("#social_warfare.postbox").length){s("#social_warfare #swp_og_title").parent().prepend('<div class="swp_CountDown"><span class="counterNumber">60</span> '+swp_localize_admin.swp_characters_remaining+"</div>"),s("#social_warfare #swp_og_description").parent().prepend('<div class="swp_CountDown"><span class="counterNumber">150</span> '+swp_localize_admin.swp_characters_remaining+"</div>"),s("#social_warfare #swp_customTweet").parent().prepend('<div class="swp_CountDown"><span class="counterNumber">118</span> '+swp_localize_admin.swp_characters_remaining+"</div>"),t(),s("#social_warfare textarea#swp_og_title").on("input",function(){t()}),r(),s("#social_warfare textarea#swp_og_description").on("input",function(){r()}),o(),s("#social_warfare textarea#swp_customTweet").on("input",function(){o()});setInterval(function(){var e,a,t=s(".swp_og_imageWrapper ul.swpmb-media-list"),r=s(".swp_pinterest_imageWrapper ul.swpmb-media-list");t.length&&t.is(":empty")?(e=t.width(),a=e*(9/16),t.css({height:a+"px"})):(a=t.find("img").height(),t.css({height:a+"px"}));var o,i;r.length&&r.is(":empty")?(o=r.width(),i=1.5*o,r.css({height:i+"px"})):(i=r.find("img").height(),r.css({height:i+"px"}))},1e3)}swpConditionalFields(),s(".swp_popular_post_options select").on("change",function(){swpConditionalFields()})})}(0,jQuery);
|
js/script.js
CHANGED
@@ -224,15 +224,18 @@ var socialWarfarePlugin = socialWarfarePlugin || {};
|
|
224 |
var backgroundColor = $( '.swp_social_panel' ).data( 'floatcolor' );
|
225 |
|
226 |
var el = $( '<div class="nc_wrapper" style="background-color:' + backgroundColor + '"></div>' );
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
|
|
|
|
233 |
firstSocialPanel.clone().appendTo( el );
|
234 |
|
235 |
$( '.nc_wrapper' ).hide().addClass( position );
|
|
|
236 |
var width = firstSocialPanel.outerWidth( true );
|
237 |
var offset = firstSocialPanel.offset();
|
238 |
|
@@ -240,6 +243,7 @@ var socialWarfarePlugin = socialWarfarePlugin || {};
|
|
240 |
width: width,
|
241 |
left: ( alignment == 'center' ? 0 : offset.left )
|
242 |
});
|
|
|
243 |
$( '.swp_social_panel .swp_count' ).css({ transition: 'padding .1s linear' });
|
244 |
$( '.swp_social_panel' ).eq( 0 ).addClass( 'swp_one' );
|
245 |
$( '.swp_social_panel' ).eq( 2 ).addClass( 'swp_two' );
|
@@ -268,7 +272,7 @@ var socialWarfarePlugin = socialWarfarePlugin || {};
|
|
268 |
}
|
269 |
|
270 |
if ( location === 'right' || location === 'left' ) {
|
271 |
-
var floatMobile = $( '.
|
272 |
var direction = (location.indexOf("left") !== -1) ? "left" : "right";
|
273 |
|
274 |
if ( $( '.swp_social_panel' ).not( '.swp_social_panelSide' ).length ) {
|
@@ -279,6 +283,7 @@ var socialWarfarePlugin = socialWarfarePlugin || {};
|
|
279 |
visible = true;
|
280 |
}
|
281 |
});
|
|
|
282 |
if ( offsetOne.left < 100 || $( window ).width() < minWidth ) {
|
283 |
visible = true;
|
284 |
if ( floatMobile == 'bottom' ) {
|
@@ -365,28 +370,28 @@ var socialWarfarePlugin = socialWarfarePlugin || {};
|
|
365 |
}
|
366 |
}
|
367 |
|
368 |
-
|
369 |
-
|
370 |
|
371 |
-
|
372 |
|
373 |
-
|
374 |
-
|
375 |
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
|
381 |
-
|
382 |
|
383 |
-
|
384 |
-
|
385 |
|
386 |
function initShareButtons() {
|
387 |
if ( 0 !== $( '.swp_social_panel' ).length ) {
|
388 |
createFloatBar();
|
389 |
-
|
390 |
swp.activateHoverStates();
|
391 |
handleWindowOpens();
|
392 |
$( window ).scrollTop();
|
224 |
var backgroundColor = $( '.swp_social_panel' ).data( 'floatcolor' );
|
225 |
|
226 |
var el = $( '<div class="nc_wrapper" style="background-color:' + backgroundColor + '"></div>' );
|
227 |
+
el.appendTo( 'body' );
|
228 |
+
|
229 |
+
if ( location === 'left' || location === 'right' ) {
|
230 |
+
var position = firstSocialPanel.data( 'float-mobile' );
|
231 |
+
} else {
|
232 |
+
var position = firstSocialPanel.data( 'float' );
|
233 |
+
}
|
234 |
+
|
235 |
firstSocialPanel.clone().appendTo( el );
|
236 |
|
237 |
$( '.nc_wrapper' ).hide().addClass( position );
|
238 |
+
|
239 |
var width = firstSocialPanel.outerWidth( true );
|
240 |
var offset = firstSocialPanel.offset();
|
241 |
|
243 |
width: width,
|
244 |
left: ( alignment == 'center' ? 0 : offset.left )
|
245 |
});
|
246 |
+
|
247 |
$( '.swp_social_panel .swp_count' ).css({ transition: 'padding .1s linear' });
|
248 |
$( '.swp_social_panel' ).eq( 0 ).addClass( 'swp_one' );
|
249 |
$( '.swp_social_panel' ).eq( 2 ).addClass( 'swp_two' );
|
272 |
}
|
273 |
|
274 |
if ( location === 'right' || location === 'left' ) {
|
275 |
+
var floatMobile = $( '.swp_social_panel' ).data( 'float-mobile' );
|
276 |
var direction = (location.indexOf("left") !== -1) ? "left" : "right";
|
277 |
|
278 |
if ( $( '.swp_social_panel' ).not( '.swp_social_panelSide' ).length ) {
|
283 |
visible = true;
|
284 |
}
|
285 |
});
|
286 |
+
|
287 |
if ( offsetOne.left < 100 || $( window ).width() < minWidth ) {
|
288 |
visible = true;
|
289 |
if ( floatMobile == 'bottom' ) {
|
370 |
}
|
371 |
}
|
372 |
|
373 |
+
function centerSidePanel() {
|
374 |
+
var sidePanel = jQuery("[class*=float-position-center]");
|
375 |
|
376 |
+
if (!sidePanel.length) return;
|
377 |
|
378 |
+
var panelHeight = sidePanel.outerHeight();
|
379 |
+
var windowHeight = window.innerHeight;
|
380 |
|
381 |
+
if (panelHeight > windowHeight) {
|
382 |
+
sidePanel.css("top", 0);
|
383 |
+
return;
|
384 |
+
}
|
385 |
|
386 |
+
var offset = (windowHeight - panelHeight) / 2;
|
387 |
|
388 |
+
sidePanel.css("top", offset);
|
389 |
+
}
|
390 |
|
391 |
function initShareButtons() {
|
392 |
if ( 0 !== $( '.swp_social_panel' ).length ) {
|
393 |
createFloatBar();
|
394 |
+
centerSidePanel();
|
395 |
swp.activateHoverStates();
|
396 |
handleWindowOpens();
|
397 |
$( window ).scrollTop();
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: holas84, dustinwstout, webinator, warfareplugins, nutsandboltsmedi
|
|
3 |
Tags: sharing buttons, social media share, floating share buttons, facebook share, google plus share, linkedin share, pin it, pinterest save, stumbleupon 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: 3.5.1
|
5 |
Tested up to: 4.9
|
6 |
-
Stable tag: 3.0.
|
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.
|
@@ -192,6 +192,19 @@ We have a growing archive of <a href="https://warfareplugins.com/support/" rel="
|
|
192 |
> Robert Ryan, Professional Web Designer
|
193 |
|
194 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
= 3.0.8 (24 MAY 2018) =
|
196 |
* Fixed 'Undefined Index' notices.
|
197 |
* Fixed 'File not found' errors.
|
3 |
Tags: sharing buttons, social media share, floating share buttons, facebook share, google plus share, linkedin share, pin it, pinterest save, stumbleupon 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: 3.5.1
|
5 |
Tested up to: 4.9
|
6 |
+
Stable tag: 3.0.9
|
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.
|
192 |
> Robert Ryan, Professional Web Designer
|
193 |
|
194 |
== Changelog ==
|
195 |
+
|
196 |
+
= 3.0.9 (08 JUN 2018) =
|
197 |
+
* Fix for slow page loads on some sites.
|
198 |
+
* Added notice to warn that StumbleUpon is being removed at the end of the month.
|
199 |
+
* Fix for buttons not showing on mobile in some cases.
|
200 |
+
* Removed calls to Google Plus' and LinkedIn's API's since they no longer offer share counts.
|
201 |
+
* Fix for the Pinterest fallback image functionality.
|
202 |
+
* Fix for admin settings page not saving in some instances.
|
203 |
+
* Fix for the post_id parameter not working in the shortcodes.
|
204 |
+
* Fix for the Buffer share button showing plusses instead of spaces.
|
205 |
+
* Fix for Bitly Authentication occasionally not working.
|
206 |
+
* Fix for some undefined index errors.
|
207 |
+
|
208 |
= 3.0.8 (24 MAY 2018) =
|
209 |
* Fixed 'Undefined Index' notices.
|
210 |
* Fixed 'File not found' errors.
|
social-warfare.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Social Warfare
|
4 |
* Plugin URI: http://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.0.
|
7 |
* Author: Warfare Plugins
|
8 |
* Author URI: http://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.0.
|
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: http://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.0.9
|
7 |
* Author: Warfare Plugins
|
8 |
* Author URI: http://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.0.9' );
|
20 |
define( 'SWP_PLUGIN_FILE', __FILE__ );
|
21 |
define( 'SWP_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
|
22 |
define( 'SWP_PLUGIN_DIR', dirname( __FILE__ ) );
|