WordPress Social Sharing Plugin – Social Warfare - Version 3.1.1

Version Description

(12 JUl 2018) = * Fixed Javascript "minWidth" is undefined. * Fixed which buttons are displayed when using Dynamic Sorting. * Fixed "Undefined Index: post_id" error. * Changed default "Float Before Content" from "ON" to "OFF". * Removed excess printing of "Float Before Content" variable.

Download this release

Release Info

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

Code changes from version 3.1.0 to 3.1.1

Files changed (66) hide show
  1. README.md +103 -0
  2. css/admin-options-page.css +918 -918
  3. css/admin-options.min.css +4 -4
  4. css/admin.css +282 -282
  5. css/style.css +1847 -1847
  6. fonts/sw-icon-font.svg +42 -42
  7. functions/Social_Warfare.php +501 -501
  8. functions/admin/SWP_Click_To_Tweet.php +150 -150
  9. functions/admin/SWP_Column.php +120 -120
  10. functions/admin/SWP_Settings_Link.php +52 -52
  11. functions/admin/SWP_Shortcode_Generator.php +123 -123
  12. functions/admin/SWP_User_Profile.php +119 -119
  13. functions/admin/assets/css/admin.css +13 -13
  14. functions/admin/assets/css/style1.css +174 -174
  15. functions/admin/assets/css/style2.css +172 -172
  16. functions/admin/assets/css/style3.css +164 -164
  17. functions/admin/assets/css/style4.css +167 -167
  18. functions/admin/assets/css/styles.css +170 -170
  19. functions/admin/assets/js/clickToTweet.js +135 -135
  20. functions/admin/assets/js/tmclicktotweet_plugin.js +28 -28
  21. functions/admin/options-fetch.php +156 -156
  22. functions/admin/options-registration.php +87 -87
  23. functions/admin/registration.php +347 -347
  24. functions/admin/swp_system_checker.php +147 -147
  25. functions/frontend-output/SWP_Buttons_Panel.php +925 -940
  26. functions/frontend-output/SWP_Display.php +177 -177
  27. functions/frontend-output/SWP_Header_Output.php +152 -152
  28. functions/frontend-output/SWP_Option_Page_Registration.php +32 -32
  29. functions/frontend-output/SWP_Script.php +294 -275
  30. functions/frontend-output/SWP_Shortcode.php +190 -190
  31. functions/includes/SWP_Addon.php +271 -271
  32. functions/includes/registration.php +59 -59
  33. functions/legacy/update-checker.php +491 -491
  34. functions/options/SWP_Addon_Registration.php +116 -116
  35. functions/options/SWP_Option.php +309 -309
  36. functions/options/SWP_Option_Icons.php +244 -244
  37. functions/options/SWP_Option_Select.php +193 -193
  38. functions/options/SWP_Option_Text.php +90 -90
  39. functions/options/SWP_Option_Textarea.php +86 -86
  40. functions/options/SWP_Option_Toggle.php +83 -83
  41. functions/options/SWP_Options_Page.php +816 -816
  42. functions/options/SWP_Options_Page_Section.php +216 -216
  43. functions/options/SWP_Options_Page_Tab.php +164 -164
  44. functions/options/SWP_Section_HTML.php +561 -561
  45. functions/options/SWP_User_Options.php +34 -34
  46. functions/social-networks/SWP_Facebook.php +197 -197
  47. functions/social-networks/SWP_Google_Plus.php +46 -46
  48. functions/social-networks/SWP_Linkedin.php +31 -31
  49. functions/social-networks/SWP_Pinterest.php +186 -186
  50. functions/social-networks/SWP_Social_Network.php +506 -506
  51. functions/social-networks/SWP_Social_Networks_Loader.php +60 -60
  52. functions/social-networks/SWP_Stumble_Upon.php +85 -85
  53. functions/social-networks/SWP_Twitter.php +181 -181
  54. functions/utilities/SWP_Abstract.php +385 -385
  55. functions/utilities/SWP_CURL.php +109 -109
  56. functions/utilities/SWP_Compatibility.php +150 -150
  57. functions/utilities/SWP_Database_Migration.php +649 -649
  58. functions/utilities/SWP_JSON_Cache_Handler.php +147 -147
  59. functions/utilities/SWP_Localization.php +53 -53
  60. functions/utilities/SWP_Notice.php +405 -405
  61. functions/utilities/SWP_Notice_Loader.php +127 -127
  62. functions/utilities/SWP_Permalink.php +214 -214
  63. functions/utilities/SWP_Plugin_Updater.php +495 -495
  64. functions/utilities/SWP_Post_Cache.php +677 -677
  65. functions/utilities/SWP_Post_Cache_Loader.php +117 -117
  66. functions/utilities/SWP_URL_Management.php +0 -227
README.md ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Social Warfare Repository and Issue Tracker
2
+ This is a public repository for the Social Warfare WordPress plugin created primarily for the purpose of publishing and maintaining a public list of bugs, known issues, and feature requests with the community at large. Please use the "Issues" link above to track or add information to existing issues or to submit new issues altogether (see the guidelines below prior to adding a new issue).
3
+
4
+ ***
5
+
6
+ ## Guidelines & Standards for Creating & Updating Code on This Project
7
+
8
+ Coding Standards are an important factor for achieving a high code quality. A common visual style, naming conventions and other technical settings allow us to produce a homogenous code which is easy to read and maintain.
9
+
10
+ While this project has used various coding standards over time, this guide should provide the framework for all new code additions and to updates made to existing code.
11
+
12
+ ### WordPress Coding Standards
13
+ All WordPress coding standards should be followed. Anything not specifically defined here should defer to WordPress's recommended coding standards found here: [WordPress Coding Standards](https://codex.wordpress.org/WordPress_Coding_Standards).
14
+
15
+ ### Variables and Class Names
16
+ All PHP and Javascript variables, functions and classes, and CSS classes and ID's should follow the following naming standards.
17
+
18
+ **PHP:** All names in PHP will use the Snake Case nomenclature. Independent function names will be preceded with the swp_ vendor prefix (e.g. swp_my_function_name). Methods and properties within classes do not require this prefix.
19
+
20
+ Classes will be snake cased as well, but will also have the first letter of each word capitalized. Class names will also use the singular and never plural (e.g. My_Thing, not My_Things). The first letter will be capitalized on variables containing an instance of a class as well (e.g. $Class = new SWP_Class() ).
21
+
22
+ Line breaks in PHP will be used generously to make the code more easily readable. Two blank lines will be used after a function or method and before the beginning of the docblock for the next function or method. One blank line will appear at the end (but within) each standard dockblock. One blank line will appear immediately before any forward-slashed comments.
23
+
24
+ **Javascript:** In Javascript, we will use the camelCase nomenclature.
25
+
26
+ **CSS:** CSS selectors will use the snake_case nomenclature just as in our PHP code.
27
+
28
+ ### Conditionals and Loops
29
+ No inline/same-line conditionals or loops will be used, nor will we continue to use brace syntax. Rather we will use the colin/endif syntax.
30
+
31
+ ### Style Guidelines for Docblocking Class Methods
32
+ Each file should begin with a docblock, as well as each function and class should be preceded with a docblock to explain it's purpose and functionality. There is no such thing as too much documentation on this project. The purpose is that any developer or even a non-developer should be able to easily browse each file and know exactly what is happening in that file.
33
+
34
+ In our experience, it is better to provide too much explanation than not enough. As such, we want to provide very thorough documentation for each function and method throughout the plugin.
35
+
36
+ The following will serve as an example docblock with instructions to follow.
37
+
38
+ ```
39
+ 1. /**
40
+ 2. * Creates the default value for any new keys.
41
+ 3. *
42
+ 4. * @since 3.0.8 | 16 MAY 2018 | Created the method.
43
+ 5. * @since 3.0.8 | 24 MAY 2018 | Added check for order_of_icons
44
+ 6. * @since 3.1.0 | 13 JUN 2018 | Replaced array bracket notation.
45
+ 7. * @param void
46
+ 8. * @return void
47
+ 9. *
48
+ 10. */
49
+ ```
50
+ **Instructions:**
51
+
52
+ 1. Every class method needs to contain a docblock immediately preceding it's declaration.
53
+ 2. Each doblock should contain, at a minimum, a @_since, a @_param, and a @_return.
54
+ 3. If either the @_param or @_return does not exist, it should be annotated with the word "void".
55
+ 4. The @_since should always use the following format @_since x.x.x | DD MMM YYYY | Description
56
+ 5. Every time a change is made to a method, a new @_since will be added logging that change.
57
+ 6. If a method is anything other than public, it should have an @_access tag explaining why.
58
+ 7. Two blank lines will precede each docblock.
59
+ 8. One blank line within the docblock will be included at the end (see line 9 above).
60
+ 9. No blank lines will be placed between the doblock and the declaration of the method.
61
+ 10. A blank line will be placed between the method description and the @ tags.
62
+ 11. If the title does not fit onto a single line (90 characters), it should be broken into a title and description separated by a blank line.
63
+
64
+ **Note:** Tags are preceded with an underscore to avoid tagging other GitHub users. Tags are not to be preceded with underscores in actual development.
65
+
66
+ ***
67
+
68
+ ## Guidelines for Submitting Issues to this GitHub Issue Tracker
69
+ Before submitting an issue to the issue tracker, please be sure of a few things. By following these guidelines, you maximize the possibility of our development team being able to find a solution to the issue in a quick and thorough manner.
70
+
71
+ ### Prerequisites: Do this BEFORE submitting an issue
72
+
73
+ #### 1. Check the Documentation
74
+ First check the [support documentation](https://warfareplugins.com/support/) on the Warfare Plugins website to ensure that a solution to your issue has not already been addressed. Once you've determined that there is no useful information for your particular issue, you may proceed to step 2.
75
+
76
+ #### 2. Submit a Support Ticket First
77
+ Once you have completed step 1, you need to submit a ticket using the [contact form on the Warfare Plugins website](https://warfareplugins.com/). Once submitted, most tickets are responded to on the same or next business day so please allow until the end of the next business day for a response.
78
+
79
+ Many tickets being posted here are issues that simply require adjusting a single setting to accomodate themes or plugins in certain ways. The support team is able to respond to these much, much more quickly than here in the developer's workspace. Since this is the case, any issues submitted without first going through the support team will be deleted. Otherwise it is a waste of both your time and ours.
80
+
81
+ #### 3. Create an Issue on GitHub
82
+ Only once you have completed the above steps should you submit an issue to GitHub. GitHub is the workspace of the development team. In the rare instances where the support team is unable to solve a particular issue, it will be brought here to be tracked and solved by the development team. GitHub is public so that not only the support team, but also all users can view and track the progress of issues as well as commenting and participating in the conversation regarding each issue.
83
+
84
+ ### Required Information: Provide this information WHILE submitting an issue
85
+ Once you've gone through support and you're ready to submit a GitHub issue, please **copy and paste the following information into your GitHub issue and fill out the blanks**:
86
+
87
+ #### Description of the Issue
88
+
89
+ A. Describe the nature of the issue:
90
+
91
+ B. How can this issue be replicated?:
92
+
93
+ C. Is this issue able to be viewed on your site right now? If so, where?
94
+
95
+ #### Additional Information
96
+
97
+ A. What version of the plugin are you using?
98
+
99
+ B. What version of WordPress are you using?
100
+
101
+ C. What caching plugin(s) are you using?
102
+
103
+ D. What version of PHP are you using?
css/admin-options-page.css CHANGED
@@ -1,918 +1,918 @@
1
- /*********************************************************
2
-
3
- A Responsive Grid System
4
-
5
- *********************************************************/
6
-
7
- .sw-grid {
8
- float: left;
9
- margin-bottom: 2.127659574468%;
10
- padding-top: 0;
11
- }
12
-
13
- .sw-grid-right {
14
- float: right;
15
- margin-bottom: 2.127659574468%;
16
- padding-top: 0;
17
- }
18
-
19
- .sw-col-60,
20
- .sw-col-140,
21
- .sw-col-220,
22
- .sw-col-300,
23
- .sw-col-380,
24
- .sw-col-460,
25
- .sw-col-540,
26
- .sw-col-620,
27
- .sw-col-700,
28
- .sw-col-780,
29
- .sw-col-860 {
30
- margin-right: 2.127659574468%;
31
- }
32
-
33
- .sw-col-60 {
34
- width: 6.382978723404%;
35
- }
36
-
37
- .sw-col-140 {
38
- width: 14.893617021277%;
39
- }
40
-
41
- .sw-col-220 {
42
- width: 23.404255319149%;
43
- }
44
-
45
- .sw-col-300 {
46
- width: 31.914893617021%;
47
- }
48
-
49
- .sw-col-380 {
50
- width: 40.425531914894%;
51
- }
52
-
53
- .sw-col-460 {
54
- width: 48.936170212766%;
55
- }
56
-
57
- .sw-col-540 {
58
- width: 57.446808510638%;
59
- }
60
-
61
- .sw-col-620 {
62
- width: 65.957446808511%;
63
- }
64
-
65
- .sw-col-700 {
66
- width: 74.468085106383%;
67
- }
68
-
69
- .sw-col-780 {
70
- width: 82.978723404255%;
71
- }
72
-
73
- .sw-col-860 {
74
- width: 91.489361702128%;
75
- }
76
-
77
- .sw-col-940 {
78
- width: 100%;
79
- }
80
-
81
- .sw-fit {
82
- margin-left: 0 !important;
83
- margin-right: 0 !important;
84
- }
85
-
86
- .sw-option-container *:last-child {
87
- margin-left: 0 !important;
88
- margin-right: 0 !important;
89
- }
90
-
91
- .sw-clearfix:after, .sw-clearfix:before {
92
- content: ' ';
93
- display: table;
94
- }
95
-
96
- .sw-clearfix:after {
97
- clear: both;
98
- }
99
-
100
- .sw-clearfix {
101
- clear: both;
102
- width: 100%;
103
- }
104
-
105
- img {
106
- -ms-interpolation-mode: bicubic;
107
- border: 0;
108
- height: auto;
109
- max-width: 100%;
110
- vertical-align: middle;
111
- }
112
-
113
- .sw-admin-divider {
114
- width: 100%;
115
- height: 1px;
116
- border-bottom: 1px solid #CED3DC;
117
- margin: 20px 0 40px 0;
118
- }
119
-
120
- .sw-hidden {
121
- display: none!important;
122
- }
123
- .swp_support_link {
124
- border: 1px solid #ccc;
125
- font-size: 18px;
126
- line-height: 20px;
127
- text-decoration: none;
128
- -webkit-border-radius: 50%;
129
- border-radius: 50%;
130
- width: 20px;
131
- display: block;
132
- float: right;
133
- text-align: center;
134
- color: #ccc;
135
- margin-right: 20px;
136
- margin-top: 4px;
137
- padding: 2px;
138
- font-weight: bold;
139
- }
140
- .swp_support_link:hover {
141
- color:#6BCCE9;
142
- border-color:#6BCCE9;
143
- }
144
- .swp_support_link.swp_four_fourths {
145
- margin-left: 20px;
146
- margin-top: 13px;
147
- }
148
- #screen-meta-links .screen-meta-toggle {
149
- display:none!important;
150
- }
151
-
152
- /*********************************************************
153
-
154
- The Header Menu
155
-
156
- *********************************************************/
157
-
158
- #wpwrap,
159
- #wpcontent {
160
- background: #fff;
161
- padding-left: 0;
162
- }
163
-
164
- .sw-top-menu {
165
- border-bottom: 1px solid #CED3DC;
166
- float: none;
167
- background: #fff;
168
- z-index: 5;
169
- margin: 0;
170
- }
171
-
172
- .sw-top-menu[sw-registered="0"] .sw-header-logo {
173
- height: 75px;
174
- float: left;
175
- }
176
-
177
- .sw-top-menu[sw-registered="1"] .sw-header-logo-pro {
178
- height: 75px;
179
- float: left;
180
- }
181
- .sw-top-menu[sw-registered="1"] .sw-header-logo {
182
- display:none;
183
- }
184
-
185
- .sw-top-menu[sw-registered="0"] .sw-header-logo-pro {
186
- display:none;
187
- }
188
-
189
- .sw-header-menu {
190
- height: 75px;
191
- margin: 0;
192
- }
193
-
194
- .sw-header-menu li {
195
- float: left;
196
- margin: 0 15px;
197
- font-size: 16px;
198
- display: table;
199
- height: 75px;
200
- }
201
-
202
- .sw-header-menu li:focus, .sw-header-menu li a:focus {
203
- outline: none;
204
- -webkit-box-shadow: none;
205
- box-shadow: none;
206
- }
207
-
208
- .sw-header-menu li span {
209
- padding: 0 5px 5px 5px;
210
- }
211
-
212
- .sw-header-menu li.sw-active-tab span, .sw-header-menu li:hover span {
213
- border-bottom: 4px solid #30394f;
214
- }
215
-
216
- .sw-header-menu li a {
217
- color: #30394f;
218
- text-decoration: none;
219
- display: table-cell;
220
- vertical-align: middle;
221
- }
222
-
223
- .sw-top-menu .sw-grid {
224
- margin-bottom: 0;
225
- }
226
-
227
-
228
- /*********************************************************
229
-
230
- The Header Menu
231
-
232
- *********************************************************/
233
-
234
- .sw-admin-wrapper, .sw-header-wrapper {
235
- clear: both;
236
- margin: 20px auto 20px auto;
237
- padding: 0 40px 20px 40px;
238
- position: relative;
239
- }
240
-
241
- .sw-header-wrapper {
242
- margin: 0;
243
- }
244
-
245
- .sw-tabs-container .sw-admin-tab {
246
- display: none;
247
- }
248
-
249
- .sw-tabs-container .sw-admin-tab:nth-child(1) {
250
- display: block;
251
- }
252
-
253
- .sw-admin-tab h2 {
254
- font-size: 26px;
255
- line-height: 1.2;
256
- margin: 0;
257
- }
258
-
259
- .sw-admin-tab h2.sw-h-label {
260
- line-height: 56px;
261
- }
262
-
263
- p.sw-subtitle {
264
- font-size: 16px;
265
- line-height: 1.2;
266
- margin: 10px 0 30px 0;
267
- }
268
-
269
- p.sw-checkbox-label,
270
- p.sw-input-label,
271
- p.sw-select-label,
272
- p.sw-authenticate-label {
273
- font-size: 16px;
274
- font-weight: bold;
275
- padding-left: 10%;
276
- }
277
-
278
- .sw-select-label.sw-no-padding {
279
- padding-left: 0;
280
- }
281
-
282
- p.sw-short {
283
- margin: 1em 0 0 0;
284
- }
285
-
286
- p.sw-subtext-label {
287
- margin-top: -10px;
288
- }
289
-
290
- .sw-admin-sidebar img {
291
- margin: 5px 0 10px 0;
292
- }
293
-
294
- .system-status-wrapper {
295
- display: none;
296
- }
297
-
298
- .system-status-container {
299
- width: 90%;
300
- height: 250px;
301
- overflow: hidden;
302
- border: 1px solid #CED3DC;
303
- padding: 5%;
304
- }
305
-
306
- h3.sw-buttons-toggle {
307
- width: 100px;
308
- float: left;
309
- clear: left;
310
- margin: 15px 0 30px 0;
311
- padding-left: 10%;
312
- }
313
-
314
-
315
- /*********************************************************
316
-
317
- Checkboxes
318
-
319
- *********************************************************/
320
-
321
- .sw-checkbox-toggle {
322
- width: 150px;
323
- height: 46px;
324
- background-color: #30394f;
325
- float: right;
326
- margin: 5px 0;
327
- cursor: pointer;
328
- -webkit-border-radius: 4px;
329
- border-radius: 4px;
330
- overflow: hidden;
331
- position: relative;
332
- }
333
-
334
- .sw-checkbox-on, .sw-checkbox-off {
335
- color: white;
336
- font-size: 15px;
337
- text-align: center;
338
- line-height: 46px;
339
- position: absolute;
340
- top: 0;
341
- width: 50%;
342
- height: 100%;
343
- }
344
-
345
- .sw-checkbox-toggle[status="on"] .sw-checkbox-on {
346
- left: 0;
347
- background-color: #71C069;
348
- }
349
-
350
- .sw-checkbox-toggle[status="on"] .sw-checkbox-off,
351
- .sw-checkbox-toggle[status="off"] .sw-checkbox-on {
352
- display: none;
353
- }
354
-
355
- .sw-admin-wrapper[sw-registered="0"] .sw-option-container[premium="1"] .sw-checkbox-toggle[status="on"] .sw-checkbox-on {
356
- display: none;
357
- }
358
- .sw-admin-wrapper[sw-registered="0"] .sw-option-container[premium="1"] .sw-checkbox-toggle[status="on"] .sw-checkbox-off {
359
- right: 0;
360
- background-color: #ee464f;
361
- display: block;
362
- }
363
-
364
- .sw-checkbox-toggle[status="off"] .sw-checkbox-off {
365
- right: 0;
366
- background-color: #ee464f;
367
- }
368
-
369
- input.sw-admin-input {
370
- padding: 15px;
371
- border: 1px solid #ced3cd;
372
- -webkit-border-radius: 4px;
373
- border-radius: 4px;
374
- float: right;
375
- -webkit-box-shadow: none;
376
- box-shadow: none;
377
- margin: 2px 0 1px 0;
378
- width: 100%;
379
- }
380
-
381
- .sw-grid select {
382
- width: 100%;
383
- -webkit-box-shadow: none;
384
- box-shadow: none;
385
- border: 1px solid #ced3cd;
386
- height: 51px;
387
- padding: 15px;
388
- margin: 2px 1px 3px 0;
389
- -webkit-border-radius: 4px;
390
- border-radius: 4px;
391
- }
392
-
393
- a.button.sw-navy-button, a.button.sw-blue-button, a.button.sw-green-button, a.button.sw-red-button {
394
- padding: 15px 30px;
395
- height: auto;
396
- line-height: 1;
397
- -webkit-border-radius: 4px;
398
- border-radius: 4px;
399
- -webkit-box-shadow: none;
400
- box-shadow: none;
401
- float: right;
402
- margin: 15px 0;
403
- }
404
-
405
- a.button.sw-navy-button, a.button.sw-navy-button:focus {
406
- background: #30394f;
407
- color: #fff;
408
- border-color: #2a2d34;
409
- -webkit-box-shadow: none;
410
- box-shadow: none;
411
- }
412
-
413
- a.button.sw-navy-button:hover, a.button.sw-blue-button:hover {
414
- background: #2a2d34;
415
- border-color: #2a2d34;
416
- color: #fff;
417
- -webkit-box-shadow: none;
418
- box-shadow: none;
419
- }
420
-
421
- a.button.sw-blue-button, a.button.sw-blue-button:focus {
422
- background: #6bcce9;
423
- border-color: #6bcce9;
424
- color: #fff;
425
- -webkit-box-shadow: none;
426
- box-shadow: none;
427
- }
428
-
429
- a.button.sw-green-button, a.button.sw-green-button:focus {
430
- background: #71C069;
431
- color: #fff;
432
- border-color: #71C069;
433
- -webkit-box-shadow: none;
434
- box-shadow: none;
435
- }
436
-
437
- a.button.sw-red-button, a.button.sw-red-button:focus, a.button.sw-red-button:hover {
438
- background: #ee464f;
439
- color: #fff;
440
- border-color: #ee464f;
441
- -webkit-box-shadow: none;
442
- box-shadow: none;
443
- }
444
-
445
- .sw-admin-tab a.button {
446
- margin: 5px 0 15px 0;
447
- }
448
-
449
- .sw-save-settings {
450
- width: 100%;
451
- text-align: center;
452
- }
453
-
454
- .sw-red-notice, .sw-green-notice {
455
- color: #fff;
456
- padding: 15px;
457
- -webkit-border-radius: 2px;
458
- border-radius: 2px;
459
- margin: 15px 0;
460
- }
461
-
462
- .sw-red-notice, .sw-loading-message {
463
- background: #ee464f
464
- }
465
-
466
- .sw-green-notice, .sw-loading-complete {
467
- background: #71C069
468
- }
469
-
470
- .sw-loading-bg {
471
- width: 100%;
472
- position: fixed;
473
- top: 0;
474
- left: 0;
475
- height: 100%;
476
- background: rgba(0, 0, 0, 0.8);
477
- z-index: 999999999999;
478
- }
479
-
480
- .sw-loading-message:before, .sw-green-notice:before, .sw-loading-complete:before {
481
- font-family: 'Dashicons';
482
- font-size: 26px;
483
- margin: 0 15px 0 0;
484
- vertical-align: middle;
485
- }
486
-
487
- .sw-red-notice:before, .sw-red-notice:before {
488
- font-family: 'sw-icon-font';
489
- font-size: 26px;
490
- margin: 0 15px 0 0;
491
- vertical-align: middle;
492
- content: 'E';
493
- }
494
-
495
- .sw-red-notice a {
496
- color: #fff;
497
- font-weight: bold;
498
- text-decoration: none;
499
- border-bottom: 2px solid #fff;
500
- }
501
-
502
- .sw-red-notice a:hover {
503
- color: #30394f;
504
- border-bottom: 2px solid #30394f;
505
- }
506
-
507
- .sw-loading-message:before {
508
- content: "\f158"
509
- }
510
-
511
- .sw-green-notice:before, .sw-loading-complete:before {
512
- content: "\f147"
513
- }
514
-
515
- .sw-admin-tab .two-thirds-advanced h2.sw-h-label {
516
- line-height: 1.2;
517
- margin-bottom: 15px;
518
- }
519
-
520
- .sw-italic {
521
- font-style: italic;
522
- }
523
-
524
- p.sw-subtitle.sw-registration-text {
525
- padding: 20px 0 0 0;
526
- font-size: 120%;
527
- line-height: 175%;
528
- }
529
-
530
- .registration-wrapper[registration="1"] .swp_is_not_registered {
531
- display: none;
532
- }
533
-
534
- .registration-wrapper[registration="0"] .swp_is_registered {
535
- display: none;
536
- }
537
-
538
- .tweet-count-wrapper[registration="true"] .swp_tweets_not_activated {
539
- display: none;
540
- }
541
-
542
- .sw-tweet-count-demo {
543
- margin: 20px 0;
544
- }
545
-
546
- .sw-loading-message, .sw-loading-complete {
547
- position: fixed;
548
- top: 50%;
549
- left: 50%;
550
- -webkit-border-radius: 3px;
551
- border-radius: 3px;
552
- padding: 25px;
553
- text-align: center;
554
- font-size: 20px;
555
- color: white;
556
- width: 240px;
557
- margin-top: -46px;
558
- margin-left: -120px;
559
- }
560
-
561
- /*********************************************************
562
-
563
- Textarea
564
-
565
- *********************************************************/
566
-
567
- .sw-grid textarea {
568
- width:100%;
569
- height:120px;
570
- }
571
-
572
- /*********************************************************
573
-
574
- Buttons Drag & Drop
575
-
576
- *********************************************************/
577
-
578
- .sw-active, .sw-inactive {
579
- margin: 0 0 5px 0;
580
- min-width: 50px;
581
- min-height: 40px;
582
- border: 1px dashed #ced3dc;
583
- padding: 0;
584
- -webkit-border-radius: 4px;
585
- border-radius: 4px;
586
- width: auto;
587
- height: auto;
588
- display: inline-block;
589
- max-width:520px;
590
- }
591
-
592
- .sw-s {
593
- font-family: 'sw-icon-font';
594
- color: #fff;
595
- padding: 5px 30px 4px;
596
- margin: 7px 5px 7px;
597
- -webkit-border-radius: 2px;
598
- border-radius: 2px;
599
- display: inline-block;
600
- font-style: normal;
601
- font-size: 15px;
602
- line-height: 15px;
603
- cursor: pointer;
604
- }
605
-
606
- .sw-twitter-icon:before {
607
- content: 's';
608
- }
609
-
610
- .sw-s.sw-twitter-icon {
611
- background-color: #429cd6;
612
- border-color: #3c87b2;
613
- }
614
-
615
- .sw-google_plus-icon:before {
616
- content: 'h';
617
- }
618
-
619
- .sw-s.sw-google_plus-icon {
620
- background-color: #df4b37;
621
- border-color: #c44133;
622
- }
623
-
624
- .sw-facebook-icon:before {
625
- content: 'j';
626
- }
627
-
628
- .sw-s.sw-facebook-icon {
629
- background-color: #3a589e;
630
- border-color: #2e4675;
631
- }
632
-
633
- .sw-pinterest-icon:before {
634
- content: 'b';
635
- }
636
-
637
- .sw-s.sw-pinterest-icon {
638
- background-color: #cd2029;
639
- border-color: #aa1b29;
640
- }
641
-
642
- .sw-linkedin-icon:before {
643
- content: 'f';
644
- }
645
-
646
- .sw-s.sw-linkedin-icon {
647
- background-color: #0d77b7;
648
- border-color: #0c6591;
649
- }
650
-
651
- .sw-tumblr-icon:before {
652
- content: 'r';
653
- }
654
-
655
- .sw-s.sw-tumblr-icon {
656
- background-color: #39475d;
657
- border-color: #27313f;
658
- }
659
-
660
- .sw-stumbleupon-icon:before {
661
- content: 'q';
662
- }
663
-
664
- .sw-s.sw-stumbleupon-icon {
665
- background-color: #ef5025;
666
- border-color: #d34427;
667
- }
668
-
669
- .sw-reddit-icon:before {
670
- content: 'a';
671
- }
672
-
673
- .sw-s.sw-reddit-icon {
674
- background-color: #f04b23;
675
- border-color: #d33f27;
676
- }
677
-
678
- .sw-yummly-icon:before {
679
- content: 'x';
680
- }
681
-
682
- .sw-s.sw-yummly-icon {
683
- background-color: #e26426;
684
- border-color: #b65027;
685
- }
686
-
687
- .sw-whatsapp-icon:before {
688
- content: 'y';
689
- }
690
-
691
- .sw-s.sw-whatsapp-icon {
692
- background-color: #71c169;
693
- border-color: #28b04b;
694
- }
695
-
696
- .sw-pocket-icon:before {
697
- content: 'B';
698
- }
699
-
700
- .sw-s.sw-pocket-icon {
701
- background-color: #ef4056;
702
- border-color: #ce3d55;
703
- }
704
-
705
- .sw-buffer-icon:before {
706
- content: 'z';
707
- }
708
-
709
- .sw-s.sw-buffer-icon {
710
- background-color: #323b43;
711
- border-color: #59626a;
712
- }
713
-
714
- .sw-email-icon:before {
715
- content: 'k';
716
- }
717
-
718
- .sw-s.sw-email-icon {
719
- background-color: #6bcce9;
720
- border-color: #6bcce9;
721
- }
722
-
723
- .sw-hacker_news-icon:before {
724
- content: 'D';
725
- }
726
-
727
- .sw-s.sw-hacker_news-icon {
728
- background-color: #f16522;
729
- border-color: #d85623;
730
- }
731
-
732
- .sw-flipboard-icon:before {
733
- content: 'C';
734
- }
735
-
736
- .sw-s.sw-flipboard-icon {
737
- background-color: #e02828;
738
- border-color: #bf2626;
739
- }
740
-
741
- @media screen and (max-width: 1350px) {
742
- .sw-header-menu li {
743
- font-size: 12px;
744
- margin: 0 10px;
745
- }
746
- }
747
-
748
- @media screen and (max-width: 1080px) {
749
- .sw-header-logo {
750
- display: none;
751
- }
752
- }
753
-
754
-
755
- /*********************************************************
756
-
757
- Premium
758
-
759
- *********************************************************/
760
-
761
- .sw-admin-wrapper[sw-registered="0"] [premium="1"] {
762
- display:none!important;
763
- }
764
-
765
- .sw-admin-wrapper[sw-registered="0"] .sw-option-container {
766
- position: relative;
767
- }
768
-
769
- .sw-admin-wrapper[sw-registered="0"] [premium="1"] .sw-premium-blocker {
770
- display:none;
771
- }
772
-
773
- .sw-admin-wrapper[sw-registered="0"] [premium="1"] .sw-premium-blocker:not(.no-icon):before {
774
- font-family: 'sw-icon-font';
775
- content: 'E';
776
- font-size: 24px;
777
- float: right;
778
- margin: 20px 20px 0 0;
779
- }
780
-
781
- .sw-admin-wrapper[sw-registered="0"] i[premium-button="1"] {
782
- display: none;
783
- }
784
-
785
- .sw-admin-wrapper[sw-registered="1"] .sw-premium-buttons {
786
- display: none;
787
- }
788
-
789
- .sw-admin-wrapper[swp-addons*="pro"] [premium],
790
- .sw-admin-wrapper[swp-addons*="affiliatewp"] [premium],
791
- .sw-admin-wrapper[swp-addons*="enhanced_shortcodes"] [premium],
792
- .sw-admin-wrapper[swp-addons*="advanced_display"] [premium] {
793
- display: none;
794
- }
795
-
796
- .sw-admin-wrapper[swp-addons*="pro"][swp-registrations*="pro"] [premium],
797
- .sw-admin-wrapper[swp-addons*="affiliatewp"][swp-registrations*="affiliatewp"] [premium],
798
- .sw-admin-wrapper[swp-addons*="enhanced_shortcodes"][swp-registrations*="enhanced_shortcodes"] [premium],
799
- .sw-admin-wrapper[swp-addons*="advanced_display"][swp-registrations*="advanced_display"] [premium]{
800
- display: inherit;
801
- }
802
-
803
- .ui-tooltip.sw-admin-hover-notice {
804
- background: #ee464f;
805
- color: #fff;
806
- padding: 15px;
807
- -webkit-border-radius: 2px;
808
- border-radius: 2px;
809
- margin: 15px 0;
810
- border: 0;
811
- -webkit-box-shadow: none;
812
- box-shadow: none;
813
- max-width: none;
814
- padding: 20px;
815
- }
816
-
817
- .sw-admin-hover-notice i:before {
818
- font-family: 'sw-icon-font';
819
- font-size: 26px;
820
- margin: 0 15px 0 0;
821
- vertical-align: middle;
822
- content: 'E';
823
- float: left;
824
- font-style: normal;
825
- }
826
-
827
- .swp_upload_image_field {
828
- display: none;
829
- }
830
-
831
- .sw-admin-image-preview {
832
- max-height: 50px;
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);
873
- height: 120px;
874
- width: 97%
875
- }
876
-
877
- #color-notice {
878
- position: fixed;
879
- bottom: 15px;
880
- margin: 0 auto;
881
- left: 25%;
882
- right: 25%;
883
- background: rgba( 255, 225, 255, .37 );
884
- background-color: #ced3dc;
885
- color: #30394f;
886
- padding: 20px;
887
- border-radius: 4px;
888
- text-align: left;
889
- width: 650px;
890
-
891
- }
892
-
893
- #color-notice p {
894
- font-size: 16px;
895
- padding: 0px;
896
- margin: 0px;
897
- }
898
-
899
- #color-notice .color-dismiss {
900
- float: right;
901
- color: #ffffff;
902
- font-weight: 600;
903
- }
904
-
905
- #color-notice .color-dismiss:before {
906
- content: 'x';
907
- background: #30394f;
908
- border-radius: 50%;
909
- width: 26px;
910
- display: block;
911
- text-align: center;
912
- height: 26px;
913
- line-height: 22px;
914
- font-size: 22px;
915
- cursor: pointer;
916
- padding: 0;
917
- opacity: .4;
918
- }
1
+ /*********************************************************
2
+
3
+ A Responsive Grid System
4
+
5
+ *********************************************************/
6
+
7
+ .sw-grid {
8
+ float: left;
9
+ margin-bottom: 2.127659574468%;
10
+ padding-top: 0;
11
+ }
12
+
13
+ .sw-grid-right {
14
+ float: right;
15
+ margin-bottom: 2.127659574468%;
16
+ padding-top: 0;
17
+ }
18
+
19
+ .sw-col-60,
20
+ .sw-col-140,
21
+ .sw-col-220,
22
+ .sw-col-300,
23
+ .sw-col-380,
24
+ .sw-col-460,
25
+ .sw-col-540,
26
+ .sw-col-620,
27
+ .sw-col-700,
28
+ .sw-col-780,
29
+ .sw-col-860 {
30
+ margin-right: 2.127659574468%;
31
+ }
32
+
33
+ .sw-col-60 {
34
+ width: 6.382978723404%;
35
+ }
36
+
37
+ .sw-col-140 {
38
+ width: 14.893617021277%;
39
+ }
40
+
41
+ .sw-col-220 {
42
+ width: 23.404255319149%;
43
+ }
44
+
45
+ .sw-col-300 {
46
+ width: 31.914893617021%;
47
+ }
48
+
49
+ .sw-col-380 {
50
+ width: 40.425531914894%;
51
+ }
52
+
53
+ .sw-col-460 {
54
+ width: 48.936170212766%;
55
+ }
56
+
57
+ .sw-col-540 {
58
+ width: 57.446808510638%;
59
+ }
60
+
61
+ .sw-col-620 {
62
+ width: 65.957446808511%;
63
+ }
64
+
65
+ .sw-col-700 {
66
+ width: 74.468085106383%;
67
+ }
68
+
69
+ .sw-col-780 {
70
+ width: 82.978723404255%;
71
+ }
72
+
73
+ .sw-col-860 {
74
+ width: 91.489361702128%;
75
+ }
76
+
77
+ .sw-col-940 {
78
+ width: 100%;
79
+ }
80
+
81
+ .sw-fit {
82
+ margin-left: 0 !important;
83
+ margin-right: 0 !important;
84
+ }
85
+
86
+ .sw-option-container *:last-child {
87
+ margin-left: 0 !important;
88
+ margin-right: 0 !important;
89
+ }
90
+
91
+ .sw-clearfix:after, .sw-clearfix:before {
92
+ content: ' ';
93
+ display: table;
94
+ }
95
+
96
+ .sw-clearfix:after {
97
+ clear: both;
98
+ }
99
+
100
+ .sw-clearfix {
101
+ clear: both;
102
+ width: 100%;
103
+ }
104
+
105
+ img {
106
+ -ms-interpolation-mode: bicubic;
107
+ border: 0;
108
+ height: auto;
109
+ max-width: 100%;
110
+ vertical-align: middle;
111
+ }
112
+
113
+ .sw-admin-divider {
114
+ width: 100%;
115
+ height: 1px;
116
+ border-bottom: 1px solid #CED3DC;
117
+ margin: 20px 0 40px 0;
118
+ }
119
+
120
+ .sw-hidden {
121
+ display: none!important;
122
+ }
123
+ .swp_support_link {
124
+ border: 1px solid #ccc;
125
+ font-size: 18px;
126
+ line-height: 20px;
127
+ text-decoration: none;
128
+ -webkit-border-radius: 50%;
129
+ border-radius: 50%;
130
+ width: 20px;
131
+ display: block;
132
+ float: right;
133
+ text-align: center;
134
+ color: #ccc;
135
+ margin-right: 20px;
136
+ margin-top: 4px;
137
+ padding: 2px;
138
+ font-weight: bold;
139
+ }
140
+ .swp_support_link:hover {
141
+ color:#6BCCE9;
142
+ border-color:#6BCCE9;
143
+ }
144
+ .swp_support_link.swp_four_fourths {
145
+ margin-left: 20px;
146
+ margin-top: 13px;
147
+ }
148
+ #screen-meta-links .screen-meta-toggle {
149
+ display:none!important;
150
+ }
151
+
152
+ /*********************************************************
153
+
154
+ The Header Menu
155
+
156
+ *********************************************************/
157
+
158
+ #wpwrap,
159
+ #wpcontent {
160
+ background: #fff;
161
+ padding-left: 0;
162
+ }
163
+
164
+ .sw-top-menu {
165
+ border-bottom: 1px solid #CED3DC;
166
+ float: none;
167
+ background: #fff;
168
+ z-index: 5;
169
+ margin: 0;
170
+ }
171
+
172
+ .sw-top-menu[sw-registered="0"] .sw-header-logo {
173
+ height: 75px;
174
+ float: left;
175
+ }
176
+
177
+ .sw-top-menu[sw-registered="1"] .sw-header-logo-pro {
178
+ height: 75px;
179
+ float: left;
180
+ }
181
+ .sw-top-menu[sw-registered="1"] .sw-header-logo {
182
+ display:none;
183
+ }
184
+
185
+ .sw-top-menu[sw-registered="0"] .sw-header-logo-pro {
186
+ display:none;
187
+ }
188
+
189
+ .sw-header-menu {
190
+ height: 75px;
191
+ margin: 0;
192
+ }
193
+
194
+ .sw-header-menu li {
195
+ float: left;
196
+ margin: 0 15px;
197
+ font-size: 16px;
198
+ display: table;
199
+ height: 75px;
200
+ }
201
+
202
+ .sw-header-menu li:focus, .sw-header-menu li a:focus {
203
+ outline: none;
204
+ -webkit-box-shadow: none;
205
+ box-shadow: none;
206
+ }
207
+
208
+ .sw-header-menu li span {
209
+ padding: 0 5px 5px 5px;
210
+ }
211
+
212
+ .sw-header-menu li.sw-active-tab span, .sw-header-menu li:hover span {
213
+ border-bottom: 4px solid #30394f;
214
+ }
215
+
216
+ .sw-header-menu li a {
217
+ color: #30394f;
218
+ text-decoration: none;
219
+ display: table-cell;
220
+ vertical-align: middle;
221
+ }
222
+
223
+ .sw-top-menu .sw-grid {
224
+ margin-bottom: 0;
225
+ }
226
+
227
+
228
+ /*********************************************************
229
+
230
+ The Header Menu
231
+
232
+ *********************************************************/
233
+
234
+ .sw-admin-wrapper, .sw-header-wrapper {
235
+ clear: both;
236
+ margin: 20px auto 20px auto;
237
+ padding: 0 40px 20px 40px;
238
+ position: relative;
239
+ }
240
+
241
+ .sw-header-wrapper {
242
+ margin: 0;
243
+ }
244
+
245
+ .sw-tabs-container .sw-admin-tab {
246
+ display: none;
247
+ }
248
+
249
+ .sw-tabs-container .sw-admin-tab:nth-child(1) {
250
+ display: block;
251
+ }
252
+
253
+ .sw-admin-tab h2 {
254
+ font-size: 26px;
255
+ line-height: 1.2;
256
+ margin: 0;
257
+ }
258
+
259
+ .sw-admin-tab h2.sw-h-label {
260
+ line-height: 56px;
261
+ }
262
+
263
+ p.sw-subtitle {
264
+ font-size: 16px;
265
+ line-height: 1.2;
266
+ margin: 10px 0 30px 0;
267
+ }
268
+
269
+ p.sw-checkbox-label,
270
+ p.sw-input-label,
271
+ p.sw-select-label,
272
+ p.sw-authenticate-label {
273
+ font-size: 16px;
274
+ font-weight: bold;
275
+ padding-left: 10%;
276
+ }
277
+
278
+ .sw-select-label.sw-no-padding {
279
+ padding-left: 0;
280
+ }
281
+
282
+ p.sw-short {
283
+ margin: 1em 0 0 0;
284
+ }
285
+
286
+ p.sw-subtext-label {
287
+ margin-top: -10px;
288
+ }
289
+
290
+ .sw-admin-sidebar img {
291
+ margin: 5px 0 10px 0;
292
+ }
293
+
294
+ .system-status-wrapper {
295
+ display: none;
296
+ }
297
+
298
+ .system-status-container {
299
+ width: 90%;
300
+ height: 250px;
301
+ overflow: hidden;
302
+ border: 1px solid #CED3DC;
303
+ padding: 5%;
304
+ }
305
+
306
+ h3.sw-buttons-toggle {
307
+ width: 100px;
308
+ float: left;
309
+ clear: left;
310
+ margin: 15px 0 30px 0;
311
+ padding-left: 10%;
312
+ }
313
+
314
+
315
+ /*********************************************************
316
+
317
+ Checkboxes
318
+
319
+ *********************************************************/
320
+
321
+ .sw-checkbox-toggle {
322
+ width: 150px;
323
+ height: 46px;
324
+ background-color: #30394f;
325
+ float: right;
326
+ margin: 5px 0;
327
+ cursor: pointer;
328
+ -webkit-border-radius: 4px;
329
+ border-radius: 4px;
330
+ overflow: hidden;
331
+ position: relative;
332
+ }
333
+
334
+ .sw-checkbox-on, .sw-checkbox-off {
335
+ color: white;
336
+ font-size: 15px;
337
+ text-align: center;
338
+ line-height: 46px;
339
+ position: absolute;
340
+ top: 0;
341
+ width: 50%;
342
+ height: 100%;
343
+ }
344
+
345
+ .sw-checkbox-toggle[status="on"] .sw-checkbox-on {
346
+ left: 0;
347
+ background-color: #71C069;
348
+ }
349
+
350
+ .sw-checkbox-toggle[status="on"] .sw-checkbox-off,
351
+ .sw-checkbox-toggle[status="off"] .sw-checkbox-on {
352
+ display: none;
353
+ }
354
+
355
+ .sw-admin-wrapper[sw-registered="0"] .sw-option-container[premium="1"] .sw-checkbox-toggle[status="on"] .sw-checkbox-on {
356
+ display: none;
357
+ }
358
+ .sw-admin-wrapper[sw-registered="0"] .sw-option-container[premium="1"] .sw-checkbox-toggle[status="on"] .sw-checkbox-off {
359
+ right: 0;
360
+ background-color: #ee464f;
361
+ display: block;
362
+ }
363
+
364
+ .sw-checkbox-toggle[status="off"] .sw-checkbox-off {
365
+ right: 0;
366
+ background-color: #ee464f;
367
+ }
368
+
369
+ input.sw-admin-input {
370
+ padding: 15px;
371
+ border: 1px solid #ced3cd;
372
+ -webkit-border-radius: 4px;
373
+ border-radius: 4px;
374
+ float: right;
375
+ -webkit-box-shadow: none;
376
+ box-shadow: none;
377
+ margin: 2px 0 1px 0;
378
+ width: 100%;
379
+ }
380
+
381
+ .sw-grid select {
382
+ width: 100%;
383
+ -webkit-box-shadow: none;
384
+ box-shadow: none;
385
+ border: 1px solid #ced3cd;
386
+ height: 51px;
387
+ padding: 15px;
388
+ margin: 2px 1px 3px 0;
389
+ -webkit-border-radius: 4px;
390
+ border-radius: 4px;
391
+ }
392
+
393
+ a.button.sw-navy-button, a.button.sw-blue-button, a.button.sw-green-button, a.button.sw-red-button {
394
+ padding: 15px 30px;
395
+ height: auto;
396
+ line-height: 1;
397
+ -webkit-border-radius: 4px;
398
+ border-radius: 4px;
399
+ -webkit-box-shadow: none;
400
+ box-shadow: none;
401
+ float: right;
402
+ margin: 15px 0;
403
+ }
404
+
405
+ a.button.sw-navy-button, a.button.sw-navy-button:focus {
406
+ background: #30394f;
407
+ color: #fff;
408
+ border-color: #2a2d34;
409
+ -webkit-box-shadow: none;
410
+ box-shadow: none;
411
+ }
412
+
413
+ a.button.sw-navy-button:hover, a.button.sw-blue-button:hover {
414
+ background: #2a2d34;
415
+ border-color: #2a2d34;
416
+ color: #fff;
417
+ -webkit-box-shadow: none;
418
+ box-shadow: none;
419
+ }
420
+
421
+ a.button.sw-blue-button, a.button.sw-blue-button:focus {
422
+ background: #6bcce9;
423
+ border-color: #6bcce9;
424
+ color: #fff;
425
+ -webkit-box-shadow: none;
426
+ box-shadow: none;
427
+ }
428
+
429
+ a.button.sw-green-button, a.button.sw-green-button:focus {
430
+ background: #71C069;
431
+ color: #fff;
432
+ border-color: #71C069;
433
+ -webkit-box-shadow: none;
434
+ box-shadow: none;
435
+ }
436
+
437
+ a.button.sw-red-button, a.button.sw-red-button:focus, a.button.sw-red-button:hover {
438
+ background: #ee464f;
439
+ color: #fff;
440
+ border-color: #ee464f;
441
+ -webkit-box-shadow: none;
442
+ box-shadow: none;
443
+ }
444
+
445
+ .sw-admin-tab a.button {
446
+ margin: 5px 0 15px 0;
447
+ }
448
+
449
+ .sw-save-settings {
450
+ width: 100%;
451
+ text-align: center;
452
+ }
453
+
454
+ .sw-red-notice, .sw-green-notice {
455
+ color: #fff;
456
+ padding: 15px;
457
+ -webkit-border-radius: 2px;
458
+ border-radius: 2px;
459
+ margin: 15px 0;
460
+ }
461
+
462
+ .sw-red-notice, .sw-loading-message {
463
+ background: #ee464f
464
+ }
465
+
466
+ .sw-green-notice, .sw-loading-complete {
467
+ background: #71C069
468
+ }
469
+
470
+ .sw-loading-bg {
471
+ width: 100%;
472
+ position: fixed;
473
+ top: 0;
474
+ left: 0;
475
+ height: 100%;
476
+ background: rgba(0, 0, 0, 0.8);
477
+ z-index: 999999999999;
478
+ }
479
+
480
+ .sw-loading-message:before, .sw-green-notice:before, .sw-loading-complete:before {
481
+ font-family: 'Dashicons';
482
+ font-size: 26px;
483
+ margin: 0 15px 0 0;
484
+ vertical-align: middle;
485
+ }
486
+
487
+ .sw-red-notice:before, .sw-red-notice:before {
488
+ font-family: 'sw-icon-font';
489
+ font-size: 26px;
490
+ margin: 0 15px 0 0;
491
+ vertical-align: middle;
492
+ content: 'E';
493
+ }
494
+
495
+ .sw-red-notice a {
496
+ color: #fff;
497
+ font-weight: bold;
498
+ text-decoration: none;
499
+ border-bottom: 2px solid #fff;
500
+ }
501
+
502
+ .sw-red-notice a:hover {
503
+ color: #30394f;
504
+ border-bottom: 2px solid #30394f;
505
+ }
506
+
507
+ .sw-loading-message:before {
508
+ content: "\f158"
509
+ }
510
+
511
+ .sw-green-notice:before, .sw-loading-complete:before {
512
+ content: "\f147"
513
+ }
514
+
515
+ .sw-admin-tab .two-thirds-advanced h2.sw-h-label {
516
+ line-height: 1.2;
517
+ margin-bottom: 15px;
518
+ }
519
+
520
+ .sw-italic {
521
+ font-style: italic;
522
+ }
523
+
524
+ p.sw-subtitle.sw-registration-text {
525
+ padding: 20px 0 0 0;
526
+ font-size: 120%;
527
+ line-height: 175%;
528
+ }
529
+
530
+ .registration-wrapper[registration="1"] .swp_is_not_registered {
531
+ display: none;
532
+ }
533
+
534
+ .registration-wrapper[registration="0"] .swp_is_registered {
535
+ display: none;
536
+ }
537
+
538
+ .tweet-count-wrapper[registration="true"] .swp_tweets_not_activated {
539
+ display: none;
540
+ }
541
+
542
+ .sw-tweet-count-demo {
543
+ margin: 20px 0;
544
+ }
545
+
546
+ .sw-loading-message, .sw-loading-complete {
547
+ position: fixed;
548
+ top: 50%;
549
+ left: 50%;
550
+ -webkit-border-radius: 3px;
551
+ border-radius: 3px;
552
+ padding: 25px;
553
+ text-align: center;
554
+ font-size: 20px;
555
+ color: white;
556
+ width: 240px;
557
+ margin-top: -46px;
558
+ margin-left: -120px;
559
+ }
560
+
561
+ /*********************************************************
562
+
563
+ Textarea
564
+
565
+ *********************************************************/
566
+
567
+ .sw-grid textarea {
568
+ width:100%;
569
+ height:120px;
570
+ }
571
+
572
+ /*********************************************************
573
+
574
+ Buttons Drag & Drop
575
+
576
+ *********************************************************/
577
+
578
+ .sw-active, .sw-inactive {
579
+ margin: 0 0 5px 0;
580
+ min-width: 50px;
581
+ min-height: 40px;
582
+ border: 1px dashed #ced3dc;
583
+ padding: 0;
584
+ -webkit-border-radius: 4px;
585
+ border-radius: 4px;
586
+ width: auto;
587
+ height: auto;
588
+ display: inline-block;
589
+ max-width:520px;
590
+ }
591
+
592
+ .sw-s {
593
+ font-family: 'sw-icon-font';
594
+ color: #fff;
595
+ padding: 5px 30px 4px;
596
+ margin: 7px 5px 7px;
597
+ -webkit-border-radius: 2px;
598
+ border-radius: 2px;
599
+ display: inline-block;
600
+ font-style: normal;
601
+ font-size: 15px;
602
+ line-height: 15px;
603
+ cursor: pointer;
604
+ }
605
+
606
+ .sw-twitter-icon:before {
607
+ content: 's';
608
+ }
609
+
610
+ .sw-s.sw-twitter-icon {
611
+ background-color: #429cd6;
612
+ border-color: #3c87b2;
613
+ }
614
+
615
+ .sw-google_plus-icon:before {
616
+ content: 'h';
617
+ }
618
+
619
+ .sw-s.sw-google_plus-icon {
620
+ background-color: #df4b37;
621
+ border-color: #c44133;
622
+ }
623
+
624
+ .sw-facebook-icon:before {
625
+ content: 'j';
626
+ }
627
+
628
+ .sw-s.sw-facebook-icon {
629
+ background-color: #3a589e;
630
+ border-color: #2e4675;
631
+ }
632
+
633
+ .sw-pinterest-icon:before {
634
+ content: 'b';
635
+ }
636
+
637
+ .sw-s.sw-pinterest-icon {
638
+ background-color: #cd2029;
639
+ border-color: #aa1b29;
640
+ }
641
+
642
+ .sw-linkedin-icon:before {
643
+ content: 'f';
644
+ }
645
+
646
+ .sw-s.sw-linkedin-icon {
647
+ background-color: #0d77b7;
648
+ border-color: #0c6591;
649
+ }
650
+
651
+ .sw-tumblr-icon:before {
652
+ content: 'r';
653
+ }
654
+
655
+ .sw-s.sw-tumblr-icon {
656
+ background-color: #39475d;
657
+ border-color: #27313f;
658
+ }
659
+
660
+ .sw-stumbleupon-icon:before {
661
+ content: 'q';
662
+ }
663
+
664
+ .sw-s.sw-stumbleupon-icon {
665
+ background-color: #ef5025;
666
+ border-color: #d34427;
667
+ }
668
+
669
+ .sw-reddit-icon:before {
670
+ content: 'a';
671
+ }
672
+
673
+ .sw-s.sw-reddit-icon {
674
+ background-color: #f04b23;
675
+ border-color: #d33f27;
676
+ }
677
+
678
+ .sw-yummly-icon:before {
679
+ content: 'x';
680
+ }
681
+
682
+ .sw-s.sw-yummly-icon {
683
+ background-color: #e26426;
684
+ border-color: #b65027;
685
+ }
686
+
687
+ .sw-whatsapp-icon:before {
688
+ content: 'y';
689
+ }
690
+
691
+ .sw-s.sw-whatsapp-icon {
692
+ background-color: #71c169;
693
+ border-color: #28b04b;
694
+ }
695
+
696
+ .sw-pocket-icon:before {
697
+ content: 'B';
698
+ }
699
+
700
+ .sw-s.sw-pocket-icon {
701
+ background-color: #ef4056;
702
+ border-color: #ce3d55;
703
+ }
704
+
705
+ .sw-buffer-icon:before {
706
+ content: 'z';
707
+ }
708
+
709
+ .sw-s.sw-buffer-icon {
710
+ background-color: #323b43;
711
+ border-color: #59626a;
712
+ }
713
+
714
+ .sw-email-icon:before {
715
+ content: 'k';
716
+ }
717
+
718
+ .sw-s.sw-email-icon {
719
+ background-color: #6bcce9;
720
+ border-color: #6bcce9;
721
+ }
722
+
723
+ .sw-hacker_news-icon:before {
724
+ content: 'D';
725
+ }
726
+
727
+ .sw-s.sw-hacker_news-icon {
728
+ background-color: #f16522;
729
+ border-color: #d85623;
730
+ }
731
+
732
+ .sw-flipboard-icon:before {
733
+ content: 'C';
734
+ }
735
+
736
+ .sw-s.sw-flipboard-icon {
737
+ background-color: #e02828;
738
+ border-color: #bf2626;
739
+ }
740
+
741
+ @media screen and (max-width: 1350px) {
742
+ .sw-header-menu li {
743
+ font-size: 12px;
744
+ margin: 0 10px;
745
+ }
746
+ }
747
+
748
+ @media screen and (max-width: 1080px) {
749
+ .sw-header-logo {
750
+ display: none;
751
+ }
752
+ }
753
+
754
+
755
+ /*********************************************************
756
+
757
+ Premium
758
+
759
+ *********************************************************/
760
+
761
+ .sw-admin-wrapper[sw-registered="0"] [premium="1"] {
762
+ display:none!important;
763
+ }
764
+
765
+ .sw-admin-wrapper[sw-registered="0"] .sw-option-container {
766
+ position: relative;
767
+ }
768
+
769
+ .sw-admin-wrapper[sw-registered="0"] [premium="1"] .sw-premium-blocker {
770
+ display:none;
771
+ }
772
+
773
+ .sw-admin-wrapper[sw-registered="0"] [premium="1"] .sw-premium-blocker:not(.no-icon):before {
774
+ font-family: 'sw-icon-font';
775
+ content: 'E';
776
+ font-size: 24px;
777
+ float: right;
778
+ margin: 20px 20px 0 0;
779
+ }
780
+
781
+ .sw-admin-wrapper[sw-registered="0"] i[premium-button="1"] {
782
+ display: none;
783
+ }
784
+
785
+ .sw-admin-wrapper[sw-registered="1"] .sw-premium-buttons {
786
+ display: none;
787
+ }
788
+
789
+ .sw-admin-wrapper[swp-addons*="pro"] [premium],
790
+ .sw-admin-wrapper[swp-addons*="affiliatewp"] [premium],
791
+ .sw-admin-wrapper[swp-addons*="enhanced_shortcodes"] [premium],
792
+ .sw-admin-wrapper[swp-addons*="advanced_display"] [premium] {
793
+ display: none;
794
+ }
795
+
796
+ .sw-admin-wrapper[swp-addons*="pro"][swp-registrations*="pro"] [premium],
797
+ .sw-admin-wrapper[swp-addons*="affiliatewp"][swp-registrations*="affiliatewp"] [premium],
798
+ .sw-admin-wrapper[swp-addons*="enhanced_shortcodes"][swp-registrations*="enhanced_shortcodes"] [premium],
799
+ .sw-admin-wrapper[swp-addons*="advanced_display"][swp-registrations*="advanced_display"] [premium]{
800
+ display: inherit;
801
+ }
802
+
803
+ .ui-tooltip.sw-admin-hover-notice {
804
+ background: #ee464f;
805
+ color: #fff;
806
+ padding: 15px;
807
+ -webkit-border-radius: 2px;
808
+ border-radius: 2px;
809
+ margin: 15px 0;
810
+ border: 0;
811
+ -webkit-box-shadow: none;
812
+ box-shadow: none;
813
+ max-width: none;
814
+ padding: 20px;
815
+ }
816
+
817
+ .sw-admin-hover-notice i:before {
818
+ font-family: 'sw-icon-font';
819
+ font-size: 26px;
820
+ margin: 0 15px 0 0;
821
+ vertical-align: middle;
822
+ content: 'E';
823
+ float: left;
824
+ font-style: normal;
825
+ }
826
+
827
+ .swp_upload_image_field {
828
+ display: none;
829
+ }
830
+
831
+ .sw-admin-image-preview {
832
+ max-height: 50px;
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);
873
+ height: 120px;
874
+ width: 97%
875
+ }
876
+
877
+ #color-notice {
878
+ position: fixed;
879
+ bottom: 15px;
880
+ margin: 0 auto;
881
+ left: 25%;
882
+ right: 25%;
883
+ background: rgba( 255, 225, 255, .37 );
884
+ background-color: #ced3dc;
885
+ color: #30394f;
886
+ padding: 20px;
887
+ border-radius: 4px;
888
+ text-align: left;
889
+ width: 650px;
890
+
891
+ }
892
+
893
+ #color-notice p {
894
+ font-size: 16px;
895
+ padding: 0px;
896
+ margin: 0px;
897
+ }
898
+
899
+ #color-notice .color-dismiss {
900
+ float: right;
901
+ color: #ffffff;
902
+ font-weight: 600;
903
+ }
904
+
905
+ #color-notice .color-dismiss:before {
906
+ content: 'x';
907
+ background: #30394f;
908
+ border-radius: 50%;
909
+ width: 26px;
910
+ display: block;
911
+ text-align: center;
912
+ height: 26px;
913
+ line-height: 22px;
914
+ font-size: 22px;
915
+ cursor: pointer;
916
+ padding: 0;
917
+ opacity: .4;
918
+ }
css/admin-options.min.css CHANGED
@@ -1,5 +1,5 @@
1
- border: rgb(221, 221, 221);
2
- box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
3
- height: 120px;
4
- width: 97%
5
  __ESCAPED_SOURCE_END_CLEAN_CSS__
1
+ border: rgb(221, 221, 221);
2
+ box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
3
+ height: 120px;
4
+ width: 97%
5
  __ESCAPED_SOURCE_END_CLEAN_CSS__
css/admin.css CHANGED
@@ -1,282 +1,282 @@
1
- .notAvailable {
2
- opacity: 0.3;
3
- }
4
-
5
- .swp_CountDown {
6
- background-color: #CCC;
7
- display: inline-block;
8
- float: right;
9
- padding: 5px 15px;
10
- -webkit-border-radius: 3px 3px 0 0;
11
- border-radius: 3px 3px 0 0;
12
- color: #FFF;
13
- font-weight: bold;
14
- margin-top: -27px;
15
- }
16
-
17
- .swp_CountDown.swp_blue {
18
- background-color: #30394F;
19
- }
20
-
21
- .swp_CountDown.swp_red {
22
- background-color: #EE464F;
23
- }
24
-
25
- #social_warfare textarea.large-text {
26
- width: 100%;
27
- }
28
-
29
- #social_warfare ul.swpmb-media-list.ui-sortable {
30
- display: block;
31
- width: 100%;
32
- -webkit-background-size: cover;
33
- background-size: cover;
34
- background-position-x: center;
35
- background-repeat: no-repeat;
36
- background-color: #ccc;
37
- -webkit-border-radius: 4px;
38
- border-radius: 4px;
39
- padding: 0;
40
- }
41
-
42
- #social_warfare .swp_og_imageWrapper ul.swpmb-media-list {
43
- background-image: url('../images/img-placeholder-og.jpg');
44
- }
45
-
46
- #social_warfare .swp_pinterest_imageWrapper ul.swpmb-media-list {
47
- background-image: url('../images/img-placeholder-pin.jpg');
48
- }
49
-
50
- .swpmb-field.swpmb-textarea-wrapper.swp_og_title,
51
- .swpmb-field.swpmb-textarea-wrapper.swp_og_description,
52
- .swpmb-field.swpmb-textarea-wrapper.swp_pinterest_descriptionWrapper,
53
- .swpmb-field.swpmb-textarea-wrapper.swp_customTweetWrapper {
54
- width: 63%;
55
- float: left;
56
- }
57
-
58
- .swpmb-field.swpmb-text-wrapper.swp_share_recoveryWrapper {
59
- width: 63%;
60
- float: left;
61
- }
62
-
63
- .swpmb-field.swpmb-text-wrapper.swp_share_recoveryWrapper input {
64
- width: 100%;
65
- }
66
-
67
-
68
- .swpmb-field.swpmb-select-wrapper.swp_pin_browser_extensionWrapper,
69
- .swpmb-field.swpmb-select-wrapper.swp_pin_browser_extension_locationWrapper,
70
- .swpmb-field.swpmb-select-wrapper.swp_post_locationWrapper,
71
- .swpmb-field.swpmb-select-wrapper.swp_float_locationWrapper {
72
- width:32%;
73
- float:left;
74
- min-width:320px;
75
- }
76
- .swpmb-field.swpmb-select-wrapper.swp_pin_browser_extensionWrapper select,
77
- .swpmb-field.swpmb-select-wrapper.swp_pin_browser_extension_locationWrapper select,
78
- .swpmb-field.swpmb-select-wrapper.swp_post_locationWrapper select,
79
- .swpmb-field.swpmb-select-wrapper.swp_float_locationWrapper select {
80
- width:90%;
81
- }
82
-
83
- .swpmb-field.swpmb-image_advanced-wrapper.swp_og_imageWrapper,
84
- .swpmb-field.swpmb-image_advanced-wrapper.swp_pinterest_imageWrapper {
85
- width: 30%;
86
- float: left;
87
- margin-right: 3%;
88
- }
89
-
90
- #social_warfare .swpmb-label, #social_warfare .swpmb-input {
91
- width: 100%;
92
- }
93
-
94
- #social_warfare .swpmb-field {
95
- margin-top: 10px;
96
- }
97
-
98
- #social_warfare .swpmb-image-item,
99
- #social_warfare .swpmb-media-preview,
100
- #social_warfare .swpmb-media-content .centered,
101
- #social_warfare .swpmb-media-content img {
102
- width: 100%;
103
- height: auto;
104
- max-height: none;
105
- -webkit-transform: none;
106
- -ms-transform: none;
107
- transform: none;
108
- }
109
-
110
- .wp-core-ui #social_warfare a.swpmb-add-media.button {
111
- display: block;
112
- background: #30394f;
113
- color: #fff;
114
- font-size: 12px;
115
- line-height: 1;
116
- text-align: center;
117
- vertical-align: middle;
118
- padding: 15px 25px;
119
- margin: 0;
120
- -webkit-box-shadow: none;
121
- box-shadow: none;
122
- border: none;
123
- height: auto;
124
- }
125
-
126
- .wp-core-ui #social_warfare a.swpmb-add-media.button:hover {
127
- background: #EE464F;
128
- }
129
-
130
- #social_warfare .swpmb-media-content img {
131
- -webkit-transform: translate(0%, 0%);
132
- -ms-transform: translate(0%, 0%);
133
- transform: translate(0%, 0%);
134
- }
135
-
136
- #social_warfare .swpmb-media-content {
137
- overflow: visible;
138
- }
139
-
140
- #social_warfare .swpmb-media-preview:before {
141
- padding-top: 0px;
142
- }
143
-
144
- #social_warfare .swpmb-media-content {
145
- position: inherit;
146
- }
147
-
148
- #social_warfare .swpmb-divider-wrapper hr {
149
- border: none!important
150
- }
151
-
152
- #social_warfare .swpmb-label label {
153
- font-weight: bold;
154
- color: #30394f;
155
- font-size: 18px;
156
- }
157
-
158
- #social_warfare .swpmb-divider-wrapper {
159
- max-height: 1px;
160
- clear: both;
161
- }
162
-
163
- #social_warfare .swpmb-label {
164
- margin-bottom: 10px;
165
- }
166
-
167
- #social_warfare h2.hndle span:before {
168
- content: 'p';
169
- margin-right: 10px;
170
- font-family: "sw-icon-font";
171
- vertical-align: middle;
172
- }
173
-
174
- #social_warfare .dashicons, #social_warfare .sw {
175
- vertical-align: middle;
176
- margin-right: 10px;
177
- font-size: 18px;
178
- }
179
-
180
- #social_warfare .sw-premium-blocker {
181
- position: absolute;
182
- width: 100%;
183
- height: 100%;
184
- top: 0;
185
- left: 0;
186
- }
187
-
188
- #social_warfare .sw-premium-blocker:not(.no-icon):before {
189
- font-family: 'sw-icon-font';
190
- content: 'E';
191
- font-size: 24px;
192
- float: right;
193
- margin: 10px 40px 0 0;
194
- }
195
- /*
196
- #social_warfare .swp_share_recoveryWrapper {
197
- margin-left: 33%;
198
- width: 90%;
199
-
200
- } */
201
-
202
- #social_warfare #swp_recovery_url {
203
- /* width: 100%; */
204
- }
205
-
206
- .ui-tooltip.sw-admin-hover-notice {
207
- background: #ee464f;
208
- color: #fff;
209
- padding: 15px;
210
- -webkit-border-radius: 2px;
211
- border-radius: 2px;
212
- margin: 15px 0;
213
- border: 0;
214
- -webkit-box-shadow: none;
215
- box-shadow: none;
216
- max-width: none;
217
- padding: 20px;
218
- }
219
-
220
- .sw-admin-hover-notice i:before {
221
- font-family: 'sw-icon-font';
222
- font-size: 26px;
223
- margin: 0 15px 0 0;
224
- vertical-align: middle;
225
- content: 'E';
226
- float: left;
227
- font-style: normal;
228
- }
229
-
230
- /* Adds the border between sections. */
231
- [class$=title_wrapper] ~ [class$=title_wrapper] {
232
- border-top: 1px solid #CED3DC;
233
- padding-top: 40px;
234
- }
235
-
236
- .swp-notice-wrapper {
237
- max-width: 73%;
238
- margin-top: -15px;
239
- margin-bottom: 15px;
240
- }
241
-
242
- .swp-notice {
243
- padding: 10px 15px;
244
- padding: 20px;
245
- }
246
-
247
- .swp-actions {
248
- display: flex;
249
- align-items: center;
250
- }
251
-
252
- .swp-notice a {
253
- cursor: hover;
254
- text-decoration: underline;
255
- margin: 0 10px;
256
- }
257
-
258
- .swp-dismiss-notice.notice.notice-info {
259
- font-size: 15px;
260
- line-height: 25px;
261
- }
262
-
263
- .swp-dismiss-notice.notice.notice-info {
264
- border-left-color: #D34250;
265
- padding: 20px;
266
- margin: 15px 0 15px;
267
- }
268
-
269
- .swp-dismiss-notice.notice.notice-info p {
270
- font-size: 15px;
271
- line-height: 25px;
272
- padding: 0;
273
- margin: 0 0 20px;
274
- }
275
-
276
- a.swp-notice-cta {
277
- cursor: pointer;
278
- text-decoration: underline;
279
- font-size: 15px;
280
- line-height: 30px;
281
- margin-right: 50px;
282
- }
1
+ .notAvailable {
2
+ opacity: 0.3;
3
+ }
4
+
5
+ .swp_CountDown {
6
+ background-color: #CCC;
7
+ display: inline-block;
8
+ float: right;
9
+ padding: 5px 15px;
10
+ -webkit-border-radius: 3px 3px 0 0;
11
+ border-radius: 3px 3px 0 0;
12
+ color: #FFF;
13
+ font-weight: bold;
14
+ margin-top: -27px;
15
+ }
16
+
17
+ .swp_CountDown.swp_blue {
18
+ background-color: #30394F;
19
+ }
20
+
21
+ .swp_CountDown.swp_red {
22
+ background-color: #EE464F;
23
+ }
24
+
25
+ #social_warfare textarea.large-text {
26
+ width: 100%;
27
+ }
28
+
29
+ #social_warfare ul.swpmb-media-list.ui-sortable {
30
+ display: block;
31
+ width: 100%;
32
+ -webkit-background-size: cover;
33
+ background-size: cover;
34
+ background-position-x: center;
35
+ background-repeat: no-repeat;
36
+ background-color: #ccc;
37
+ -webkit-border-radius: 4px;
38
+ border-radius: 4px;
39
+ padding: 0;
40
+ }
41
+
42
+ #social_warfare .swp_og_imageWrapper ul.swpmb-media-list {
43
+ background-image: url('../images/img-placeholder-og.jpg');
44
+ }
45
+
46
+ #social_warfare .swp_pinterest_imageWrapper ul.swpmb-media-list {
47
+ background-image: url('../images/img-placeholder-pin.jpg');
48
+ }
49
+
50
+ .swpmb-field.swpmb-textarea-wrapper.swp_og_title,
51
+ .swpmb-field.swpmb-textarea-wrapper.swp_og_description,
52
+ .swpmb-field.swpmb-textarea-wrapper.swp_pinterest_descriptionWrapper,
53
+ .swpmb-field.swpmb-textarea-wrapper.swp_customTweetWrapper {
54
+ width: 63%;
55
+ float: left;
56
+ }
57
+
58
+ .swpmb-field.swpmb-text-wrapper.swp_share_recoveryWrapper {
59
+ width: 63%;
60
+ float: left;
61
+ }
62
+
63
+ .swpmb-field.swpmb-text-wrapper.swp_share_recoveryWrapper input {
64
+ width: 100%;
65
+ }
66
+
67
+
68
+ .swpmb-field.swpmb-select-wrapper.swp_pin_browser_extensionWrapper,
69
+ .swpmb-field.swpmb-select-wrapper.swp_pin_browser_extension_locationWrapper,
70
+ .swpmb-field.swpmb-select-wrapper.swp_post_locationWrapper,
71
+ .swpmb-field.swpmb-select-wrapper.swp_float_locationWrapper {
72
+ width:32%;
73
+ float:left;
74
+ min-width:320px;
75
+ }
76
+ .swpmb-field.swpmb-select-wrapper.swp_pin_browser_extensionWrapper select,
77
+ .swpmb-field.swpmb-select-wrapper.swp_pin_browser_extension_locationWrapper select,
78
+ .swpmb-field.swpmb-select-wrapper.swp_post_locationWrapper select,
79
+ .swpmb-field.swpmb-select-wrapper.swp_float_locationWrapper select {
80
+ width:90%;
81
+ }
82
+
83
+ .swpmb-field.swpmb-image_advanced-wrapper.swp_og_imageWrapper,
84
+ .swpmb-field.swpmb-image_advanced-wrapper.swp_pinterest_imageWrapper {
85
+ width: 30%;
86
+ float: left;
87
+ margin-right: 3%;
88
+ }
89
+
90
+ #social_warfare .swpmb-label, #social_warfare .swpmb-input {
91
+ width: 100%;
92
+ }
93
+
94
+ #social_warfare .swpmb-field {
95
+ margin-top: 10px;
96
+ }
97
+
98
+ #social_warfare .swpmb-image-item,
99
+ #social_warfare .swpmb-media-preview,
100
+ #social_warfare .swpmb-media-content .centered,
101
+ #social_warfare .swpmb-media-content img {
102
+ width: 100%;
103
+ height: auto;
104
+ max-height: none;
105
+ -webkit-transform: none;
106
+ -ms-transform: none;
107
+ transform: none;
108
+ }
109
+
110
+ .wp-core-ui #social_warfare a.swpmb-add-media.button {
111
+ display: block;
112
+ background: #30394f;
113
+ color: #fff;
114
+ font-size: 12px;
115
+ line-height: 1;
116
+ text-align: center;
117
+ vertical-align: middle;
118
+ padding: 15px 25px;
119
+ margin: 0;
120
+ -webkit-box-shadow: none;
121
+ box-shadow: none;
122
+ border: none;
123
+ height: auto;
124
+ }
125
+
126
+ .wp-core-ui #social_warfare a.swpmb-add-media.button:hover {
127
+ background: #EE464F;
128
+ }
129
+
130
+ #social_warfare .swpmb-media-content img {
131
+ -webkit-transform: translate(0%, 0%);
132
+ -ms-transform: translate(0%, 0%);
133
+ transform: translate(0%, 0%);
134
+ }
135
+
136
+ #social_warfare .swpmb-media-content {
137
+ overflow: visible;
138
+ }
139
+
140
+ #social_warfare .swpmb-media-preview:before {
141
+ padding-top: 0px;
142
+ }
143
+
144
+ #social_warfare .swpmb-media-content {
145
+ position: inherit;
146
+ }
147
+
148
+ #social_warfare .swpmb-divider-wrapper hr {
149
+ border: none!important
150
+ }
151
+
152
+ #social_warfare .swpmb-label label {
153
+ font-weight: bold;
154
+ color: #30394f;
155
+ font-size: 18px;
156
+ }
157
+
158
+ #social_warfare .swpmb-divider-wrapper {
159
+ max-height: 1px;
160
+ clear: both;
161
+ }
162
+
163
+ #social_warfare .swpmb-label {
164
+ margin-bottom: 10px;
165
+ }
166
+
167
+ #social_warfare h2.hndle span:before {
168
+ content: 'p';
169
+ margin-right: 10px;
170
+ font-family: "sw-icon-font";
171
+ vertical-align: middle;
172
+ }
173
+
174
+ #social_warfare .dashicons, #social_warfare .sw {
175
+ vertical-align: middle;
176
+ margin-right: 10px;
177
+ font-size: 18px;
178
+ }
179
+
180
+ #social_warfare .sw-premium-blocker {
181
+ position: absolute;
182
+ width: 100%;
183
+ height: 100%;
184
+ top: 0;
185
+ left: 0;
186
+ }
187
+
188
+ #social_warfare .sw-premium-blocker:not(.no-icon):before {
189
+ font-family: 'sw-icon-font';
190
+ content: 'E';
191
+ font-size: 24px;
192
+ float: right;
193
+ margin: 10px 40px 0 0;
194
+ }
195
+ /*
196
+ #social_warfare .swp_share_recoveryWrapper {
197
+ margin-left: 33%;
198
+ width: 90%;
199
+
200
+ } */
201
+
202
+ #social_warfare #swp_recovery_url {
203
+ /* width: 100%; */
204
+ }
205
+
206
+ .ui-tooltip.sw-admin-hover-notice {
207
+ background: #ee464f;
208
+ color: #fff;
209
+ padding: 15px;
210
+ -webkit-border-radius: 2px;
211
+ border-radius: 2px;
212
+ margin: 15px 0;
213
+ border: 0;
214
+ -webkit-box-shadow: none;
215
+ box-shadow: none;
216
+ max-width: none;
217
+ padding: 20px;
218
+ }
219
+
220
+ .sw-admin-hover-notice i:before {
221
+ font-family: 'sw-icon-font';
222
+ font-size: 26px;
223
+ margin: 0 15px 0 0;
224
+ vertical-align: middle;
225
+ content: 'E';
226
+ float: left;
227
+ font-style: normal;
228
+ }
229
+
230
+ /* Adds the border between sections. */
231
+ [class$=title_wrapper] ~ [class$=title_wrapper] {
232
+ border-top: 1px solid #CED3DC;
233
+ padding-top: 40px;
234
+ }
235
+
236
+ .swp-notice-wrapper {
237
+ max-width: 73%;
238
+ margin-top: -15px;
239
+ margin-bottom: 15px;
240
+ }
241
+
242
+ .swp-notice {
243
+ padding: 10px 15px;
244
+ padding: 20px;
245
+ }
246
+
247
+ .swp-actions {
248
+ display: flex;
249
+ align-items: center;
250
+ }
251
+
252
+ .swp-notice a {
253
+ cursor: hover;
254
+ text-decoration: underline;
255
+ margin: 0 10px;
256
+ }
257
+
258
+ .swp-dismiss-notice.notice.notice-info {
259
+ font-size: 15px;
260
+ line-height: 25px;
261
+ }
262
+
263
+ .swp-dismiss-notice.notice.notice-info {
264
+ border-left-color: #D34250;
265
+ padding: 20px;
266
+ margin: 15px 0 15px;
267
+ }
268
+
269
+ .swp-dismiss-notice.notice.notice-info p {
270
+ font-size: 15px;
271
+ line-height: 25px;
272
+ padding: 0;
273
+ margin: 0 0 20px;
274
+ }
275
+
276
+ a.swp-notice-cta {
277
+ cursor: pointer;
278
+ text-decoration: underline;
279
+ font-size: 15px;
280
+ line-height: 30px;
281
+ margin-right: 50px;
282
+ }
css/style.css CHANGED
@@ -1,1847 +1,1847 @@
1
- .swp_social_panel {
2
- clear: both;
3
- display: -webkit-box;
4
- display: -webkit-flex;
5
- display: -moz-box;
6
- display: -ms-flexbox;
7
- display: flex;
8
- height: 34px;
9
- line-height: 1;
10
- margin-bottom: 20px!important;
11
- margin-top: 20px!important;
12
- overflow: hidden;
13
- padding: 0;
14
-
15
- -webkit-align-items: stretch;
16
- align-items: stretch;
17
- -webkit-box-align: stretch;
18
- -moz-box-align: stretch;
19
- -webkit-box-pack: justify;
20
- -moz-box-pack: justify;
21
- direction: ltr;
22
- -ms-flex-align: stretch;
23
- -ms-flex-line-pack: center;
24
- -ms-flex-pack: justify;
25
- -webkit-flex-wrap: wrap;
26
- -ms-flex-wrap: wrap;
27
- flex-wrap: wrap;
28
- -webkit-justify-content: space-between;
29
- justify-content: space-between;
30
- }
31
-
32
- .swp_social_panel:not(.nc_floater):not(.swp_social_panelSide) {
33
- width: 100%!important;
34
- }
35
-
36
- .nc_wrapper .swp_social_panel {
37
- margin-bottom: 10px!important;
38
- margin-top: 10px!important;
39
- }
40
-
41
- div.swp_social_panel .nc_tweetContainer {
42
- -webkit-border-radius: 2px;
43
- border-radius: 2px;
44
- cursor: pointer;
45
- float: left;
46
- font-family: Lato;
47
- height: 32px;
48
- margin: 0 5px 3px 5px;
49
- min-width: 34px;
50
- overflow: hidden;
51
- text-align: center;
52
- -webkit-transition: all 0.1s linear;
53
- transition: all 0.1s linear;
54
- }
55
-
56
- div.swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer {
57
- -webkit-box-flex: 1;
58
- -moz-box-flex: 1;
59
- -webkit-flex: 1;
60
- -ms-flex: 1;
61
- flex: 1;
62
- }
63
-
64
- .swp_social_panel .nc_tweetContainer a.nc_tweet,
65
- .swp_social_panel .total_shares .swp_count {
66
- display: block;
67
- display: -webkit-box;
68
- display: -webkit-flex;
69
- display: -moz-box;
70
- display: -ms-flexbox;
71
- display: flex;
72
- font-family: Lato, sans-serif;
73
- font-size: 18px!important;
74
- font-weight: bold;
75
- height: 30px;
76
- text-decoration: none;
77
- text-decoration: none!important;
78
- text-transform: none;
79
-
80
- -webkit-box-direction: normal;
81
- -moz-box-direction: normal;
82
- -webkit-box-orient: horizontal;
83
- -moz-box-orient: horizontal;
84
- -webkit-flex-flow: row wrap;
85
- -ms-flex-flow: row wrap;
86
- flex-flow: row wrap;
87
- }
88
-
89
- .swp_social_panel:not(.nc_floater):not(.swp_social_panelSide).swp_shift {
90
- padding:0 10px;
91
- }
92
-
93
- .swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer:nth-child(1) {
94
- margin-left: 0;
95
- }
96
-
97
- .swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer:nth-last-child(1) {
98
- margin-right: 0;
99
- }
100
-
101
- .swp_social_panel a .swp_count:not(.swp_hide) {
102
- display: inline-block;
103
- line-height: 32px;
104
- margin: 0;
105
- padding: 0 5px;
106
-
107
- -webkit-box-flex: 1;
108
- -moz-box-flex: 1;
109
- -webkit-flex: 1;
110
- -ms-flex: 1;
111
- flex: 1;
112
- }
113
-
114
- .swp_social_panel a .swp_count.swp_hide {
115
- margin: 0 auto;
116
- }
117
-
118
- .swp_social_panel span:before {
119
- content: initial!important;
120
- }
121
-
122
- .swp_social_panel .total_shares .swp_count {
123
- line-height: 30px;
124
- }
125
-
126
- .swp_social_panel span.swp_count {
127
- font-size: 14px;
128
- }
129
-
130
- .swp_social_panel span.iconFiller {
131
- font-size: 18px;
132
- margin: 0 auto;
133
- }
134
-
135
- .swp_social_panel.notMobile .nc_tweetContainer:nth-child(1) {
136
- margin-left: 0;
137
- }
138
-
139
- .swp_social_panel:not(.swp_social_panelSide) {
140
- -webkit-transition: opacity 0.2s ease-in-out;
141
- transition: opacity 0.2s ease-in-out;
142
- }
143
-
144
- .swp_social_panel:not(.swp_social_panelSide) div.total_shares.total_sharesalt:nth-child(1) {
145
- margin-left: 0;
146
- margin-right: 15px;
147
- padding-left: 0;
148
- }
149
-
150
- .swp_social_panel:not(.swp_social_panelSide) div.total_shares.total_sharesalt:nth-last-child(1) {
151
- margin-right: 0;
152
- padding-right: 0;
153
- }
154
-
155
- a.swp_CTT {
156
- cursor: pointer;
157
- }
158
-
159
- span.swp_share {
160
- display: block;
161
- float: right;
162
- float: left;
163
- font-size: 14px;
164
- font-weight: normal;
165
- height: 30px;
166
- line-height: 30px;
167
- margin: 0 0 0 6px;
168
- max-width: none!important;
169
- vertical-align: middle;
170
- }
171
-
172
- .swp_social_panelSide span.swp_share {
173
- margin: 0;
174
- }
175
-
176
- .swp_social_panel .sw {
177
- float: left;
178
- height: 30px;
179
- line-height: 32px;
180
- margin: 0 5px;
181
- text-shadow: none!important;
182
- width: 20px;
183
- }
184
-
185
- .iconFiller {
186
- display: block;
187
- float: left;
188
- height: 30px;
189
- overflow: hidden;
190
- -webkit-transition: width 0.1s linear;
191
- transition: width 0.1s linear;
192
- }
193
-
194
- .swp_social_panel .iconFiller {
195
- width: 30px;
196
- }
197
-
198
- span.spaceManWilly {
199
- display: block;
200
- width: 120px;
201
- }
202
-
203
- .swp_social_panel .total_shares {
204
- background: transparent !important;;
205
- border: none !important;
206
- -webkit-border-radius: 2px;
207
- border-radius: 2px;
208
- color: white;
209
- cursor: default;
210
- display: block;
211
- font-size: 19px;
212
- padding: 0 10px;
213
-
214
- -webkit-box-flex: 0!important;
215
- -moz-box-flex: 0!important;
216
- -webkit-flex: none!important;
217
- -ms-flex: none!important;
218
- flex: none!important;
219
- }
220
-
221
- .swp_social_panel .total_sharesalt {
222
- background: transparent !important;
223
- border: none !important;
224
- }
225
-
226
- .swp_social_panel div.total_shares.total_sharesalt,
227
- .swp_social_panel:hover div.total_shares.total_sharesalt:not(:nth-child(1)) {
228
- background: transparent!important;
229
- border: none;
230
- color: #474b4d;
231
- margin-left: 0!important;
232
- margin-bottom: 10px !important;
233
- }
234
-
235
- div.swp_social_panel:hover div.total_shares.total_sharesalt:not(:nth-child(1)) {
236
- background: transparent;
237
- color: #474b4d;
238
- margin-left: 10px;
239
- }
240
-
241
- .swp_social_panel .total_shares.total_sharesalt .swp_label {
242
- color: #474b4d;
243
- font-size: 10px;
244
- letter-spacing: 0;
245
- min-width: 40px;
246
- vertical-align: middle;
247
- }
248
-
249
- .swp_social_panel .total_shares .swp_label {
250
- font-size: 10px;
251
- vertical-align: middle;
252
- }
253
-
254
- .swp_social_panel .total_shares.total_sharesalt .swp_count {
255
- color: #474b4d;
256
- font-size: 24px;
257
- }
258
-
259
- .swp_social_panel:hover .total_shares,
260
- .swp_social_panel.swp_full_color .total_shares,
261
- .swp_social_panel.swp_fade .total_shares,
262
- .swp_social_panel.swp_customFull:hover div.total_shares {
263
- background: #e08a0f;
264
- }
265
-
266
- .swp_social_panel .nc_tweetContainer.total_shares.total_sharesalt:before {
267
- content: "o";
268
- display: inline-block;
269
- font-family: sw-icon-font;
270
- margin-top: 7px;
271
- vertical-align: top;
272
- }
273
-
274
- .swp_social_panel:not(.swp_social_panelSide) .total_shares.total_sharesalt .swp_count {
275
- display: inline-block;
276
- line-height: 0;
277
- margin-left: 8px;
278
- margin-top: 12px;
279
- min-width: 45px;
280
- position: relative;
281
- vertical-align: middle;
282
- }
283
-
284
- span.swp_label {
285
- display: block;
286
- font-size: 9px!important;
287
- margin-top: 13px;
288
- position: absolute;
289
- text-align: center!important;
290
- text-transform: uppercase;
291
- }
292
-
293
- .swp_social_panelSide span.swp_label {
294
- margin-top: 0;
295
- }
296
-
297
- .swp_social_panel.swp_leaf .nc_tweetContainer {
298
- -webkit-border-radius: 15px 0!important;
299
- border-radius: 15px 0!important;
300
- border-width: 1px;
301
- }
302
-
303
- .swp_social_panel.swp_pill .nc_tweetContainer {
304
- -webkit-border-radius: 50px;
305
- border-radius: 50px;
306
- border-width: 1px;
307
- }
308
-
309
- .swp_social_panel.swp_shift .nc_tweetContainer:not(.total_shares) {
310
- border-width: 1px;
311
- -moz-transform: skew(-25deg);
312
- -o-transform: skew(-25deg);
313
- -webkit-transform: skew(-25deg);
314
- }
315
-
316
- .swp_social_panel.swp_shift .nc_tweetContainer a {
317
- -moz-transform: skew(25deg);
318
- -o-transform: skew(25deg);
319
- -webkit-transform: skew(25deg);
320
- }
321
-
322
- .swp_connected .nc_tweetContainer,
323
- .swp_connected:hover .nc_tweetContainer,
324
- .swp_connected .nc_tweetContainer:hover {
325
- -webkit-border-radius: 0!important;
326
- border-radius: 0!important;
327
- border-width: 1px;
328
- margin: 0!important;
329
- }
330
-
331
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_google_plus,
332
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_google_plus:hover,
333
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_google_plus:not(:hover) {
334
- border: 1px solid #df4b37;
335
- }
336
-
337
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_twitter,
338
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_twitter:hover,
339
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_twitter:not(:hover) {
340
- border: 1px solid #429cd6;
341
- }
342
-
343
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_facebook,
344
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_facebook:hover,
345
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_facebook:not(:hover) {
346
- border: 1px solid #3a589e;
347
- }
348
-
349
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_pinterest,
350
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_pinterest:hover,
351
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_pinterest:not(:hover) {
352
- border: 1px solid #cd2029;
353
- }
354
-
355
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_linkedin,
356
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_linkedin:hover,
357
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_linkedin:not(:hover) {
358
- border: 1px solid #0d77b7;
359
- }
360
-
361
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_tumblr,
362
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_tumblr:hover,
363
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_tumblr:not(:hover) {
364
- border: 1px solid #39475d;
365
- }
366
-
367
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_stumbleupon,
368
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_stumbleupon:hover,
369
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_stumbleupon:not(:hover) {
370
- border: 1px solid #ef5025;
371
- }
372
-
373
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_yummly,
374
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_yummly:hover,
375
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_yummly:not(:hover) {
376
- border: 1px solid #e26426;
377
- }
378
-
379
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_reddit,
380
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_reddit:hover,
381
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_reddit:not(:hover) {
382
- border: 1px solid #f04b23;
383
- }
384
-
385
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_email,
386
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_email:hover,
387
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_email:not(:hover) {
388
- border: 1px solid #6bcce9;
389
- }
390
-
391
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_whatsapp,
392
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_whatsapp:hover,
393
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_whatsapp:not(:hover) {
394
- border: 1px solid #71c169;
395
- }
396
-
397
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_pocket,
398
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_pocket:hover,
399
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_pocket:not(:hover) {
400
- border: 1px solid #ef4056;
401
- }
402
-
403
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_buffer,
404
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_buffer:hover,
405
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_buffer:not(:hover) {
406
- border: 1px solid #323b43;
407
- }
408
-
409
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_hacker_news,
410
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_hacker_news:hover,
411
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_hacker_news:not(:hover) {
412
- border: 1px solid #d85623;
413
- }
414
-
415
- .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_flipboard,
416
- html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_flipboard:hover,
417
- body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_flipboard:not(:hover) {
418
- border: 1px solid #bf2626;
419
- }
420
-
421
- .swp_social_panel.swp_default_full_color .swp_google_plus,
422
- html body .swp_social_panel.swp_individual_full_color .swp_google_plus:hover,
423
- body .swp_social_panel.swp_other_full_color:hover .swp_google_plus {
424
- background: #df4b37;
425
- border: 1px solid #c44133;
426
- }
427
-
428
- .swp_social_panel.swp_default_full_color .swp_twitter,
429
- html body .swp_social_panel.swp_individual_full_color .swp_twitter:hover,
430
- body .swp_social_panel.swp_other_full_color:hover .swp_twitter {
431
- background: #429cd6;
432
- border: 1px solid #3c87b2;
433
- }
434
-
435
- .swp_social_panel.swp_default_full_color .swp_facebook,
436
- html body .swp_social_panel.swp_individual_full_color .swp_facebook:hover,
437
- body .swp_social_panel.swp_other_full_color:hover .swp_facebook {
438
- background: #3a589e;
439
- border: 1px solid #2e4675;
440
- }
441
-
442
- .swp_social_panel.swp_default_full_color .swp_pinterest,
443
- html body .swp_social_panel.swp_individual_full_color .swp_pinterest:hover,
444
- body .swp_social_panel.swp_other_full_color:hover .swp_pinterest {
445
- background: #cd2029;
446
- border: 1px solid #aa1b29;
447
- }
448
-
449
- .swp_social_panel.swp_default_full_color .swp_linkedin,
450
- html body .swp_social_panel.swp_individual_full_color .swp_linkedin:hover,
451
- body .swp_social_panel.swp_other_full_color:hover .swp_linkedin {
452
- background: #0d77b7;
453
- border: 1px solid #0c6591;
454
- }
455
-
456
- .swp_social_panel.swp_default_full_color .swp_tumblr,
457
- html body .swp_social_panel.swp_individual_full_color .swp_tumblr:hover,
458
- body .swp_social_panel.swp_other_full_color:hover .swp_tumblr {
459
- background: #39475d;
460
- border: 1px solid #27313f;
461
- }
462
-
463
- .swp_social_panel.swp_default_full_color .swp_stumbleupon,
464
- html body .swp_social_panel.swp_individual_full_color .swp_stumbleupon:hover,
465
- body .swp_social_panel.swp_other_full_color:hover .swp_stumbleupon {
466
- background: #ef5025;
467
- border: 1px solid #d34427;
468
- }
469
-
470
- .swp_social_panel.swp_default_full_color .swp_yummly,
471
- html body .swp_social_panel.swp_individual_full_color .swp_yummly:hover,
472
- body .swp_social_panel.swp_other_full_color:hover .swp_yummly {
473
- background: #e26426;
474
- border: 1px solid #b65027;
475
- }
476
-
477
- .swp_social_panel.swp_default_full_color .swp_reddit,
478
- html body .swp_social_panel.swp_individual_full_color .swp_reddit:hover,
479
- body .swp_social_panel.swp_other_full_color:hover .swp_reddit {
480
- background: #f04b23;
481
- border: 1px solid #d33f27;
482
- }
483
-
484
- .swp_social_panel.swp_default_full_color .swp_email,
485
- html body .swp_social_panel.swp_individual_full_color .swp_email:hover,
486
- body .swp_social_panel.swp_other_full_color:hover .swp_email {
487
- background: #6bcce9;
488
- border: 1px solid #61bace;
489
- }
490
-
491
- .swp_social_panel.swp_default_full_color .swp_whatsapp,
492
- html body .swp_social_panel.swp_individual_full_color .swp_whatsapp:hover,
493
- body .swp_social_panel.swp_other_full_color:hover .swp_whatsapp {
494
- background: #71c169;
495
- border: 1px solid #28b04b;
496
- }
497
-
498
- .swp_social_panel.swp_default_full_color .swp_pocket,
499
- html body .swp_social_panel.swp_individual_full_color .swp_pocket:hover,
500
- body .swp_social_panel.swp_other_full_color:hover .swp_pocket {
501
- background: #ef4056;
502
- border: 1px solid #ce3d55;
503
- }
504
-
505
- .swp_social_panel.swp_default_full_color .swp_buffer,
506
- html body .swp_social_panel.swp_individual_full_color .swp_buffer:hover,
507
- body .swp_social_panel.swp_other_full_color:hover .swp_buffer {
508
- background: #323b43;
509
- border: 1px solid #000;
510
- }
511
-
512
- .swp_social_panel.swp_default_full_color .swp_hacker_news,
513
- html body .swp_social_panel.swp_individual_full_color .swp_hacker_news:hover,
514
- body .swp_social_panel.swp_other_full_color:hover .swp_hacker_news {
515
- background: #f16522;
516
- border: 1px solid #d85623;
517
- }
518
-
519
- .swp_social_panel.swp_default_full_color .swp_flipboard,
520
- html body .swp_social_panel.swp_individual_full_color .swp_flipboard:hover,
521
- body .swp_social_panel.swp_other_full_color:hover .swp_flipboard {
522
- background: #e02828;
523
- border: 1px solid #bf2626;
524
- }
525
-
526
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_google_plus,
527
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_google_plus:hover,
528
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_google_plus {
529
- border-bottom: 3px solid #c44133;
530
- }
531
-
532
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_twitter,
533
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_twitter:hover,
534
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_twitter {
535
- border-bottom: 3px solid #5595bc;
536
- }
537
-
538
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_facebook,
539
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_facebook:hover,
540
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_facebook {
541
- border-bottom: 3px solid #2e4675;
542
- }
543
-
544
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_pinterest,
545
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_pinterest:hover,
546
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_pinterest {
547
- border-bottom: 3px solid #aa1b29;
548
- }
549
-
550
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_linkedin,
551
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_linkedin:hover,
552
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_linkedin {
553
- border-bottom: 3px solid #0c6591;
554
- }
555
-
556
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_tumblr,
557
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_tumblr:hover,
558
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_tumblr {
559
- border-bottom: 3px solid #27313f;
560
- }
561
-
562
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_stumbleupon,
563
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_stumbleupon:hover,
564
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_stumbleupon {
565
- border-bottom: 3px solid #d34427;
566
- }
567
-
568
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_yummly,
569
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_yummly:hover,
570
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_yummly {
571
- border-bottom: 3px solid #b65027;
572
- }
573
-
574
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_reddit,
575
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_reddit:hover,
576
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_reddit {
577
- border-bottom: 3px solid #d33f27;
578
- }
579
-
580
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_email,
581
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_email:hover,
582
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_email {
583
- border-bottom: 3px solid #61bace;
584
- }
585
-
586
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_whatsapp,
587
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_whatsapp:hover,
588
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_whatsapp {
589
- border-bottom: 3px solid #28b04b;
590
- }
591
-
592
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_pocket,
593
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_pocket:hover,
594
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_pocket {
595
- border-bottom: 3px solid #ce3d55;
596
- }
597
-
598
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_buffer,
599
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_buffer:hover,
600
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_buffer {
601
- border-bottom: 3px solid #000;
602
- }
603
-
604
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_hacker_news,
605
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_hacker_news:hover,
606
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_hacker_news {
607
- border-bottom: 3px solid #d85623;
608
- }
609
-
610
- .swp_social_panel.swp_three_dee.swp_default_full_color .swp_flipboard,
611
- html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_flipboard:hover,
612
- body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_flipboard {
613
- border-bottom: 3px solid #bf2626;
614
- }
615
-
616
- .swp_social_panel.swp_default_light_gray .nc_tweetContainer,
617
- html body .swp_social_panel.swp_individual_light_gray .nc_tweetContainer:hover,
618
- body .swp_social_panel.swp_other_light_gray:hover .nc_tweetContainer {
619
- background-color: #ccc;
620
- border: 1px solid #ccc;
621
- }
622
-
623
- .swp_social_panel.swp_three_dee.swp_default_light_gray .nc_tweetContainer:not(.total_sharesalt),
624
- html body .swp_social_panel.swp_three_dee.swp_individual_light_gray .nc_tweetContainer:not(.total_sharesalt):hover,
625
- body .swp_social_panel.swp_three_dee.swp_other_light_gray:hover .nc_tweetContainer:not(.total_sharesalt) {
626
- border-bottom: 3px solid #999;
627
- }
628
-
629
- .swp_social_panel.swp_default_medium_gray .nc_tweetContainer,
630
- html body .swp_social_panel.swp_individual_medium_gray .nc_tweetContainer:hover,
631
- body .swp_social_panel.swp_other_medium_gray:hover .nc_tweetContainer {
632
- background-color: #999;
633
- border: 1px solid #999;
634
- }
635
-
636
- .swp_social_panel.swp_three_dee.swp_default_medium_gray .nc_tweetContainer:not(.total_sharesalt),
637
- html body .swp_social_panel.swp_three_dee.swp_individual_medium_gray .nc_tweetContainer:not(.total_sharesalt):hover,
638
- body .swp_social_panel.swp_three_dee.swp_other_medium_gray:hover .nc_tweetContainer:not(.total_sharesalt) {
639
- border-bottom: 3px solid #444;
640
- }
641
-
642
- .swp_social_panel.swp_default_dark_gray .nc_tweetContainer,
643
- html body .swp_social_panel.swp_individual_dark_gray .nc_tweetContainer:hover,
644
- body .swp_social_panel.swp_other_dark_gray:hover .nc_tweetContainer {
645
- background-color: #444;
646
- border: 1px solid #444;
647
- }
648
-
649
- .swp_social_panel.swp_three_dee.swp_default_dark_gray .nc_tweetContainer:not(.total_sharesalt),
650
- html body .swp_social_panel.swp_three_dee.swp_individual_dark_gray .nc_tweetContainer:not(.total_sharesalt):hover,
651
- body .swp_social_panel.swp_three_dee.swp_other_dark_gray:hover .nc_tweetContainer:not(.total_sharesalt) {
652
- border-bottom: 3px solid #222;
653
- }
654
-
655
- .swp_social_panel.swp_default_light_gray_outlines a,
656
- html body .swp_social_panel.swp_individual_light_gray_outlines a:hover,
657
- body .swp_social_panel.swp_other_light_gray_outlines:hover a {
658
- color: #ccc;
659
- }
660
-
661
- .swp_social_panel.swp_default_light_gray_outlines .nc_tweetContainer,
662
- html body .swp_social_panel.swp_individual_light_gray_outlines .nc_tweetContainer:hover,
663
- body .swp_social_panel.swp_other_light_gray_outlines:hover .nc_tweetContainer {
664
- background: transparent;
665
- border: 1px solid #ccc;
666
- }
667
-
668
- .swp_social_panel.swp_default_medium_gray_outlines a,
669
- html body .swp_social_panel.swp_individual_medium_gray_outlines a:hover,
670
- body .swp_social_panel.swp_other_medium_gray_outlines:hover a {
671
- color: #999;
672
- }
673
-
674
- .swp_social_panel.swp_default_medium_gray_outlines .nc_tweetContainer,
675
- html body .swp_social_panel.swp_individual_medium_gray_outlines .nc_tweetContainer:hover,
676
- body .swp_social_panel.swp_other_medium_gray_outlines:hover .nc_tweetContainer {
677
- background: transparent;
678
- border: 1px solid #999;
679
- }
680
-
681
- .swp_social_panel.swp_default_dark_gray_outlines a,
682
- html body .swp_social_panel.swp_individual_dark_gray_outlines a:hover,
683
- body .swp_social_panel.swp_other_dark_gray_outlines:hover a {
684
- color: #444;
685
- }
686
-
687
- .swp_social_panel.swp_default_dark_gray_outlines .nc_tweetContainer,
688
- html body .swp_social_panel.swp_individual_dark_gray_outlines .nc_tweetContainer:hover,
689
- body .swp_social_panel.swp_other_dark_gray_outlines:hover .nc_tweetContainer {
690
- background: transparent;
691
- border: 1px solid #444;
692
- }
693
-
694
- .swp_social_panel.swp_default_color_outlines .swp_google_plus a,
695
- html body .swp_social_panel.swp_individual_color_outlines .swp_google_plus a:hover,
696
- body .swp_social_panel.swp_other_color_outlines:hover .swp_google_plus a {
697
- color: #df4b37;
698
- }
699
-
700
- .swp_social_panel.swp_default_color_outlines .swp_facebook a,
701
- html body .swp_social_panel.swp_individual_color_outlines .swp_facebook a:hover,
702
- body .swp_social_panel.swp_other_color_outlines:hover .swp_facebook a {
703
- color: #3a589e;
704
- }
705
-
706
- .swp_social_panel.swp_default_color_outlines .swp_pinterest a,
707
- html body .swp_social_panel.swp_individual_color_outlines .swp_pinterest a:hover,
708
- body .swp_social_panel.swp_other_color_outlines:hover .swp_pinterest a {
709
- color: #cd2029;
710
- }
711
-
712
- .swp_social_panel.swp_default_color_outlines .swp_linkedin a,
713
- html body .swp_social_panel.swp_individual_color_outlines .swp_linkedin a:hover,
714
- body .swp_social_panel.swp_other_color_outlines:hover .swp_linkedin a {
715
- color: #0d77b7;
716
- }
717
-
718
- .swp_social_panel.swp_default_color_outlines .swp_tumblr a,
719
- html body .swp_social_panel.swp_individual_color_outlines .swp_tumblr a:hover,
720
- body .swp_social_panel.swp_other_color_outlines:hover .swp_tumblr a {
721
- color: #39475d;
722
- }
723
-
724
- .swp_social_panel.swp_default_color_outlines .swp_stumbleupon a,
725
- html body .swp_social_panel.swp_individual_color_outlines .swp_stumbleupon a:hover,
726
- body .swp_social_panel.swp_other_color_outlines:hover .swp_stumbleupon a {
727
- color: #ef5025;
728
- }
729
-
730
- .swp_social_panel.swp_default_color_outlines .swp_yummly a,
731
- html body .swp_social_panel.swp_individual_color_outlines .swp_yummly a:hover,
732
- body .swp_social_panel.swp_other_color_outlines:hover .swp_yummly a {
733
- color: #e26426;
734
- }
735
-
736
- .swp_social_panel.swp_default_color_outlines .swp_whatsapp a,
737
- html body .swp_social_panel.swp_individual_color_outlines .swp_whatsapp a:hover,
738
- body .swp_social_panel.swp_other_color_outlines:hover .swp_whatsapp a {
739
- color: #71c169;
740
- }
741
-
742
- .swp_social_panel.swp_default_color_outlines .swp_pocket a,
743
- html body .swp_social_panel.swp_individual_color_outlines .swp_pocket a:hover,
744
- body .swp_social_panel.swp_other_color_outlines:hover .swp_pocket a {
745
- color: #ef4056;
746
- }
747
-
748
- .swp_social_panel.swp_default_color_outlines .swp_reddit a,
749
- html body .swp_social_panel.swp_individual_color_outlines .swp_reddit a:hover,
750
- body .swp_social_panel.swp_other_color_outlines:hover .swp_reddit a {
751
- color: #f04b23;
752
- }
753
-
754
- .swp_social_panel.swp_default_color_outlines .swp_email a,
755
- html body .swp_social_panel.swp_individual_color_outlines .swp_email a:hover,
756
- body .swp_social_panel.swp_other_color_outlines:hover .swp_email a {
757
- color: #6bcce9;
758
- }
759
-
760
- .swp_social_panel.swp_default_color_outlines .swp_buffer a,
761
- html body .swp_social_panel.swp_individual_color_outlines .swp_buffer a:hover,
762
- body .swp_social_panel.swp_other_color_outlines:hover .swp_buffer a {
763
- color: #323b43;
764
- }
765
-
766
- .swp_social_panel.swp_default_color_outlines .swp_hacker_news a,
767
- html body .swp_social_panel.swp_individual_color_outlines .swp_hacker_news a:hover,
768
- body .swp_social_panel.swp_other_color_outlines:hover .swp_hacker_news a {
769
- color: #f16522;
770
- }
771
-
772
- .swp_social_panel.swp_default_color_outlines .swp_flipboard a,
773
- html body .swp_social_panel.swp_individual_color_outlines .swp_flipboard a:hover,
774
- body .swp_social_panel.swp_other_color_outlines:hover .swp_flipboard a {
775
- color: #e02828;
776
- }
777
-
778
- .swp_social_panel.swp_default_color_outlines .swp_google_plus,
779
- html body .swp_social_panel.swp_individual_color_outlines .swp_google_plus:hover,
780
- body .swp_social_panel.swp_other_color_outlines:hover .swp_google_plus {
781
- background: transparent;
782
- border: 1px solid #df4b37;
783
- }
784
-
785
- .swp_social_panel.swp_default_color_outlines .swp_twitter,
786
- html body .swp_social_panel.swp_individual_color_outlines .swp_twitter:hover,
787
- body .swp_social_panel.swp_other_color_outlines:hover .swp_twitter {
788
- background: transparent;
789
- border: 1px solid #429cd6;
790
- }
791
-
792
- .swp_social_panel.swp_default_color_outlines .swp_facebook,
793
- html body .swp_social_panel.swp_individual_color_outlines .swp_facebook:hover,
794
- body .swp_social_panel.swp_other_color_outlines:hover .swp_facebook {
795
- background: transparent;
796
- border: 1px solid #3a589e;
797
- }
798
-
799
- .swp_social_panel.swp_default_color_outlines .swp_pinterest,
800
- html body .swp_social_panel.swp_individual_color_outlines .swp_pinterest:hover,
801
- body .swp_social_panel.swp_other_color_outlines:hover .swp_pinterest {
802
- background: transparent;
803
- border: 1px solid #cd2029;
804
- }
805
-
806
- .swp_social_panel.swp_default_color_outlines .swp_linkedin,
807
- html body .swp_social_panel.swp_individual_color_outlines .swp_linkedin:hover,
808
- body .swp_social_panel.swp_other_color_outlines:hover .swp_linkedin {
809
- background: transparent;
810
- border: 1px solid #0d77b7;
811
- }
812
-
813
- .swp_social_panel.swp_default_color_outlines .swp_tumblr,
814
- html body .swp_social_panel.swp_individual_color_outlines .swp_tumblr:hover,
815
- body .swp_social_panel.swp_other_color_outlines:hover .swp_tumblr {
816
- background: transparent;
817
- border: 1px solid #39475d;
818
- }
819
-
820
- .swp_social_panel.swp_default_color_outlines .swp_stumbleupon,
821
- html body .swp_social_panel.swp_individual_color_outlines .swp_stumbleupon:hover,
822
- body .swp_social_panel.swp_other_color_outlines:hover .swp_stumbleupon {
823
- background: transparent;
824
- border: 1px solid #ef5025;
825
- }
826
-
827
- .swp_social_panel.swp_default_color_outlines .swp_yummly,
828
- html body .swp_social_panel.swp_individual_color_outlines .swp_yummly:hover,
829
- body .swp_social_panel.swp_other_color_outlines:hover .swp_yummly {
830
- background: transparent;
831
- border: 1px solid #e26426;
832
- }
833
-
834
- .swp_social_panel.swp_default_color_outlines .swp_whatsapp,
835
- html body .swp_social_panel.swp_individual_color_outlines .swp_whatsapp:hover,
836
- body .swp_social_panel.swp_other_color_outlines:hover .swp_whatsapp {
837
- background: transparent;
838
- border: 1px solid #71c169;
839
- }
840
-
841
- .swp_social_panel.swp_default_color_outlines .swp_reddit,
842
- html body .swp_social_panel.swp_individual_color_outlines .swp_reddit:hover,
843
- body .swp_social_panel.swp_other_color_outlines:hover .swp_reddit {
844
- background: transparent;
845
- border: 1px solid #f04b23;
846
- }
847
-
848
- .swp_social_panel.swp_default_color_outlines .swp_email,
849
- html body .swp_social_panel.swp_individual_color_outlines .swp_email:hover,
850
- body .swp_social_panel.swp_other_color_outlines:hover .swp_email {
851
- background: transparent;
852
- border: 1px solid #6bcce9;
853
- }
854
-
855
- .swp_social_panel.swp_default_color_outlines .swp_pocket,
856
- html body .swp_social_panel.swp_individual_color_outlines .swp_pocket:hover,
857
- body .swp_social_panel.swp_other_color_outlines:hover .swp_pocket {
858
- background: transparent;
859
- border: 1px solid #ef4056;
860
- }
861
-
862
- .swp_social_panel.swp_default_color_outlines .swp_buffer,
863
- html body .swp_social_panel.swp_individual_color_outlines .swp_buffer:hover,
864
- body .swp_social_panel.swp_other_color_outlines:hover .swp_buffer {
865
- background: transparent;
866
- border: 1px solid #323b43;
867
- }
868
-
869
- .swp_social_panel.swp_default_color_outlines .swp_hacker_news,
870
- html body .swp_social_panel.swp_individual_color_outlines .swp_hacker_news:hover,
871
- body .swp_social_panel.swp_other_color_outlines:hover .swp_hacker_news {
872
- background: transparent;
873
- border: 1px solid #f16522;
874
- }
875
-
876
- .swp_social_panel.swp_default_color_outlines .swp_flipboard,
877
- html body .swp_social_panel.swp_individual_color_outlines .swp_flipboard:hover,
878
- body .swp_social_panel.swp_other_color_outlines:hover .swp_flipboard {
879
- background: transparent;
880
- border: 1px solid #bf2626;
881
- }
882
-
883
- .swp_social_panelSide {
884
- flex-direction: column;
885
- height: auto;
886
- overflow: visible;
887
- /*top: 200px;*/
888
- -webkit-transition: all 0.2s linear;
889
- transition: all 0.2s linear;
890
-
891
- z-index: 9998;
892
- margin: 10px 5px !important;
893
- padding: 0;
894
-
895
- -webkit-box-direction: normal;
896
- -moz-box-direction: normal;
897
- -webkit-box-orient: vertical;
898
- -moz-box-orient: vertical;
899
- -webkit-flex-direction: column;
900
- -ms-flex-direction: column;
901
- }
902
-
903
- .swp_social_panelSide.slide,
904
- .swp_social_panelSide.fade {
905
- position: fixed;
906
- -webkit-transition: all 0.2s linear;
907
- transition: all 0.2s linear;
908
- }
909
-
910
- .swp_social_panelSide.fade.swp_float_left {
911
- left: 5px;
912
- }
913
-
914
- .swp_social_panelSide.fade.swp_float_right {
915
- right: 5px;
916
- }
917
-
918
- .swp_social_panelSide[class*=swp_side] {
919
- height: auto;
920
- display: flex;
921
- position: fixed;
922
- padding: 30px 0;
923
- }
924
-
925
- .swp_social_panelSide.fade {
926
- display: none;
927
- }
928
-
929
- .swp_social_panelSide.swp_float_right {
930
- align-content: flex-end;
931
- }
932
-
933
- .swp_social_panelSide.swp_side_top {
934
- top: 15px;
935
- }
936
-
937
- .swp_social_panelSide.swp_side_bottom {
938
- bottom: 15px;
939
- }
940
-
941
- .swp_social_panelSide.swp_side_center {
942
- }
943
-
944
- .swp_social_panelSide .nc_tweetContainer {
945
- -webkit-border-radius: 3px;
946
- border-radius: 3px;
947
- clear: both;
948
- display: block;
949
- font-family: Lato, sans-serif;
950
- height: 32px;
951
- margin: 3px 0!important;
952
- overflow: hidden;
953
- padding: 0;
954
- -webkit-transition: all 0.1s linear;
955
- transition: all 0.1s linear;
956
- vertical-align: top;
957
- width: 90px;
958
- }
959
-
960
- .swp_social_panelSide .nc_tweetContainer .iconFiller {
961
- display: inline-block;
962
- height: 40px;
963
- margin: 0 6px;
964
- padding: 0;
965
- -webkit-transition: all 0.1s linear;
966
- transition: all 0.1s linear;
967
- vertical-align: middle;
968
- width: 21px;
969
- }
970
-
971
- .swp_social_panelSide .nc_tweetContainer .swp_count {
972
- display: inline-block;
973
- font-size: 14px;
974
- height: 32px;
975
- line-height: 16px;
976
- margin: 0;
977
- overflow: hidden;
978
- padding: 0;
979
- text-align: right;
980
- -webkit-transition: all 0.1s linear;
981
- transition: all 0.1s linear;
982
- vertical-align: top;
983
- width: 0;
984
- }
985
-
986
- .swp_social_panelSide .nc_tweetContainer a {
987
- cursor: pointer;
988
- display: block;
989
- font-weight: 500;
990
- height: 36px;
991
- margin: 0;
992
- padding: 0;
993
- text-decoration: none;
994
- -webkit-transition: all 0.1s linear;
995
- transition: all 0.1s linear;
996
- vertical-align: top;
997
- }
998
-
999
- .swp_social_panelSide .nc_tweetContainer .sw,
1000
- .swp_social_panelSide .nc_tweetContainer .swp_share {
1001
- float: left;
1002
- line-height: 34px;
1003
- }
1004
-
1005
- .swp_social_panelSide.swp_default .nc_tweetContainer .sw {
1006
- line-height: 32px;
1007
- }
1008
-
1009
- .swp_social_panelSide.swp_default .nc_tweetContainer .swp_share {
1010
- line-height: 30px;
1011
- }
1012
-
1013
- .swp_social_panelSide .nc_tweetContainer .swp_share {
1014
- font-size: 13px;
1015
- }
1016
-
1017
- .swp_social_panelSide .nc_tweetContainer:hover,
1018
- .swp_social_panelSide .nc_tweetContainer:hover .iconFiller,
1019
- .swp_social_panelSide .nc_tweetContainer:hover .swp_count {
1020
- -webkit-transition: all 0.1s linear;
1021
- transition: all 0.1s linear;
1022
- }
1023
-
1024
- .swp_social_panelSide.swp_boxed .nc_tweetContainer, .swp_social_panelSide.swp_circles .nc_tweetContainer {
1025
- margin-bottom: 5px;
1026
- width: 67.5px !important;
1027
- }
1028
-
1029
- .swp_social_panelSide.swp_boxed .nc_tweetContainer,
1030
- .swp_social_panelSide.swp_boxed .nc_tweetContainer a,
1031
- .swp_social_panelSide.swp_circles .nc_tweetContainer,
1032
- .swp_social_panelSide.swp_circles .nc_tweetContainer a {
1033
- width: 67.5px;
1034
- height: 67.5px;
1035
- position: relative;
1036
- }
1037
- .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares),
1038
- .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) a {
1039
- border-radius:50%!important;
1040
- }
1041
-
1042
- .swp_social_panelSide.swp_boxed .nc_tweetContainer i.sw,
1043
- .swp_social_panelSide.swp_circles .nc_tweetContainer i.sw {
1044
- font-size: 27px;
1045
- height: 40px;
1046
- margin: 0;
1047
- padding-top: 10px;
1048
- text-align: center;
1049
- width: 100%;
1050
- }
1051
-
1052
- .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares) span.swp_share,
1053
- .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) span.swp_share {
1054
- height: 35px;
1055
- opacity: 0;
1056
- position: absolute;
1057
- bottom: 0;
1058
- left: 0;
1059
- text-align: center;
1060
- width: 67.5px;
1061
- }
1062
-
1063
- .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares) span.swp_count,
1064
- .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) span.swp_count {
1065
- height: 35px;
1066
- margin: 0;
1067
- padding: 0;
1068
- position: absolute;
1069
- bottom: 0;
1070
- left: 0;
1071
- text-align: center;
1072
- -webkit-transition: padding 0.1s linear;
1073
- transition: padding 0.1s linear;
1074
- width: 100%;
1075
- }
1076
-
1077
- .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares) span.swp_count.swp_hide,
1078
- .swp_social_panelSide.swp_boxed .nc_tweetContainer span.swp_hide .iconFiller,
1079
- .swp_social_panelSide.swp_boxed .nc_tweetContainer span.swp_hide .spaceManWilly,
1080
- .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) span.swp_count.swp_hide,
1081
- .swp_social_panelSide.swp_circles .nc_tweetContainer span.swp_hide .iconFiller,
1082
- .swp_social_panelSide.swp_circles .nc_tweetContainer span.swp_hide .spaceManWilly {
1083
- height: 67.5px;
1084
- opacity: 1;
1085
- }
1086
-
1087
- .swp_social_panelSide.swp_boxed .nc_tweetContainer span.iconFiller,
1088
- .swp_social_panelSide.swp_circles .nc_tweetContainer span.iconFiller {
1089
- height: 40px;
1090
- width: 67.5px;
1091
- }
1092
-
1093
-
1094
- .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares):hover span.swp_count:not(.swp_hide),
1095
- .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares):hover span.swp_count:not(.swp_hide) {
1096
- opacity: 0;
1097
- }
1098
-
1099
- .swp_social_panelSide.swp_boxed .total_shares,
1100
- .swp_social_panelSide.swp_circles .total_shares {
1101
- padding: 0;
1102
- width: 67.5px!important;
1103
- }
1104
-
1105
- .swp_social_panelSide .nc_tweetContainer:not(.total_shares) {
1106
- line-height: 34px;
1107
- }
1108
-
1109
- .swp_social_panelSide:not(.swp_boxed):not(.swp_circles) .nc_tweetContainer:not(.total_shares) .iconFiller{
1110
- margin-left: 2px;
1111
- width: 30px;
1112
- }
1113
-
1114
- .swp_social_panelSide .nc_tweetContainer:not(.total_shares) .swp_count {
1115
- padding: 0 8px;
1116
- width: 48px;
1117
- }
1118
-
1119
- .swp_social_panelSide .nc_tweetContainer:not(.total_shares) .swp_count.swp_hide {
1120
- padding: 0;
1121
- width: 100%;
1122
- }
1123
-
1124
- .swp_social_panelSide .nc_tweetContainer:not(.total_shares) .swp_count.swp_hide .iconFiller {
1125
- display: block;
1126
- float: none;
1127
- margin: 0 auto;
1128
- }
1129
-
1130
-
1131
- .swp_social_panelSide:not(.swp_boxed):not(.swp_circles) .nc_tweetContainer:not(.total_shares):hover {
1132
- width: 150px;
1133
- }
1134
-
1135
- .swp_social_panelSide .nc_tweetContainer[data-network]:not(.total_shares):hover .iconFiller,
1136
- .swp_social_panelSide .nc_tweetContainer:not(.total_shares) .spaceManWilly {
1137
- width: 90px;
1138
- }
1139
-
1140
- .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares):hover .iconFiller,
1141
- .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares) .spaceManWilly,
1142
- .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares):hover .iconFiller,
1143
- .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) .spaceManWilly {
1144
- width: 100%;
1145
- }
1146
-
1147
- .swp_social_panelSide .nc_tweetContainer.total_shares {
1148
- background: rgba(0, 0, 0, 0);
1149
- border: 0!important;
1150
- font-weight: 800;
1151
- height: 55px;
1152
- margin: 0;
1153
- padding: 0;
1154
- text-align: center;
1155
- width: 90px;
1156
- order:-100;
1157
- }
1158
-
1159
- .swp_social_panelSide .nc_tweetContainer.total_shares .swp_count {
1160
- color: #444;
1161
- display: block;
1162
- font-family: Lato, sans-serif;
1163
- height: 28px;
1164
- text-align: center;
1165
- width: 100%;
1166
- }
1167
-
1168
- .swp_social_panelSide .nc_tweetContainer.total_shares .swp_label {
1169
- color: #444;
1170
- display: block;
1171
- font-family: Lato, sans-serif;
1172
- font-size: 50%;
1173
- position: relative;
1174
- text-align: center;
1175
- width: 100%;
1176
- }
1177
-
1178
- .nc_wrapper {
1179
- background: white;
1180
- position: fixed;
1181
- -webkit-transition: top 0.5s bottom 0.5s;
1182
- transition: top 0.5s bottom 0.5s;
1183
- width: 100%;
1184
- z-index: 99999;
1185
- }
1186
-
1187
- .nc_wrapper.bottom {
1188
- bottom: 0;
1189
- left: 0;
1190
- }
1191
-
1192
- .nc_wrapper.top {
1193
- top: 0;
1194
- left: 0;
1195
- }
1196
-
1197
- .nc_floater {
1198
- margin: 10px 0;
1199
- position: relative;
1200
- left: 304px;
1201
- width: 740px;
1202
- }
1203
-
1204
- .swp_social_panelSide.hideCounts a {
1205
- text-align: center;
1206
- }
1207
-
1208
- .swp_social_panelSide.hideCounts .iconFiller {
1209
- float: none;
1210
- text-align: left;
1211
- }
1212
-
1213
- .sw {
1214
- display: inline-block;
1215
- font-family: sw-icon-font!important;
1216
- font-size: inherit;
1217
- -moz-osx-font-smoothing: grayscale;
1218
- -webkit-font-smoothing: antialiased;
1219
- font-style: normal;
1220
- font-weight: normal;
1221
- text-rendering: auto;
1222
- text-transform: none!important;
1223
- -ms-transform: translate(0, 0);
1224
- -webkit-transform: translate(0, 0);
1225
- transform: translate(0, 0);
1226
- }
1227
-
1228
- .sw:before {
1229
- display: block!important;
1230
- }
1231
-
1232
- .wp-editor-container .sw:before {
1233
- font-size: 18px;
1234
- line-height: 22px;
1235
- }
1236
-
1237
- .wp-editor-container .sw-social-warfare:before {
1238
- color: #ee464f;
1239
- }
1240
-
1241
- .mce-container .sw-social-warfare {
1242
- color: #ee464f;
1243
- font-size: 20px;
1244
- margin-right: 15px;
1245
- vertical-align: middle;
1246
- }
1247
-
1248
- i.swp_google_plus_icon:before {
1249
- content: "h";
1250
- }
1251
-
1252
- i.swp_pinterest_icon:before {
1253
- content: "b";
1254
- }
1255
-
1256
- i.swp_twitter_icon:before {
1257
- content: "s";
1258
- }
1259
-
1260
- i.swp_facebook_icon:before {
1261
- content: "j";
1262
- }
1263
-
1264
- i.swp_linkedin_icon:before {
1265
- content: "f";
1266
- }
1267
-
1268
- i.swp_tumblr_icon:before {
1269
- content: "r";
1270
- }
1271
-
1272
- i.swp_stumbleupon_icon:before {
1273
- content: "q";
1274
- }
1275
-
1276
- i.swp_reddit_icon:before {
1277
- content: "a";
1278
- }
1279
-
1280
- i.swp_email_icon:before {
1281
- content: "k";
1282
- }
1283
-
1284
- i.swp_yummly_icon:before {
1285
- content: "x";
1286
- }
1287
-
1288
- i.swp_whatsapp_icon:before {
1289
- content: "y";
1290
- }
1291
-
1292
- i.swp_pocket_icon:before {
1293
- content: "B";
1294
- }
1295
-
1296
- i.swp_buffer_icon:before {
1297
- content: "z";
1298
- }
1299
-
1300
- i.swp_hacker_news_icon:before {
1301
- content: "D";
1302
- }
1303
-
1304
- i.swp_flipboard_icon:before {
1305
- content: "C";
1306
- }
1307
-
1308
- .sw-social-warfare:before {
1309
- content: "p";
1310
- }
1311
-
1312
- .swp_CTT {
1313
- text-decoration: none!important;
1314
- }
1315
-
1316
- .sw-tweet-clear {
1317
- zoom: 1;
1318
- }
1319
-
1320
- .sw-tweet-clear:after {
1321
- clear: both;
1322
- content: ".";
1323
- display: block;
1324
- height: 0;
1325
- visibility: hidden;
1326
- }
1327
-
1328
- .sw-click-to-tweet {
1329
- display: block;
1330
- margin: 15px 0;
1331
- padding: 15px 30px;
1332
- position: relative;
1333
- }
1334
-
1335
- .sw-click-to-tweet:after {
1336
- clear: both;
1337
- content: ".";
1338
- display: block;
1339
- height: 0;
1340
- line-height: 0;
1341
- visibility: hidden;
1342
- }
1343
-
1344
- .sw-click-to-tweet .sw-ctt-text {
1345
- margin: 0 0 10px;
1346
- padding: 0;
1347
- position: relative;
1348
- word-wrap: break-word;
1349
- }
1350
-
1351
- a .sw-click-to-tweet .sw-ctt-text {
1352
- display: block;
1353
- font-size: 24px;
1354
- font-weight: 500;
1355
- line-height: 140%;
1356
- margin: 0;
1357
- padding: 0;
1358
- position: relative;
1359
- text-decoration: none;
1360
- text-transform: none;
1361
- }
1362
-
1363
- .sw-click-to-tweet .sw-ctt-btn {
1364
- display: block;
1365
- float: right;
1366
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
1367
- font-size: 12px;
1368
- font-weight: bold;
1369
- line-height: 100%;
1370
- margin: 10px 0 0;
1371
- padding: 3px 5px 3px 3px;
1372
- position: relative;
1373
- text-decoration: none;
1374
- text-transform: uppercase;
1375
- }
1376
-
1377
- .sw-click-to-tweet i.swp_twitter_icon {
1378
- float: right;
1379
- font-size: 21px;
1380
- margin-left: 15px !important;
1381
- margin-top: 2px;
1382
- text-transform: none;
1383
- }
1384
-
1385
- a.swp_CTT.style1 .sw-click-to-tweet {
1386
- background-color: #fff;
1387
- border: 1px solid #ddd;
1388
- -webkit-border-radius: 4px;
1389
- border-radius: 4px;
1390
- }
1391
-
1392
- a.swp_CTT.style2 .sw-click-to-tweet {
1393
- background-color: #fff;
1394
- border: 4px double #ddd;
1395
- -webkit-border-radius: 0;
1396
- border-radius: 0;
1397
- }
1398
-
1399
- a.style2 .sw-click-to-tweet .sw-ctt-text {
1400
- color: #666;
1401
- font-style: italic;
1402
- text-decoration: none;
1403
- }
1404
-
1405
- a.swp_CTT.style3:hover .sw-click-to-tweet {
1406
- border-left: 10px solid #3c87b2;
1407
- padding-right: 20px;
1408
- -webkit-transition: all 0.25s linear;
1409
- transition: all 0.25s linear;
1410
- }
1411
-
1412
- a.swp_CTT.style3 .sw-click-to-tweet {
1413
- background-color: #429cd6;
1414
- border: none;
1415
- border-left: 10px solid #429cd6;
1416
- -webkit-border-radius: 0;
1417
- border-radius: 0;
1418
- padding-right: 20px;
1419
- -webkit-transition: all 0.25s linear;
1420
- transition: all 0.25s linear;
1421
- }
1422
-
1423
- a.style3 .sw-click-to-tweet .sw-ctt-text {
1424
- color: #fff;
1425
- font-style: italic;
1426
- text-decoration: none;
1427
- }
1428
-
1429
- a.swp_CTT.style4:hover .sw-click-to-tweet {
1430
- border-left: 10px solid #3c87b2;
1431
- -webkit-transition: all 0.25s linear;
1432
- transition: all 0.25s linear;
1433
- }
1434
-
1435
- a.swp_CTT.style4 .sw-click-to-tweet {
1436
- background-color: #333;
1437
- border-left: 10px solid #c33;
1438
- -webkit-border-radius: 0;
1439
- border-radius: 0;
1440
- -webkit-transition: all 0.25s linear;
1441
- transition: all 0.25s linear;
1442
- }
1443
-
1444
- a.swp_CTT.style5:hover .sw-click-to-tweet {
1445
- background-color: #d34250;
1446
- border-left: 10px solid #30394f;
1447
- -webkit-transition: all 0.25s linear;
1448
- transition: all 0.25s linear;
1449
- }
1450
-
1451
- a.swp_CTT.style5 .sw-click-to-tweet {
1452
- background-color: #30394f;
1453
- border-left: 10px solid #d34250;
1454
- -webkit-border-radius: 0;
1455
- border-radius: 0;
1456
- -webkit-transition: all 0.25s linear;
1457
- transition: all 0.25s linear;
1458
- }
1459
-
1460
- a.swp_CTT.style6:hover .sw-click-to-tweet {
1461
- background-color: #ced3dc;
1462
- border-left: 10px solid #d34250;
1463
- -webkit-transition: all 0.25s linear;
1464
- transition: all 0.25s linear;
1465
- }
1466
-
1467
- a.swp_CTT.style6 .sw-click-to-tweet {
1468
- background-color: #eee;
1469
- border-left: 10px solid #d34250;
1470
- -webkit-border-radius: 0;
1471
- border-radius: 0;
1472
- -webkit-transition: all 0.25s linear;
1473
- transition: all 0.25s linear;
1474
- }
1475
-
1476
- a.style6 .sw-click-to-tweet i.swp_twitter {
1477
- color: #30394f;
1478
- }
1479
-
1480
- .swp_pop_thumb {
1481
- -webkit-border-radius: 3px;
1482
- border-radius: 3px;
1483
- float: left;
1484
- height: 100px;
1485
- margin: 5px 25px 5px 0;
1486
- width: 100px;
1487
- }
1488
-
1489
- .swp_popular_post {
1490
- clear: both;
1491
- }
1492
-
1493
- .swp_clearfix:after {
1494
- clear: both;
1495
- content: " ";
1496
- display: block;
1497
- height: 0;
1498
- visibility: hidden;
1499
- }
1500
-
1501
- .swp_popular_post a.swp_popularity {
1502
- border: none;
1503
- display: block;
1504
- line-height: 1.5;
1505
- margin: 20px 0;
1506
- }
1507
-
1508
- span.swp_pop_count {
1509
- display: block;
1510
- font-size: 70%;
1511
- }
1512
-
1513
- .swp_widget_box {
1514
- -webkit-border-radius: 3px;
1515
- border-radius: 3px;
1516
- }
1517
-
1518
- div.sw-pinit {
1519
- display: table !important;
1520
- line-height: 0;
1521
- position: relative !important;
1522
- }
1523
-
1524
- div.sw-pinit a.sw-pinit-button,
1525
- div.sw-pinit a.sw-pinit-button:visited {
1526
- background: #cd2029;
1527
- border: 1px solid #aa1b29;
1528
- border: 0;
1529
- border-bottom: none;
1530
- -webkit-border-radius: 4px;
1531
- border-radius: 3px;
1532
- -webkit-box-shadow: none;
1533
- box-shadow: none;
1534
- color: #fff;
1535
- font-family: Lato,sans-serif;
1536
- font-size: 20px;
1537
- font-size: 15px;
1538
- height: 32px;
1539
- line-height: 32px;
1540
- opacity: 0;
1541
- padding: 0 20px;
1542
- position: absolute;
1543
- text-decoration: none;
1544
- text-decoration: none;
1545
- -webkit-transition: opacity 0.5s;
1546
- transition: opacity 0.5s;
1547
- z-index: 200;
1548
- }
1549
-
1550
- div.sw-pinit:hover a.sw-pinit-button,
1551
- div.sw-pinit:focus a.sw-pinit-button {
1552
- opacity: 1;
1553
- }
1554
-
1555
- div.sw-pinit a.sw-pinit-button::before {
1556
- color: #fff;
1557
- content: "b";
1558
- float: left;
1559
- font-family: sw-icon-font;
1560
- font-size: 20px;
1561
- font-weight: 400;
1562
- line-height: 36px;
1563
- margin-left: -5px;
1564
- margin-right: 10px;
1565
- }
1566
-
1567
- div.sw-pinit a.sw-pinit-button:hover::before {
1568
- content: "F";
1569
- }
1570
-
1571
- div.sw-pinit a.sw-pinit-button:hover,
1572
- div.sw-pinit a.sw-pinit-button:focus {
1573
- background: #aa1b29;
1574
- color: #fff;
1575
- text-decoration: none;
1576
- }
1577
-
1578
- div.sw-pinit .sw-pinit-left {
1579
- left: 30px;
1580
- }
1581
-
1582
- div.sw-pinit .sw-pinit-center {
1583
- margin-left: -60px;
1584
- left: 50%;
1585
- }
1586
-
1587
- div.sw-pinit .sw-pinit-right {
1588
- right: 30px;
1589
- }
1590
-
1591
- div.sw-pinit .sw-pinit-top {
1592
- top: 30px;
1593
- }
1594
-
1595
- div.sw-pinit .sw-pinit-middle {
1596
- margin-top: -25px;
1597
- top: 50%;
1598
- }
1599
-
1600
- div.sw-pinit .sw-pinit-bottom {
1601
- bottom: 30px;
1602
- }
1603
-
1604
- .swp_social_panel.notMobile .nc_tweetContainer:nth-last-child(1),
1605
- .mobile .nc_tweetContainer:nth-last-child(2),
1606
- .nc_tweetContainer.total_shares:nth-last-child(1) {
1607
- margin-right: 0;
1608
- }
1609
-
1610
- .swp_social_panel.swp_default_full_color a,
1611
- html body .swp_social_panel.swp_individual_full_color .nc_tweetContainer:hover a,
1612
- body .swp_social_panel.swp_other_full_color:hover a,
1613
- .swp_social_panel.swp_default_light_gray a,
1614
- html body .swp_social_panel.swp_individual_light_gray .nc_tweetContainer:hover a,
1615
- body .swp_social_panel.swp_other_light_gray:hover a,
1616
- .swp_social_panel.swp_default_medium_gray a,
1617
- html body .swp_social_panel.swp_individual_medium_gray a:hover,
1618
- body .swp_social_panel.swp_other_medium_gray:hover a,
1619
- .swp_social_panel.swp_default_dark_gray a,
1620
- html body .swp_social_panel.swp_individual_dark_gray a:hover,
1621
- body .swp_social_panel.swp_other_dark_gray:hover a {
1622
- color: white;
1623
- }
1624
-
1625
- .swp_social_panel.swp_default_color_outlines .swp_twitter a,
1626
- html body .swp_social_panel.swp_individual_color_outlines .swp_twitter a:hover,
1627
- body .swp_social_panel.swp_other_color_outlines:hover .swp_twitter a,
1628
- .wp-editor-container .swp_twitter:before,
1629
- a.style1 .sw-click-to-tweet i.swp_twitter,
1630
- a.style2 .sw-click-to-tweet i.swp_twitter {
1631
- color: #429cd6;
1632
- }
1633
-
1634
- .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares) .swp_hide span.swp_share,
1635
- .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares):hover span.swp_share:not(.swp_hide),
1636
- .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) .swp_hide span.swp_share,
1637
- .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares):hover span.swp_share:not(.swp_hide) {
1638
- opacity: 1;
1639
- }
1640
-
1641
- .swp_social_panel.mobile .iconFiller ~ .swp_count,
1642
- .sw-content-locator {
1643
- display: none;
1644
- }
1645
-
1646
- a.style1 .sw-click-to-tweet .sw-ctt-text,
1647
- a.style1 .sw-click-to-tweet .sw-ctt-btn {
1648
- color: #999;
1649
- text-decoration: none;
1650
- }
1651
-
1652
- a.style1:hover .sw-click-to-tweet .sw-ctt-text,
1653
- a.style1:hover .sw-click-to-tweet .sw-ctt-btn,
1654
- a.style2:hover .sw-click-to-tweet .sw-ctt-text,
1655
- a.style2 .sw-click-to-tweet .sw-ctt-btn,
1656
- a.style2:hover .sw-click-to-tweet .sw-ctt-btn {
1657
- color: #666;
1658
- text-decoration: none;
1659
- }
1660
-
1661
- a.style3:hover .sw-click-to-tweet .sw-ctt-text,
1662
- a.style3 .sw-click-to-tweet .sw-ctt-btn,
1663
- a.style3:hover .sw-click-to-tweet .sw-ctt-btn,
1664
- a.style3 .sw-click-to-tweet i.swp_twitter,
1665
- a.style4 .sw-click-to-tweet .sw-ctt-text,
1666
- a.style4:hover .sw-click-to-tweet .sw-ctt-text,
1667
- a.style4 .sw-click-to-tweet .sw-ctt-btn,
1668
- a.style4:hover .sw-click-to-tweet .sw-ctt-btn,
1669
- a.style5 .sw-click-to-tweet .sw-ctt-text,
1670
- a.style5:hover .sw-click-to-tweet .sw-ctt-text,
1671
- a.style5 .sw-click-to-tweet .sw-ctt-btn,
1672
- a.style5:hover .sw-click-to-tweet .sw-ctt-btn {
1673
- color: #fff;
1674
- text-decoration: none;
1675
- }
1676
-
1677
- a.style4 .sw-click-to-tweet i.swp_twitter,
1678
- a.style5 .sw-click-to-tweet i.swp_twitter {
1679
- color: #fff;
1680
- }
1681
-
1682
- a.style6 .sw-click-to-tweet .sw-ctt-text,
1683
- a.style6 .sw-click-to-tweet .sw-ctt-btn {
1684
- color: #30394f;
1685
- text-decoration: none;
1686
- }
1687
-
1688
- a.style6:hover .sw-click-to-tweet .sw-ctt-text,
1689
- a.style6:hover .sw-click-to-tweet .sw-ctt-btn,
1690
- a.style6:hover .sw-click-to-tweet i.swp_twitter {
1691
- color: #2a2d34;
1692
- text-decoration: none;
1693
- }
1694
-
1695
- .scale-70 {
1696
- -ms-transform: scale(0.7);
1697
- -webkit-transform: scale(0.7);
1698
- transform: scale(0.7);
1699
- }
1700
-
1701
- .swp_social_panel:not(.nc_floater).scale-70.scale-full_width {
1702
- width: 142.8571428571429%!important;
1703
- }
1704
-
1705
- .scale-80 {
1706
- -ms-transform: scale(0.8);
1707
- -webkit-transform: scale(0.8);
1708
- transform: scale(0.8);
1709
- }
1710
-
1711
- .swp_social_panel:not(.nc_floater).scale-80.scale-full_width {
1712
- width: 125%!important;
1713
- }
1714
-
1715
- .scale-90 {
1716
- -ms-transform: scale(0.9);
1717
- -webkit-transform: scale(0.9);
1718
- transform: scale(0.9);
1719
- }
1720
-
1721
- .swp_social_panel:not(.nc_floater).scale-90.scale-full_width {
1722
- width: 111.111111111111%!important;
1723
- }
1724
-
1725
- .scale-110 {
1726
- -ms-transform: scale(1.1);
1727
- -webkit-transform: scale(1.1);
1728
- transform: scale(1.1);
1729
- }
1730
-
1731
- .swp_social_panel:not(.nc_floater).scale-110.scale-full_width {
1732
- width: 90.90909090909091%!important;
1733
- }
1734
-
1735
- .scale-120 {
1736
- -ms-transform: scale(1.2);
1737
- -webkit-transform: scale(1.2);
1738
- transform: scale(1.2);
1739
- }
1740
-
1741
- .swp_social_panel:not(.nc_floater).scale-120.scale-full_width {
1742
- width: 83.33333333333333%!important;
1743
- }
1744
-
1745
- .scale-130 {
1746
- -ms-transform: scale(1.3);
1747
- -webkit-transform: scale(1.3);
1748
- transform: scale(1.3);
1749
- }
1750
-
1751
- .swp_social_panel:not(.nc_floater).scale-130.scale-full_width {
1752
- width: 76.92307692307692%!important;
1753
- }
1754
-
1755
- .scale-140 {
1756
- -ms-transform: scale(1.4);
1757
- -webkit-transform: scale(1.4);
1758
- transform: scale(1.4);
1759
- }
1760
-
1761
- .swp_social_panel:not(.nc_floater).scale-140.scale-full_width {
1762
- width: 71.42857142857143%!important;
1763
- }
1764
-
1765
- .scale-full_width,
1766
- .scale-left,
1767
- .nc_floater.scale-center,
1768
- .nc_floater.scale-right {
1769
- -ms-transform-origin: left;
1770
- -webkit-transform-origin: left;
1771
- transform-origin: left;
1772
- }
1773
-
1774
- .scale-right {
1775
- -ms-transform-origin: right;
1776
- -webkit-transform-origin: right;
1777
- transform-origin: right;
1778
- }
1779
-
1780
- .scale-center {
1781
- -ms-transform-origin: center;
1782
- -webkit-transform-origin: center;
1783
- transform-origin: center;
1784
- }
1785
-
1786
- div.swp_social_panel .nc_tweetContainer.swp_emphasize {
1787
- -webkit-box-flex: 2;
1788
- -moz-box-flex: 2;
1789
- -webkit-flex: 2;
1790
- -ms-flex: 2;
1791
- flex: 2;
1792
- }
1793
-
1794
- .sw-pinit.aligncenter {
1795
- margin: 0 auto;
1796
- }
1797
-
1798
- @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
1799
- div.sw-pinit {
1800
- display: inline-block!important;
1801
- max-width: 100%;
1802
- }
1803
- }
1804
-
1805
- .swp_hidden_pin_image {
1806
- height: 0;
1807
- opacity: 0;
1808
- position: absolute;
1809
- top: 0;
1810
- width: 0;
1811
- }
1812
- .fl-module-content .uabb-blog-posts .uabb-post-thumbnail .sw-pinit.lazyloaded {
1813
- display: block !important;
1814
- }
1815
-
1816
- .swp-content-locator {
1817
- display: none !important;
1818
- margin: 0 !important;
1819
- }
1820
-
1821
- .float-position-top-left {
1822
- transform-origin: top left;
1823
- }
1824
-
1825
- .float-position-center-left {
1826
- transform-origin: center left;
1827
- }
1828
-
1829
- .float-position-bottom-left {
1830
- transform-origin: bottom left;
1831
- }
1832
-
1833
- .float-position-top-right {
1834
- transform-origin: top right;
1835
- }
1836
-
1837
- .float-position-center-right {
1838
- transform-origin: center right;
1839
- }
1840
-
1841
- .float-position-bottom-right {
1842
- transform-origin: bottom right;
1843
- }
1844
-
1845
- div[class*=custom_color][class^=_wrapper] {
1846
- display: none;
1847
- }
1
+ .swp_social_panel {
2
+ clear: both;
3
+ display: -webkit-box;
4
+ display: -webkit-flex;
5
+ display: -moz-box;
6
+ display: -ms-flexbox;
7
+ display: flex;
8
+ height: 34px;
9
+ line-height: 1;
10
+ margin-bottom: 20px!important;
11
+ margin-top: 20px!important;
12
+ overflow: hidden;
13
+ padding: 0;
14
+
15
+ -webkit-align-items: stretch;
16
+ align-items: stretch;
17
+ -webkit-box-align: stretch;
18
+ -moz-box-align: stretch;
19
+ -webkit-box-pack: justify;
20
+ -moz-box-pack: justify;
21
+ direction: ltr;
22
+ -ms-flex-align: stretch;
23
+ -ms-flex-line-pack: center;
24
+ -ms-flex-pack: justify;
25
+ -webkit-flex-wrap: wrap;
26
+ -ms-flex-wrap: wrap;
27
+ flex-wrap: wrap;
28
+ -webkit-justify-content: space-between;
29
+ justify-content: space-between;
30
+ }
31
+
32
+ .swp_social_panel:not(.nc_floater):not(.swp_social_panelSide) {
33
+ width: 100%!important;
34
+ }
35
+
36
+ .nc_wrapper .swp_social_panel {
37
+ margin-bottom: 10px!important;
38
+ margin-top: 10px!important;
39
+ }
40
+
41
+ div.swp_social_panel .nc_tweetContainer {
42
+ -webkit-border-radius: 2px;
43
+ border-radius: 2px;
44
+ cursor: pointer;
45
+ float: left;
46
+ font-family: Lato;
47
+ height: 32px;
48
+ margin: 0 5px 3px 5px;
49
+ min-width: 34px;
50
+ overflow: hidden;
51
+ text-align: center;
52
+ -webkit-transition: all 0.1s linear;
53
+ transition: all 0.1s linear;
54
+ }
55
+
56
+ div.swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer {
57
+ -webkit-box-flex: 1;
58
+ -moz-box-flex: 1;
59
+ -webkit-flex: 1;
60
+ -ms-flex: 1;
61
+ flex: 1;
62
+ }
63
+
64
+ .swp_social_panel .nc_tweetContainer a.nc_tweet,
65
+ .swp_social_panel .total_shares .swp_count {
66
+ display: block;
67
+ display: -webkit-box;
68
+ display: -webkit-flex;
69
+ display: -moz-box;
70
+ display: -ms-flexbox;
71
+ display: flex;
72
+ font-family: Lato, sans-serif;
73
+ font-size: 18px!important;
74
+ font-weight: bold;
75
+ height: 30px;
76
+ text-decoration: none;
77
+ text-decoration: none!important;
78
+ text-transform: none;
79
+
80
+ -webkit-box-direction: normal;
81
+ -moz-box-direction: normal;
82
+ -webkit-box-orient: horizontal;
83
+ -moz-box-orient: horizontal;
84
+ -webkit-flex-flow: row wrap;
85
+ -ms-flex-flow: row wrap;
86
+ flex-flow: row wrap;
87
+ }
88
+
89
+ .swp_social_panel:not(.nc_floater):not(.swp_social_panelSide).swp_shift {
90
+ padding:0 10px;
91
+ }
92
+
93
+ .swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer:nth-child(1) {
94
+ margin-left: 0;
95
+ }
96
+
97
+ .swp_social_panel:not(.swp_social_panelSide) .nc_tweetContainer:nth-last-child(1) {
98
+ margin-right: 0;
99
+ }
100
+
101
+ .swp_social_panel a .swp_count:not(.swp_hide) {
102
+ display: inline-block;
103
+ line-height: 32px;
104
+ margin: 0;
105
+ padding: 0 5px;
106
+
107
+ -webkit-box-flex: 1;
108
+ -moz-box-flex: 1;
109
+ -webkit-flex: 1;
110
+ -ms-flex: 1;
111
+ flex: 1;
112
+ }
113
+
114
+ .swp_social_panel a .swp_count.swp_hide {
115
+ margin: 0 auto;
116
+ }
117
+
118
+ .swp_social_panel span:before {
119
+ content: initial!important;
120
+ }
121
+
122
+ .swp_social_panel .total_shares .swp_count {
123
+ line-height: 30px;
124
+ }
125
+
126
+ .swp_social_panel span.swp_count {
127
+ font-size: 14px;
128
+ }
129
+
130
+ .swp_social_panel span.iconFiller {
131
+ font-size: 18px;
132
+ margin: 0 auto;
133
+ }
134
+
135
+ .swp_social_panel.notMobile .nc_tweetContainer:nth-child(1) {
136
+ margin-left: 0;
137
+ }
138
+
139
+ .swp_social_panel:not(.swp_social_panelSide) {
140
+ -webkit-transition: opacity 0.2s ease-in-out;
141
+ transition: opacity 0.2s ease-in-out;
142
+ }
143
+
144
+ .swp_social_panel:not(.swp_social_panelSide) div.total_shares.total_sharesalt:nth-child(1) {
145
+ margin-left: 0;
146
+ margin-right: 15px;
147
+ padding-left: 0;
148
+ }
149
+
150
+ .swp_social_panel:not(.swp_social_panelSide) div.total_shares.total_sharesalt:nth-last-child(1) {
151
+ margin-right: 0;
152
+ padding-right: 0;
153
+ }
154
+
155
+ a.swp_CTT {
156
+ cursor: pointer;
157
+ }
158
+
159
+ span.swp_share {
160
+ display: block;
161
+ float: right;
162
+ float: left;
163
+ font-size: 14px;
164
+ font-weight: normal;
165
+ height: 30px;
166
+ line-height: 30px;
167
+ margin: 0 0 0 6px;
168
+ max-width: none!important;
169
+ vertical-align: middle;
170
+ }
171
+
172
+ .swp_social_panelSide span.swp_share {
173
+ margin: 0;
174
+ }
175
+
176
+ .swp_social_panel .sw {
177
+ float: left;
178
+ height: 30px;
179
+ line-height: 32px;
180
+ margin: 0 5px;
181
+ text-shadow: none!important;
182
+ width: 20px;
183
+ }
184
+
185
+ .iconFiller {
186
+ display: block;
187
+ float: left;
188
+ height: 30px;
189
+ overflow: hidden;
190
+ -webkit-transition: width 0.1s linear;
191
+ transition: width 0.1s linear;
192
+ }
193
+
194
+ .swp_social_panel .iconFiller {
195
+ width: 30px;
196
+ }
197
+
198
+ span.spaceManWilly {
199
+ display: block;
200
+ width: 120px;
201
+ }
202
+
203
+ .swp_social_panel .total_shares {
204
+ background: transparent !important;;
205
+ border: none !important;
206
+ -webkit-border-radius: 2px;
207
+ border-radius: 2px;
208
+ color: white;
209
+ cursor: default;
210
+ display: block;
211
+ font-size: 19px;
212
+ padding: 0 10px;
213
+
214
+ -webkit-box-flex: 0!important;
215
+ -moz-box-flex: 0!important;
216
+ -webkit-flex: none!important;
217
+ -ms-flex: none!important;
218
+ flex: none!important;
219
+ }
220
+
221
+ .swp_social_panel .total_sharesalt {
222
+ background: transparent !important;
223
+ border: none !important;
224
+ }
225
+
226
+ .swp_social_panel div.total_shares.total_sharesalt,
227
+ .swp_social_panel:hover div.total_shares.total_sharesalt:not(:nth-child(1)) {
228
+ background: transparent!important;
229
+ border: none;
230
+ color: #474b4d;
231
+ margin-left: 0!important;
232
+ margin-bottom: 10px !important;
233
+ }
234
+
235
+ div.swp_social_panel:hover div.total_shares.total_sharesalt:not(:nth-child(1)) {
236
+ background: transparent;
237
+ color: #474b4d;
238
+ margin-left: 10px;
239
+ }
240
+
241
+ .swp_social_panel .total_shares.total_sharesalt .swp_label {
242
+ color: #474b4d;
243
+ font-size: 10px;
244
+ letter-spacing: 0;
245
+ min-width: 40px;
246
+ vertical-align: middle;
247
+ }
248
+
249
+ .swp_social_panel .total_shares .swp_label {
250
+ font-size: 10px;
251
+ vertical-align: middle;
252
+ }
253
+
254
+ .swp_social_panel .total_shares.total_sharesalt .swp_count {
255
+ color: #474b4d;
256
+ font-size: 24px;
257
+ }
258
+
259
+ .swp_social_panel:hover .total_shares,
260
+ .swp_social_panel.swp_full_color .total_shares,
261
+ .swp_social_panel.swp_fade .total_shares,
262
+ .swp_social_panel.swp_customFull:hover div.total_shares {
263
+ background: #e08a0f;
264
+ }
265
+
266
+ .swp_social_panel .nc_tweetContainer.total_shares.total_sharesalt:before {
267
+ content: "o";
268
+ display: inline-block;
269
+ font-family: sw-icon-font;
270
+ margin-top: 7px;
271
+ vertical-align: top;
272
+ }
273
+
274
+ .swp_social_panel:not(.swp_social_panelSide) .total_shares.total_sharesalt .swp_count {
275
+ display: inline-block;
276
+ line-height: 0;
277
+ margin-left: 8px;
278
+ margin-top: 12px;
279
+ min-width: 45px;
280
+ position: relative;
281
+ vertical-align: middle;
282
+ }
283
+
284
+ span.swp_label {
285
+ display: block;
286
+ font-size: 9px!important;
287
+ margin-top: 13px;
288
+ position: absolute;
289
+ text-align: center!important;
290
+ text-transform: uppercase;
291
+ }
292
+
293
+ .swp_social_panelSide span.swp_label {
294
+ margin-top: 0;
295
+ }
296
+
297
+ .swp_social_panel.swp_leaf .nc_tweetContainer {
298
+ -webkit-border-radius: 15px 0!important;
299
+ border-radius: 15px 0!important;
300
+ border-width: 1px;
301
+ }
302
+
303
+ .swp_social_panel.swp_pill .nc_tweetContainer {
304
+ -webkit-border-radius: 50px;
305
+ border-radius: 50px;
306
+ border-width: 1px;
307
+ }
308
+
309
+ .swp_social_panel.swp_shift .nc_tweetContainer:not(.total_shares) {
310
+ border-width: 1px;
311
+ -moz-transform: skew(-25deg);
312
+ -o-transform: skew(-25deg);
313
+ -webkit-transform: skew(-25deg);
314
+ }
315
+
316
+ .swp_social_panel.swp_shift .nc_tweetContainer a {
317
+ -moz-transform: skew(25deg);
318
+ -o-transform: skew(25deg);
319
+ -webkit-transform: skew(25deg);
320
+ }
321
+
322
+ .swp_connected .nc_tweetContainer,
323
+ .swp_connected:hover .nc_tweetContainer,
324
+ .swp_connected .nc_tweetContainer:hover {
325
+ -webkit-border-radius: 0!important;
326
+ border-radius: 0!important;
327
+ border-width: 1px;
328
+ margin: 0!important;
329
+ }
330
+
331
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_google_plus,
332
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_google_plus:hover,
333
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_google_plus:not(:hover) {
334
+ border: 1px solid #df4b37;
335
+ }
336
+
337
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_twitter,
338
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_twitter:hover,
339
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_twitter:not(:hover) {
340
+ border: 1px solid #429cd6;
341
+ }
342
+
343
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_facebook,
344
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_facebook:hover,
345
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_facebook:not(:hover) {
346
+ border: 1px solid #3a589e;
347
+ }
348
+
349
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_pinterest,
350
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_pinterest:hover,
351
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_pinterest:not(:hover) {
352
+ border: 1px solid #cd2029;
353
+ }
354
+
355
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_linkedin,
356
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_linkedin:hover,
357
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_linkedin:not(:hover) {
358
+ border: 1px solid #0d77b7;
359
+ }
360
+
361
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_tumblr,
362
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_tumblr:hover,
363
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_tumblr:not(:hover) {
364
+ border: 1px solid #39475d;
365
+ }
366
+
367
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_stumbleupon,
368
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_stumbleupon:hover,
369
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_stumbleupon:not(:hover) {
370
+ border: 1px solid #ef5025;
371
+ }
372
+
373
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_yummly,
374
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_yummly:hover,
375
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_yummly:not(:hover) {
376
+ border: 1px solid #e26426;
377
+ }
378
+
379
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_reddit,
380
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_reddit:hover,
381
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_reddit:not(:hover) {
382
+ border: 1px solid #f04b23;
383
+ }
384
+
385
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_email,
386
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_email:hover,
387
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_email:not(:hover) {
388
+ border: 1px solid #6bcce9;
389
+ }
390
+
391
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_whatsapp,
392
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_whatsapp:hover,
393
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_whatsapp:not(:hover) {
394
+ border: 1px solid #71c169;
395
+ }
396
+
397
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_pocket,
398
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_pocket:hover,
399
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_pocket:not(:hover) {
400
+ border: 1px solid #ef4056;
401
+ }
402
+
403
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_buffer,
404
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_buffer:hover,
405
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_buffer:not(:hover) {
406
+ border: 1px solid #323b43;
407
+ }
408
+
409
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_hacker_news,
410
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_hacker_news:hover,
411
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_hacker_news:not(:hover) {
412
+ border: 1px solid #d85623;
413
+ }
414
+
415
+ .swp_social_panel.swp_flat_fresh.swp_default_full_color .swp_flipboard,
416
+ html body .swp_social_panel.swp_flat_fresh.swp_individual_full_color .swp_flipboard:hover,
417
+ body .swp_social_panel.swp_flat_fresh.swp_other_full_color:hover .swp_flipboard:not(:hover) {
418
+ border: 1px solid #bf2626;
419
+ }
420
+
421
+ .swp_social_panel.swp_default_full_color .swp_google_plus,
422
+ html body .swp_social_panel.swp_individual_full_color .swp_google_plus:hover,
423
+ body .swp_social_panel.swp_other_full_color:hover .swp_google_plus {
424
+ background: #df4b37;
425
+ border: 1px solid #c44133;
426
+ }
427
+
428
+ .swp_social_panel.swp_default_full_color .swp_twitter,
429
+ html body .swp_social_panel.swp_individual_full_color .swp_twitter:hover,
430
+ body .swp_social_panel.swp_other_full_color:hover .swp_twitter {
431
+ background: #429cd6;
432
+ border: 1px solid #3c87b2;
433
+ }
434
+
435
+ .swp_social_panel.swp_default_full_color .swp_facebook,
436
+ html body .swp_social_panel.swp_individual_full_color .swp_facebook:hover,
437
+ body .swp_social_panel.swp_other_full_color:hover .swp_facebook {
438
+ background: #3a589e;
439
+ border: 1px solid #2e4675;
440
+ }
441
+
442
+ .swp_social_panel.swp_default_full_color .swp_pinterest,
443
+ html body .swp_social_panel.swp_individual_full_color .swp_pinterest:hover,
444
+ body .swp_social_panel.swp_other_full_color:hover .swp_pinterest {
445
+ background: #cd2029;
446
+ border: 1px solid #aa1b29;
447
+ }
448
+
449
+ .swp_social_panel.swp_default_full_color .swp_linkedin,
450
+ html body .swp_social_panel.swp_individual_full_color .swp_linkedin:hover,
451
+ body .swp_social_panel.swp_other_full_color:hover .swp_linkedin {
452
+ background: #0d77b7;
453
+ border: 1px solid #0c6591;
454
+ }
455
+
456
+ .swp_social_panel.swp_default_full_color .swp_tumblr,
457
+ html body .swp_social_panel.swp_individual_full_color .swp_tumblr:hover,
458
+ body .swp_social_panel.swp_other_full_color:hover .swp_tumblr {
459
+ background: #39475d;
460
+ border: 1px solid #27313f;
461
+ }
462
+
463
+ .swp_social_panel.swp_default_full_color .swp_stumbleupon,
464
+ html body .swp_social_panel.swp_individual_full_color .swp_stumbleupon:hover,
465
+ body .swp_social_panel.swp_other_full_color:hover .swp_stumbleupon {
466
+ background: #ef5025;
467
+ border: 1px solid #d34427;
468
+ }
469
+
470
+ .swp_social_panel.swp_default_full_color .swp_yummly,
471
+ html body .swp_social_panel.swp_individual_full_color .swp_yummly:hover,
472
+ body .swp_social_panel.swp_other_full_color:hover .swp_yummly {
473
+ background: #e26426;
474
+ border: 1px solid #b65027;
475
+ }
476
+
477
+ .swp_social_panel.swp_default_full_color .swp_reddit,
478
+ html body .swp_social_panel.swp_individual_full_color .swp_reddit:hover,
479
+ body .swp_social_panel.swp_other_full_color:hover .swp_reddit {
480
+ background: #f04b23;
481
+ border: 1px solid #d33f27;
482
+ }
483
+
484
+ .swp_social_panel.swp_default_full_color .swp_email,
485
+ html body .swp_social_panel.swp_individual_full_color .swp_email:hover,
486
+ body .swp_social_panel.swp_other_full_color:hover .swp_email {
487
+ background: #6bcce9;
488
+ border: 1px solid #61bace;
489
+ }
490
+
491
+ .swp_social_panel.swp_default_full_color .swp_whatsapp,
492
+ html body .swp_social_panel.swp_individual_full_color .swp_whatsapp:hover,
493
+ body .swp_social_panel.swp_other_full_color:hover .swp_whatsapp {
494
+ background: #71c169;
495
+ border: 1px solid #28b04b;
496
+ }
497
+
498
+ .swp_social_panel.swp_default_full_color .swp_pocket,
499
+ html body .swp_social_panel.swp_individual_full_color .swp_pocket:hover,
500
+ body .swp_social_panel.swp_other_full_color:hover .swp_pocket {
501
+ background: #ef4056;
502
+ border: 1px solid #ce3d55;
503
+ }
504
+
505
+ .swp_social_panel.swp_default_full_color .swp_buffer,
506
+ html body .swp_social_panel.swp_individual_full_color .swp_buffer:hover,
507
+ body .swp_social_panel.swp_other_full_color:hover .swp_buffer {
508
+ background: #323b43;
509
+ border: 1px solid #000;
510
+ }
511
+
512
+ .swp_social_panel.swp_default_full_color .swp_hacker_news,
513
+ html body .swp_social_panel.swp_individual_full_color .swp_hacker_news:hover,
514
+ body .swp_social_panel.swp_other_full_color:hover .swp_hacker_news {
515
+ background: #f16522;
516
+ border: 1px solid #d85623;
517
+ }
518
+
519
+ .swp_social_panel.swp_default_full_color .swp_flipboard,
520
+ html body .swp_social_panel.swp_individual_full_color .swp_flipboard:hover,
521
+ body .swp_social_panel.swp_other_full_color:hover .swp_flipboard {
522
+ background: #e02828;
523
+ border: 1px solid #bf2626;
524
+ }
525
+
526
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_google_plus,
527
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_google_plus:hover,
528
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_google_plus {
529
+ border-bottom: 3px solid #c44133;
530
+ }
531
+
532
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_twitter,
533
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_twitter:hover,
534
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_twitter {
535
+ border-bottom: 3px solid #5595bc;
536
+ }
537
+
538
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_facebook,
539
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_facebook:hover,
540
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_facebook {
541
+ border-bottom: 3px solid #2e4675;
542
+ }
543
+
544
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_pinterest,
545
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_pinterest:hover,
546
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_pinterest {
547
+ border-bottom: 3px solid #aa1b29;
548
+ }
549
+
550
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_linkedin,
551
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_linkedin:hover,
552
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_linkedin {
553
+ border-bottom: 3px solid #0c6591;
554
+ }
555
+
556
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_tumblr,
557
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_tumblr:hover,
558
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_tumblr {
559
+ border-bottom: 3px solid #27313f;
560
+ }
561
+
562
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_stumbleupon,
563
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_stumbleupon:hover,
564
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_stumbleupon {
565
+ border-bottom: 3px solid #d34427;
566
+ }
567
+
568
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_yummly,
569
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_yummly:hover,
570
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_yummly {
571
+ border-bottom: 3px solid #b65027;
572
+ }
573
+
574
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_reddit,
575
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_reddit:hover,
576
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_reddit {
577
+ border-bottom: 3px solid #d33f27;
578
+ }
579
+
580
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_email,
581
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_email:hover,
582
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_email {
583
+ border-bottom: 3px solid #61bace;
584
+ }
585
+
586
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_whatsapp,
587
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_whatsapp:hover,
588
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_whatsapp {
589
+ border-bottom: 3px solid #28b04b;
590
+ }
591
+
592
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_pocket,
593
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_pocket:hover,
594
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_pocket {
595
+ border-bottom: 3px solid #ce3d55;
596
+ }
597
+
598
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_buffer,
599
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_buffer:hover,
600
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_buffer {
601
+ border-bottom: 3px solid #000;
602
+ }
603
+
604
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_hacker_news,
605
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_hacker_news:hover,
606
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_hacker_news {
607
+ border-bottom: 3px solid #d85623;
608
+ }
609
+
610
+ .swp_social_panel.swp_three_dee.swp_default_full_color .swp_flipboard,
611
+ html body .swp_social_panel.swp_three_dee.swp_individual_full_color .swp_flipboard:hover,
612
+ body .swp_social_panel.swp_three_dee.swp_other_full_color:hover .swp_flipboard {
613
+ border-bottom: 3px solid #bf2626;
614
+ }
615
+
616
+ .swp_social_panel.swp_default_light_gray .nc_tweetContainer,
617
+ html body .swp_social_panel.swp_individual_light_gray .nc_tweetContainer:hover,
618
+ body .swp_social_panel.swp_other_light_gray:hover .nc_tweetContainer {
619
+ background-color: #ccc;
620
+ border: 1px solid #ccc;
621
+ }
622
+
623
+ .swp_social_panel.swp_three_dee.swp_default_light_gray .nc_tweetContainer:not(.total_sharesalt),
624
+ html body .swp_social_panel.swp_three_dee.swp_individual_light_gray .nc_tweetContainer:not(.total_sharesalt):hover,
625
+ body .swp_social_panel.swp_three_dee.swp_other_light_gray:hover .nc_tweetContainer:not(.total_sharesalt) {
626
+ border-bottom: 3px solid #999;
627
+ }
628
+
629
+ .swp_social_panel.swp_default_medium_gray .nc_tweetContainer,
630
+ html body .swp_social_panel.swp_individual_medium_gray .nc_tweetContainer:hover,
631
+ body .swp_social_panel.swp_other_medium_gray:hover .nc_tweetContainer {
632
+ background-color: #999;
633
+ border: 1px solid #999;
634
+ }
635
+
636
+ .swp_social_panel.swp_three_dee.swp_default_medium_gray .nc_tweetContainer:not(.total_sharesalt),
637
+ html body .swp_social_panel.swp_three_dee.swp_individual_medium_gray .nc_tweetContainer:not(.total_sharesalt):hover,
638
+ body .swp_social_panel.swp_three_dee.swp_other_medium_gray:hover .nc_tweetContainer:not(.total_sharesalt) {
639
+ border-bottom: 3px solid #444;
640
+ }
641
+
642
+ .swp_social_panel.swp_default_dark_gray .nc_tweetContainer,
643
+ html body .swp_social_panel.swp_individual_dark_gray .nc_tweetContainer:hover,
644
+ body .swp_social_panel.swp_other_dark_gray:hover .nc_tweetContainer {
645
+ background-color: #444;
646
+ border: 1px solid #444;
647
+ }
648
+
649
+ .swp_social_panel.swp_three_dee.swp_default_dark_gray .nc_tweetContainer:not(.total_sharesalt),
650
+ html body .swp_social_panel.swp_three_dee.swp_individual_dark_gray .nc_tweetContainer:not(.total_sharesalt):hover,
651
+ body .swp_social_panel.swp_three_dee.swp_other_dark_gray:hover .nc_tweetContainer:not(.total_sharesalt) {
652
+ border-bottom: 3px solid #222;
653
+ }
654
+
655
+ .swp_social_panel.swp_default_light_gray_outlines a,
656
+ html body .swp_social_panel.swp_individual_light_gray_outlines a:hover,
657
+ body .swp_social_panel.swp_other_light_gray_outlines:hover a {
658
+ color: #ccc;
659
+ }
660
+
661
+ .swp_social_panel.swp_default_light_gray_outlines .nc_tweetContainer,
662
+ html body .swp_social_panel.swp_individual_light_gray_outlines .nc_tweetContainer:hover,
663
+ body .swp_social_panel.swp_other_light_gray_outlines:hover .nc_tweetContainer {
664
+ background: transparent;
665
+ border: 1px solid #ccc;
666
+ }
667
+
668
+ .swp_social_panel.swp_default_medium_gray_outlines a,
669
+ html body .swp_social_panel.swp_individual_medium_gray_outlines a:hover,
670
+ body .swp_social_panel.swp_other_medium_gray_outlines:hover a {
671
+ color: #999;
672
+ }
673
+
674
+ .swp_social_panel.swp_default_medium_gray_outlines .nc_tweetContainer,
675
+ html body .swp_social_panel.swp_individual_medium_gray_outlines .nc_tweetContainer:hover,
676
+ body .swp_social_panel.swp_other_medium_gray_outlines:hover .nc_tweetContainer {
677
+ background: transparent;
678
+ border: 1px solid #999;
679
+ }
680
+
681
+ .swp_social_panel.swp_default_dark_gray_outlines a,
682
+ html body .swp_social_panel.swp_individual_dark_gray_outlines a:hover,
683
+ body .swp_social_panel.swp_other_dark_gray_outlines:hover a {
684
+ color: #444;
685
+ }
686
+
687
+ .swp_social_panel.swp_default_dark_gray_outlines .nc_tweetContainer,
688
+ html body .swp_social_panel.swp_individual_dark_gray_outlines .nc_tweetContainer:hover,
689
+ body .swp_social_panel.swp_other_dark_gray_outlines:hover .nc_tweetContainer {
690
+ background: transparent;
691
+ border: 1px solid #444;
692
+ }
693
+
694
+ .swp_social_panel.swp_default_color_outlines .swp_google_plus a,
695
+ html body .swp_social_panel.swp_individual_color_outlines .swp_google_plus a:hover,
696
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_google_plus a {
697
+ color: #df4b37;
698
+ }
699
+
700
+ .swp_social_panel.swp_default_color_outlines .swp_facebook a,
701
+ html body .swp_social_panel.swp_individual_color_outlines .swp_facebook a:hover,
702
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_facebook a {
703
+ color: #3a589e;
704
+ }
705
+
706
+ .swp_social_panel.swp_default_color_outlines .swp_pinterest a,
707
+ html body .swp_social_panel.swp_individual_color_outlines .swp_pinterest a:hover,
708
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_pinterest a {
709
+ color: #cd2029;
710
+ }
711
+
712
+ .swp_social_panel.swp_default_color_outlines .swp_linkedin a,
713
+ html body .swp_social_panel.swp_individual_color_outlines .swp_linkedin a:hover,
714
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_linkedin a {
715
+ color: #0d77b7;
716
+ }
717
+
718
+ .swp_social_panel.swp_default_color_outlines .swp_tumblr a,
719
+ html body .swp_social_panel.swp_individual_color_outlines .swp_tumblr a:hover,
720
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_tumblr a {
721
+ color: #39475d;
722
+ }
723
+
724
+ .swp_social_panel.swp_default_color_outlines .swp_stumbleupon a,
725
+ html body .swp_social_panel.swp_individual_color_outlines .swp_stumbleupon a:hover,
726
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_stumbleupon a {
727
+ color: #ef5025;
728
+ }
729
+
730
+ .swp_social_panel.swp_default_color_outlines .swp_yummly a,
731
+ html body .swp_social_panel.swp_individual_color_outlines .swp_yummly a:hover,
732
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_yummly a {
733
+ color: #e26426;
734
+ }
735
+
736
+ .swp_social_panel.swp_default_color_outlines .swp_whatsapp a,
737
+ html body .swp_social_panel.swp_individual_color_outlines .swp_whatsapp a:hover,
738
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_whatsapp a {
739
+ color: #71c169;
740
+ }
741
+
742
+ .swp_social_panel.swp_default_color_outlines .swp_pocket a,
743
+ html body .swp_social_panel.swp_individual_color_outlines .swp_pocket a:hover,
744
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_pocket a {
745
+ color: #ef4056;
746
+ }
747
+
748
+ .swp_social_panel.swp_default_color_outlines .swp_reddit a,
749
+ html body .swp_social_panel.swp_individual_color_outlines .swp_reddit a:hover,
750
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_reddit a {
751
+ color: #f04b23;
752
+ }
753
+
754
+ .swp_social_panel.swp_default_color_outlines .swp_email a,
755
+ html body .swp_social_panel.swp_individual_color_outlines .swp_email a:hover,
756
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_email a {
757
+ color: #6bcce9;
758
+ }
759
+
760
+ .swp_social_panel.swp_default_color_outlines .swp_buffer a,
761
+ html body .swp_social_panel.swp_individual_color_outlines .swp_buffer a:hover,
762
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_buffer a {
763
+ color: #323b43;
764
+ }
765
+
766
+ .swp_social_panel.swp_default_color_outlines .swp_hacker_news a,
767
+ html body .swp_social_panel.swp_individual_color_outlines .swp_hacker_news a:hover,
768
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_hacker_news a {
769
+ color: #f16522;
770
+ }
771
+
772
+ .swp_social_panel.swp_default_color_outlines .swp_flipboard a,
773
+ html body .swp_social_panel.swp_individual_color_outlines .swp_flipboard a:hover,
774
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_flipboard a {
775
+ color: #e02828;
776
+ }
777
+
778
+ .swp_social_panel.swp_default_color_outlines .swp_google_plus,
779
+ html body .swp_social_panel.swp_individual_color_outlines .swp_google_plus:hover,
780
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_google_plus {
781
+ background: transparent;
782
+ border: 1px solid #df4b37;
783
+ }
784
+
785
+ .swp_social_panel.swp_default_color_outlines .swp_twitter,
786
+ html body .swp_social_panel.swp_individual_color_outlines .swp_twitter:hover,
787
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_twitter {
788
+ background: transparent;
789
+ border: 1px solid #429cd6;
790
+ }
791
+
792
+ .swp_social_panel.swp_default_color_outlines .swp_facebook,
793
+ html body .swp_social_panel.swp_individual_color_outlines .swp_facebook:hover,
794
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_facebook {
795
+ background: transparent;
796
+ border: 1px solid #3a589e;
797
+ }
798
+
799
+ .swp_social_panel.swp_default_color_outlines .swp_pinterest,
800
+ html body .swp_social_panel.swp_individual_color_outlines .swp_pinterest:hover,
801
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_pinterest {
802
+ background: transparent;
803
+ border: 1px solid #cd2029;
804
+ }
805
+
806
+ .swp_social_panel.swp_default_color_outlines .swp_linkedin,
807
+ html body .swp_social_panel.swp_individual_color_outlines .swp_linkedin:hover,
808
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_linkedin {
809
+ background: transparent;
810
+ border: 1px solid #0d77b7;
811
+ }
812
+
813
+ .swp_social_panel.swp_default_color_outlines .swp_tumblr,
814
+ html body .swp_social_panel.swp_individual_color_outlines .swp_tumblr:hover,
815
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_tumblr {
816
+ background: transparent;
817
+ border: 1px solid #39475d;
818
+ }
819
+
820
+ .swp_social_panel.swp_default_color_outlines .swp_stumbleupon,
821
+ html body .swp_social_panel.swp_individual_color_outlines .swp_stumbleupon:hover,
822
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_stumbleupon {
823
+ background: transparent;
824
+ border: 1px solid #ef5025;
825
+ }
826
+
827
+ .swp_social_panel.swp_default_color_outlines .swp_yummly,
828
+ html body .swp_social_panel.swp_individual_color_outlines .swp_yummly:hover,
829
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_yummly {
830
+ background: transparent;
831
+ border: 1px solid #e26426;
832
+ }
833
+
834
+ .swp_social_panel.swp_default_color_outlines .swp_whatsapp,
835
+ html body .swp_social_panel.swp_individual_color_outlines .swp_whatsapp:hover,
836
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_whatsapp {
837
+ background: transparent;
838
+ border: 1px solid #71c169;
839
+ }
840
+
841
+ .swp_social_panel.swp_default_color_outlines .swp_reddit,
842
+ html body .swp_social_panel.swp_individual_color_outlines .swp_reddit:hover,
843
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_reddit {
844
+ background: transparent;
845
+ border: 1px solid #f04b23;
846
+ }
847
+
848
+ .swp_social_panel.swp_default_color_outlines .swp_email,
849
+ html body .swp_social_panel.swp_individual_color_outlines .swp_email:hover,
850
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_email {
851
+ background: transparent;
852
+ border: 1px solid #6bcce9;
853
+ }
854
+
855
+ .swp_social_panel.swp_default_color_outlines .swp_pocket,
856
+ html body .swp_social_panel.swp_individual_color_outlines .swp_pocket:hover,
857
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_pocket {
858
+ background: transparent;
859
+ border: 1px solid #ef4056;
860
+ }
861
+
862
+ .swp_social_panel.swp_default_color_outlines .swp_buffer,
863
+ html body .swp_social_panel.swp_individual_color_outlines .swp_buffer:hover,
864
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_buffer {
865
+ background: transparent;
866
+ border: 1px solid #323b43;
867
+ }
868
+
869
+ .swp_social_panel.swp_default_color_outlines .swp_hacker_news,
870
+ html body .swp_social_panel.swp_individual_color_outlines .swp_hacker_news:hover,
871
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_hacker_news {
872
+ background: transparent;
873
+ border: 1px solid #f16522;
874
+ }
875
+
876
+ .swp_social_panel.swp_default_color_outlines .swp_flipboard,
877
+ html body .swp_social_panel.swp_individual_color_outlines .swp_flipboard:hover,
878
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_flipboard {
879
+ background: transparent;
880
+ border: 1px solid #bf2626;
881
+ }
882
+
883
+ .swp_social_panelSide {
884
+ flex-direction: column;
885
+ height: auto;
886
+ overflow: visible;
887
+ /*top: 200px;*/
888
+ -webkit-transition: all 0.2s linear;
889
+ transition: all 0.2s linear;
890
+
891
+ z-index: 9998;
892
+ margin: 10px 5px !important;
893
+ padding: 0;
894
+
895
+ -webkit-box-direction: normal;
896
+ -moz-box-direction: normal;
897
+ -webkit-box-orient: vertical;
898
+ -moz-box-orient: vertical;
899
+ -webkit-flex-direction: column;
900
+ -ms-flex-direction: column;
901
+ }
902
+
903
+ .swp_social_panelSide.slide,
904
+ .swp_social_panelSide.fade {
905
+ position: fixed;
906
+ -webkit-transition: all 0.2s linear;
907
+ transition: all 0.2s linear;
908
+ }
909
+
910
+ .swp_social_panelSide.fade.swp_float_left {
911
+ left: 5px;
912
+ }
913
+
914
+ .swp_social_panelSide.fade.swp_float_right {
915
+ right: 5px;
916
+ }
917
+
918
+ .swp_social_panelSide[class*=swp_side] {
919
+ height: auto;
920
+ display: flex;
921
+ position: fixed;
922
+ padding: 30px 0;
923
+ }
924
+
925
+ .swp_social_panelSide.fade {
926
+ display: none;
927
+ }
928
+
929
+ .swp_social_panelSide.swp_float_right {
930
+ align-content: flex-end;
931
+ }
932
+
933
+ .swp_social_panelSide.swp_side_top {
934
+ top: 15px;
935
+ }
936
+
937
+ .swp_social_panelSide.swp_side_bottom {
938
+ bottom: 15px;
939
+ }
940
+
941
+ .swp_social_panelSide.swp_side_center {
942
+ }
943
+
944
+ .swp_social_panelSide .nc_tweetContainer {
945
+ -webkit-border-radius: 3px;
946
+ border-radius: 3px;
947
+ clear: both;
948
+ display: block;
949
+ font-family: Lato, sans-serif;
950
+ height: 32px;
951
+ margin: 3px 0!important;
952
+ overflow: hidden;
953
+ padding: 0;
954
+ -webkit-transition: all 0.1s linear;
955
+ transition: all 0.1s linear;
956
+ vertical-align: top;
957
+ width: 90px;
958
+ }
959
+
960
+ .swp_social_panelSide .nc_tweetContainer .iconFiller {
961
+ display: inline-block;
962
+ height: 40px;
963
+ margin: 0 6px;
964
+ padding: 0;
965
+ -webkit-transition: all 0.1s linear;
966
+ transition: all 0.1s linear;
967
+ vertical-align: middle;
968
+ width: 21px;
969
+ }
970
+
971
+ .swp_social_panelSide .nc_tweetContainer .swp_count {
972
+ display: inline-block;
973
+ font-size: 14px;
974
+ height: 32px;
975
+ line-height: 16px;
976
+ margin: 0;
977
+ overflow: hidden;
978
+ padding: 0;
979
+ text-align: right;
980
+ -webkit-transition: all 0.1s linear;
981
+ transition: all 0.1s linear;
982
+ vertical-align: top;
983
+ width: 0;
984
+ }
985
+
986
+ .swp_social_panelSide .nc_tweetContainer a {
987
+ cursor: pointer;
988
+ display: block;
989
+ font-weight: 500;
990
+ height: 36px;
991
+ margin: 0;
992
+ padding: 0;
993
+ text-decoration: none;
994
+ -webkit-transition: all 0.1s linear;
995
+ transition: all 0.1s linear;
996
+ vertical-align: top;
997
+ }
998
+
999
+ .swp_social_panelSide .nc_tweetContainer .sw,
1000
+ .swp_social_panelSide .nc_tweetContainer .swp_share {
1001
+ float: left;
1002
+ line-height: 34px;
1003
+ }
1004
+
1005
+ .swp_social_panelSide.swp_default .nc_tweetContainer .sw {
1006
+ line-height: 32px;
1007
+ }
1008
+
1009
+ .swp_social_panelSide.swp_default .nc_tweetContainer .swp_share {
1010
+ line-height: 30px;
1011
+ }
1012
+
1013
+ .swp_social_panelSide .nc_tweetContainer .swp_share {
1014
+ font-size: 13px;
1015
+ }
1016
+
1017
+ .swp_social_panelSide .nc_tweetContainer:hover,
1018
+ .swp_social_panelSide .nc_tweetContainer:hover .iconFiller,
1019
+ .swp_social_panelSide .nc_tweetContainer:hover .swp_count {
1020
+ -webkit-transition: all 0.1s linear;
1021
+ transition: all 0.1s linear;
1022
+ }
1023
+
1024
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer, .swp_social_panelSide.swp_circles .nc_tweetContainer {
1025
+ margin-bottom: 5px;
1026
+ width: 67.5px !important;
1027
+ }
1028
+
1029
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer,
1030
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer a,
1031
+ .swp_social_panelSide.swp_circles .nc_tweetContainer,
1032
+ .swp_social_panelSide.swp_circles .nc_tweetContainer a {
1033
+ width: 67.5px;
1034
+ height: 67.5px;
1035
+ position: relative;
1036
+ }
1037
+ .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares),
1038
+ .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) a {
1039
+ border-radius:50%!important;
1040
+ }
1041
+
1042
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer i.sw,
1043
+ .swp_social_panelSide.swp_circles .nc_tweetContainer i.sw {
1044
+ font-size: 27px;
1045
+ height: 40px;
1046
+ margin: 0;
1047
+ padding-top: 10px;
1048
+ text-align: center;
1049
+ width: 100%;
1050
+ }
1051
+
1052
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares) span.swp_share,
1053
+ .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) span.swp_share {
1054
+ height: 35px;
1055
+ opacity: 0;
1056
+ position: absolute;
1057
+ bottom: 0;
1058
+ left: 0;
1059
+ text-align: center;
1060
+ width: 67.5px;
1061
+ }
1062
+
1063
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares) span.swp_count,
1064
+ .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) span.swp_count {
1065
+ height: 35px;
1066
+ margin: 0;
1067
+ padding: 0;
1068
+ position: absolute;
1069
+ bottom: 0;
1070
+ left: 0;
1071
+ text-align: center;
1072
+ -webkit-transition: padding 0.1s linear;
1073
+ transition: padding 0.1s linear;
1074
+ width: 100%;
1075
+ }
1076
+
1077
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares) span.swp_count.swp_hide,
1078
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer span.swp_hide .iconFiller,
1079
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer span.swp_hide .spaceManWilly,
1080
+ .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) span.swp_count.swp_hide,
1081
+ .swp_social_panelSide.swp_circles .nc_tweetContainer span.swp_hide .iconFiller,
1082
+ .swp_social_panelSide.swp_circles .nc_tweetContainer span.swp_hide .spaceManWilly {
1083
+ height: 67.5px;
1084
+ opacity: 1;
1085
+ }
1086
+
1087
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer span.iconFiller,
1088
+ .swp_social_panelSide.swp_circles .nc_tweetContainer span.iconFiller {
1089
+ height: 40px;
1090
+ width: 67.5px;
1091
+ }
1092
+
1093
+
1094
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares):hover span.swp_count:not(.swp_hide),
1095
+ .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares):hover span.swp_count:not(.swp_hide) {
1096
+ opacity: 0;
1097
+ }
1098
+
1099
+ .swp_social_panelSide.swp_boxed .total_shares,
1100
+ .swp_social_panelSide.swp_circles .total_shares {
1101
+ padding: 0;
1102
+ width: 67.5px!important;
1103
+ }
1104
+
1105
+ .swp_social_panelSide .nc_tweetContainer:not(.total_shares) {
1106
+ line-height: 34px;
1107
+ }
1108
+
1109
+ .swp_social_panelSide:not(.swp_boxed):not(.swp_circles) .nc_tweetContainer:not(.total_shares) .iconFiller{
1110
+ margin-left: 2px;
1111
+ width: 30px;
1112
+ }
1113
+
1114
+ .swp_social_panelSide .nc_tweetContainer:not(.total_shares) .swp_count {
1115
+ padding: 0 8px;
1116
+ width: 48px;
1117
+ }
1118
+
1119
+ .swp_social_panelSide .nc_tweetContainer:not(.total_shares) .swp_count.swp_hide {
1120
+ padding: 0;
1121
+ width: 100%;
1122
+ }
1123
+
1124
+ .swp_social_panelSide .nc_tweetContainer:not(.total_shares) .swp_count.swp_hide .iconFiller {
1125
+ display: block;
1126
+ float: none;
1127
+ margin: 0 auto;
1128
+ }
1129
+
1130
+
1131
+ .swp_social_panelSide:not(.swp_boxed):not(.swp_circles) .nc_tweetContainer:not(.total_shares):hover {
1132
+ width: 150px;
1133
+ }
1134
+
1135
+ .swp_social_panelSide .nc_tweetContainer[data-network]:not(.total_shares):hover .iconFiller,
1136
+ .swp_social_panelSide .nc_tweetContainer:not(.total_shares) .spaceManWilly {
1137
+ width: 90px;
1138
+ }
1139
+
1140
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares):hover .iconFiller,
1141
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares) .spaceManWilly,
1142
+ .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares):hover .iconFiller,
1143
+ .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) .spaceManWilly {
1144
+ width: 100%;
1145
+ }
1146
+
1147
+ .swp_social_panelSide .nc_tweetContainer.total_shares {
1148
+ background: rgba(0, 0, 0, 0);
1149
+ border: 0!important;
1150
+ font-weight: 800;
1151
+ height: 55px;
1152
+ margin: 0;
1153
+ padding: 0;
1154
+ text-align: center;
1155
+ width: 90px;
1156
+ order:-100;
1157
+ }
1158
+
1159
+ .swp_social_panelSide .nc_tweetContainer.total_shares .swp_count {
1160
+ color: #444;
1161
+ display: block;
1162
+ font-family: Lato, sans-serif;
1163
+ height: 28px;
1164
+ text-align: center;
1165
+ width: 100%;
1166
+ }
1167
+
1168
+ .swp_social_panelSide .nc_tweetContainer.total_shares .swp_label {
1169
+ color: #444;
1170
+ display: block;
1171
+ font-family: Lato, sans-serif;
1172
+ font-size: 50%;
1173
+ position: relative;
1174
+ text-align: center;
1175
+ width: 100%;
1176
+ }
1177
+
1178
+ .nc_wrapper {
1179
+ background: white;
1180
+ position: fixed;
1181
+ -webkit-transition: top 0.5s bottom 0.5s;
1182
+ transition: top 0.5s bottom 0.5s;
1183
+ width: 100%;
1184
+ z-index: 99999;
1185
+ }
1186
+
1187
+ .nc_wrapper.bottom {
1188
+ bottom: 0;
1189
+ left: 0;
1190
+ }
1191
+
1192
+ .nc_wrapper.top {
1193
+ top: 0;
1194
+ left: 0;
1195
+ }
1196
+
1197
+ .nc_floater {
1198
+ margin: 10px 0;
1199
+ position: relative;
1200
+ left: 304px;
1201
+ width: 740px;
1202
+ }
1203
+
1204
+ .swp_social_panelSide.hideCounts a {
1205
+ text-align: center;
1206
+ }
1207
+
1208
+ .swp_social_panelSide.hideCounts .iconFiller {
1209
+ float: none;
1210
+ text-align: left;
1211
+ }
1212
+
1213
+ .sw {
1214
+ display: inline-block;
1215
+ font-family: sw-icon-font!important;
1216
+ font-size: inherit;
1217
+ -moz-osx-font-smoothing: grayscale;
1218
+ -webkit-font-smoothing: antialiased;
1219
+ font-style: normal;
1220
+ font-weight: normal;
1221
+ text-rendering: auto;
1222
+ text-transform: none!important;
1223
+ -ms-transform: translate(0, 0);
1224
+ -webkit-transform: translate(0, 0);
1225
+ transform: translate(0, 0);
1226
+ }
1227
+
1228
+ .sw:before {
1229
+ display: block!important;
1230
+ }
1231
+
1232
+ .wp-editor-container .sw:before {
1233
+ font-size: 18px;
1234
+ line-height: 22px;
1235
+ }
1236
+
1237
+ .wp-editor-container .sw-social-warfare:before {
1238
+ color: #ee464f;
1239
+ }
1240
+
1241
+ .mce-container .sw-social-warfare {
1242
+ color: #ee464f;
1243
+ font-size: 20px;
1244
+ margin-right: 15px;
1245
+ vertical-align: middle;
1246
+ }
1247
+
1248
+ i.swp_google_plus_icon:before {
1249
+ content: "h";
1250
+ }
1251
+
1252
+ i.swp_pinterest_icon:before {
1253
+ content: "b";
1254
+ }
1255
+
1256
+ i.swp_twitter_icon:before {
1257
+ content: "s";
1258
+ }
1259
+
1260
+ i.swp_facebook_icon:before {
1261
+ content: "j";
1262
+ }
1263
+
1264
+ i.swp_linkedin_icon:before {
1265
+ content: "f";
1266
+ }
1267
+
1268
+ i.swp_tumblr_icon:before {
1269
+ content: "r";
1270
+ }
1271
+
1272
+ i.swp_stumbleupon_icon:before {
1273
+ content: "q";
1274
+ }
1275
+
1276
+ i.swp_reddit_icon:before {
1277
+ content: "a";
1278
+ }
1279
+
1280
+ i.swp_email_icon:before {
1281
+ content: "k";
1282
+ }
1283
+
1284
+ i.swp_yummly_icon:before {
1285
+ content: "x";
1286
+ }
1287
+
1288
+ i.swp_whatsapp_icon:before {
1289
+ content: "y";
1290
+ }
1291
+
1292
+ i.swp_pocket_icon:before {
1293
+ content: "B";
1294
+ }
1295
+
1296
+ i.swp_buffer_icon:before {
1297
+ content: "z";
1298
+ }
1299
+
1300
+ i.swp_hacker_news_icon:before {
1301
+ content: "D";
1302
+ }
1303
+
1304
+ i.swp_flipboard_icon:before {
1305
+ content: "C";
1306
+ }
1307
+
1308
+ .sw-social-warfare:before {
1309
+ content: "p";
1310
+ }
1311
+
1312
+ .swp_CTT {
1313
+ text-decoration: none!important;
1314
+ }
1315
+
1316
+ .sw-tweet-clear {
1317
+ zoom: 1;
1318
+ }
1319
+
1320
+ .sw-tweet-clear:after {
1321
+ clear: both;
1322
+ content: ".";
1323
+ display: block;
1324
+ height: 0;
1325
+ visibility: hidden;
1326
+ }
1327
+
1328
+ .sw-click-to-tweet {
1329
+ display: block;
1330
+ margin: 15px 0;
1331
+ padding: 15px 30px;
1332
+ position: relative;
1333
+ }
1334
+
1335
+ .sw-click-to-tweet:after {
1336
+ clear: both;
1337
+ content: ".";
1338
+ display: block;
1339
+ height: 0;
1340
+ line-height: 0;
1341
+ visibility: hidden;
1342
+ }
1343
+
1344
+ .sw-click-to-tweet .sw-ctt-text {
1345
+ margin: 0 0 10px;
1346
+ padding: 0;
1347
+ position: relative;
1348
+ word-wrap: break-word;
1349
+ }
1350
+
1351
+ a .sw-click-to-tweet .sw-ctt-text {
1352
+ display: block;
1353
+ font-size: 24px;
1354
+ font-weight: 500;
1355
+ line-height: 140%;
1356
+ margin: 0;
1357
+ padding: 0;
1358
+ position: relative;
1359
+ text-decoration: none;
1360
+ text-transform: none;
1361
+ }
1362
+
1363
+ .sw-click-to-tweet .sw-ctt-btn {
1364
+ display: block;
1365
+ float: right;
1366
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
1367
+ font-size: 12px;
1368
+ font-weight: bold;
1369
+ line-height: 100%;
1370
+ margin: 10px 0 0;
1371
+ padding: 3px 5px 3px 3px;
1372
+ position: relative;
1373
+ text-decoration: none;
1374
+ text-transform: uppercase;
1375
+ }
1376
+
1377
+ .sw-click-to-tweet i.swp_twitter_icon {
1378
+ float: right;
1379
+ font-size: 21px;
1380
+ margin-left: 15px !important;
1381
+ margin-top: 2px;
1382
+ text-transform: none;
1383
+ }
1384
+
1385
+ a.swp_CTT.style1 .sw-click-to-tweet {
1386
+ background-color: #fff;
1387
+ border: 1px solid #ddd;
1388
+ -webkit-border-radius: 4px;
1389
+ border-radius: 4px;
1390
+ }
1391
+
1392
+ a.swp_CTT.style2 .sw-click-to-tweet {
1393
+ background-color: #fff;
1394
+ border: 4px double #ddd;
1395
+ -webkit-border-radius: 0;
1396
+ border-radius: 0;
1397
+ }
1398
+
1399
+ a.style2 .sw-click-to-tweet .sw-ctt-text {
1400
+ color: #666;
1401
+ font-style: italic;
1402
+ text-decoration: none;
1403
+ }
1404
+
1405
+ a.swp_CTT.style3:hover .sw-click-to-tweet {
1406
+ border-left: 10px solid #3c87b2;
1407
+ padding-right: 20px;
1408
+ -webkit-transition: all 0.25s linear;
1409
+ transition: all 0.25s linear;
1410
+ }
1411
+
1412
+ a.swp_CTT.style3 .sw-click-to-tweet {
1413
+ background-color: #429cd6;
1414
+ border: none;
1415
+ border-left: 10px solid #429cd6;
1416
+ -webkit-border-radius: 0;
1417
+ border-radius: 0;
1418
+ padding-right: 20px;
1419
+ -webkit-transition: all 0.25s linear;
1420
+ transition: all 0.25s linear;
1421
+ }
1422
+
1423
+ a.style3 .sw-click-to-tweet .sw-ctt-text {
1424
+ color: #fff;
1425
+ font-style: italic;
1426
+ text-decoration: none;
1427
+ }
1428
+
1429
+ a.swp_CTT.style4:hover .sw-click-to-tweet {
1430
+ border-left: 10px solid #3c87b2;
1431
+ -webkit-transition: all 0.25s linear;
1432
+ transition: all 0.25s linear;
1433
+ }
1434
+
1435
+ a.swp_CTT.style4 .sw-click-to-tweet {
1436
+ background-color: #333;
1437
+ border-left: 10px solid #c33;
1438
+ -webkit-border-radius: 0;
1439
+ border-radius: 0;
1440
+ -webkit-transition: all 0.25s linear;
1441
+ transition: all 0.25s linear;
1442
+ }
1443
+
1444
+ a.swp_CTT.style5:hover .sw-click-to-tweet {
1445
+ background-color: #d34250;
1446
+ border-left: 10px solid #30394f;
1447
+ -webkit-transition: all 0.25s linear;
1448
+ transition: all 0.25s linear;
1449
+ }
1450
+
1451
+ a.swp_CTT.style5 .sw-click-to-tweet {
1452
+ background-color: #30394f;
1453
+ border-left: 10px solid #d34250;
1454
+ -webkit-border-radius: 0;
1455
+ border-radius: 0;
1456
+ -webkit-transition: all 0.25s linear;
1457
+ transition: all 0.25s linear;
1458
+ }
1459
+
1460
+ a.swp_CTT.style6:hover .sw-click-to-tweet {
1461
+ background-color: #ced3dc;
1462
+ border-left: 10px solid #d34250;
1463
+ -webkit-transition: all 0.25s linear;
1464
+ transition: all 0.25s linear;
1465
+ }
1466
+
1467
+ a.swp_CTT.style6 .sw-click-to-tweet {
1468
+ background-color: #eee;
1469
+ border-left: 10px solid #d34250;
1470
+ -webkit-border-radius: 0;
1471
+ border-radius: 0;
1472
+ -webkit-transition: all 0.25s linear;
1473
+ transition: all 0.25s linear;
1474
+ }
1475
+
1476
+ a.style6 .sw-click-to-tweet i.swp_twitter {
1477
+ color: #30394f;
1478
+ }
1479
+
1480
+ .swp_pop_thumb {
1481
+ -webkit-border-radius: 3px;
1482
+ border-radius: 3px;
1483
+ float: left;
1484
+ height: 100px;
1485
+ margin: 5px 25px 5px 0;
1486
+ width: 100px;
1487
+ }
1488
+
1489
+ .swp_popular_post {
1490
+ clear: both;
1491
+ }
1492
+
1493
+ .swp_clearfix:after {
1494
+ clear: both;
1495
+ content: " ";
1496
+ display: block;
1497
+ height: 0;
1498
+ visibility: hidden;
1499
+ }
1500
+
1501
+ .swp_popular_post a.swp_popularity {
1502
+ border: none;
1503
+ display: block;
1504
+ line-height: 1.5;
1505
+ margin: 20px 0;
1506
+ }
1507
+
1508
+ span.swp_pop_count {
1509
+ display: block;
1510
+ font-size: 70%;
1511
+ }
1512
+
1513
+ .swp_widget_box {
1514
+ -webkit-border-radius: 3px;
1515
+ border-radius: 3px;
1516
+ }
1517
+
1518
+ div.sw-pinit {
1519
+ display: table !important;
1520
+ line-height: 0;
1521
+ position: relative !important;
1522
+ }
1523
+
1524
+ div.sw-pinit a.sw-pinit-button,
1525
+ div.sw-pinit a.sw-pinit-button:visited {
1526
+ background: #cd2029;
1527
+ border: 1px solid #aa1b29;
1528
+ border: 0;
1529
+ border-bottom: none;
1530
+ -webkit-border-radius: 4px;
1531
+ border-radius: 3px;
1532
+ -webkit-box-shadow: none;
1533
+ box-shadow: none;
1534
+ color: #fff;
1535
+ font-family: Lato,sans-serif;
1536
+ font-size: 20px;
1537
+ font-size: 15px;
1538
+ height: 32px;
1539
+ line-height: 32px;
1540
+ opacity: 0;
1541
+ padding: 0 20px;
1542
+ position: absolute;
1543
+ text-decoration: none;
1544
+ text-decoration: none;
1545
+ -webkit-transition: opacity 0.5s;
1546
+ transition: opacity 0.5s;
1547
+ z-index: 200;
1548
+ }
1549
+
1550
+ div.sw-pinit:hover a.sw-pinit-button,
1551
+ div.sw-pinit:focus a.sw-pinit-button {
1552
+ opacity: 1;
1553
+ }
1554
+
1555
+ div.sw-pinit a.sw-pinit-button::before {
1556
+ color: #fff;
1557
+ content: "b";
1558
+ float: left;
1559
+ font-family: sw-icon-font;
1560
+ font-size: 20px;
1561
+ font-weight: 400;
1562
+ line-height: 36px;
1563
+ margin-left: -5px;
1564
+ margin-right: 10px;
1565
+ }
1566
+
1567
+ div.sw-pinit a.sw-pinit-button:hover::before {
1568
+ content: "F";
1569
+ }
1570
+
1571
+ div.sw-pinit a.sw-pinit-button:hover,
1572
+ div.sw-pinit a.sw-pinit-button:focus {
1573
+ background: #aa1b29;
1574
+ color: #fff;
1575
+ text-decoration: none;
1576
+ }
1577
+
1578
+ div.sw-pinit .sw-pinit-left {
1579
+ left: 30px;
1580
+ }
1581
+
1582
+ div.sw-pinit .sw-pinit-center {
1583
+ margin-left: -60px;
1584
+ left: 50%;
1585
+ }
1586
+
1587
+ div.sw-pinit .sw-pinit-right {
1588
+ right: 30px;
1589
+ }
1590
+
1591
+ div.sw-pinit .sw-pinit-top {
1592
+ top: 30px;
1593
+ }
1594
+
1595
+ div.sw-pinit .sw-pinit-middle {
1596
+ margin-top: -25px;
1597
+ top: 50%;
1598
+ }
1599
+
1600
+ div.sw-pinit .sw-pinit-bottom {
1601
+ bottom: 30px;
1602
+ }
1603
+
1604
+ .swp_social_panel.notMobile .nc_tweetContainer:nth-last-child(1),
1605
+ .mobile .nc_tweetContainer:nth-last-child(2),
1606
+ .nc_tweetContainer.total_shares:nth-last-child(1) {
1607
+ margin-right: 0;
1608
+ }
1609
+
1610
+ .swp_social_panel.swp_default_full_color a,
1611
+ html body .swp_social_panel.swp_individual_full_color .nc_tweetContainer:hover a,
1612
+ body .swp_social_panel.swp_other_full_color:hover a,
1613
+ .swp_social_panel.swp_default_light_gray a,
1614
+ html body .swp_social_panel.swp_individual_light_gray .nc_tweetContainer:hover a,
1615
+ body .swp_social_panel.swp_other_light_gray:hover a,
1616
+ .swp_social_panel.swp_default_medium_gray a,
1617
+ html body .swp_social_panel.swp_individual_medium_gray a:hover,
1618
+ body .swp_social_panel.swp_other_medium_gray:hover a,
1619
+ .swp_social_panel.swp_default_dark_gray a,
1620
+ html body .swp_social_panel.swp_individual_dark_gray a:hover,
1621
+ body .swp_social_panel.swp_other_dark_gray:hover a {
1622
+ color: white;
1623
+ }
1624
+
1625
+ .swp_social_panel.swp_default_color_outlines .swp_twitter a,
1626
+ html body .swp_social_panel.swp_individual_color_outlines .swp_twitter a:hover,
1627
+ body .swp_social_panel.swp_other_color_outlines:hover .swp_twitter a,
1628
+ .wp-editor-container .swp_twitter:before,
1629
+ a.style1 .sw-click-to-tweet i.swp_twitter,
1630
+ a.style2 .sw-click-to-tweet i.swp_twitter {
1631
+ color: #429cd6;
1632
+ }
1633
+
1634
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares) .swp_hide span.swp_share,
1635
+ .swp_social_panelSide.swp_boxed .nc_tweetContainer:not(.total_shares):hover span.swp_share:not(.swp_hide),
1636
+ .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares) .swp_hide span.swp_share,
1637
+ .swp_social_panelSide.swp_circles .nc_tweetContainer:not(.total_shares):hover span.swp_share:not(.swp_hide) {
1638
+ opacity: 1;
1639
+ }
1640
+
1641
+ .swp_social_panel.mobile .iconFiller ~ .swp_count,
1642
+ .sw-content-locator {
1643
+ display: none;
1644
+ }
1645
+
1646
+ a.style1 .sw-click-to-tweet .sw-ctt-text,
1647
+ a.style1 .sw-click-to-tweet .sw-ctt-btn {
1648
+ color: #999;
1649
+ text-decoration: none;
1650
+ }
1651
+
1652
+ a.style1:hover .sw-click-to-tweet .sw-ctt-text,
1653
+ a.style1:hover .sw-click-to-tweet .sw-ctt-btn,
1654
+ a.style2:hover .sw-click-to-tweet .sw-ctt-text,
1655
+ a.style2 .sw-click-to-tweet .sw-ctt-btn,
1656
+ a.style2:hover .sw-click-to-tweet .sw-ctt-btn {
1657
+ color: #666;
1658
+ text-decoration: none;
1659
+ }
1660
+
1661
+ a.style3:hover .sw-click-to-tweet .sw-ctt-text,
1662
+ a.style3 .sw-click-to-tweet .sw-ctt-btn,
1663
+ a.style3:hover .sw-click-to-tweet .sw-ctt-btn,
1664
+ a.style3 .sw-click-to-tweet i.swp_twitter,
1665
+ a.style4 .sw-click-to-tweet .sw-ctt-text,
1666
+ a.style4:hover .sw-click-to-tweet .sw-ctt-text,
1667
+ a.style4 .sw-click-to-tweet .sw-ctt-btn,
1668
+ a.style4:hover .sw-click-to-tweet .sw-ctt-btn,
1669
+ a.style5 .sw-click-to-tweet .sw-ctt-text,
1670
+ a.style5:hover .sw-click-to-tweet .sw-ctt-text,
1671
+ a.style5 .sw-click-to-tweet .sw-ctt-btn,
1672
+ a.style5:hover .sw-click-to-tweet .sw-ctt-btn {
1673
+ color: #fff;
1674
+ text-decoration: none;
1675
+ }
1676
+
1677
+ a.style4 .sw-click-to-tweet i.swp_twitter,
1678
+ a.style5 .sw-click-to-tweet i.swp_twitter {
1679
+ color: #fff;
1680
+ }
1681
+
1682
+ a.style6 .sw-click-to-tweet .sw-ctt-text,
1683
+ a.style6 .sw-click-to-tweet .sw-ctt-btn {
1684
+ color: #30394f;
1685
+ text-decoration: none;
1686
+ }
1687
+
1688
+ a.style6:hover .sw-click-to-tweet .sw-ctt-text,
1689
+ a.style6:hover .sw-click-to-tweet .sw-ctt-btn,
1690
+ a.style6:hover .sw-click-to-tweet i.swp_twitter {
1691
+ color: #2a2d34;
1692
+ text-decoration: none;
1693
+ }
1694
+
1695
+ .scale-70 {
1696
+ -ms-transform: scale(0.7);
1697
+ -webkit-transform: scale(0.7);
1698
+ transform: scale(0.7);
1699
+ }
1700
+
1701
+ .swp_social_panel:not(.nc_floater).scale-70.scale-full_width {
1702
+ width: 142.8571428571429%!important;
1703
+ }
1704
+
1705
+ .scale-80 {
1706
+ -ms-transform: scale(0.8);
1707
+ -webkit-transform: scale(0.8);
1708
+ transform: scale(0.8);
1709
+ }
1710
+
1711
+ .swp_social_panel:not(.nc_floater).scale-80.scale-full_width {
1712
+ width: 125%!important;
1713
+ }
1714
+
1715
+ .scale-90 {
1716
+ -ms-transform: scale(0.9);
1717
+ -webkit-transform: scale(0.9);
1718
+ transform: scale(0.9);
1719
+ }
1720
+
1721
+ .swp_social_panel:not(.nc_floater).scale-90.scale-full_width {
1722
+ width: 111.111111111111%!important;
1723
+ }
1724
+
1725
+ .scale-110 {
1726
+ -ms-transform: scale(1.1);
1727
+ -webkit-transform: scale(1.1);
1728
+ transform: scale(1.1);
1729
+ }
1730
+
1731
+ .swp_social_panel:not(.nc_floater).scale-110.scale-full_width {
1732
+ width: 90.90909090909091%!important;
1733
+ }
1734
+
1735
+ .scale-120 {
1736
+ -ms-transform: scale(1.2);
1737
+ -webkit-transform: scale(1.2);
1738
+ transform: scale(1.2);
1739
+ }
1740
+
1741
+ .swp_social_panel:not(.nc_floater).scale-120.scale-full_width {
1742
+ width: 83.33333333333333%!important;
1743
+ }
1744
+
1745
+ .scale-130 {
1746
+ -ms-transform: scale(1.3);
1747
+ -webkit-transform: scale(1.3);
1748
+ transform: scale(1.3);
1749
+ }
1750
+
1751
+ .swp_social_panel:not(.nc_floater).scale-130.scale-full_width {
1752
+ width: 76.92307692307692%!important;
1753
+ }
1754
+
1755
+ .scale-140 {
1756
+ -ms-transform: scale(1.4);
1757
+ -webkit-transform: scale(1.4);
1758
+ transform: scale(1.4);
1759
+ }
1760
+
1761
+ .swp_social_panel:not(.nc_floater).scale-140.scale-full_width {
1762
+ width: 71.42857142857143%!important;
1763
+ }
1764
+
1765
+ .scale-full_width,
1766
+ .scale-left,
1767
+ .nc_floater.scale-center,
1768
+ .nc_floater.scale-right {
1769
+ -ms-transform-origin: left;
1770
+ -webkit-transform-origin: left;
1771
+ transform-origin: left;
1772
+ }
1773
+
1774
+ .scale-right {
1775
+ -ms-transform-origin: right;
1776
+ -webkit-transform-origin: right;
1777
+ transform-origin: right;
1778
+ }
1779
+
1780
+ .scale-center {
1781
+ -ms-transform-origin: center;
1782
+ -webkit-transform-origin: center;
1783
+ transform-origin: center;
1784
+ }
1785
+
1786
+ div.swp_social_panel .nc_tweetContainer.swp_emphasize {
1787
+ -webkit-box-flex: 2;
1788
+ -moz-box-flex: 2;
1789
+ -webkit-flex: 2;
1790
+ -ms-flex: 2;
1791
+ flex: 2;
1792
+ }
1793
+
1794
+ .sw-pinit.aligncenter {
1795
+ margin: 0 auto;
1796
+ }
1797
+
1798
+ @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
1799
+ div.sw-pinit {
1800
+ display: inline-block!important;
1801
+ max-width: 100%;
1802
+ }
1803
+ }
1804
+
1805
+ .swp_hidden_pin_image {
1806
+ height: 0;
1807
+ opacity: 0;
1808
+ position: absolute;
1809
+ top: 0;
1810
+ width: 0;
1811
+ }
1812
+ .fl-module-content .uabb-blog-posts .uabb-post-thumbnail .sw-pinit.lazyloaded {
1813
+ display: block !important;
1814
+ }
1815
+
1816
+ .swp-content-locator {
1817
+ display: none !important;
1818
+ margin: 0 !important;
1819
+ }
1820
+
1821
+ .float-position-top-left {
1822
+ transform-origin: top left;
1823
+ }
1824
+
1825
+ .float-position-center-left {
1826
+ transform-origin: center left;
1827
+ }
1828
+
1829
+ .float-position-bottom-left {
1830
+ transform-origin: bottom left;
1831
+ }
1832
+
1833
+ .float-position-top-right {
1834
+ transform-origin: top right;
1835
+ }
1836
+
1837
+ .float-position-center-right {
1838
+ transform-origin: center right;
1839
+ }
1840
+
1841
+ .float-position-bottom-right {
1842
+ transform-origin: bottom right;
1843
+ }
1844
+
1845
+ div[class*=custom_color][class^=_wrapper] {
1846
+ display: none;
1847
+ }
fonts/sw-icon-font.svg CHANGED
@@ -1,42 +1,42 @@
1
- <?xml version="1.0" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
- <svg xmlns="http://www.w3.org/2000/svg">
4
- <metadata>Generated by Fontastic.me</metadata>
5
- <defs>
6
- <font id="social-warfare-icons" horiz-adv-x="512">
7
- <font-face font-family="social-warfare-icons" units-per-em="512" ascent="480" descent="-32"/>
8
- <missing-glyph horiz-adv-x="512" />
9
-
10
- <glyph glyph-name="reddit" unicode="&#97;" d="M448 338c-19 0-38-10-51-26l-3-3c-31 21-72 33-117 37l21 64 56-13c3-27 25-48 54-48 30 0 54 24 54 54 0 31-24 55-54 55-21 0-38-12-48-29l-69 16c-8 1-16-3-19-11l-27-87c-50-1-95-16-128-37l-3 5c-13 15-31 24-50 24-35 0-64-29-64-64 0-27 18-51 43-61l11-4 0 3c0 0 0-2 0-2 0-75 90-136 202-136 110 0 200 61 202 136l11 3c27 8 45 34 45 61-2 34-31 63-66 63z m-40 86c11 0 19-10 19-19 0-11-9-21-19-21-11 0-19 10-19 21 0 9 8 19 19 19z m-355-178c-11 5-18 16-18 28 0 17 13 30 29 30 8 0 16-3 22-10l4-4c-15-13-24-29-31-45z m201-139c-92 0-168 47-168 104 0 58 76 104 168 104 93 0 168-46 168-104 0-57-75-104-168-104z m204 139l-8-3c-7 16-16 32-29 45l5 6c6 7 14 10 22 10 16 0 30-13 30-30-1-12-9-23-20-28z m-237-4c0 16-13 30-31 30-17 0-30-14-30-30 0-16 14-31 30-31 16 0 31 15 31 31z m101 30c-16 0-31-14-31-30 0-16 15-31 31-31 16 0 30 13 30 31-2 17-14 30-30 30z m-2-93c-5 0-8-1-11-5-10-9-27-14-53-14-26 0-42 5-53 14-6 7-17 7-22 0-3-3-5-6-5-11 0-5 2-8 5-11 16-16 40-24 75-24 34 0 59 8 75 24 3 3 5 6 5 11 0 5-2 8-5 11-3 4-6 5-11 5z"/>
11
- <glyph glyph-name="pinterest" unicode="&#98;" d="M256 450c-107 0-194-87-194-194 0-78 48-147 116-178 0 13 0 31 3 45 3 16 25 106 25 106 0 0-6 13-6 30 0 29 16 50 37 50 17 0 25-13 25-29 0-18-11-45-17-69-5-21 9-37 30-37 37 0 61 47 61 103 0 41-29 73-80 73-59 0-94-43-94-92 0-18 4-29 12-39 4-5 5-6 4-11-2-3-4-13-4-16-1-5-4-6-9-5-27 11-40 40-40 74 0 54 46 120 137 120 74 0 122-53 122-111 0-75-42-132-104-132-21 0-40 11-46 24 0 0-12-45-15-53-5-15-13-31-19-42 18-5 35-8 54-8 108 0 194 87 194 194 2 110-85 197-192 197z"/>
12
- <glyph glyph-name="periscope" unicode="&#99;" d="M258 464c-93 0-167-77-167-171 0-98 130-245 167-245 32 0 161 147 161 245 2 94-72 171-161 171z m1-261c-57 0-102 45-102 96 0 24 8 47 21 63 0-21 17-39 40-39 22 0 38 18 38 39 0 16-10 28-24 35 8 1 18 3 26 3 52 0 97-45 97-102 0-50-45-95-96-95z"/>
13
- <glyph glyph-name="medium" unicode="&#101;" d="M493 389l-19 0c-7 0-16-10-16-16l0-232c0-7 9-15 16-15l19 0 0-54-170 0 0 54 35 0 0 242-1 0-83-299-64 0-82 299-2 0 0-245 36 0 0-54-143 0 0 54 18 0c8 0 17 8 17 15l0 233c0 7-9 16-17 16l-18 0 0 56 178 0 57-217 2 0 59 217 178 0z"/>
14
- <glyph glyph-name="linkedin" unicode="&#102;" d="M115 443c-25 0-46-21-46-46 0-26 21-47 46-47 26 2 45 23 45 47 0 25-19 46-45 46z m-40-374l79 0 0 249-79 0z m282 257c0 0-63 5-77-41l0 33-78 0 0-249 78 0 0 133c0 4 2 54 48 54 43 0 40-58 40-58l0-128 77 0 0 144c-2-1 8 112-88 112z"/>
15
- <glyph glyph-name="instagram" unicode="&#103;" d="M400 285l-32 0c2-10 3-19 3-29 0-64-51-115-115-115-64 0-115 51-115 115 0 10 1 19 3 29l-32 0 0-159c0-8 6-14 14-14l260 0c8 0 14 6 14 14z m0 101c0 8-6 14-14 14l-44 0c-8 0-14-6-14-14l0-44c0-8 6-14 14-14l44 0c8 0 14 6 14 14z m-144-58c-40 0-72-32-72-72 0-40 32-72 72-72 40 0 72 32 72 72 0 40-32 72-72 72m144-259l-288 0c-24 0-43 19-43 43l0 288c0 24 19 43 43 43l288 0c24 0 43-19 43-43l0-288c0-24-19-43-43-43"/>
16
- <glyph glyph-name="google-plus" unicode="&#104;" d="M168 280l0-58 96 0c-5-24-29-72-96-72-58 0-102 48-102 106 0 58 44 106 102 106 34 0 54-15 67-26l45 43c-29 29-67 45-112 45-94 0-168-75-168-168 0-93 74-168 168-168 96 0 160 67 160 163 0 11 0 19-2 29z m344 0l-48 0 0 48-48 0 0-48-48 0 0-48 48 0 0-48 48 0 0 48 48 0"/>
17
- <glyph glyph-name="flickr" unicode="&#105;" d="M510 256c0-66-52-118-118-118-66 0-118 52-118 118 0 66 52 118 118 118 66 0 118-52 118-118z m-270 0c0-66-53-118-118-118-66 0-120 52-120 118 0 66 52 118 118 118 66 0 120-52 120-118z"/>
18
- <glyph glyph-name="facebook" unicode="&#106;" d="M288 48l0 190 64 0 10 74-74 0 0 48c0 21 6 37 37 37l40 0 0 64c-8 1-31 3-58 3-56 0-96-35-96-98l0-54-64 0 0-74 64 0 0-190z"/>
19
- <glyph glyph-name="email" unicode="&#107;" d="M166 277l-152 120 0-275z m330 147l-480 0 240-184z m-173-162l-67-51-67 51-175-174 482 0z m21 13l154-153 0 273z"/>
20
- <glyph glyph-name="ello" unicode="&#108;" d="M256 454c-109 0-198-89-198-198 0-109 89-198 198-198 109 0 198 89 198 198 0 109-89 198-198 198z m-3-321c-82 0-114 67-119 102-1 8 5 16 13 18 8 1 16-5 18-13 0-3 13-75 88-75 75 0 91 73 93 77 1 8 9 14 17 12 8-1 15-9 13-17-6-39-42-104-123-104z"/>
21
- <glyph glyph-name="blogger" unicode="&#109;" d="M442 288l-4 6-4 5c-7 5-42 0-52 8-6 7-8 18-9 32-5 29-7 31-11 40-16 35-61 61-92 64l-83 0c-65 0-118-53-118-118l0-138c0-65 53-118 118-118l136 0c66 0 119 53 119 118z m-253 59l65 0c13 0 23-9 23-22 0-13-10-23-23-23l-65 0c-13 0-23 10-23 23 0 11 10 22 23 22z m134-181l-133 0c-12 0-22 10-22 23 0 13 10 22 22 22l133 0c13 0 23-9 23-22 0-13-12-23-23-23z"/>
22
- <glyph glyph-name="rss" unicode="&#110;" d="M166 114c0-29-24-53-52-53-29 0-53 24-53 53 0 28 24 52 53 52 30 0 52-22 52-52z m-104 204l0-78c98-2 178-80 178-178l78 0c-1 141-115 255-256 256z m0 55c84 0 160-32 220-91 59-60 91-136 91-220l78 0c0 215-174 388-387 389l0-78z"/>
23
- <glyph glyph-name="share" unicode="&#111;" d="M382 170c-16 0-30-7-41-16l-149 86c2 5 2 10 2 14 0 5 0 10-2 15l147 86c11-11 26-17 43-17 36 0 63 28 63 62 0 34-29 64-63 64-33 0-62-29-62-62 0-5 0-10 2-15l-148-86c-11 11-25 17-43 17-35 0-62-28-62-62 0-34 27-64 61-64 16 0 32 6 43 18l149-87c-2-5-2-9-2-14 0-34 27-61 61-61 33 0 61 27 61 61 0 33-26 61-60 61z"/>
24
- <glyph glyph-name="social-warfare" unicode="&#112;" d="M138 354c3 12 28 67 88 100-96-14-170-97-170-196 0-26 5-52 14-74 4 3 8 5 13 5l74 14c13 3 17-3 14-16-8-29 8-46 37-46 29 0 58 17 59 33 7 53-179 42-129 180z m297-8c-5-5-9-10-17-12l-76-14c-12-3-17 3-14 14 5 24-10 40-38 40-24 0-44-14-45-27-8-46 182-46 134-184-5-13-37-73-109-105 104 6 188 92 188 198-2 32-10 62-23 90z"/>
25
- <glyph glyph-name="stumble-upon" unicode="&#113;" d="M282 302l33-16 50 15 0 35c-2 59-50 106-109 106-59 0-107-47-109-106l0-158c0-15-11-26-25-26-15 0-26 11-26 26l0 67-85 0c0 0 0-67 0-69 0-61 50-110 111-110 60 0 108 48 108 108l0 157c0 15 12 26 26 26 14 0 26-11 26-26z m136-56l0-70c0-14-12-26-26-26-14 0-26 12-26 26l0 69-49-15-34 16 0-68c0-61 50-109 111-109 60 0 110 49 110 110 0 0 0 69 0 69l-86 0z"/>
26
- <glyph glyph-name="tumblr" unicode="&#114;" d="M355 133c-65-29-73 24-73 24l0 131 78 0 0 70-78 0 0 106-64 0c0 0-8-94-82-115l0-61 46 0 0-136c0-67 56-104 116-104 59 0 78 26 78 26z"/>
27
- <glyph glyph-name="twitter" unicode="&#115;" d="M491 402c-17-8-35-13-56-15 19 11 35 31 43 53-19-11-40-19-60-24-18 19-44 30-71 30-62 0-109-57-94-118-80 5-152 43-199 101-25-43-12-101 31-130-16 0-31 5-43 13-2-45 30-86 76-96-12-3-28-5-43-2 13-38 48-65 90-67-40-32-91-46-143-40 44-27 93-43 148-43 179 0 280 152 273 286 19 15 35 32 48 52z"/>
28
- <glyph glyph-name="vimeo" unicode="&#116;" d="M11 354l19-26c0 0 42 32 55 16 14-16 65-211 83-248 16-32 58-74 104-43 46 30 198 160 227 315 27 154-184 122-206-13 56 34 86-14 57-67-28-53-54-88-68-88-15 0-24 35-40 98-16 64-16 180-84 168-64-13-147-112-147-112z"/>
29
- <glyph glyph-name="vine" unicode="&#117;" d="M438 258c-11-4-20-4-30-4-53 0-93 37-93 101 0 32 13 48 29 48 16 0 27-14 27-45 0-17-5-35-8-46 0 0 16-29 61-19 10 21 14 48 14 72 0 64-32 101-92 101-61 0-98-48-98-109 0-63 29-115 77-139-21-40-45-76-72-103-48 58-91 136-109 288l-70 0c33-253 131-333 156-349 15-8 28-8 40-1 21 11 85 75 119 149 14 0 32 1 49 6z"/>
30
- <glyph glyph-name="warfare-plugins" unicode="&#118;" d="M424 365l-32-163c-2-7 3-7 6 0l52 104c-4 20-13 41-26 59z m-155 86l-55-249c-1-7 4-7 7 0l120 233c-23 10-47 16-74 18 2 0 2 0 2-2z m38-240l-85-147c0 0-1-2-1-2 13-1 25-3 38-3 13 0 24 2 37 3 0 0 0 2 0 2l19 147c0 5-5 5-8 0z m-246 45c0-50 17-94 48-130l48 300c-58-34-96-98-96-170z"/>
31
- <glyph glyph-name="youtube" unicode="&#119;" d="M365 437l-218 0c-123 0-142-7-142-127l0-108c0-120 19-127 142-127l216 0c123 0 143 7 143 127l0 108c1 120-18 127-141 127z m-160-271l0 188 142-95z"/>
32
- <glyph glyph-name="yummly" unicode="&#120;" d="M91 430c2 7 8 12 13 15 19 13 42 21 64 19 19-2 34-11 37-34 3-14 0-28-3-43-8-30-16-61-24-91-2-6-2-11-2-18 0-8 5-12 13-12 9-2 17 0 25 3 15 3 28 9 40 16 2 1 4 3 4 5 3 19 6 36 9 56 3 19 7 36 10 56 1 12 5 24 6 36 0 4 0 8-1 13-2 5 0 7 3 8 9 5 21 7 32 3 9-1 14-8 14-17 0-10-1-19-3-31-3-20-6-40-11-60-3-21-8-44-11-64-4-21-8-44-12-64-1-8-3-18-4-26 0-2 0-3 1-3 35-5 71-15 103-29 4-3 11-3 17-5 5-1 7-3 7-6 0-8-2-15-7-23-8-11-21-16-35-11-10 3-18 8-26 13-19 11-38 18-60 21-2 0-5 0-7 0-1 0-3 0-3-3-3-20-10-37-18-53-6-13-16-26-27-35-11-10-24-15-38-16-3 0-7-2-10-2-3 0-6 0-9 0-2 0-4 0-4 0-14 2-28 8-38 19-11 15-13 31-10 47 5 27 21 48 45 62 21 11 43 18 66 21 1 0 3 0 3 3 2 5 2 10 3 14 2 7 2 12 3 18-3-2-4-3-6-3-26-15-53-21-83-18-15 2-26 8-32 21-7 13-8 26-5 38 6 28 14 56 22 84 8 16 12 30 15 44 1 12-2 20-16 15-10-2-18-8-24-15-2-3-5-3-8 0-7 5-10 10-13 16-2 4-3 7-5 12 0 1 0 3 0 4z m144-273c-17-3-32-8-45-21-6-6-9-14-9-24 0-10 8-16 17-13 8 2 15 7 20 13 6 10 9 19 12 30 4 4 4 10 5 15z"/>
33
- <glyph glyph-name="whatsapp" unicode="&#121;" d="M400 402c-38 38-90 59-144 59-112 0-203-91-203-203 0-36 9-71 27-101l-29-106 109 29c29-16 62-24 98-24 112 0 203 91 203 203-2 53-23 104-61 143z m-142-312c-31 0-60 8-87 24l-6 3-64-16 17 62-4 7c-18 27-26 57-26 89 0 93 75 168 168 168 45 0 88-17 118-49 32-32 50-74 50-119 2-94-74-169-166-169z m91 126c-5 3-31 14-35 16-5 2-8 3-12-3-3-5-12-16-16-19-3-4-6-4-11-2-5 3-21 8-40 26-14 12-25 30-29 35-3 5 0 8 2 9 2 2 5 7 8 10 3 3 3 5 5 8 1 3 1 6 0 10-2 3-11 27-16 36-3 8-8 8-11 8-4 0-7 0-10 0-3 0-10-1-13-6-5-5-17-18-17-42 0-25 17-49 20-52 4-4 36-56 87-77 43-18 51-13 61-13 9 2 30 13 33 24 5 11 5 22 3 24 0 3-4 5-9 8z"/>
34
- <glyph glyph-name="buffer" unicode="&#122;" d="M72 357l170-80c9-5 20-5 28 0l170 80c3 1 3 6 0 8l-168 80c-10 5-22 5-32 0l-170-80c-1-3-1-7 2-8z m368-98l-35 16c-7 3-15 3-23 0l-112-53c-9-4-20-4-28 0l-112 53c-7 3-15 3-21 0l-37-17c-3-2-3-7 0-8l170-80c9-5 20-5 28 0l170 80c3 3 3 8 0 9z m0-102l-35 16c-7 3-15 3-23 0l-112-53c-9-5-20-5-28 0l-112 53c-7 3-15 3-21 0l-37-18c-3-1-3-6 0-8l170-80c9-5 20-5 28 0l170 80c3 2 3 8 0 10z"/>
35
- <glyph glyph-name="print" unicode="&#65;" d="M378 326l0 106-244 0 0-106-44 0 0-180 40 0 0-66 252 0 0 66 40 0 0 180z m-26-216l-192 0 0 36 192 0z m5 133l-202 0 0 168 202 0z m25-77c-3 0-4 0-8 2-1 0-3 2-3 2-1 0-1 1-3 1-2 2-2 2-3 3 0 0 0 2-2 2-1 2-1 3-3 5 0 1-2 5-2 6 0 13 10 23 23 23 13 0 22-10 22-23 0-13-8-21-21-21z m-44 204l-164 0 0-21 164 0z m0-37l-164 0 0-21 164 0z m0-39l-164 0 0-20 164 0z"/>
36
- <glyph glyph-name="meerkat" unicode="&#100;" d="M205 384c-11 10-24 13-39 8-9-2-17-8-24-14-9-10-14-21-14-34 0-3 0-5 0-8 2-5 3-10 5-14 3-8 8-13 14-18 3-3 7-5 10-6 1-2 5-2 6 0 3 1 3 6 0 8-3 1-6 4-8 8-3 3-5 6-8 11-1 3-3 9-3 16 0 3 0 5 2 8 0 3 1 8 4 11 5 5 10 11 16 14 4 2 7 4 10 4 5 1 11 0 16-4 8-3 14-8 19-16 2-3 3-4 7-8 0 0 0-1 0-1 0-2 1-3 3-5 1-2 3 0 5 2 1 1 1 3 1 4 0 4-1 7-1 10-7 10-13 18-21 24z m219-26c-8 5-16 8-24 10-6 2-14 3-19 6-5 4-10 7-15 10-8 6-16 14-24 22-11 12-24 23-36 34-15 13-32 19-52 22-16 2-30 0-46-3-21-5-40-11-58-19-16-5-28-11-41-21-23-17-35-41-35-70 0-11 1-24 4-35 4-18 8-36 10-55 3-22 3-43 3-65 0-21 0-40-1-61 0-18-2-37-4-55 0-11-1-20-3-32l226 0c-2 4-3 7-5 10-10 19-19 40-29 59-6 13-11 27-13 42-1 11-1 22-1 32 0 14 1 29 5 43 1 6 4 10 9 10 5 0 10 1 15 1 11 2 22 2 33 2 24 1 48 9 69 24 6 5 13 9 19 14 5 3 10 8 13 13 6 11 10 22 10 35 4 13 0 23-10 27z m-24-52c-10-7-19-13-30-18-2 0-2 0-4 0-16 5-30 11-44 21-2 0-4 1-5 1-2 0-3-1-3-3 0-1 0-5 1-5 3-3 8-4 11-8 8-3 16-8 24-11 0 0 2 0 2 0-6-1-13-3-19-5-10-1-21-1-31-3-11-1-22-1-32-5-12-3-20-11-24-24-3-11-4-22-6-35 0-16 0-33 2-49 1-18 6-34 12-52 7-14 13-28 21-43l-163 0c0 2 0 2 0 3 2 26 3 53 5 79 0 13 0 25 1 37 0 19 0 38-1 56-2 16-3 32-7 48-1 12-4 24-6 36-3 10-5 20-5 29 0 18 8 32 21 43 10 8 22 15 34 20 16 8 33 14 51 19 11 3 21 5 32 5 19 0 37-7 53-20 14-11 27-24 41-38 11-11 23-21 35-29 5-3 12-6 18-8 0 0 2-1 2-1 4-13 11-26 17-37 0-2-1-2-3-3z m-94 80c-12 0-21-10-21-21 0-2 0-5 0-8-3 0-7 1-10 1-1 0-5 0-5-1 0-2 0-5 2-5 2-2 5-2 6-3 8-3 18-5 26-5 11 0 21 10 21 21 1 11-8 21-19 21z"/>
37
- <glyph glyph-name="pocket" unicode="&#66;" d="M462 418c-4 14-19 25-35 25l-342 0c-16 0-31-9-35-24-2-5-4-9-4-14l0-127 2-25c6-58 35-107 82-141 1 0 1-2 3-2 24-17 53-30 81-36 15-4 28-5 42-5 13 0 26 1 38 3 2 0 4 0 5 2 0 0 2 0 2 0 29 6 54 17 78 35 2 0 2 1 3 1 47 36 76 85 82 141l2 26 0 128c0 5-2 8-4 13z m-88-132l-97-94c-5-5-13-8-19-8-7 0-15 3-20 8l-97 94c-11 12-11 29-2 40 11 12 29 12 40 2l79-75 78 75c11 11 29 11 40-2 10-11 10-28-2-40z"/>
38
- <glyph glyph-name="flipboard" unicode="&#67;" d="M69 443l0-374 125 0 0 125 124 0 0 124 125 0 0 125z"/>
39
- <glyph glyph-name="hacker-news" unicode="&#68;" d="M96 464l61 0 78-160c11-24 21-46 21-46 0 0 10 22 22 46l80 160 58 0-136-254 0-162-51 0 0 165z"/>
40
- <glyph glyph-name="upgrade" unicode="&#69;" d="M376 298l0 40c0 62-46 118-109 123-64 5-118-40-128-99 5 0 45 0 48 0 10 35 47 60 87 49 32-8 52-38 52-72l0-40c0-1 0-1 0-1l-190 0c-26-2-45-23-45-48l0-152c0-28 23-48 48-48l231 0c27 0 48 22 48 48l0 152c1 25-18 46-42 48z m-35-159c-7-6-18-6-26 0l-59 59-61-60c-3-4-8-5-13-5-4 0-9 1-12 5-7 6-7 17 0 25l73 74c7 6 18 6 26 0l72-72c8-8 8-19 0-26z"/>
41
- <glyph glyph-name="pin" unicode="&#70;" d="M366 222c-1 39-20 71-49 90l0 112c24 18 37 40 37 40l-196 0c0 0 13-24 39-42l0-110c-31-19-50-53-50-90l90 0 0-112c0-11 9-62 21-62 11 0 20 51 20 62l0 112z"/>
42
- </font></defs></svg>
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>Generated by Fontastic.me</metadata>
5
+ <defs>
6
+ <font id="social-warfare-icons" horiz-adv-x="512">
7
+ <font-face font-family="social-warfare-icons" units-per-em="512" ascent="480" descent="-32"/>
8
+ <missing-glyph horiz-adv-x="512" />
9
+
10
+ <glyph glyph-name="reddit" unicode="&#97;" d="M448 338c-19 0-38-10-51-26l-3-3c-31 21-72 33-117 37l21 64 56-13c3-27 25-48 54-48 30 0 54 24 54 54 0 31-24 55-54 55-21 0-38-12-48-29l-69 16c-8 1-16-3-19-11l-27-87c-50-1-95-16-128-37l-3 5c-13 15-31 24-50 24-35 0-64-29-64-64 0-27 18-51 43-61l11-4 0 3c0 0 0-2 0-2 0-75 90-136 202-136 110 0 200 61 202 136l11 3c27 8 45 34 45 61-2 34-31 63-66 63z m-40 86c11 0 19-10 19-19 0-11-9-21-19-21-11 0-19 10-19 21 0 9 8 19 19 19z m-355-178c-11 5-18 16-18 28 0 17 13 30 29 30 8 0 16-3 22-10l4-4c-15-13-24-29-31-45z m201-139c-92 0-168 47-168 104 0 58 76 104 168 104 93 0 168-46 168-104 0-57-75-104-168-104z m204 139l-8-3c-7 16-16 32-29 45l5 6c6 7 14 10 22 10 16 0 30-13 30-30-1-12-9-23-20-28z m-237-4c0 16-13 30-31 30-17 0-30-14-30-30 0-16 14-31 30-31 16 0 31 15 31 31z m101 30c-16 0-31-14-31-30 0-16 15-31 31-31 16 0 30 13 30 31-2 17-14 30-30 30z m-2-93c-5 0-8-1-11-5-10-9-27-14-53-14-26 0-42 5-53 14-6 7-17 7-22 0-3-3-5-6-5-11 0-5 2-8 5-11 16-16 40-24 75-24 34 0 59 8 75 24 3 3 5 6 5 11 0 5-2 8-5 11-3 4-6 5-11 5z"/>
11
+ <glyph glyph-name="pinterest" unicode="&#98;" d="M256 450c-107 0-194-87-194-194 0-78 48-147 116-178 0 13 0 31 3 45 3 16 25 106 25 106 0 0-6 13-6 30 0 29 16 50 37 50 17 0 25-13 25-29 0-18-11-45-17-69-5-21 9-37 30-37 37 0 61 47 61 103 0 41-29 73-80 73-59 0-94-43-94-92 0-18 4-29 12-39 4-5 5-6 4-11-2-3-4-13-4-16-1-5-4-6-9-5-27 11-40 40-40 74 0 54 46 120 137 120 74 0 122-53 122-111 0-75-42-132-104-132-21 0-40 11-46 24 0 0-12-45-15-53-5-15-13-31-19-42 18-5 35-8 54-8 108 0 194 87 194 194 2 110-85 197-192 197z"/>
12
+ <glyph glyph-name="periscope" unicode="&#99;" d="M258 464c-93 0-167-77-167-171 0-98 130-245 167-245 32 0 161 147 161 245 2 94-72 171-161 171z m1-261c-57 0-102 45-102 96 0 24 8 47 21 63 0-21 17-39 40-39 22 0 38 18 38 39 0 16-10 28-24 35 8 1 18 3 26 3 52 0 97-45 97-102 0-50-45-95-96-95z"/>
13
+ <glyph glyph-name="medium" unicode="&#101;" d="M493 389l-19 0c-7 0-16-10-16-16l0-232c0-7 9-15 16-15l19 0 0-54-170 0 0 54 35 0 0 242-1 0-83-299-64 0-82 299-2 0 0-245 36 0 0-54-143 0 0 54 18 0c8 0 17 8 17 15l0 233c0 7-9 16-17 16l-18 0 0 56 178 0 57-217 2 0 59 217 178 0z"/>
14
+ <glyph glyph-name="linkedin" unicode="&#102;" d="M115 443c-25 0-46-21-46-46 0-26 21-47 46-47 26 2 45 23 45 47 0 25-19 46-45 46z m-40-374l79 0 0 249-79 0z m282 257c0 0-63 5-77-41l0 33-78 0 0-249 78 0 0 133c0 4 2 54 48 54 43 0 40-58 40-58l0-128 77 0 0 144c-2-1 8 112-88 112z"/>
15
+ <glyph glyph-name="instagram" unicode="&#103;" d="M400 285l-32 0c2-10 3-19 3-29 0-64-51-115-115-115-64 0-115 51-115 115 0 10 1 19 3 29l-32 0 0-159c0-8 6-14 14-14l260 0c8 0 14 6 14 14z m0 101c0 8-6 14-14 14l-44 0c-8 0-14-6-14-14l0-44c0-8 6-14 14-14l44 0c8 0 14 6 14 14z m-144-58c-40 0-72-32-72-72 0-40 32-72 72-72 40 0 72 32 72 72 0 40-32 72-72 72m144-259l-288 0c-24 0-43 19-43 43l0 288c0 24 19 43 43 43l288 0c24 0 43-19 43-43l0-288c0-24-19-43-43-43"/>
16
+ <glyph glyph-name="google-plus" unicode="&#104;" d="M168 280l0-58 96 0c-5-24-29-72-96-72-58 0-102 48-102 106 0 58 44 106 102 106 34 0 54-15 67-26l45 43c-29 29-67 45-112 45-94 0-168-75-168-168 0-93 74-168 168-168 96 0 160 67 160 163 0 11 0 19-2 29z m344 0l-48 0 0 48-48 0 0-48-48 0 0-48 48 0 0-48 48 0 0 48 48 0"/>
17
+ <glyph glyph-name="flickr" unicode="&#105;" d="M510 256c0-66-52-118-118-118-66 0-118 52-118 118 0 66 52 118 118 118 66 0 118-52 118-118z m-270 0c0-66-53-118-118-118-66 0-120 52-120 118 0 66 52 118 118 118 66 0 120-52 120-118z"/>
18
+ <glyph glyph-name="facebook" unicode="&#106;" d="M288 48l0 190 64 0 10 74-74 0 0 48c0 21 6 37 37 37l40 0 0 64c-8 1-31 3-58 3-56 0-96-35-96-98l0-54-64 0 0-74 64 0 0-190z"/>
19
+ <glyph glyph-name="email" unicode="&#107;" d="M166 277l-152 120 0-275z m330 147l-480 0 240-184z m-173-162l-67-51-67 51-175-174 482 0z m21 13l154-153 0 273z"/>
20
+ <glyph glyph-name="ello" unicode="&#108;" d="M256 454c-109 0-198-89-198-198 0-109 89-198 198-198 109 0 198 89 198 198 0 109-89 198-198 198z m-3-321c-82 0-114 67-119 102-1 8 5 16 13 18 8 1 16-5 18-13 0-3 13-75 88-75 75 0 91 73 93 77 1 8 9 14 17 12 8-1 15-9 13-17-6-39-42-104-123-104z"/>
21
+ <glyph glyph-name="blogger" unicode="&#109;" d="M442 288l-4 6-4 5c-7 5-42 0-52 8-6 7-8 18-9 32-5 29-7 31-11 40-16 35-61 61-92 64l-83 0c-65 0-118-53-118-118l0-138c0-65 53-118 118-118l136 0c66 0 119 53 119 118z m-253 59l65 0c13 0 23-9 23-22 0-13-10-23-23-23l-65 0c-13 0-23 10-23 23 0 11 10 22 23 22z m134-181l-133 0c-12 0-22 10-22 23 0 13 10 22 22 22l133 0c13 0 23-9 23-22 0-13-12-23-23-23z"/>
22
+ <glyph glyph-name="rss" unicode="&#110;" d="M166 114c0-29-24-53-52-53-29 0-53 24-53 53 0 28 24 52 53 52 30 0 52-22 52-52z m-104 204l0-78c98-2 178-80 178-178l78 0c-1 141-115 255-256 256z m0 55c84 0 160-32 220-91 59-60 91-136 91-220l78 0c0 215-174 388-387 389l0-78z"/>
23
+ <glyph glyph-name="share" unicode="&#111;" d="M382 170c-16 0-30-7-41-16l-149 86c2 5 2 10 2 14 0 5 0 10-2 15l147 86c11-11 26-17 43-17 36 0 63 28 63 62 0 34-29 64-63 64-33 0-62-29-62-62 0-5 0-10 2-15l-148-86c-11 11-25 17-43 17-35 0-62-28-62-62 0-34 27-64 61-64 16 0 32 6 43 18l149-87c-2-5-2-9-2-14 0-34 27-61 61-61 33 0 61 27 61 61 0 33-26 61-60 61z"/>
24
+ <glyph glyph-name="social-warfare" unicode="&#112;" d="M138 354c3 12 28 67 88 100-96-14-170-97-170-196 0-26 5-52 14-74 4 3 8 5 13 5l74 14c13 3 17-3 14-16-8-29 8-46 37-46 29 0 58 17 59 33 7 53-179 42-129 180z m297-8c-5-5-9-10-17-12l-76-14c-12-3-17 3-14 14 5 24-10 40-38 40-24 0-44-14-45-27-8-46 182-46 134-184-5-13-37-73-109-105 104 6 188 92 188 198-2 32-10 62-23 90z"/>
25
+ <glyph glyph-name="stumble-upon" unicode="&#113;" d="M282 302l33-16 50 15 0 35c-2 59-50 106-109 106-59 0-107-47-109-106l0-158c0-15-11-26-25-26-15 0-26 11-26 26l0 67-85 0c0 0 0-67 0-69 0-61 50-110 111-110 60 0 108 48 108 108l0 157c0 15 12 26 26 26 14 0 26-11 26-26z m136-56l0-70c0-14-12-26-26-26-14 0-26 12-26 26l0 69-49-15-34 16 0-68c0-61 50-109 111-109 60 0 110 49 110 110 0 0 0 69 0 69l-86 0z"/>
26
+ <glyph glyph-name="tumblr" unicode="&#114;" d="M355 133c-65-29-73 24-73 24l0 131 78 0 0 70-78 0 0 106-64 0c0 0-8-94-82-115l0-61 46 0 0-136c0-67 56-104 116-104 59 0 78 26 78 26z"/>
27
+ <glyph glyph-name="twitter" unicode="&#115;" d="M491 402c-17-8-35-13-56-15 19 11 35 31 43 53-19-11-40-19-60-24-18 19-44 30-71 30-62 0-109-57-94-118-80 5-152 43-199 101-25-43-12-101 31-130-16 0-31 5-43 13-2-45 30-86 76-96-12-3-28-5-43-2 13-38 48-65 90-67-40-32-91-46-143-40 44-27 93-43 148-43 179 0 280 152 273 286 19 15 35 32 48 52z"/>
28
+ <glyph glyph-name="vimeo" unicode="&#116;" d="M11 354l19-26c0 0 42 32 55 16 14-16 65-211 83-248 16-32 58-74 104-43 46 30 198 160 227 315 27 154-184 122-206-13 56 34 86-14 57-67-28-53-54-88-68-88-15 0-24 35-40 98-16 64-16 180-84 168-64-13-147-112-147-112z"/>
29
+ <glyph glyph-name="vine" unicode="&#117;" d="M438 258c-11-4-20-4-30-4-53 0-93 37-93 101 0 32 13 48 29 48 16 0 27-14 27-45 0-17-5-35-8-46 0 0 16-29 61-19 10 21 14 48 14 72 0 64-32 101-92 101-61 0-98-48-98-109 0-63 29-115 77-139-21-40-45-76-72-103-48 58-91 136-109 288l-70 0c33-253 131-333 156-349 15-8 28-8 40-1 21 11 85 75 119 149 14 0 32 1 49 6z"/>
30
+ <glyph glyph-name="warfare-plugins" unicode="&#118;" d="M424 365l-32-163c-2-7 3-7 6 0l52 104c-4 20-13 41-26 59z m-155 86l-55-249c-1-7 4-7 7 0l120 233c-23 10-47 16-74 18 2 0 2 0 2-2z m38-240l-85-147c0 0-1-2-1-2 13-1 25-3 38-3 13 0 24 2 37 3 0 0 0 2 0 2l19 147c0 5-5 5-8 0z m-246 45c0-50 17-94 48-130l48 300c-58-34-96-98-96-170z"/>
31
+ <glyph glyph-name="youtube" unicode="&#119;" d="M365 437l-218 0c-123 0-142-7-142-127l0-108c0-120 19-127 142-127l216 0c123 0 143 7 143 127l0 108c1 120-18 127-141 127z m-160-271l0 188 142-95z"/>
32
+ <glyph glyph-name="yummly" unicode="&#120;" d="M91 430c2 7 8 12 13 15 19 13 42 21 64 19 19-2 34-11 37-34 3-14 0-28-3-43-8-30-16-61-24-91-2-6-2-11-2-18 0-8 5-12 13-12 9-2 17 0 25 3 15 3 28 9 40 16 2 1 4 3 4 5 3 19 6 36 9 56 3 19 7 36 10 56 1 12 5 24 6 36 0 4 0 8-1 13-2 5 0 7 3 8 9 5 21 7 32 3 9-1 14-8 14-17 0-10-1-19-3-31-3-20-6-40-11-60-3-21-8-44-11-64-4-21-8-44-12-64-1-8-3-18-4-26 0-2 0-3 1-3 35-5 71-15 103-29 4-3 11-3 17-5 5-1 7-3 7-6 0-8-2-15-7-23-8-11-21-16-35-11-10 3-18 8-26 13-19 11-38 18-60 21-2 0-5 0-7 0-1 0-3 0-3-3-3-20-10-37-18-53-6-13-16-26-27-35-11-10-24-15-38-16-3 0-7-2-10-2-3 0-6 0-9 0-2 0-4 0-4 0-14 2-28 8-38 19-11 15-13 31-10 47 5 27 21 48 45 62 21 11 43 18 66 21 1 0 3 0 3 3 2 5 2 10 3 14 2 7 2 12 3 18-3-2-4-3-6-3-26-15-53-21-83-18-15 2-26 8-32 21-7 13-8 26-5 38 6 28 14 56 22 84 8 16 12 30 15 44 1 12-2 20-16 15-10-2-18-8-24-15-2-3-5-3-8 0-7 5-10 10-13 16-2 4-3 7-5 12 0 1 0 3 0 4z m144-273c-17-3-32-8-45-21-6-6-9-14-9-24 0-10 8-16 17-13 8 2 15 7 20 13 6 10 9 19 12 30 4 4 4 10 5 15z"/>
33
+ <glyph glyph-name="whatsapp" unicode="&#121;" d="M400 402c-38 38-90 59-144 59-112 0-203-91-203-203 0-36 9-71 27-101l-29-106 109 29c29-16 62-24 98-24 112 0 203 91 203 203-2 53-23 104-61 143z m-142-312c-31 0-60 8-87 24l-6 3-64-16 17 62-4 7c-18 27-26 57-26 89 0 93 75 168 168 168 45 0 88-17 118-49 32-32 50-74 50-119 2-94-74-169-166-169z m91 126c-5 3-31 14-35 16-5 2-8 3-12-3-3-5-12-16-16-19-3-4-6-4-11-2-5 3-21 8-40 26-14 12-25 30-29 35-3 5 0 8 2 9 2 2 5 7 8 10 3 3 3 5 5 8 1 3 1 6 0 10-2 3-11 27-16 36-3 8-8 8-11 8-4 0-7 0-10 0-3 0-10-1-13-6-5-5-17-18-17-42 0-25 17-49 20-52 4-4 36-56 87-77 43-18 51-13 61-13 9 2 30 13 33 24 5 11 5 22 3 24 0 3-4 5-9 8z"/>
34
+ <glyph glyph-name="buffer" unicode="&#122;" d="M72 357l170-80c9-5 20-5 28 0l170 80c3 1 3 6 0 8l-168 80c-10 5-22 5-32 0l-170-80c-1-3-1-7 2-8z m368-98l-35 16c-7 3-15 3-23 0l-112-53c-9-4-20-4-28 0l-112 53c-7 3-15 3-21 0l-37-17c-3-2-3-7 0-8l170-80c9-5 20-5 28 0l170 80c3 3 3 8 0 9z m0-102l-35 16c-7 3-15 3-23 0l-112-53c-9-5-20-5-28 0l-112 53c-7 3-15 3-21 0l-37-18c-3-1-3-6 0-8l170-80c9-5 20-5 28 0l170 80c3 2 3 8 0 10z"/>
35
+ <glyph glyph-name="print" unicode="&#65;" d="M378 326l0 106-244 0 0-106-44 0 0-180 40 0 0-66 252 0 0 66 40 0 0 180z m-26-216l-192 0 0 36 192 0z m5 133l-202 0 0 168 202 0z m25-77c-3 0-4 0-8 2-1 0-3 2-3 2-1 0-1 1-3 1-2 2-2 2-3 3 0 0 0 2-2 2-1 2-1 3-3 5 0 1-2 5-2 6 0 13 10 23 23 23 13 0 22-10 22-23 0-13-8-21-21-21z m-44 204l-164 0 0-21 164 0z m0-37l-164 0 0-21 164 0z m0-39l-164 0 0-20 164 0z"/>
36
+ <glyph glyph-name="meerkat" unicode="&#100;" d="M205 384c-11 10-24 13-39 8-9-2-17-8-24-14-9-10-14-21-14-34 0-3 0-5 0-8 2-5 3-10 5-14 3-8 8-13 14-18 3-3 7-5 10-6 1-2 5-2 6 0 3 1 3 6 0 8-3 1-6 4-8 8-3 3-5 6-8 11-1 3-3 9-3 16 0 3 0 5 2 8 0 3 1 8 4 11 5 5 10 11 16 14 4 2 7 4 10 4 5 1 11 0 16-4 8-3 14-8 19-16 2-3 3-4 7-8 0 0 0-1 0-1 0-2 1-3 3-5 1-2 3 0 5 2 1 1 1 3 1 4 0 4-1 7-1 10-7 10-13 18-21 24z m219-26c-8 5-16 8-24 10-6 2-14 3-19 6-5 4-10 7-15 10-8 6-16 14-24 22-11 12-24 23-36 34-15 13-32 19-52 22-16 2-30 0-46-3-21-5-40-11-58-19-16-5-28-11-41-21-23-17-35-41-35-70 0-11 1-24 4-35 4-18 8-36 10-55 3-22 3-43 3-65 0-21 0-40-1-61 0-18-2-37-4-55 0-11-1-20-3-32l226 0c-2 4-3 7-5 10-10 19-19 40-29 59-6 13-11 27-13 42-1 11-1 22-1 32 0 14 1 29 5 43 1 6 4 10 9 10 5 0 10 1 15 1 11 2 22 2 33 2 24 1 48 9 69 24 6 5 13 9 19 14 5 3 10 8 13 13 6 11 10 22 10 35 4 13 0 23-10 27z m-24-52c-10-7-19-13-30-18-2 0-2 0-4 0-16 5-30 11-44 21-2 0-4 1-5 1-2 0-3-1-3-3 0-1 0-5 1-5 3-3 8-4 11-8 8-3 16-8 24-11 0 0 2 0 2 0-6-1-13-3-19-5-10-1-21-1-31-3-11-1-22-1-32-5-12-3-20-11-24-24-3-11-4-22-6-35 0-16 0-33 2-49 1-18 6-34 12-52 7-14 13-28 21-43l-163 0c0 2 0 2 0 3 2 26 3 53 5 79 0 13 0 25 1 37 0 19 0 38-1 56-2 16-3 32-7 48-1 12-4 24-6 36-3 10-5 20-5 29 0 18 8 32 21 43 10 8 22 15 34 20 16 8 33 14 51 19 11 3 21 5 32 5 19 0 37-7 53-20 14-11 27-24 41-38 11-11 23-21 35-29 5-3 12-6 18-8 0 0 2-1 2-1 4-13 11-26 17-37 0-2-1-2-3-3z m-94 80c-12 0-21-10-21-21 0-2 0-5 0-8-3 0-7 1-10 1-1 0-5 0-5-1 0-2 0-5 2-5 2-2 5-2 6-3 8-3 18-5 26-5 11 0 21 10 21 21 1 11-8 21-19 21z"/>
37
+ <glyph glyph-name="pocket" unicode="&#66;" d="M462 418c-4 14-19 25-35 25l-342 0c-16 0-31-9-35-24-2-5-4-9-4-14l0-127 2-25c6-58 35-107 82-141 1 0 1-2 3-2 24-17 53-30 81-36 15-4 28-5 42-5 13 0 26 1 38 3 2 0 4 0 5 2 0 0 2 0 2 0 29 6 54 17 78 35 2 0 2 1 3 1 47 36 76 85 82 141l2 26 0 128c0 5-2 8-4 13z m-88-132l-97-94c-5-5-13-8-19-8-7 0-15 3-20 8l-97 94c-11 12-11 29-2 40 11 12 29 12 40 2l79-75 78 75c11 11 29 11 40-2 10-11 10-28-2-40z"/>
38
+ <glyph glyph-name="flipboard" unicode="&#67;" d="M69 443l0-374 125 0 0 125 124 0 0 124 125 0 0 125z"/>
39
+ <glyph glyph-name="hacker-news" unicode="&#68;" d="M96 464l61 0 78-160c11-24 21-46 21-46 0 0 10 22 22 46l80 160 58 0-136-254 0-162-51 0 0 165z"/>
40
+ <glyph glyph-name="upgrade" unicode="&#69;" d="M376 298l0 40c0 62-46 118-109 123-64 5-118-40-128-99 5 0 45 0 48 0 10 35 47 60 87 49 32-8 52-38 52-72l0-40c0-1 0-1 0-1l-190 0c-26-2-45-23-45-48l0-152c0-28 23-48 48-48l231 0c27 0 48 22 48 48l0 152c1 25-18 46-42 48z m-35-159c-7-6-18-6-26 0l-59 59-61-60c-3-4-8-5-13-5-4 0-9 1-12 5-7 6-7 17 0 25l73 74c7 6 18 6 26 0l72-72c8-8 8-19 0-26z"/>
41
+ <glyph glyph-name="pin" unicode="&#70;" d="M366 222c-1 39-20 71-49 90l0 112c24 18 37 40 37 40l-196 0c0 0 13-24 39-42l0-110c-31-19-50-53-50-90l90 0 0-112c0-11 9-62 21-62 11 0 20 51 20 62l0 112z"/>
42
+ </font></defs></svg>
functions/Social_Warfare.php CHANGED
@@ -1,501 +1,501 @@
1
- <?php
2
-
3
- /**
4
- * A class of functions used to load the plugin files and functions
5
- *
6
- * This is the class that brings the entire plugin to life. It is used to
7
- * instatiate all other classes throughout the plugin.
8
- *
9
- * This class also serves as a table of contents for all of the plugin's
10
- * functionality. By browsing below, you will see a brief description of each
11
- * class that is being instantiated.
12
- *
13
- * @package SocialWarfare\Utilities
14
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
15
- * @license GPL-3.0+
16
- * @since 3.0.0 | 19 FEB 2018 | Created
17
- * @since 3.1.0 | 20 JUN 2018 | Added instantiate_frontend_classes()
18
- *
19
- */
20
- class Social_Warfare {
21
-
22
-
23
- /**
24
- * The magic method used to instantiate this class.
25
- *
26
- * This method will load all of the classes using the "require_once" command.
27
- * It will then instantiate them all one by one.
28
- *
29
- * @since 3.0.0 | 19 FEB 2018 | Created
30
- * @since 3.1.0 | 20 JUN 2018 | Added instantiate_frontend_classes()
31
- * @param void
32
- * @return void
33
- * @access public
34
- *
35
- */
36
- public function __construct() {
37
-
38
- // Block these classes from being loaded again if a child class attempts
39
- // to run the parent::__construct() method.
40
- if ( get_class($this) === 'Social_Warfare' ) {
41
-
42
- // Loads the files for each class.
43
- $this->load_classes();
44
-
45
- // Instantiate all the core classes
46
- $this->instantiate_classes();
47
-
48
- // Instantiate the admin-only classes.
49
- if( true === is_admin() ) {
50
- $this->instantiate_admin_classes();
51
- }
52
-
53
- // Instantiate the frontend-only classes.
54
- if( false === is_admin() ) {
55
- $this->instantiate_frontend_classes();
56
- }
57
-
58
- }
59
-
60
- $this->core_version = SWP_VERSION;
61
- }
62
-
63
-
64
- /**
65
- * The method used to instantiate all classes used on both frontend and admin.
66
- *
67
- * This method will instantiate every class throughout the plugin except for
68
- * those classes that are used in both the frontend and the admin area.
69
- *
70
- * @since 3.0.0
71
- * @param void
72
- * @return void
73
- * @access public
74
- *
75
- */
76
- private function instantiate_classes() {
77
- global $SWP_Options_Page;
78
-
79
-
80
- /**
81
- * The Social Networks Loader
82
- *
83
- * Instantiates the class that will load the social networks.
84
- *
85
- */
86
- new SWP_Social_Networks_Loader();
87
-
88
-
89
- /**
90
- * The Localization Class
91
- *
92
- * Instantiates the class that will load the plugin translations.
93
- *
94
- */
95
- $Localization = new SWP_Localization();
96
- $Localization->init();
97
-
98
-
99
- /**
100
- * The URL_Management Class
101
- *
102
- * This is the class that controls short links and UTM parameters.
103
- *
104
- */
105
- new SWP_URL_Management();
106
-
107
-
108
- /**
109
- * The Script Class
110
- *
111
- * Instantiates the class that will enqueue all of the styles and
112
- * scripts used throughout the plugin both frontend, and admin.
113
- *
114
- */
115
- new SWP_Script();
116
-
117
-
118
- /**
119
- * The Shortcode Class
120
- *
121
- * Instantiate the class that will process all instances of the
122
- * [social_warfare] shortcode used in posts and pages, and consequently
123
- * convert those shortcodes into sets of share buttons.
124
- *
125
- */
126
- new SWP_Shortcode();
127
-
128
-
129
- /**
130
- * The Header Output Class
131
- *
132
- * Instantiate the class that processes the values and creates the HTML
133
- * output required in the <head> section of a website. This includes our
134
- * font css, open graph meta tags, and Twitter cards.
135
- *
136
- */
137
- new SWP_Header_Output();
138
-
139
-
140
- /**
141
- * The Display Class
142
- *
143
- * Instantiates the class that is used to queue up or hook the buttons
144
- * generator into WordPress' the_content() hook which allows us to
145
- * append our buttons to it.
146
- *
147
- */
148
- new SWP_Display();
149
-
150
-
151
- /**
152
- * The Compatibility Class
153
- *
154
- * Instantiate the class that provides solutions to very specific
155
- * incompatibilities with certain other plugins.
156
- *
157
- */
158
- new SWP_Compatibility();
159
-
160
-
161
- /**
162
- * The Widget Class
163
- *
164
- * Instantiate the class that registers and output the "Popular Posts"
165
- * widget. If other widgets are added later, this class will fire those
166
- * up as well.
167
- *
168
- */
169
- new SWP_Widget();
170
-
171
-
172
- /**
173
- * Database Migration
174
- *
175
- * Converts camelCased variable names to the new snake_case option names.
176
- *
177
- */
178
- new SWP_Database_Migration();
179
-
180
-
181
- /**
182
- * The Options Page Class
183
- *
184
- * Instantiates the class that will load the plugin options page.
185
- *
186
- */
187
- $SWP_Options_Page = new SWP_Options_Page();
188
-
189
-
190
- /**
191
- * The Post Cache Loader Class
192
- *
193
- * Instantiates a global object that will manage and load cached data
194
- * for each individual post on a site allowing access to cached data like
195
- * share counts, for example.
196
- *
197
- */
198
- global $SWP_Post_Caches;
199
- $SWP_Post_Caches = new SWP_Post_Cache_Loader();
200
-
201
- }
202
-
203
-
204
- /**
205
- * This method will load up all of the frontend-only classes.
206
- *
207
- * @since 3.1.0 | 20 JUNE 2018 | Created
208
- * @param void
209
- * @return void
210
- * @access private
211
- */
212
- private function instantiate_frontend_classes() {
213
-
214
-
215
- }
216
-
217
- /**
218
- * This method will load up all of the admin-only classes.
219
- *
220
- * @since 3.0.0
221
- * @param void
222
- * @return void
223
- * @access public
224
- *
225
- */
226
- private function instantiate_admin_classes() {
227
-
228
-
229
- /**
230
- * The Shortcode Generator
231
- *
232
- * Instantiate the class that creates the shortcode generator on the
233
- * post editor which allows users to generate the [social_warfare]
234
- * shortcodes by simply pointing clicking, and filling in a few fill in
235
- * the blanks.
236
- *
237
- */
238
- new SWP_Shortcode_Generator();
239
-
240
-
241
- /**
242
- * The Click to Tweet Class
243
- *
244
- * Instantiate the class that that creates the Click to Tweet button in
245
- * the WordPress post editor's dashboard (the kitchen sink) and also
246
- * process the shortcode on the front end.
247
- *
248
- */
249
- new SWP_Click_To_Tweet();
250
-
251
-
252
- /**
253
- * The "Social Shares" column in the posts view.
254
- *
255
- * Instantiate the class that creates the column in the posts view of
256
- * the WordPress admin area. This column allows you to see how many
257
- * times each post has been shared. It also allows you to sort the
258
- * column in ascending or descending order.
259
- *
260
- */
261
- new SWP_Column();
262
-
263
-
264
- /**
265
- * The The Settings Link
266
- *
267
- * Instantiates the class that addes links to the plugin listing on the
268
- * plugins page of the WordPress admin area. This will link to the
269
- * Social Warfare options page.
270
- *
271
- */
272
- new SWP_Settings_Link();
273
-
274
-
275
- /**
276
- * The User Profile Fields
277
- *
278
- * Instantiates the class that adds our custom fields to the user
279
- * profile area of the WordPress backend. This allows users to set a
280
- * Twitter username and Facebook author URL on a per-user basis. If set,
281
- * this will override these same settings from the options page on any
282
- * posts authored by that user.
283
- *
284
- */
285
- new SWP_User_Profile();
286
-
287
- new SWP_JSON_Cache_Handler();
288
-
289
-
290
- /**
291
- * Instantiates all of our notices.
292
- *
293
- */
294
- new SWP_Notice_Loader();
295
- }
296
-
297
-
298
- /**
299
- * The method is used to include all of the files needed.
300
- *
301
- * @since 3.0.0
302
- * @param none
303
- * @return none
304
- * @access public
305
- *
306
- */
307
- private function load_classes() {
308
-
309
- // Require WordPress' core plugin class.
310
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
311
-
312
-
313
- /**
314
- * Utility Classes
315
- *
316
- * This loads our Utility Trait and our various classes used to provide general
317
- * functionality that will be used by many different classes throughout the plugin.
318
- *
319
- */
320
- $utilities = array(
321
- 'Utility_Trait',
322
- 'Abstract',
323
- 'Compatibility',
324
- 'CURL',
325
- 'Localization',
326
- 'Permalink',
327
- 'Plugin_Updater',
328
- 'Database_Migration',
329
- 'URL_Management',
330
- 'Notice',
331
- 'Notice_Loader',
332
- 'Post_Cache_Loader',
333
- 'Post_Cache',
334
- 'JSON_Cache_Handler'
335
- );
336
- $this->load_files( '/functions/utilities/', $utilities);
337
-
338
-
339
- /**
340
- * The Social Network Classes
341
- *
342
- * This family of classes provides the framework and the model needed
343
- * for creating a unique object for each social network. It also
344
- * provides for maximum extensibility to allow addons even easier access
345
- * than ever before to create and add more social networks to the plugin.
346
- *
347
- */
348
- $social_networks = array(
349
- 'Social_Networks_Loader',
350
- 'Social_Network',
351
- 'Google_Plus',
352
- 'Facebook',
353
- 'Twitter',
354
- 'Linkedin',
355
- 'Pinterest',
356
- 'Stumble_Upon'
357
- );
358
- $this->load_files( '/functions/social-networks/', $social_networks);
359
-
360
-
361
- /**
362
- * The Addon Classes
363
- *
364
- * This family of classes provide for the management of addons. These
365
- * control the framework for registering addons, checking for updates
366
- * for the addons, and other addon specific tasks.
367
- *
368
- */
369
- $includes = array(
370
- 'Addon'
371
- );
372
- $this->load_files( '/functions/includes/', $includes);
373
-
374
-
375
- /**
376
- * The Frontend Output Classes
377
- *
378
- * This family of classes control everything that is output on the
379
- * WordPress frontend. This includes the HTML for the buttons panels,
380
- * the meta data that is output in the head section of the site, scripts
381
- * and styles being enqueued for output, and other things like that.
382
- *
383
- */
384
- $frontends = array(
385
- 'Buttons_Panel',
386
- 'Header_Output',
387
- 'Display',
388
- 'Script',
389
- 'Shortcode',
390
- );
391
- $this->load_files( '/functions/frontend-output/', $frontends );
392
-
393
-
394
- /**
395
- * The Widget Classes
396
- *
397
- * These are the classes that create the widgets available for output in
398
- * WordPress. Built in is the Popular Posts widget, but these also
399
- * provide the framework for extensibility so that more widgets can be
400
- * created later via addons.
401
- *
402
- */
403
- $widgets = array(
404
- 'Popular_Posts_Widget',
405
- 'Widget',
406
- );
407
- $this->load_files( '/functions/widgets/', $widgets );
408
-
409
-
410
- /**
411
- * The Admin Classes
412
- *
413
- * This family of classes power everything that you see in the WordPress
414
- * admin area of the site. This includes the Click To Tweet generator
415
- * and Social Warfare shortcode generator buttons that you see at the
416
- * top of the post editor. These include adding the share count column
417
- * to the posts view and a few other things related to the admin area.
418
- * This does NOT include the classes used to generate the options page
419
- * for Social Warfare.
420
- *
421
- */
422
- $admins = array(
423
- 'Click_To_Tweet',
424
- 'Column',
425
- 'Settings_Link',
426
- 'Shortcode_Generator',
427
- 'User_Profile',
428
- );
429
- $this->load_files( '/functions/admin/', $admins );
430
-
431
-
432
- /**
433
- * The Options Classes
434
- *
435
- * These classes provide the framework that creates the admin options
436
- * page as well as the tools needed for addons to be able to interface
437
- * with it to add their own options.
438
- *
439
- */
440
- $options = array(
441
- 'Option',
442
- 'Options_Page',
443
- 'Options_Page_Tab',
444
- 'Options_Page_Section',
445
- 'Option_Toggle',
446
- 'Option_Select',
447
- 'Option_Text',
448
- 'Option_Textarea',
449
- 'Section_HTML',
450
- 'Option_Icons',
451
- 'Addon_Registration',
452
- );
453
- $this->load_files( '/functions/options/', $options );
454
-
455
- }
456
-
457
-
458
- /**
459
- * Loads an array of related files.
460
- *
461
- * @param string $path The relative path to the files home.
462
- * @param array $files The name of the files (classes), no vendor prefix.
463
- * @return none The files are loaded into memory.
464
- *
465
- */
466
- private function load_files( $path, $files ) {
467
- foreach( $files as $file ) {
468
-
469
- //* Add our vendor prefix to the file name.
470
- $file = "SWP_" . $file;
471
- require_once SWP_PLUGIN_DIR . $path . $file . '.php';
472
- }
473
- }
474
- }
475
-
476
-
477
- /*******************************************************************************
478
- *
479
- *
480
- * WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
481
- *
482
- * EVERY FILE BELOW THIS POINT NEEDS TO BE REFACTORED. IT'S "REQUIRE_ONCE" THEN
483
- * NEEDS TO BE MIGRATED INTO THE CLASS ABOVE.
484
- *
485
- *
486
- * *****************************************************************************/
487
-
488
-
489
- // TODO: These files need refactored into classes and to the appropriate sections above.
490
- require_once SWP_PLUGIN_DIR . '/functions/admin/registration.php';
491
- require_once SWP_PLUGIN_DIR . '/functions/admin/options-fetch.php';
492
- require_once SWP_PLUGIN_DIR . '/functions/utilities/utility.php';
493
-
494
- /**
495
- * Include the plugin's admin files.
496
- *
497
- */
498
- if ( is_admin() ) {
499
- require_once SWP_PLUGIN_DIR . '/functions/admin/swp_system_checker.php';
500
- // require_once SWP_PLUGIN_DIR . '/functions/admin/options-page.php';
501
- }
1
+ <?php
2
+
3
+ /**
4
+ * A class of functions used to load the plugin files and functions
5
+ *
6
+ * This is the class that brings the entire plugin to life. It is used to
7
+ * instatiate all other classes throughout the plugin.
8
+ *
9
+ * This class also serves as a table of contents for all of the plugin's
10
+ * functionality. By browsing below, you will see a brief description of each
11
+ * class that is being instantiated.
12
+ *
13
+ * @package SocialWarfare\Utilities
14
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
15
+ * @license GPL-3.0+
16
+ * @since 3.0.0 | 19 FEB 2018 | Created
17
+ * @since 3.1.0 | 20 JUN 2018 | Added instantiate_frontend_classes()
18
+ *
19
+ */
20
+ class Social_Warfare {
21
+
22
+
23
+ /**
24
+ * The magic method used to instantiate this class.
25
+ *
26
+ * This method will load all of the classes using the "require_once" command.
27
+ * It will then instantiate them all one by one.
28
+ *
29
+ * @since 3.0.0 | 19 FEB 2018 | Created
30
+ * @since 3.1.0 | 20 JUN 2018 | Added instantiate_frontend_classes()
31
+ * @param void
32
+ * @return void
33
+ * @access public
34
+ *
35
+ */
36
+ public function __construct() {
37
+
38
+ // Block these classes from being loaded again if a child class attempts
39
+ // to run the parent::__construct() method.
40
+ if ( get_class($this) === 'Social_Warfare' ) {
41
+
42
+ // Loads the files for each class.
43
+ $this->load_classes();
44
+
45
+ // Instantiate all the core classes
46
+ $this->instantiate_classes();
47
+
48
+ // Instantiate the admin-only classes.
49
+ if( true === is_admin() ) {
50
+ $this->instantiate_admin_classes();
51
+ }
52
+
53
+ // Instantiate the frontend-only classes.
54
+ if( false === is_admin() ) {
55
+ $this->instantiate_frontend_classes();
56
+ }
57
+
58
+ }
59
+
60
+ $this->core_version = SWP_VERSION;
61
+ }
62
+
63
+
64
+ /**
65
+ * The method used to instantiate all classes used on both frontend and admin.
66
+ *
67
+ * This method will instantiate every class throughout the plugin except for
68
+ * those classes that are used in both the frontend and the admin area.
69
+ *
70
+ * @since 3.0.0
71
+ * @param void
72
+ * @return void
73
+ * @access public
74
+ *
75
+ */
76
+ private function instantiate_classes() {
77
+ global $SWP_Options_Page;
78
+
79
+
80
+ /**
81
+ * The Social Networks Loader
82
+ *
83
+ * Instantiates the class that will load the social networks.
84
+ *
85
+ */
86
+ new SWP_Social_Networks_Loader();
87
+
88
+
89
+ /**
90
+ * The Localization Class
91
+ *
92
+ * Instantiates the class that will load the plugin translations.
93
+ *
94
+ */
95
+ $Localization = new SWP_Localization();
96
+ $Localization->init();
97
+
98
+
99
+ /**
100
+ * The URL_Management Class
101
+ *
102
+ * This is the class that controls short links and UTM parameters.
103
+ *
104
+ */
105
+ new SWP_URL_Management();
106
+
107
+
108
+ /**
109
+ * The Script Class
110
+ *
111
+ * Instantiates the class that will enqueue all of the styles and
112
+ * scripts used throughout the plugin both frontend, and admin.
113
+ *
114
+ */
115
+ new SWP_Script();
116
+
117
+
118
+ /**
119
+ * The Shortcode Class
120
+ *
121
+ * Instantiate the class that will process all instances of the
122
+ * [social_warfare] shortcode used in posts and pages, and consequently
123
+ * convert those shortcodes into sets of share buttons.
124
+ *
125
+ */
126
+ new SWP_Shortcode();
127
+
128
+
129
+ /**
130
+ * The Header Output Class
131
+ *
132
+ * Instantiate the class that processes the values and creates the HTML
133
+ * output required in the <head> section of a website. This includes our
134
+ * font css, open graph meta tags, and Twitter cards.
135
+ *
136
+ */
137
+ new SWP_Header_Output();
138
+
139
+
140
+ /**
141
+ * The Display Class
142
+ *
143
+ * Instantiates the class that is used to queue up or hook the buttons
144
+ * generator into WordPress' the_content() hook which allows us to
145
+ * append our buttons to it.
146
+ *
147
+ */
148
+ new SWP_Display();
149
+
150
+
151
+ /**
152
+ * The Compatibility Class
153
+ *
154
+ * Instantiate the class that provides solutions to very specific
155
+ * incompatibilities with certain other plugins.
156
+ *
157
+ */
158
+ new SWP_Compatibility();
159
+
160
+
161
+ /**
162
+ * The Widget Class
163
+ *
164
+ * Instantiate the class that registers and output the "Popular Posts"
165
+ * widget. If other widgets are added later, this class will fire those
166
+ * up as well.
167
+ *
168
+ */
169
+ new SWP_Widget();
170
+
171
+
172
+ /**
173
+ * Database Migration
174
+ *
175
+ * Converts camelCased variable names to the new snake_case option names.
176
+ *
177
+ */
178
+ new SWP_Database_Migration();
179
+
180
+
181
+ /**
182
+ * The Options Page Class
183
+ *
184
+ * Instantiates the class that will load the plugin options page.
185
+ *
186
+ */
187
+ $SWP_Options_Page = new SWP_Options_Page();
188
+
189
+
190
+ /**
191
+ * The Post Cache Loader Class
192
+ *
193
+ * Instantiates a global object that will manage and load cached data
194
+ * for each individual post on a site allowing access to cached data like
195
+ * share counts, for example.
196
+ *
197
+ */
198
+ global $SWP_Post_Caches;
199
+ $SWP_Post_Caches = new SWP_Post_Cache_Loader();
200
+
201
+ }
202
+
203
+
204
+ /**
205
+ * This method will load up all of the frontend-only classes.
206
+ *
207
+ * @since 3.1.0 | 20 JUNE 2018 | Created
208
+ * @param void
209
+ * @return void
210
+ * @access private
211
+ */
212
+ private function instantiate_frontend_classes() {
213
+
214
+
215
+ }
216
+
217
+ /**
218
+ * This method will load up all of the admin-only classes.
219
+ *
220
+ * @since 3.0.0
221
+ * @param void
222
+ * @return void
223
+ * @access public
224
+ *
225
+ */
226
+ private function instantiate_admin_classes() {
227
+
228
+
229
+ /**
230
+ * The Shortcode Generator
231
+ *
232
+ * Instantiate the class that creates the shortcode generator on the
233
+ * post editor which allows users to generate the [social_warfare]
234
+ * shortcodes by simply pointing clicking, and filling in a few fill in
235
+ * the blanks.
236
+ *
237
+ */
238
+ new SWP_Shortcode_Generator();
239
+
240
+
241
+ /**
242
+ * The Click to Tweet Class
243
+ *
244
+ * Instantiate the class that that creates the Click to Tweet button in
245
+ * the WordPress post editor's dashboard (the kitchen sink) and also
246
+ * process the shortcode on the front end.
247
+ *
248
+ */
249
+ new SWP_Click_To_Tweet();
250
+
251
+
252
+ /**
253
+ * The "Social Shares" column in the posts view.
254
+ *
255
+ * Instantiate the class that creates the column in the posts view of
256
+ * the WordPress admin area. This column allows you to see how many
257
+ * times each post has been shared. It also allows you to sort the
258
+ * column in ascending or descending order.
259
+ *
260
+ */
261
+ new SWP_Column();
262
+
263
+
264
+ /**
265
+ * The The Settings Link
266
+ *
267
+ * Instantiates the class that addes links to the plugin listing on the
268
+ * plugins page of the WordPress admin area. This will link to the
269
+ * Social Warfare options page.
270
+ *
271
+ */
272
+ new SWP_Settings_Link();
273
+
274
+
275
+ /**
276
+ * The User Profile Fields
277
+ *
278
+ * Instantiates the class that adds our custom fields to the user
279
+ * profile area of the WordPress backend. This allows users to set a
280
+ * Twitter username and Facebook author URL on a per-user basis. If set,
281
+ * this will override these same settings from the options page on any
282
+ * posts authored by that user.
283
+ *
284
+ */
285
+ new SWP_User_Profile();
286
+
287
+ new SWP_JSON_Cache_Handler();
288
+
289
+
290
+ /**
291
+ * Instantiates all of our notices.
292
+ *
293
+ */
294
+ new SWP_Notice_Loader();
295
+ }
296
+
297
+
298
+ /**
299
+ * The method is used to include all of the files needed.
300
+ *
301
+ * @since 3.0.0
302
+ * @param none
303
+ * @return none
304
+ * @access public
305
+ *
306
+ */
307
+ private function load_classes() {
308
+
309
+ // Require WordPress' core plugin class.
310
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
311
+
312
+
313
+ /**
314
+ * Utility Classes
315
+ *
316
+ * This loads our Utility Trait and our various classes used to provide general
317
+ * functionality that will be used by many different classes throughout the plugin.
318
+ *
319
+ */
320
+ $utilities = array(
321
+ 'Utility_Trait',
322
+ 'Abstract',
323
+ 'Compatibility',
324
+ 'CURL',
325
+ 'Localization',
326
+ 'Permalink',
327
+ 'Plugin_Updater',
328
+ 'Database_Migration',
329
+ 'URL_Management',
330
+ 'Notice',
331
+ 'Notice_Loader',
332
+ 'Post_Cache_Loader',
333
+ 'Post_Cache',
334
+ 'JSON_Cache_Handler'
335
+ );
336
+ $this->load_files( '/functions/utilities/', $utilities);
337
+
338
+
339
+ /**
340
+ * The Social Network Classes
341
+ *
342
+ * This family of classes provides the framework and the model needed
343
+ * for creating a unique object for each social network. It also
344
+ * provides for maximum extensibility to allow addons even easier access
345
+ * than ever before to create and add more social networks to the plugin.
346
+ *
347
+ */
348
+ $social_networks = array(
349
+ 'Social_Networks_Loader',
350
+ 'Social_Network',
351
+ 'Google_Plus',
352
+ 'Facebook',
353
+ 'Twitter',
354
+ 'Linkedin',
355
+ 'Pinterest',
356
+ 'Stumble_Upon'
357
+ );
358
+ $this->load_files( '/functions/social-networks/', $social_networks);
359
+
360
+
361
+ /**
362
+ * The Addon Classes
363
+ *
364
+ * This family of classes provide for the management of addons. These
365
+ * control the framework for registering addons, checking for updates
366
+ * for the addons, and other addon specific tasks.
367
+ *
368
+ */
369
+ $includes = array(
370
+ 'Addon'
371
+ );
372
+ $this->load_files( '/functions/includes/', $includes);
373
+
374
+
375
+ /**
376
+ * The Frontend Output Classes
377
+ *
378
+ * This family of classes control everything that is output on the
379
+ * WordPress frontend. This includes the HTML for the buttons panels,
380
+ * the meta data that is output in the head section of the site, scripts
381
+ * and styles being enqueued for output, and other things like that.
382
+ *
383
+ */
384
+ $frontends = array(
385
+ 'Buttons_Panel',
386
+ 'Header_Output',
387
+ 'Display',
388
+ 'Script',
389
+ 'Shortcode',
390
+ );
391
+ $this->load_files( '/functions/frontend-output/', $frontends );
392
+
393
+
394
+ /**
395
+ * The Widget Classes
396
+ *
397
+ * These are the classes that create the widgets available for output in
398
+ * WordPress. Built in is the Popular Posts widget, but these also
399
+ * provide the framework for extensibility so that more widgets can be
400
+ * created later via addons.
401
+ *
402
+ */
403
+ $widgets = array(
404
+ 'Popular_Posts_Widget',
405
+ 'Widget',
406
+ );
407
+ $this->load_files( '/functions/widgets/', $widgets );
408
+
409
+
410
+ /**
411
+ * The Admin Classes
412
+ *
413
+ * This family of classes power everything that you see in the WordPress
414
+ * admin area of the site. This includes the Click To Tweet generator
415
+ * and Social Warfare shortcode generator buttons that you see at the
416
+ * top of the post editor. These include adding the share count column
417
+ * to the posts view and a few other things related to the admin area.
418
+ * This does NOT include the classes used to generate the options page
419
+ * for Social Warfare.
420
+ *
421
+ */
422
+ $admins = array(
423
+ 'Click_To_Tweet',
424
+ 'Column',
425
+ 'Settings_Link',
426
+ 'Shortcode_Generator',
427
+ 'User_Profile',
428
+ );
429
+ $this->load_files( '/functions/admin/', $admins );
430
+
431
+
432
+ /**
433
+ * The Options Classes
434
+ *
435
+ * These classes provide the framework that creates the admin options
436
+ * page as well as the tools needed for addons to be able to interface
437
+ * with it to add their own options.
438
+ *
439
+ */
440
+ $options = array(
441
+ 'Option',
442
+ 'Options_Page',
443
+ 'Options_Page_Tab',
444
+ 'Options_Page_Section',
445
+ 'Option_Toggle',
446
+ 'Option_Select',
447
+ 'Option_Text',
448
+ 'Option_Textarea',
449
+ 'Section_HTML',
450
+ 'Option_Icons',
451
+ 'Addon_Registration',
452
+ );
453
+ $this->load_files( '/functions/options/', $options );
454
+
455
+ }
456
+
457
+
458
+ /**
459
+ * Loads an array of related files.
460
+ *
461
+ * @param string $path The relative path to the files home.
462
+ * @param array $files The name of the files (classes), no vendor prefix.
463
+ * @return none The files are loaded into memory.
464
+ *
465
+ */
466
+ private function load_files( $path, $files ) {
467
+ foreach( $files as $file ) {
468
+
469
+ //* Add our vendor prefix to the file name.
470
+ $file = "SWP_" . $file;
471
+ require_once SWP_PLUGIN_DIR . $path . $file . '.php';
472
+ }
473
+ }
474
+ }
475
+
476
+
477
+ /*******************************************************************************
478
+ *
479
+ *
480
+ * WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
481
+ *
482
+ * EVERY FILE BELOW THIS POINT NEEDS TO BE REFACTORED. IT'S "REQUIRE_ONCE" THEN
483
+ * NEEDS TO BE MIGRATED INTO THE CLASS ABOVE.
484
+ *
485
+ *
486
+ * *****************************************************************************/
487
+
488
+
489
+ // TODO: These files need refactored into classes and to the appropriate sections above.
490
+ require_once SWP_PLUGIN_DIR . '/functions/admin/registration.php';
491
+ require_once SWP_PLUGIN_DIR . '/functions/admin/options-fetch.php';
492
+ require_once SWP_PLUGIN_DIR . '/functions/utilities/utility.php';
493
+
494
+ /**
495
+ * Include the plugin's admin files.
496
+ *
497
+ */
498
+ if ( is_admin() ) {
499
+ require_once SWP_PLUGIN_DIR . '/functions/admin/swp_system_checker.php';
500
+ // require_once SWP_PLUGIN_DIR . '/functions/admin/options-page.php';
501
+ }
functions/admin/SWP_Click_To_Tweet.php CHANGED
@@ -1,150 +1,150 @@
1
- <?php
2
-
3
- /**
4
- * Functions for creating click to tweets
5
- *
6
- * @package SocialWarfare\Functions
7
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
- * @license GPL-3.0+
9
- * @since 1.0.0
10
- * @since 3.0.0 | Feb 23 2018 | Updated class to fit our style guide.
11
- *
12
- */
13
- class SWP_Click_To_Tweet {
14
-
15
-
16
- /**
17
- * The Magic Construct method.
18
- *
19
- * Everything gets added later via hooks.
20
- *
21
- * @since 3.0.0 | 23 FEB 2018 | Created
22
- * @param void
23
- * @return void
24
- *
25
- */
26
- public function __construct() {
27
- register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) );
28
- register_deactivation_hook( __FILE__, array( __CLASS__, 'deactivation' ) );
29
-
30
- if ( is_admin() ) {
31
- $this->register_admin_hooks();
32
- }
33
- }
34
-
35
-
36
- /**
37
- * Register the uninstall hook to remove our button later.
38
- *
39
- * @since 3.0.0 | 23 FEB 2018 | Created
40
- * @param void
41
- * @return void
42
- *
43
- */
44
- public function activation() {
45
- register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
46
- }
47
-
48
-
49
- /**
50
- * Register the admin hooks.
51
- *
52
- * @since 3.0.0 | 23 FEB 2018 | Created
53
- * @param void
54
- * @return void
55
- *
56
- */
57
- public function register_admin_hooks() {
58
- add_filter( 'tiny_mce_version', array( $this, 'refresh_mce' ) );
59
- add_action( 'init', array( $this, 'tinymce_button' ) );
60
- }
61
-
62
-
63
- /**
64
- * Add the button to the post editor
65
- *
66
- * @since 3.0.0 | 23 FEB 2018 | Created
67
- * @param void
68
- * @return void
69
- *
70
- */
71
- public function tinymce_button() {
72
- if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
73
- return;
74
- }
75
-
76
- if ( get_user_option( 'rich_editing' ) == 'true' ) {
77
- add_filter( 'mce_external_plugins', array( $this, 'tinymce_register_plugin' ) );
78
- add_filter( 'mce_buttons', array( $this, 'tinymce_register_button' ) );
79
- }
80
- }
81
-
82
-
83
- /**
84
- * Add the button to the TinyMCE buttons array
85
- *
86
- * @since 3.0.0 | 23 FEB 2018 | Created
87
- * @param array $buttons The array of buttons passed in by the hook.
88
- * @return array The modified array with our new button added.
89
- *
90
- */
91
- public function tinymce_register_button( $buttons ) {
92
- array_push( $buttons, '|', 'click_to_tweet' );
93
- return $buttons;
94
- }
95
-
96
-
97
- /**
98
- * Register the JS file used to control the button.
99
- *
100
- * @since 3.0.0 | 23 FEB 2018 | Created
101
- * @param array $plugin_array Array of tinyMCE plugins that are registered.
102
- * @return array The modified array with our plugin's JS file added.
103
- *
104
- */
105
- public function tinymce_register_plugin( $plugin_array ) {
106
- $plugin_array['click_to_tweet'] = plugins_url( '/assets/js/clickToTweet.js', __FILE__ );
107
- return $plugin_array;
108
- }
109
-
110
-
111
- /**
112
- * Register settings
113
- *
114
- * @since 3.0.0 | 23 FEB 2018 | Created
115
- * @param void
116
- * @return void
117
- *
118
- */
119
- public function register_settings() {
120
- register_setting( 'tmclicktotweet-options', 'twitter-handle', array( $this, 'validate_settings' ) );
121
- }
122
-
123
-
124
- /**
125
- * Validate Settings
126
- *
127
- * @since 3.0.0 | 23 FEB 2018 | Created
128
- * @param str $input The string to validate
129
- * @return str The modified string.
130
- *
131
- */
132
- public function validate_settings( $input ) {
133
- return str_replace( '@', '', strip_tags( stripslashes( $input ) ) );
134
- }
135
-
136
-
137
- /**
138
- * Refresh the tinyMCE
139
- *
140
- * @since 3.0.0 | 23 FEB 2018 | Created
141
- * @param int $ver The current version of the tinyMCE editor.
142
- * @return int The modified version of the tinyMCE editor.
143
- *
144
- */
145
- public function refresh_mce( $ver ) {
146
- $ver += 3;
147
- return $ver;
148
- }
149
-
150
- }
1
+ <?php
2
+
3
+ /**
4
+ * Functions for creating click to tweets
5
+ *
6
+ * @package SocialWarfare\Functions
7
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
+ * @license GPL-3.0+
9
+ * @since 1.0.0
10
+ * @since 3.0.0 | Feb 23 2018 | Updated class to fit our style guide.
11
+ *
12
+ */
13
+ class SWP_Click_To_Tweet {
14
+
15
+
16
+ /**
17
+ * The Magic Construct method.
18
+ *
19
+ * Everything gets added later via hooks.
20
+ *
21
+ * @since 3.0.0 | 23 FEB 2018 | Created
22
+ * @param void
23
+ * @return void
24
+ *
25
+ */
26
+ public function __construct() {
27
+ register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) );
28
+ register_deactivation_hook( __FILE__, array( __CLASS__, 'deactivation' ) );
29
+
30
+ if ( is_admin() ) {
31
+ $this->register_admin_hooks();
32
+ }
33
+ }
34
+
35
+
36
+ /**
37
+ * Register the uninstall hook to remove our button later.
38
+ *
39
+ * @since 3.0.0 | 23 FEB 2018 | Created
40
+ * @param void
41
+ * @return void
42
+ *
43
+ */
44
+ public function activation() {
45
+ register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
46
+ }
47
+
48
+
49
+ /**
50
+ * Register the admin hooks.
51
+ *
52
+ * @since 3.0.0 | 23 FEB 2018 | Created
53
+ * @param void
54
+ * @return void
55
+ *
56
+ */
57
+ public function register_admin_hooks() {
58
+ add_filter( 'tiny_mce_version', array( $this, 'refresh_mce' ) );
59
+ add_action( 'init', array( $this, 'tinymce_button' ) );
60
+ }
61
+
62
+
63
+ /**
64
+ * Add the button to the post editor
65
+ *
66
+ * @since 3.0.0 | 23 FEB 2018 | Created
67
+ * @param void
68
+ * @return void
69
+ *
70
+ */
71
+ public function tinymce_button() {
72
+ if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
73
+ return;
74
+ }
75
+
76
+ if ( get_user_option( 'rich_editing' ) == 'true' ) {
77
+ add_filter( 'mce_external_plugins', array( $this, 'tinymce_register_plugin' ) );
78
+ add_filter( 'mce_buttons', array( $this, 'tinymce_register_button' ) );
79
+ }
80
+ }
81
+
82
+
83
+ /**
84
+ * Add the button to the TinyMCE buttons array
85
+ *
86
+ * @since 3.0.0 | 23 FEB 2018 | Created
87
+ * @param array $buttons The array of buttons passed in by the hook.
88
+ * @return array The modified array with our new button added.
89
+ *
90
+ */
91
+ public function tinymce_register_button( $buttons ) {
92
+ array_push( $buttons, '|', 'click_to_tweet' );
93
+ return $buttons;
94
+ }
95
+
96
+
97
+ /**
98
+ * Register the JS file used to control the button.
99
+ *
100
+ * @since 3.0.0 | 23 FEB 2018 | Created
101
+ * @param array $plugin_array Array of tinyMCE plugins that are registered.
102
+ * @return array The modified array with our plugin's JS file added.
103
+ *
104
+ */
105
+ public function tinymce_register_plugin( $plugin_array ) {
106
+ $plugin_array['click_to_tweet'] = plugins_url( '/assets/js/clickToTweet.js', __FILE__ );
107
+ return $plugin_array;
108
+ }
109
+
110
+
111
+ /**
112
+ * Register settings
113
+ *
114
+ * @since 3.0.0 | 23 FEB 2018 | Created
115
+ * @param void
116
+ * @return void
117
+ *
118
+ */
119
+ public function register_settings() {
120
+ register_setting( 'tmclicktotweet-options', 'twitter-handle', array( $this, 'validate_settings' ) );
121
+ }
122
+
123
+
124
+ /**
125
+ * Validate Settings
126
+ *
127
+ * @since 3.0.0 | 23 FEB 2018 | Created
128
+ * @param str $input The string to validate
129
+ * @return str The modified string.
130
+ *
131
+ */
132
+ public function validate_settings( $input ) {
133
+ return str_replace( '@', '', strip_tags( stripslashes( $input ) ) );
134
+ }
135
+
136
+
137
+ /**
138
+ * Refresh the tinyMCE
139
+ *
140
+ * @since 3.0.0 | 23 FEB 2018 | Created
141
+ * @param int $ver The current version of the tinyMCE editor.
142
+ * @return int The modified version of the tinyMCE editor.
143
+ *
144
+ */
145
+ public function refresh_mce( $ver ) {
146
+ $ver += 3;
147
+ return $ver;
148
+ }
149
+
150
+ }
functions/admin/SWP_Column.php CHANGED
@@ -1,120 +1,120 @@
1
- <?php
2
-
3
- /**
4
- * A class for modifying the default admin columns behavior.
5
- *
6
- * This class will add the the Social Shares column to the list
7
- * of posts and pages in the WordPress admin panel.
8
- *
9
- * @package Social-Warfare\Functions\Admin
10
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
11
- * @license GPL-3.0+
12
- * @since 1.0.0 | UNKNOWN | Created
13
- * @since 3.0.0 | 21 FEB 2018 | Refactored into a class-based system.
14
- * @since 3.1.0 | 14 JUN 2018 | Added number_format for numeric output.
15
- *
16
- */
17
- class SWP_Column {
18
-
19
-
20
- /**
21
- * The magic __construct method used to instatiate our class. This method
22
- * will queue up all the other methods by adding them to the necessary
23
- * WordPress action and filter hooks.
24
- *
25
- * NOTE: These "duplicate" hooks/functions are to cover both posts and pages.
26
- *
27
- * @since 3.0.0 | 01 MAR 2018 | Created
28
- * @param void
29
- * @return void
30
- *
31
- */
32
- public function __construct() {
33
-
34
- // Create the social shares column
35
- add_filter( 'manage_post_posts_columns', array($this, 'create_social_shares_column' ) );
36
- add_filter( 'manage_page_posts_columns', array($this, 'create_social_shares_column' ) );
37
-
38
- // Populate the social shares column with data
39
- add_action( 'manage_posts_custom_column', array( $this, 'populate_social_shares_column' ), 10, 2 );
40
- add_action( 'manage_page_posts_custom_column', array( $this, 'populate_social_shares_column' ), 10, 2 );
41
-
42
- // Make the social shares column sortable
43
- add_filter( 'manage_edit-post_sortable_columns', array($this, 'make_social_shares_sortable' ) );
44
- add_filter( 'manage_edit-page_sortable_columns', array($this, 'make_social_shares_sortable' ) );
45
-
46
- // Sort the output of the posts according to the sortable option created above
47
- add_action( 'pre_get_posts', array( $this, 'swp_social_shares_orderby' ) );
48
- }
49
-
50
-
51
- /**
52
- * Add a share counts column to the post listing admin pages; make it Sortable.
53
- *
54
- * @since 1.4.0 | 01 JAN 2016 | Created
55
- * @param array $defaults The default columns registered with WordPress.
56
- * @return array The array modified with our new column.
57
- *
58
- */
59
- public function create_social_shares_column( $defaults ) {
60
- $defaults['swSocialShares'] = 'Social Shares';
61
- return $defaults;
62
- }
63
-
64
-
65
- /**
66
- * Populate the new column with the share count from the meta field
67
- *
68
- * @since 1.4.0 | 01 JAN 2018 | Created
69
- * @since 3.1.0 | 14 JUN 2018 | Added number_format
70
- * @param string $column_name The name of the column to be modified.
71
- * @param int $post_ID The Post ID
72
- * @return void The number is echoed to the screen.
73
- *
74
- */
75
- public function populate_social_shares_column( $column_name, $post_ID ) {
76
- if ( $column_name == 'swSocialShares' ) {
77
- $answer = get_post_meta( $post_ID , '_total_shares' , true );
78
- if( !empty( $answer ) ):
79
- echo number_format( intval( $answer ) );
80
- else:
81
- echo 0;
82
- endif;
83
- }
84
- }
85
-
86
-
87
- /**
88
- * Make the column sortable
89
- *
90
- * @since 1.4.0 | 01 JAN 2018 | Created
91
- * @param array The array of registered columns.
92
- * @return array The array modified columns.
93
- *
94
- */
95
- public function make_social_shares_sortable( $columns ) {
96
- $columns['swSocialShares'] = 'Social Shares';
97
- return $columns;
98
- }
99
-
100
-
101
- /**
102
- * Sort the column by share count.
103
- *
104
- * @since 1.4.0 | 01 JAN 2018 | Created
105
- * @param object $query The WordPress query object.
106
- * @return void
107
- *
108
- */
109
- public function swp_social_shares_orderby( $query ) {
110
- if ( !is_admin() ) {
111
- return;
112
- }
113
- $orderby = $query->get( 'orderby' );
114
-
115
- if ( 'Social Shares' === $orderby ) {
116
- $query->set( 'meta_key', '_total_shares' );
117
- $query->set( 'orderby', 'meta_value_num' );
118
- }
119
- }
120
- }
1
+ <?php
2
+
3
+ /**
4
+ * A class for modifying the default admin columns behavior.
5
+ *
6
+ * This class will add the the Social Shares column to the list
7
+ * of posts and pages in the WordPress admin panel.
8
+ *
9
+ * @package Social-Warfare\Functions\Admin
10
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
11
+ * @license GPL-3.0+
12
+ * @since 1.0.0 | UNKNOWN | Created
13
+ * @since 3.0.0 | 21 FEB 2018 | Refactored into a class-based system.
14
+ * @since 3.1.0 | 14 JUN 2018 | Added number_format for numeric output.
15
+ *
16
+ */
17
+ class SWP_Column {
18
+
19
+
20
+ /**
21
+ * The magic __construct method used to instatiate our class. This method
22
+ * will queue up all the other methods by adding them to the necessary
23
+ * WordPress action and filter hooks.
24
+ *
25
+ * NOTE: These "duplicate" hooks/functions are to cover both posts and pages.
26
+ *
27
+ * @since 3.0.0 | 01 MAR 2018 | Created
28
+ * @param void
29
+ * @return void
30
+ *
31
+ */
32
+ public function __construct() {
33
+
34
+ // Create the social shares column
35
+ add_filter( 'manage_post_posts_columns', array($this, 'create_social_shares_column' ) );
36
+ add_filter( 'manage_page_posts_columns', array($this, 'create_social_shares_column' ) );
37
+
38
+ // Populate the social shares column with data
39
+ add_action( 'manage_posts_custom_column', array( $this, 'populate_social_shares_column' ), 10, 2 );
40
+ add_action( 'manage_page_posts_custom_column', array( $this, 'populate_social_shares_column' ), 10, 2 );
41
+
42
+ // Make the social shares column sortable
43
+ add_filter( 'manage_edit-post_sortable_columns', array($this, 'make_social_shares_sortable' ) );
44
+ add_filter( 'manage_edit-page_sortable_columns', array($this, 'make_social_shares_sortable' ) );
45
+
46
+ // Sort the output of the posts according to the sortable option created above
47
+ add_action( 'pre_get_posts', array( $this, 'swp_social_shares_orderby' ) );
48
+ }
49
+
50
+
51
+ /**
52
+ * Add a share counts column to the post listing admin pages; make it Sortable.
53
+ *
54
+ * @since 1.4.0 | 01 JAN 2016 | Created
55
+ * @param array $defaults The default columns registered with WordPress.
56
+ * @return array The array modified with our new column.
57
+ *
58
+ */
59
+ public function create_social_shares_column( $defaults ) {
60
+ $defaults['swSocialShares'] = 'Social Shares';
61
+ return $defaults;
62
+ }
63
+
64
+
65
+ /**
66
+ * Populate the new column with the share count from the meta field
67
+ *
68
+ * @since 1.4.0 | 01 JAN 2018 | Created
69
+ * @since 3.1.0 | 14 JUN 2018 | Added number_format
70
+ * @param string $column_name The name of the column to be modified.
71
+ * @param int $post_ID The Post ID
72
+ * @return void The number is echoed to the screen.
73
+ *
74
+ */
75
+ public function populate_social_shares_column( $column_name, $post_ID ) {
76
+ if ( $column_name == 'swSocialShares' ) {
77
+ $answer = get_post_meta( $post_ID , '_total_shares' , true );
78
+ if( !empty( $answer ) ):
79
+ echo number_format( intval( $answer ) );
80
+ else:
81
+ echo 0;
82
+ endif;
83
+ }
84
+ }
85
+
86
+
87
+ /**
88
+ * Make the column sortable
89
+ *
90
+ * @since 1.4.0 | 01 JAN 2018 | Created
91
+ * @param array The array of registered columns.
92
+ * @return array The array modified columns.
93
+ *
94
+ */
95
+ public function make_social_shares_sortable( $columns ) {
96
+ $columns['swSocialShares'] = 'Social Shares';
97
+ return $columns;
98
+ }
99
+
100
+
101
+ /**
102
+ * Sort the column by share count.
103
+ *
104
+ * @since 1.4.0 | 01 JAN 2018 | Created
105
+ * @param object $query The WordPress query object.
106
+ * @return void
107
+ *
108
+ */
109
+ public function swp_social_shares_orderby( $query ) {
110
+ if ( !is_admin() ) {
111
+ return;
112
+ }
113
+ $orderby = $query->get( 'orderby' );
114
+
115
+ if ( 'Social Shares' === $orderby ) {
116
+ $query->set( 'meta_key', '_total_shares' );
117
+ $query->set( 'orderby', 'meta_value_num' );
118
+ }
119
+ }
120
+ }
functions/admin/SWP_Settings_Link.php CHANGED
@@ -1,52 +1,52 @@
1
- <?php
2
-
3
- /**
4
- * Adding the settings link to the plugins page
5
- *
6
- * This class and its methods add a link to the plugins page which links directly
7
- * to the Social Warfare settings page.
8
- *
9
- * @package SocialWarfare\Admin\Functions
10
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
11
- * @license GPL-3.0+
12
- * @since 1.0.0
13
- * @since 3.0.0 | 21 FEB 2018 | Refactored into a class based system.
14
- *
15
- */
16
- class SWP_Settings_Link {
17
-
18
-
19
- /**
20
- * The magic method for instatiating this class
21
- *
22
- * This method called in the settings link by attaching it to the appropriate
23
- * WordPress hooks and filtering the passed array of $links.
24
- *
25
- * @since 3.0.0
26
- * @param None
27
- * @return None
28
- *
29
- */
30
- public function __construct() {
31
- add_filter( 'plugin_action_links_' . plugin_basename( SWP_PLUGIN_FILE ), array( $this , 'add_settings_links' ) );
32
- }
33
-
34
- /**
35
- * Add a "Settings" link to the listing on the plugins page
36
- *
37
- * @since 1.0.0
38
- * @param array $links Array of links passed in from WordPress core.
39
- * @return array $links Array of links modified by the function passed back to WordPress
40
- *
41
- */
42
- public function add_settings_links( $links ) {
43
- $settings_link = sprintf( '<a href="admin.php?page=social-warfare">%s</a>',
44
- esc_html__( 'Settings', 'social-warfare' )
45
- );
46
-
47
- array_unshift( $links, $settings_link );
48
-
49
- return $links;
50
- }
51
-
52
- }
1
+ <?php
2
+
3
+ /**
4
+ * Adding the settings link to the plugins page
5
+ *
6
+ * This class and its methods add a link to the plugins page which links directly
7
+ * to the Social Warfare settings page.
8
+ *
9
+ * @package SocialWarfare\Admin\Functions
10
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
11
+ * @license GPL-3.0+
12
+ * @since 1.0.0
13
+ * @since 3.0.0 | 21 FEB 2018 | Refactored into a class based system.
14
+ *
15
+ */
16
+ class SWP_Settings_Link {
17
+
18
+
19
+ /**
20
+ * The magic method for instatiating this class
21
+ *
22
+ * This method called in the settings link by attaching it to the appropriate
23
+ * WordPress hooks and filtering the passed array of $links.
24
+ *
25
+ * @since 3.0.0
26
+ * @param None
27
+ * @return None
28
+ *
29
+ */
30
+ public function __construct() {
31
+ add_filter( 'plugin_action_links_' . plugin_basename( SWP_PLUGIN_FILE ), array( $this , 'add_settings_links' ) );
32
+ }
33
+
34
+ /**
35
+ * Add a "Settings" link to the listing on the plugins page
36
+ *
37
+ * @since 1.0.0
38
+ * @param array $links Array of links passed in from WordPress core.
39
+ * @return array $links Array of links modified by the function passed back to WordPress
40
+ *
41
+ */
42
+ public function add_settings_links( $links ) {
43
+ $settings_link = sprintf( '<a href="admin.php?page=social-warfare">%s</a>',
44
+ esc_html__( 'Settings', 'social-warfare' )
45
+ );
46
+
47
+ array_unshift( $links, $settings_link );
48
+
49
+ return $links;
50
+ }
51
+
52
+ }
functions/admin/SWP_Shortcode_Generator.php CHANGED
@@ -1,123 +1,123 @@
1
- <?php
2
-
3
- /**
4
- * A class of functions used to render the shortcode generator
5
- *
6
- * This provides the shortcode generator for the [social_warfare]
7
- * shortcode which allows the user to be able to output a panel of
8
- * share buttons right in the middle of a post if they want.
9
- *
10
- * @package SocialWarfare\Frontend-Output
11
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
12
- * @license GPL-3.0+
13
- * @since 1.0.0
14
- * @since 3.0.0 | 20 FEB 2018 | Refactored this file to align
15
- * with our code style guide
16
- *
17
- */
18
- class SWP_Shortcode_Generator {
19
-
20
- /**
21
- * The magic method for instatiating this class
22
- *
23
- * This method called the activation and decativation hooks and
24
- * sets up the button and it's associated JS to be registered with
25
- * the TinyMCE editor on WordPress posts (AKA the Kitchen Sink).
26
- *
27
- * @param None
28
- * @return None
29
- *
30
- */
31
- public function __construct() {
32
- register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) );
33
- register_deactivation_hook( __FILE__, array( __CLASS__, 'deactivation' ) );
34
-
35
- if ( is_admin() ) {
36
- $this->register_admin_hooks();
37
- }
38
- }
39
-
40
- /**
41
- * Pretty print data for debugging.
42
- *
43
- * @param Array $array The data to print.
44
- *
45
- */
46
- public function debug( $array ) {
47
- echo '<pre>';
48
- print_r( $array );
49
- echo '</pre>';
50
- }
51
-
52
- /**
53
- * Activate the shortcode
54
- *
55
- */
56
- public function activation() {
57
- register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
58
- }
59
-
60
-
61
- /**
62
- * Register the admin hooks
63
- *
64
- */
65
- public function register_admin_hooks() {
66
- add_filter( 'tiny_mce_version', array( $this, 'refresh_mce' ) );
67
- add_action( 'init', array( $this, 'tinymce_button' ) );
68
- }
69
-
70
-
71
- /**
72
- * A method for adding the button to tinymce editor
73
- *
74
- */
75
- public function tinymce_button() {
76
- if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
77
- return;
78
- }
79
-
80
- if ( get_user_option( 'rich_editing' ) == 'true' ) {
81
- add_filter( 'mce_external_plugins', array( $this, 'tinymce_register_plugin' ) );
82
- add_filter( 'mce_buttons', array( $this, 'tinymce_register_button' ) );
83
- }
84
- }
85
-
86
-
87
-
88
- /**
89
- * Register the shortcode button.
90
- *
91
- * @param array $buttons
92
- * @return array
93
- *
94
- */
95
- public function tinymce_register_button( $buttons ) {
96
- array_push( $buttons, '|', 'swp_shortcode_generator' );
97
- return $buttons;
98
- }
99
-
100
-
101
- /**
102
- * Register the JS file with the TinyMCE editor
103
- *
104
- * @param Array An array of plugins registered with the TinyMCE editor
105
- * @return Array The modified array with our plugin and JS file added
106
- *
107
- */
108
- public function tinymce_register_plugin( $plugin_array ) {
109
- $plugin_array['swp_shortcode_generator'] = SWP_PLUGIN_URL . '/js/sw-shortcode-generator.js';
110
- return $plugin_array;
111
- }
112
-
113
- /**
114
- * Force TinyMCE to refresh.
115
- *
116
- * @param int $version
117
- * @return int
118
- */
119
- public function refresh_mce( $ver ) {
120
- $ver += 3;
121
- return $ver;
122
- }
123
- }
1
+ <?php
2
+
3
+ /**
4
+ * A class of functions used to render the shortcode generator
5
+ *
6
+ * This provides the shortcode generator for the [social_warfare]
7
+ * shortcode which allows the user to be able to output a panel of
8
+ * share buttons right in the middle of a post if they want.
9
+ *
10
+ * @package SocialWarfare\Frontend-Output
11
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
12
+ * @license GPL-3.0+
13
+ * @since 1.0.0
14
+ * @since 3.0.0 | 20 FEB 2018 | Refactored this file to align
15
+ * with our code style guide
16
+ *
17
+ */
18
+ class SWP_Shortcode_Generator {
19
+
20
+ /**
21
+ * The magic method for instatiating this class
22
+ *
23
+ * This method called the activation and decativation hooks and
24
+ * sets up the button and it's associated JS to be registered with
25
+ * the TinyMCE editor on WordPress posts (AKA the Kitchen Sink).
26
+ *
27
+ * @param None
28
+ * @return None
29
+ *
30
+ */
31
+ public function __construct() {
32
+ register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) );
33
+ register_deactivation_hook( __FILE__, array( __CLASS__, 'deactivation' ) );
34
+
35
+ if ( is_admin() ) {
36
+ $this->register_admin_hooks();
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Pretty print data for debugging.
42
+ *
43
+ * @param Array $array The data to print.
44
+ *
45
+ */
46
+ public function debug( $array ) {
47
+ echo '<pre>';
48
+ print_r( $array );
49
+ echo '</pre>';
50
+ }
51
+
52
+ /**
53
+ * Activate the shortcode
54
+ *
55
+ */
56
+ public function activation() {
57
+ register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
58
+ }
59
+
60
+
61
+ /**
62
+ * Register the admin hooks
63
+ *
64
+ */
65
+ public function register_admin_hooks() {
66
+ add_filter( 'tiny_mce_version', array( $this, 'refresh_mce' ) );
67
+ add_action( 'init', array( $this, 'tinymce_button' ) );
68
+ }
69
+
70
+
71
+ /**
72
+ * A method for adding the button to tinymce editor
73
+ *
74
+ */
75
+ public function tinymce_button() {
76
+ if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
77
+ return;
78
+ }
79
+
80
+ if ( get_user_option( 'rich_editing' ) == 'true' ) {
81
+ add_filter( 'mce_external_plugins', array( $this, 'tinymce_register_plugin' ) );
82
+ add_filter( 'mce_buttons', array( $this, 'tinymce_register_button' ) );
83
+ }
84
+ }
85
+
86
+
87
+
88
+ /**
89
+ * Register the shortcode button.
90
+ *
91
+ * @param array $buttons
92
+ * @return array
93
+ *
94
+ */
95
+ public function tinymce_register_button( $buttons ) {
96
+ array_push( $buttons, '|', 'swp_shortcode_generator' );
97
+ return $buttons;
98
+ }
99
+
100
+
101
+ /**
102
+ * Register the JS file with the TinyMCE editor
103
+ *
104
+ * @param Array An array of plugins registered with the TinyMCE editor
105
+ * @return Array The modified array with our plugin and JS file added
106
+ *
107
+ */
108
+ public function tinymce_register_plugin( $plugin_array ) {
109
+ $plugin_array['swp_shortcode_generator'] = SWP_PLUGIN_URL . '/js/sw-shortcode-generator.js';
110
+ return $plugin_array;
111
+ }
112
+
113
+ /**
114
+ * Force TinyMCE to refresh.
115
+ *
116
+ * @param int $version
117
+ * @return int
118
+ */
119
+ public function refresh_mce( $ver ) {
120
+ $ver += 3;
121
+ return $ver;
122
+ }
123
+ }
functions/admin/SWP_User_Profile.php CHANGED
@@ -1,119 +1,119 @@
1
- <?php
2
-
3
- /**
4
- * SWP_User_Profile: Manages the input fields on the user profile page.
5
- *
6
- * This class is used to create and control the fields of input on the user
7
- * profile within WordPress. It is specially used to allow users to input their
8
- * Twitter username and Facebook author URL so that we can use these to control
9
- * tagging and mentions on these respective social media platforms.
10
- *
11
- * These fields will override the Twitter username and Facebook URL that is set
12
- * in the global options page.
13
- *
14
- * @since Unknown | Created |
15
- * @since 2.2.4 | Updated | 07 MAR 2017 | Added gettext calls to the form.
16
- * @since 3.0.0 | Updated | 21 FEB 2017 | Refactored into a class-based system.
17
- * @access public
18
- * @return none
19
- *
20
- */
21
- class SWP_User_Profile {
22
-
23
-
24
- /**
25
- * This is the magic method used to instantiate this class
26
- *
27
- * This method is used to queue up all the other methods by attaching them
28
- * to the appropriate action hooks in WordPress. The first set of functions
29
- * make it so the fields appear. The second set take care of saving the data
30
- * when the profile is updated.
31
- *
32
- * @param object $user The user object
33
- * @since Unknown
34
- * @since 3.0.0 | Created | 21 FEB 2017
35
- * @access public
36
- * @return none
37
- *
38
- */
39
- public function __construct() {
40
- add_action( 'show_user_profile', array( $this , 'show_user_profile_fields' ) );
41
- add_action( 'edit_user_profile', array( $this , 'show_user_profile_fields' ) );
42
- add_action( 'personal_options_update', array( $this , 'save_user_profile_fields' ) );
43
- add_action( 'edit_user_profile_update', array( $this , 'save_user_profile_fields' ) );
44
- }
45
-
46
-
47
- /**
48
- * Display the new options on the user profile edit page
49
- *
50
- * This method outputs the user profile fields for the Twitter username
51
- * and the Facebook author URL.
52
- *
53
- * @param object $user The user object
54
- * @since Unknown
55
- * @since 2.2.4 | Updated | 07 MAR 2017 | Added translation gettext calls to each title and description
56
- * @access public
57
- * @return none
58
- *
59
- */
60
- public function show_user_profile_fields( $user ) {
61
- echo '<h3>Social Warfare Fields</h3>';
62
- echo '<table class="form-table">';
63
- echo '<tr>';
64
- echo '<th><label for="twitter">' . __( 'Twitter Username','social-warfare' ) . '</label></th>';
65
- echo '<td>';
66
- echo '<input type="text" name="swp_twitter" id="swp_twitter" value="' . esc_attr( get_the_author_meta( 'swp_twitter' , $user->ID ) ) . '" class="regular-text" />';
67
- echo '<br /><span class="description">' . __( 'Please enter your Twitter username.','social-warfare' ) . '</span>';
68
- echo '</td>';
69
- echo '</tr>';
70
- echo '<tr>';
71
- echo '<th><label for="facebook_author">' . __( 'Facebook Author URL','social-warfare' ) . '</label></th>';
72
- echo '<td>';
73
- echo '<input type="text" name="swp_fb_author" id="swp_fb_author" value="' . esc_attr( get_the_author_meta( 'swp_fb_author' , $user->ID ) ) . '" class="regular-text" />';
74
- echo '<br /><span class="description">' . __( 'Please enter the URL of your Facebok profile.','social-warfare' ) . '</span>';
75
- echo '</td>';
76
- echo '</tr>';
77
- echo '</table>';
78
- }
79
-
80
-
81
- /**
82
- * Save our fields when the page is udpated
83
- *
84
- * This is the method that will save the user's input when the user profile
85
- * is updated.
86
- *
87
- * @param integer $user_id The user ID
88
- * @since Unknown
89
- * @access public
90
- * @return none
91
- *
92
- */
93
- public function save_user_profile_fields( $user_id ) {
94
-
95
- if ( ! current_user_can( 'edit_user', $user_id ) ) {
96
- return false;
97
- }
98
-
99
- update_user_meta( $user_id, 'swp_twitter', $_POST['swp_twitter'] );
100
- update_user_meta( $user_id, 'swp_fb_author', $_POST['swp_fb_author'] );
101
- }
102
-
103
-
104
- /**
105
- * Traces a post ID back to the user ID of that post.
106
- *
107
- * Given a post ID, this function will return the author of that post.
108
- *
109
- * @since Unknown
110
- * @access public
111
- * @param integer $post_id The post ID
112
- * @return integer The author ID
113
- *
114
- */
115
- public static function get_author( $post_id = 0 ) {
116
- $post = get_post( $post_id );
117
- return $post->post_author;
118
- }
119
- }
1
+ <?php
2
+
3
+ /**
4
+ * SWP_User_Profile: Manages the input fields on the user profile page.
5
+ *
6
+ * This class is used to create and control the fields of input on the user
7
+ * profile within WordPress. It is specially used to allow users to input their
8
+ * Twitter username and Facebook author URL so that we can use these to control
9
+ * tagging and mentions on these respective social media platforms.
10
+ *
11
+ * These fields will override the Twitter username and Facebook URL that is set
12
+ * in the global options page.
13
+ *
14
+ * @since Unknown | Created |
15
+ * @since 2.2.4 | Updated | 07 MAR 2017 | Added gettext calls to the form.
16
+ * @since 3.0.0 | Updated | 21 FEB 2017 | Refactored into a class-based system.
17
+ * @access public
18
+ * @return none
19
+ *
20
+ */
21
+ class SWP_User_Profile {
22
+
23
+
24
+ /**
25
+ * This is the magic method used to instantiate this class
26
+ *
27
+ * This method is used to queue up all the other methods by attaching them
28
+ * to the appropriate action hooks in WordPress. The first set of functions
29
+ * make it so the fields appear. The second set take care of saving the data
30
+ * when the profile is updated.
31
+ *
32
+ * @param object $user The user object
33
+ * @since Unknown
34
+ * @since 3.0.0 | Created | 21 FEB 2017
35
+ * @access public
36
+ * @return none
37
+ *
38
+ */
39
+ public function __construct() {
40
+ add_action( 'show_user_profile', array( $this , 'show_user_profile_fields' ) );
41
+ add_action( 'edit_user_profile', array( $this , 'show_user_profile_fields' ) );
42
+ add_action( 'personal_options_update', array( $this , 'save_user_profile_fields' ) );
43
+ add_action( 'edit_user_profile_update', array( $this , 'save_user_profile_fields' ) );
44
+ }
45
+
46
+
47
+ /**
48
+ * Display the new options on the user profile edit page
49
+ *
50
+ * This method outputs the user profile fields for the Twitter username
51
+ * and the Facebook author URL.
52
+ *
53
+ * @param object $user The user object
54
+ * @since Unknown
55
+ * @since 2.2.4 | Updated | 07 MAR 2017 | Added translation gettext calls to each title and description
56
+ * @access public
57
+ * @return none
58
+ *
59
+ */
60
+ public function show_user_profile_fields( $user ) {
61
+ echo '<h3>Social Warfare Fields</h3>';
62
+ echo '<table class="form-table">';
63
+ echo '<tr>';
64
+ echo '<th><label for="twitter">' . __( 'Twitter Username','social-warfare' ) . '</label></th>';
65
+ echo '<td>';
66
+ echo '<input type="text" name="swp_twitter" id="swp_twitter" value="' . esc_attr( get_the_author_meta( 'swp_twitter' , $user->ID ) ) . '" class="regular-text" />';
67
+ echo '<br /><span class="description">' . __( 'Please enter your Twitter username.','social-warfare' ) . '</span>';
68
+ echo '</td>';
69
+ echo '</tr>';
70
+ echo '<tr>';
71
+ echo '<th><label for="facebook_author">' . __( 'Facebook Author URL','social-warfare' ) . '</label></th>';
72
+ echo '<td>';
73
+ echo '<input type="text" name="swp_fb_author" id="swp_fb_author" value="' . esc_attr( get_the_author_meta( 'swp_fb_author' , $user->ID ) ) . '" class="regular-text" />';
74
+ echo '<br /><span class="description">' . __( 'Please enter the URL of your Facebok profile.','social-warfare' ) . '</span>';
75
+ echo '</td>';
76
+ echo '</tr>';
77
+ echo '</table>';
78
+ }
79
+
80
+
81
+ /**
82
+ * Save our fields when the page is udpated
83
+ *
84
+ * This is the method that will save the user's input when the user profile
85
+ * is updated.
86
+ *
87
+ * @param integer $user_id The user ID
88
+ * @since Unknown
89
+ * @access public
90
+ * @return none
91
+ *
92
+ */
93
+ public function save_user_profile_fields( $user_id ) {
94
+
95
+ if ( ! current_user_can( 'edit_user', $user_id ) ) {
96
+ return false;
97
+ }
98
+
99
+ update_user_meta( $user_id, 'swp_twitter', $_POST['swp_twitter'] );
100
+ update_user_meta( $user_id, 'swp_fb_author', $_POST['swp_fb_author'] );
101
+ }
102
+
103
+
104
+ /**
105
+ * Traces a post ID back to the user ID of that post.
106
+ *
107
+ * Given a post ID, this function will return the author of that post.
108
+ *
109
+ * @since Unknown
110
+ * @access public
111
+ * @param integer $post_id The post ID
112
+ * @return integer The author ID
113
+ *
114
+ */
115
+ public static function get_author( $post_id = 0 ) {
116
+ $post = get_post( $post_id );
117
+ return $post->post_author;
118
+ }
119
+ }
functions/admin/assets/css/admin.css CHANGED
@@ -1,13 +1,13 @@
1
- i.mce-i-icon {
2
- font: 400 20px/1 dashicons;
3
- padding: 0;
4
- vertical-align: top;
5
- speak: none;
6
- -webkit-font-smoothing: antialiased;
7
- -moz-osx-font-smoothing: grayscale;
8
- margin-left: -2px;
9
- padding-right: 2px;
10
- }
11
- i.mce-i-icon:before {
12
- color:#60a8dc;
13
- }
1
+ i.mce-i-icon {
2
+ font: 400 20px/1 dashicons;
3
+ padding: 0;
4
+ vertical-align: top;
5
+ speak: none;
6
+ -webkit-font-smoothing: antialiased;
7
+ -moz-osx-font-smoothing: grayscale;
8
+ margin-left: -2px;
9
+ padding-right: 2px;
10
+ }
11
+ i.mce-i-icon:before {
12
+ color:#60a8dc;
13
+ }
functions/admin/assets/css/style1.css CHANGED
@@ -1,174 +1,174 @@
1
- .sw-CTT {
2
- display:block;
3
- }
4
- .sw-tweet-clear {
5
- zoom: 1;
6
- }
7
- .sw-tweet-clear:after {
8
- display: block;
9
- visibility: hidden;
10
- height: 0;
11
- clear: both;
12
- content: ".";
13
- }
14
- .sw-click-to-tweet {
15
- display: block;
16
- background-color: #fff;
17
- margin: 0;
18
- padding: 0;
19
- position: relative;
20
- border: 1px solid #dddddd;
21
- -moz-border-radius: 4px;
22
- border-radius: 4px;
23
- padding: 15px 30px;
24
- margin: 15px 0px;
25
- zoom: 1;
26
- }
27
- .sw-click-to-tweet .clearfix {
28
- zoom: 1;
29
- }
30
- .sw-click-to-tweet .clearfix:after {
31
- display: block;
32
- visibility: hidden;
33
- height: 0;
34
- clear: both;
35
- content: ".";
36
- }
37
- .sw-click-to-tweet .clear {
38
- clear: both;
39
- }
40
- .sw-click-to-tweet .f-left {
41
- float: left;
42
- display: inline-block;
43
- position: relative;
44
- }
45
- .sw-click-to-tweet .f-right {
46
- float: right;
47
- display: inline-block;
48
- position: relative;
49
- }
50
- .sw-click-to-tweet .list-reset {
51
- list-style: none;
52
- margin: 0;
53
- padding: 0;
54
- }
55
- .sw-click-to-tweet .list-reset li {
56
- list-style: none;
57
- margin: 0;
58
- padding: 0;
59
- }
60
- .sw-click-to-tweet .list-float {
61
- zoom: 1;
62
- }
63
- .sw-click-to-tweet .list-float:after {
64
- display: block;
65
- visibility: hidden;
66
- height: 0;
67
- clear: both;
68
- content: ".";
69
- }
70
- .sw-click-to-tweet .list-float li {
71
- float: left;
72
- display: inline-block;
73
- }
74
- .sw-click-to-tweet .kill-box-shadow {
75
- box-shadow: none;
76
- -webkit-box-shadow: none;
77
- -moz-box-shadow: none;
78
- }
79
- .sw-click-to-tweet .alignright {
80
- float: right;
81
- margin-bottom: 10px;
82
- margin-left: 10px;
83
- text-align: right;
84
- }
85
- .sw-click-to-tweet .alignleft {
86
- float: left;
87
- margin-bottom: 10px;
88
- margin-right: 10px;
89
- text-align: right;
90
- }
91
- .sw-click-to-tweet:after {
92
- content: ".";
93
- display: block;
94
- clear: both;
95
- visibility: hidden;
96
- line-height: 0;
97
- height: 0;
98
- }
99
- .sw-click-to-tweet .sw-ctt-reset {
100
- margin: 0;
101
- padding: 0;
102
- position: relative;
103
- }
104
- .sw-click-to-tweet:after {
105
- display: block;
106
- visibility: hidden;
107
- height: 0;
108
- clear: both;
109
- content: ".";
110
- }
111
- .sw-click-to-tweet a {
112
- text-decoration: none;
113
- text-transform: none;
114
- }
115
- .sw-click-to-tweet a:hover {
116
- text-decoration: none;
117
- }
118
- .sw-click-to-tweet .sw-ctt-text {
119
- margin: 0;
120
- padding: 0;
121
- position: relative;
122
- margin-bottom: 10px;
123
- word-wrap: break-word;
124
- }
125
- a .sw-click-to-tweet .sw-ctt-text {
126
- margin: 0;
127
- padding: 0;
128
- position: relative;
129
- color: #999999;
130
- font-size: 24px;
131
- line-height: 140%;
132
- text-transform: none;
133
- font-weight: 500;
134
- text-decoration: none;
135
- text-transform: none;
136
- display:block;
137
- }
138
- a:hover .sw-click-to-tweet .sw-ctt-text {
139
- text-decoration: none;
140
- color: #666666;
141
- }
142
- .sw-click-to-tweet .sw-ctt-btn {
143
- margin: 0;
144
- padding: 3px;
145
- position: relative;
146
- display: block;
147
- text-transform: uppercase;
148
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
149
- font-size: 12px;
150
- font-weight: bold;
151
- line-height: 100%;
152
- color: #999999;
153
- float: right;
154
- padding-right: 24px;
155
- text-decoration: none;
156
- background: transparent url("//4.bp.blogspot.com/-Ku-iYrKVffw/VHjB2LFSO1I/AAAAAAAAEyI/NDiWlshts4M/s1600/twitter-little-bird.png") no-repeat right top;
157
- }
158
- a:hover .sw-click-to-tweet .sw-ctt-btn {
159
- text-decoration: none;
160
- color: #666666;
161
- text-transform: uppercase;
162
- }
163
- .sw-click-to-tweet .sw-powered-by {
164
- font-size: 10px;
165
- color: #999999;
166
- }
167
- .sw-click-to-tweet .sw-powered-by a {
168
- font-size: 10px;
169
- color: #999999 !important;
170
- }
171
- .sw-click-to-tweet .sw-powered-by a:hover {
172
- color: #999999 !important;
173
- text-decoration: underline !important;
174
- }
1
+ .sw-CTT {
2
+ display:block;
3
+ }
4
+ .sw-tweet-clear {
5
+ zoom: 1;
6
+ }
7
+ .sw-tweet-clear:after {
8
+ display: block;
9
+ visibility: hidden;
10
+ height: 0;
11
+ clear: both;
12
+ content: ".";
13
+ }
14
+ .sw-click-to-tweet {
15
+ display: block;
16
+ background-color: #fff;
17
+ margin: 0;
18
+ padding: 0;
19
+ position: relative;
20
+ border: 1px solid #dddddd;
21
+ -moz-border-radius: 4px;
22
+ border-radius: 4px;
23
+ padding: 15px 30px;
24
+ margin: 15px 0px;
25
+ zoom: 1;
26
+ }
27
+ .sw-click-to-tweet .clearfix {
28
+ zoom: 1;
29
+ }
30
+ .sw-click-to-tweet .clearfix:after {
31
+ display: block;
32
+ visibility: hidden;
33
+ height: 0;
34
+ clear: both;
35
+ content: ".";
36
+ }
37
+ .sw-click-to-tweet .clear {
38
+ clear: both;
39
+ }
40
+ .sw-click-to-tweet .f-left {
41
+ float: left;
42
+ display: inline-block;
43
+ position: relative;
44
+ }
45
+ .sw-click-to-tweet .f-right {
46
+ float: right;
47
+ display: inline-block;
48
+ position: relative;
49
+ }
50
+ .sw-click-to-tweet .list-reset {
51
+ list-style: none;
52
+ margin: 0;
53
+ padding: 0;
54
+ }
55
+ .sw-click-to-tweet .list-reset li {
56
+ list-style: none;
57
+ margin: 0;
58
+ padding: 0;
59
+ }
60
+ .sw-click-to-tweet .list-float {
61
+ zoom: 1;
62
+ }
63
+ .sw-click-to-tweet .list-float:after {
64
+ display: block;
65
+ visibility: hidden;
66
+ height: 0;
67
+ clear: both;
68
+ content: ".";
69
+ }
70
+ .sw-click-to-tweet .list-float li {
71
+ float: left;
72
+ display: inline-block;
73
+ }
74
+ .sw-click-to-tweet .kill-box-shadow {
75
+ box-shadow: none;
76
+ -webkit-box-shadow: none;
77
+ -moz-box-shadow: none;
78
+ }
79
+ .sw-click-to-tweet .alignright {
80
+ float: right;
81
+ margin-bottom: 10px;
82
+ margin-left: 10px;
83
+ text-align: right;
84
+ }
85
+ .sw-click-to-tweet .alignleft {
86
+ float: left;
87
+ margin-bottom: 10px;
88
+ margin-right: 10px;
89
+ text-align: right;
90
+ }
91
+ .sw-click-to-tweet:after {
92
+ content: ".";
93
+ display: block;
94
+ clear: both;
95
+ visibility: hidden;
96
+ line-height: 0;
97
+ height: 0;
98
+ }
99
+ .sw-click-to-tweet .sw-ctt-reset {
100
+ margin: 0;
101
+ padding: 0;
102
+ position: relative;
103
+ }
104
+ .sw-click-to-tweet:after {
105
+ display: block;
106
+ visibility: hidden;
107
+ height: 0;
108
+ clear: both;
109
+ content: ".";
110
+ }
111
+ .sw-click-to-tweet a {
112
+ text-decoration: none;
113
+ text-transform: none;
114
+ }
115
+ .sw-click-to-tweet a:hover {
116
+ text-decoration: none;
117
+ }
118
+ .sw-click-to-tweet .sw-ctt-text {
119
+ margin: 0;
120
+ padding: 0;
121
+ position: relative;
122
+ margin-bottom: 10px;
123
+ word-wrap: break-word;
124
+ }
125
+ a .sw-click-to-tweet .sw-ctt-text {
126
+ margin: 0;
127
+ padding: 0;
128
+ position: relative;
129
+ color: #999999;
130
+ font-size: 24px;
131
+ line-height: 140%;
132
+ text-transform: none;
133
+ font-weight: 500;
134
+ text-decoration: none;
135
+ text-transform: none;
136
+ display:block;
137
+ }
138
+ a:hover .sw-click-to-tweet .sw-ctt-text {
139
+ text-decoration: none;
140
+ color: #666666;
141
+ }
142
+ .sw-click-to-tweet .sw-ctt-btn {
143
+ margin: 0;
144
+ padding: 3px;
145
+ position: relative;
146
+ display: block;
147
+ text-transform: uppercase;
148
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
149
+ font-size: 12px;
150
+ font-weight: bold;
151
+ line-height: 100%;
152
+ color: #999999;
153
+ float: right;
154
+ padding-right: 24px;
155
+ text-decoration: none;
156
+ background: transparent url("//4.bp.blogspot.com/-Ku-iYrKVffw/VHjB2LFSO1I/AAAAAAAAEyI/NDiWlshts4M/s1600/twitter-little-bird.png") no-repeat right top;
157
+ }
158
+ a:hover .sw-click-to-tweet .sw-ctt-btn {
159
+ text-decoration: none;
160
+ color: #666666;
161
+ text-transform: uppercase;
162
+ }
163
+ .sw-click-to-tweet .sw-powered-by {
164
+ font-size: 10px;
165
+ color: #999999;
166
+ }
167
+ .sw-click-to-tweet .sw-powered-by a {
168
+ font-size: 10px;
169
+ color: #999999 !important;
170
+ }
171
+ .sw-click-to-tweet .sw-powered-by a:hover {
172
+ color: #999999 !important;
173
+ text-decoration: underline !important;
174
+ }
functions/admin/assets/css/style2.css CHANGED
@@ -1,172 +1,172 @@
1
- .sw-tweet-clear {
2
- zoom: 1;
3
- }
4
- .sw-tweet-clear:after {
5
- display: block;
6
- visibility: hidden;
7
- height: 0;
8
- clear: both;
9
- content: ".";
10
- }
11
- .sw-click-to-tweet {
12
- display: block;
13
- background-color: #FFF;
14
- margin: 0;
15
- padding: 0;
16
- position: relative;
17
- border: 4px double #DDD;
18
- -moz-border-radius: 0px;
19
- border-radius: 0px;
20
- padding: 30px 30px;
21
- margin: 15px 0px;
22
- zoom: 1;
23
- }
24
- .sw-click-to-tweet .clearfix {
25
- zoom: 1;
26
- }
27
- .sw-click-to-tweet .clearfix:after {
28
- display: block;
29
- visibility: hidden;
30
- height: 0;
31
- clear: both;
32
- content: ".";
33
- }
34
- .sw-click-to-tweet .clear {
35
- clear: both;
36
- }
37
- .sw-click-to-tweet .f-left {
38
- float: left;
39
- display: inline-block;
40
- position: relative;
41
- }
42
- .sw-click-to-tweet .f-right {
43
- float: right;
44
- display: inline-block;
45
- position: relative;
46
- }
47
- .sw-click-to-tweet .list-reset {
48
- list-style: none;
49
- margin: 0;
50
- padding: 0;
51
- }
52
- .sw-click-to-tweet .list-reset li {
53
- list-style: none;
54
- margin: 0;
55
- padding: 0;
56
- }
57
- .sw-click-to-tweet .list-float {
58
- zoom: 1;
59
- }
60
- .sw-click-to-tweet .list-float:after {
61
- display: block;
62
- visibility: hidden;
63
- height: 0;
64
- clear: both;
65
- content: ".";
66
- }
67
- .sw-click-to-tweet .list-float li {
68
- float: left;
69
- display: inline-block;
70
- }
71
- .sw-click-to-tweet .kill-box-shadow {
72
- box-shadow: none;
73
- -webkit-box-shadow: none;
74
- -moz-box-shadow: none;
75
- }
76
- .sw-click-to-tweet .alignright {
77
- float: right;
78
- margin-bottom: 10px;
79
- margin-left: 10px;
80
- text-align: right;
81
- }
82
- .sw-click-to-tweet .alignleft {
83
- float: left;
84
- margin-bottom: 10px;
85
- margin-right: 10px;
86
- text-align: right;
87
- }
88
- .sw-click-to-tweet:after {
89
- content: ".";
90
- display: block;
91
- clear: both;
92
- visibility: hidden;
93
- line-height: 0;
94
- height: 0;
95
- }
96
- .sw-click-to-tweet .sw-ctt-reset {
97
- margin: 0;
98
- padding: 0;
99
- position: relative;
100
- }
101
- .sw-click-to-tweet:after {
102
- display: block;
103
- visibility: hidden;
104
- height: 0;
105
- clear: both;
106
- content: ".";
107
- }
108
- .sw-click-to-tweet a {
109
- text-decoration: none;
110
- text-transform: none;
111
- }
112
- .sw-click-to-tweet a:hover {
113
- text-decoration: none;
114
- }
115
- .sw-click-to-tweet .sw-ctt-text {
116
- margin: 0;
117
- padding: 0;
118
- position: relative;
119
- margin-bottom: 10px;
120
- word-wrap: break-word;
121
- }
122
- a .sw-click-to-tweet .sw-ctt-text {
123
- margin: 0;
124
- padding: 0;
125
- position: relative;
126
- color: #777;
127
- font-size: 24px;
128
- line-height: 140%;
129
- text-transform: none;
130
- font-weight: 500;
131
- text-decoration: none;
132
- text-transform: none;
133
- font-style: italic;
134
- display:block;
135
- }
136
- a:hover .sw-click-to-tweet .sw-ctt-text {
137
- text-decoration: none;
138
- color: #666666;
139
- }
140
- .sw-click-to-tweet .sw-ctt-btn {
141
- margin: 0;
142
- padding: 3px;
143
- position: relative;
144
- display: block;
145
- text-transform: uppercase;
146
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
147
- font-size: 12px;
148
- font-weight: bold;
149
- line-height: 100%;
150
- color: #999999;
151
- float: right;
152
- padding-right: 24px;
153
- text-decoration: none;
154
- background: transparent url("//4.bp.blogspot.com/-Ku-iYrKVffw/VHjB2LFSO1I/AAAAAAAAEyI/NDiWlshts4M/s1600/twitter-little-bird.png") no-repeat right top;
155
- }
156
- a:hover .sw-click-to-tweet .sw-ctt-btn{
157
- text-decoration: none;
158
- color: #666666;
159
- text-transform: uppercase;
160
- }
161
- .sw-click-to-tweet .sw-powered-by {
162
- font-size: 10px;
163
- color: #999999;
164
- }
165
- .sw-click-to-tweet .sw-powered-by a {
166
- font-size: 10px;
167
- color: #999999 !important;
168
- }
169
- .sw-click-to-tweet .sw-powered-by a:hover {
170
- color: #999999 !important;
171
- text-decoration: underline !important;
172
- }
1
+ .sw-tweet-clear {
2
+ zoom: 1;
3
+ }
4
+ .sw-tweet-clear:after {
5
+ display: block;
6
+ visibility: hidden;
7
+ height: 0;
8
+ clear: both;
9
+ content: ".";
10
+ }
11
+ .sw-click-to-tweet {
12
+ display: block;
13
+ background-color: #FFF;
14
+ margin: 0;
15
+ padding: 0;
16
+ position: relative;
17
+ border: 4px double #DDD;
18
+ -moz-border-radius: 0px;
19
+ border-radius: 0px;
20
+ padding: 30px 30px;
21
+ margin: 15px 0px;
22
+ zoom: 1;
23
+ }
24
+ .sw-click-to-tweet .clearfix {
25
+ zoom: 1;
26
+ }
27
+ .sw-click-to-tweet .clearfix:after {
28
+ display: block;
29
+ visibility: hidden;
30
+ height: 0;
31
+ clear: both;
32
+ content: ".";
33
+ }
34
+ .sw-click-to-tweet .clear {
35
+ clear: both;
36
+ }
37
+ .sw-click-to-tweet .f-left {
38
+ float: left;
39
+ display: inline-block;
40
+ position: relative;
41
+ }
42
+ .sw-click-to-tweet .f-right {
43
+ float: right;
44
+ display: inline-block;
45
+ position: relative;
46
+ }
47
+ .sw-click-to-tweet .list-reset {
48
+ list-style: none;
49
+ margin: 0;
50
+ padding: 0;
51
+ }
52
+ .sw-click-to-tweet .list-reset li {
53
+ list-style: none;
54
+ margin: 0;
55
+ padding: 0;
56
+ }
57
+ .sw-click-to-tweet .list-float {
58
+ zoom: 1;
59
+ }
60
+ .sw-click-to-tweet .list-float:after {
61
+ display: block;
62
+ visibility: hidden;
63
+ height: 0;
64
+ clear: both;
65
+ content: ".";
66
+ }
67
+ .sw-click-to-tweet .list-float li {
68
+ float: left;
69
+ display: inline-block;
70
+ }
71
+ .sw-click-to-tweet .kill-box-shadow {
72
+ box-shadow: none;
73
+ -webkit-box-shadow: none;
74
+ -moz-box-shadow: none;
75
+ }
76
+ .sw-click-to-tweet .alignright {
77
+ float: right;
78
+ margin-bottom: 10px;
79
+ margin-left: 10px;
80
+ text-align: right;
81
+ }
82
+ .sw-click-to-tweet .alignleft {
83
+ float: left;
84
+ margin-bottom: 10px;
85
+ margin-right: 10px;
86
+ text-align: right;
87
+ }
88
+ .sw-click-to-tweet:after {
89
+ content: ".";
90
+ display: block;
91
+ clear: both;
92
+ visibility: hidden;
93
+ line-height: 0;
94
+ height: 0;
95
+ }
96
+ .sw-click-to-tweet .sw-ctt-reset {
97
+ margin: 0;
98
+ padding: 0;
99
+ position: relative;
100
+ }
101
+ .sw-click-to-tweet:after {
102
+ display: block;
103
+ visibility: hidden;
104
+ height: 0;
105
+ clear: both;
106
+ content: ".";
107
+ }
108
+ .sw-click-to-tweet a {
109
+ text-decoration: none;
110
+ text-transform: none;
111
+ }
112
+ .sw-click-to-tweet a:hover {
113
+ text-decoration: none;
114
+ }
115
+ .sw-click-to-tweet .sw-ctt-text {
116
+ margin: 0;
117
+ padding: 0;
118
+ position: relative;
119
+ margin-bottom: 10px;
120
+ word-wrap: break-word;
121
+ }
122
+ a .sw-click-to-tweet .sw-ctt-text {
123
+ margin: 0;
124
+ padding: 0;
125
+ position: relative;
126
+ color: #777;
127
+ font-size: 24px;
128
+ line-height: 140%;
129
+ text-transform: none;
130
+ font-weight: 500;
131
+ text-decoration: none;
132
+ text-transform: none;
133
+ font-style: italic;
134
+ display:block;
135
+ }
136
+ a:hover .sw-click-to-tweet .sw-ctt-text {
137
+ text-decoration: none;
138
+ color: #666666;
139
+ }
140
+ .sw-click-to-tweet .sw-ctt-btn {
141
+ margin: 0;
142
+ padding: 3px;
143
+ position: relative;
144
+ display: block;
145
+ text-transform: uppercase;
146
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
147
+ font-size: 12px;
148
+ font-weight: bold;
149
+ line-height: 100%;
150
+ color: #999999;
151
+ float: right;
152
+ padding-right: 24px;
153
+ text-decoration: none;
154
+ background: transparent url("//4.bp.blogspot.com/-Ku-iYrKVffw/VHjB2LFSO1I/AAAAAAAAEyI/NDiWlshts4M/s1600/twitter-little-bird.png") no-repeat right top;
155
+ }
156
+ a:hover .sw-click-to-tweet .sw-ctt-btn{
157
+ text-decoration: none;
158
+ color: #666666;
159
+ text-transform: uppercase;
160
+ }
161
+ .sw-click-to-tweet .sw-powered-by {
162
+ font-size: 10px;
163
+ color: #999999;
164
+ }
165
+ .sw-click-to-tweet .sw-powered-by a {
166
+ font-size: 10px;
167
+ color: #999999 !important;
168
+ }
169
+ .sw-click-to-tweet .sw-powered-by a:hover {
170
+ color: #999999 !important;
171
+ text-decoration: underline !important;
172
+ }
functions/admin/assets/css/style3.css CHANGED
@@ -1,164 +1,164 @@
1
- .sw-tweet-clear {
2
- zoom: 1;
3
- }
4
- .sw-tweet-clear:after {
5
- display: block;
6
- visibility: hidden;
7
- height: 0;
8
- clear: both;
9
- content: ".";
10
- }
11
- .sw-click-to-tweet {
12
- display: block;
13
- background-color: #60A8DC;
14
- margin: 0;
15
- padding: 0;
16
- position: relative;
17
- padding: 30px 30px;
18
- margin: 15px 0px;
19
- zoom: 1;
20
- border-left:0px solid #60A8DC;
21
- transition: all 0.3s ease-in-out;
22
- }
23
- .sw-click-to-tweet:hover {
24
- background: #5696C4;
25
- border-left: 10px solid #60A8DC;
26
- transition: all 0.3s ease-in-out;
27
- }
28
- .sw-click-to-tweet .clearfix {
29
- zoom: 1;
30
- }
31
- .sw-click-to-tweet .clearfix:after {
32
- display: block;
33
- visibility: hidden;
34
- height: 0;
35
- clear: both;
36
- content: ".";
37
- }
38
- .sw-click-to-tweet .clear {
39
- clear: both;
40
- }
41
- .sw-click-to-tweet .f-left {
42
- float: left;
43
- display: inline-block;
44
- position: relative;
45
- }
46
- .sw-click-to-tweet .f-right {
47
- float: right;
48
- display: inline-block;
49
- position: relative;
50
- }
51
- .sw-click-to-tweet .list-reset {
52
- list-style: none;
53
- margin: 0;
54
- padding: 0;
55
- }
56
- .sw-click-to-tweet .list-reset li {
57
- list-style: none;
58
- margin: 0;
59
- padding: 0;
60
- }
61
- .sw-click-to-tweet .list-float {
62
- zoom: 1;
63
- }
64
- .sw-click-to-tweet .list-float:after {
65
- display: block;
66
- visibility: hidden;
67
- height: 0;
68
- clear: both;
69
- content: ".";
70
- }
71
- .sw-click-to-tweet .list-float li {
72
- float: left;
73
- display: inline-block;
74
- }
75
- .sw-click-to-tweet .kill-box-shadow {
76
- box-shadow: none;
77
- -webkit-box-shadow: none;
78
- -moz-box-shadow: none;
79
- }
80
- .sw-click-to-tweet .alignright {
81
- float: right;
82
- margin-bottom: 10px;
83
- margin-left: 10px;
84
- text-align: right;
85
- }
86
- .sw-click-to-tweet .alignleft {
87
- float: left;
88
- margin-bottom: 10px;
89
- margin-right: 10px;
90
- text-align: right;
91
- }
92
- .sw-click-to-tweet:after {
93
- content: ".";
94
- display: block;
95
- clear: both;
96
- visibility: hidden;
97
- line-height: 0;
98
- height: 0;
99
- }
100
- .sw-click-to-tweet .sw-ctt-reset {
101
- margin: 0;
102
- padding: 0;
103
- position: relative;
104
- }
105
- .sw-click-to-tweet:after {
106
- display: block;
107
- visibility: hidden;
108
- height: 0;
109
- clear: both;
110
- content: ".";
111
- }
112
- .sw-click-to-tweet a {
113
- text-decoration: none;
114
- text-transform: none;
115
- }
116
- .sw-click-to-tweet a:hover {
117
- text-decoration: none;
118
- }
119
- .sw-click-to-tweet .sw-ctt-text {
120
- margin: 0;
121
- padding: 0;
122
- position: relative;
123
- margin-bottom: 10px;
124
- word-wrap: break-word;
125
- }
126
- a .sw-click-to-tweet .sw-ctt-text {
127
- margin: 0;
128
- padding: 0;
129
- position: relative;
130
- color: #FFF;
131
- font-size: 24px;
132
- line-height: 140%;
133
- text-transform: none;
134
- font-weight: 500;
135
- text-decoration: none;
136
- text-transform: none;
137
- font-style: italic;
138
- display:block;
139
- }
140
- a:hover .sw-click-to-tweet .sw-ctt-text {
141
- text-decoration: none;
142
- color: #FFF;
143
- }
144
- .sw-click-to-tweet .sw-ctt-btn {
145
- margin: 0;
146
- padding: 3px;
147
- position: relative;
148
- display: block;
149
- text-transform: uppercase;
150
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
151
- font-size: 12px;
152
- font-weight: bold;
153
- line-height: 100%;
154
- color: #FFF;
155
- float: right;
156
- padding-right: 24px;
157
- text-decoration: none;
158
- background: rgba(0, 0, 0, 0) url("//4.bp.blogspot.com/-JsBK9mPEjWo/VHjB2OUI-uI/AAAAAAAAEyA/NteFI3uXm9U/s1600/twitter-little-bird-white.png") no-repeat right top;
159
- }
160
- a:hover .sw-click-to-tweet .sw-ctt-btn {
161
- text-decoration: none;
162
- color: #FFF;
163
- text-transform: uppercase;
164
- }
1
+ .sw-tweet-clear {
2
+ zoom: 1;
3
+ }
4
+ .sw-tweet-clear:after {
5
+ display: block;
6
+ visibility: hidden;
7
+ height: 0;
8
+ clear: both;
9
+ content: ".";
10
+ }
11
+ .sw-click-to-tweet {
12
+ display: block;
13
+ background-color: #60A8DC;
14
+ margin: 0;
15
+ padding: 0;
16
+ position: relative;
17
+ padding: 30px 30px;
18
+ margin: 15px 0px;
19
+ zoom: 1;
20
+ border-left:0px solid #60A8DC;
21
+ transition: all 0.3s ease-in-out;
22
+ }
23
+ .sw-click-to-tweet:hover {
24
+ background: #5696C4;
25
+ border-left: 10px solid #60A8DC;
26
+ transition: all 0.3s ease-in-out;
27
+ }
28
+ .sw-click-to-tweet .clearfix {
29
+ zoom: 1;
30
+ }
31
+ .sw-click-to-tweet .clearfix:after {
32
+ display: block;
33
+ visibility: hidden;
34
+ height: 0;
35
+ clear: both;
36
+ content: ".";
37
+ }
38
+ .sw-click-to-tweet .clear {
39
+ clear: both;
40
+ }
41
+ .sw-click-to-tweet .f-left {
42
+ float: left;
43
+ display: inline-block;
44
+ position: relative;
45
+ }
46
+ .sw-click-to-tweet .f-right {
47
+ float: right;
48
+ display: inline-block;
49
+ position: relative;
50
+ }
51
+ .sw-click-to-tweet .list-reset {
52
+ list-style: none;
53
+ margin: 0;
54
+ padding: 0;
55
+ }
56
+ .sw-click-to-tweet .list-reset li {
57
+ list-style: none;
58
+ margin: 0;
59
+ padding: 0;
60
+ }
61
+ .sw-click-to-tweet .list-float {
62
+ zoom: 1;
63
+ }
64
+ .sw-click-to-tweet .list-float:after {
65
+ display: block;
66
+ visibility: hidden;
67
+ height: 0;
68
+ clear: both;
69
+ content: ".";
70
+ }
71
+ .sw-click-to-tweet .list-float li {
72
+ float: left;
73
+ display: inline-block;
74
+ }
75
+ .sw-click-to-tweet .kill-box-shadow {
76
+ box-shadow: none;
77
+ -webkit-box-shadow: none;
78
+ -moz-box-shadow: none;
79
+ }
80
+ .sw-click-to-tweet .alignright {
81
+ float: right;
82
+ margin-bottom: 10px;
83
+ margin-left: 10px;
84
+ text-align: right;
85
+ }
86
+ .sw-click-to-tweet .alignleft {
87
+ float: left;
88
+ margin-bottom: 10px;
89
+ margin-right: 10px;
90
+ text-align: right;
91
+ }
92
+ .sw-click-to-tweet:after {
93
+ content: ".";
94
+ display: block;
95
+ clear: both;
96
+ visibility: hidden;
97
+ line-height: 0;
98
+ height: 0;
99
+ }
100
+ .sw-click-to-tweet .sw-ctt-reset {
101
+ margin: 0;
102
+ padding: 0;
103
+ position: relative;
104
+ }
105
+ .sw-click-to-tweet:after {
106
+ display: block;
107
+ visibility: hidden;
108
+ height: 0;
109
+ clear: both;
110
+ content: ".";
111
+ }
112
+ .sw-click-to-tweet a {
113
+ text-decoration: none;
114
+ text-transform: none;
115
+ }
116
+ .sw-click-to-tweet a:hover {
117
+ text-decoration: none;
118
+ }
119
+ .sw-click-to-tweet .sw-ctt-text {
120
+ margin: 0;
121
+ padding: 0;
122
+ position: relative;
123
+ margin-bottom: 10px;
124
+ word-wrap: break-word;
125
+ }
126
+ a .sw-click-to-tweet .sw-ctt-text {
127
+ margin: 0;
128
+ padding: 0;
129
+ position: relative;
130
+ color: #FFF;
131
+ font-size: 24px;
132
+ line-height: 140%;
133
+ text-transform: none;
134
+ font-weight: 500;
135
+ text-decoration: none;
136
+ text-transform: none;
137
+ font-style: italic;
138
+ display:block;
139
+ }
140
+ a:hover .sw-click-to-tweet .sw-ctt-text {
141
+ text-decoration: none;
142
+ color: #FFF;
143
+ }
144
+ .sw-click-to-tweet .sw-ctt-btn {
145
+ margin: 0;
146
+ padding: 3px;
147
+ position: relative;
148
+ display: block;
149
+ text-transform: uppercase;
150
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
151
+ font-size: 12px;
152
+ font-weight: bold;
153
+ line-height: 100%;
154
+ color: #FFF;
155
+ float: right;
156
+ padding-right: 24px;
157
+ text-decoration: none;
158
+ background: rgba(0, 0, 0, 0) url("//4.bp.blogspot.com/-JsBK9mPEjWo/VHjB2OUI-uI/AAAAAAAAEyA/NteFI3uXm9U/s1600/twitter-little-bird-white.png") no-repeat right top;
159
+ }
160
+ a:hover .sw-click-to-tweet .sw-ctt-btn {
161
+ text-decoration: none;
162
+ color: #FFF;
163
+ text-transform: uppercase;
164
+ }
functions/admin/assets/css/style4.css CHANGED
@@ -1,167 +1,167 @@
1
- .sw-CTT {
2
- display:block;
3
- }
4
- .sw-tweet-clear {
5
- zoom: 1;
6
- }
7
- .sw-tweet-clear:after {
8
- display: block;
9
- visibility: hidden;
10
- height: 0;
11
- clear: both;
12
- content: ".";
13
- }
14
- .sw-click-to-tweet {
15
- display: block;
16
- background: #333;
17
- margin: 0;
18
- padding: 0;
19
- position: relative;
20
- padding: 30px 30px;
21
- margin: 15px 0px;
22
- zoom: 1;
23
- border-left:0px solid #60A8DC;
24
- border-left: 10px solid #C33;
25
- transition: all 0.3s ease-in-out;
26
- }
27
- .sw-click-to-tweet:hover {
28
- background: #222;
29
- transition: all 0.3s ease-in-out;
30
- }
31
- .sw-click-to-tweet .clearfix {
32
- zoom: 1;
33
- }
34
- .sw-click-to-tweet .clearfix:after {
35
- display: block;
36
- visibility: hidden;
37
- height: 0;
38
- clear: both;
39
- content: ".";
40
- }
41
- .sw-click-to-tweet .clear {
42
- clear: both;
43
- }
44
- .sw-click-to-tweet .f-left {
45
- float: left;
46
- display: inline-block;
47
- position: relative;
48
- }
49
- .sw-click-to-tweet .f-right {
50
- float: right;
51
- display: inline-block;
52
- position: relative;
53
- }
54
- .sw-click-to-tweet .list-reset {
55
- list-style: none;
56
- margin: 0;
57
- padding: 0;
58
- }
59
- .sw-click-to-tweet .list-reset li {
60
- list-style: none;
61
- margin: 0;
62
- padding: 0;
63
- }
64
- .sw-click-to-tweet .list-float {
65
- zoom: 1;
66
- }
67
- .sw-click-to-tweet .list-float:after {
68
- display: block;
69
- visibility: hidden;
70
- height: 0;
71
- clear: both;
72
- content: ".";
73
- }
74
- .sw-click-to-tweet .list-float li {
75
- float: left;
76
- display: inline-block;
77
- }
78
- .sw-click-to-tweet .kill-box-shadow {
79
- box-shadow: none;
80
- -webkit-box-shadow: none;
81
- -moz-box-shadow: none;
82
- }
83
- .sw-click-to-tweet .alignright {
84
- float: right;
85
- margin-bottom: 10px;
86
- margin-left: 10px;
87
- text-align: right;
88
- }
89
- .sw-click-to-tweet .alignleft {
90
- float: left;
91
- margin-bottom: 10px;
92
- margin-right: 10px;
93
- text-align: right;
94
- }
95
- .sw-click-to-tweet:after {
96
- content: ".";
97
- display: block;
98
- clear: both;
99
- visibility: hidden;
100
- line-height: 0;
101
- height: 0;
102
- }
103
- .sw-click-to-tweet .sw-ctt-reset {
104
- margin: 0;
105
- padding: 0;
106
- position: relative;
107
- }
108
- .sw-click-to-tweet:after {
109
- display: block;
110
- visibility: hidden;
111
- height: 0;
112
- clear: both;
113
- content: ".";
114
- }
115
- a.swp_CTT {
116
- text-decoration: none;
117
- text-transform: none;
118
- }
119
- a.swp_CTT:hover {
120
- text-decoration: none;
121
- }
122
- .sw-click-to-tweet .sw-ctt-text {
123
- margin: 0;
124
- padding: 0;
125
- position: relative;
126
- margin-bottom: 10px;
127
- word-wrap: break-word;
128
- }
129
- a .sw-click-to-tweet .sw-ctt-text {
130
- margin: 0;
131
- padding: 0;
132
- position: relative;
133
- color: #FFF;
134
- font-size: 24px;
135
- line-height: 140%;
136
- text-transform: none;
137
- font-weight: 500;
138
- text-decoration: none;
139
- text-transform: none;
140
- font-style: normal;
141
- display:block;
142
- }
143
- a:hover .sw-click-to-tweet .sw-ctt-text {
144
- text-decoration: none;
145
- color: #FFF;
146
- }
147
- .sw-click-to-tweet .sw-ctt-btn {
148
- margin: 0;
149
- padding: 3px;
150
- position: relative;
151
- display: block;
152
- text-transform: uppercase;
153
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
154
- font-size: 12px;
155
- font-weight: bold;
156
- line-height: 100%;
157
- color: #FFF;
158
- float: right;
159
- padding-right: 24px;
160
- text-decoration: none;
161
- background: rgba(0, 0, 0, 0) url("//4.bp.blogspot.com/-JsBK9mPEjWo/VHjB2OUI-uI/AAAAAAAAEyA/NteFI3uXm9U/s1600/twitter-little-bird-white.png") no-repeat right top;
162
- }
163
- .sw-click-to-tweet .sw-ctt-btn:hover {
164
- text-decoration: none;
165
- color: #FFF;
166
- text-transform: uppercase;
167
- }
1
+ .sw-CTT {
2
+ display:block;
3
+ }
4
+ .sw-tweet-clear {
5
+ zoom: 1;
6
+ }
7
+ .sw-tweet-clear:after {
8
+ display: block;
9
+ visibility: hidden;
10
+ height: 0;
11
+ clear: both;
12
+ content: ".";
13
+ }
14
+ .sw-click-to-tweet {
15
+ display: block;
16
+ background: #333;
17
+ margin: 0;
18
+ padding: 0;
19
+ position: relative;
20
+ padding: 30px 30px;
21
+ margin: 15px 0px;
22
+ zoom: 1;
23
+ border-left:0px solid #60A8DC;
24
+ border-left: 10px solid #C33;
25
+ transition: all 0.3s ease-in-out;
26
+ }
27
+ .sw-click-to-tweet:hover {
28
+ background: #222;
29
+ transition: all 0.3s ease-in-out;
30
+ }
31
+ .sw-click-to-tweet .clearfix {
32
+ zoom: 1;
33
+ }
34
+ .sw-click-to-tweet .clearfix:after {
35
+ display: block;
36
+ visibility: hidden;
37
+ height: 0;
38
+ clear: both;
39
+ content: ".";
40
+ }
41
+ .sw-click-to-tweet .clear {
42
+ clear: both;
43
+ }
44
+ .sw-click-to-tweet .f-left {
45
+ float: left;
46
+ display: inline-block;
47
+ position: relative;
48
+ }
49
+ .sw-click-to-tweet .f-right {
50
+ float: right;
51
+ display: inline-block;
52
+ position: relative;
53
+ }
54
+ .sw-click-to-tweet .list-reset {
55
+ list-style: none;
56
+ margin: 0;
57
+ padding: 0;
58
+ }
59
+ .sw-click-to-tweet .list-reset li {
60
+ list-style: none;
61
+ margin: 0;
62
+ padding: 0;
63
+ }
64
+ .sw-click-to-tweet .list-float {
65
+ zoom: 1;
66
+ }
67
+ .sw-click-to-tweet .list-float:after {
68
+ display: block;
69
+ visibility: hidden;
70
+ height: 0;
71
+ clear: both;
72
+ content: ".";
73
+ }
74
+ .sw-click-to-tweet .list-float li {
75
+ float: left;
76
+ display: inline-block;
77
+ }
78
+ .sw-click-to-tweet .kill-box-shadow {
79
+ box-shadow: none;
80
+ -webkit-box-shadow: none;
81
+ -moz-box-shadow: none;
82
+ }
83
+ .sw-click-to-tweet .alignright {
84
+ float: right;
85
+ margin-bottom: 10px;
86
+ margin-left: 10px;
87
+ text-align: right;
88
+ }
89
+ .sw-click-to-tweet .alignleft {
90
+ float: left;
91
+ margin-bottom: 10px;
92
+ margin-right: 10px;
93
+ text-align: right;
94
+ }
95
+ .sw-click-to-tweet:after {
96
+ content: ".";
97
+ display: block;
98
+ clear: both;
99
+ visibility: hidden;
100
+ line-height: 0;
101
+ height: 0;
102
+ }
103
+ .sw-click-to-tweet .sw-ctt-reset {
104
+ margin: 0;
105
+ padding: 0;
106
+ position: relative;
107
+ }
108
+ .sw-click-to-tweet:after {
109
+ display: block;
110
+ visibility: hidden;
111
+ height: 0;
112
+ clear: both;
113
+ content: ".";
114
+ }
115
+ a.swp_CTT {
116
+ text-decoration: none;
117
+ text-transform: none;
118
+ }
119
+ a.swp_CTT:hover {
120
+ text-decoration: none;
121
+ }
122
+ .sw-click-to-tweet .sw-ctt-text {
123
+ margin: 0;
124
+ padding: 0;
125
+ position: relative;
126
+ margin-bottom: 10px;
127
+ word-wrap: break-word;
128
+ }
129
+ a .sw-click-to-tweet .sw-ctt-text {
130
+ margin: 0;
131
+ padding: 0;
132
+ position: relative;
133
+ color: #FFF;
134
+ font-size: 24px;
135
+ line-height: 140%;
136
+ text-transform: none;
137
+ font-weight: 500;
138
+ text-decoration: none;
139
+ text-transform: none;
140
+ font-style: normal;
141
+ display:block;
142
+ }
143
+ a:hover .sw-click-to-tweet .sw-ctt-text {
144
+ text-decoration: none;
145
+ color: #FFF;
146
+ }
147
+ .sw-click-to-tweet .sw-ctt-btn {
148
+ margin: 0;
149
+ padding: 3px;
150
+ position: relative;
151
+ display: block;
152
+ text-transform: uppercase;
153
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
154
+ font-size: 12px;
155
+ font-weight: bold;
156
+ line-height: 100%;
157
+ color: #FFF;
158
+ float: right;
159
+ padding-right: 24px;
160
+ text-decoration: none;
161
+ background: rgba(0, 0, 0, 0) url("//4.bp.blogspot.com/-JsBK9mPEjWo/VHjB2OUI-uI/AAAAAAAAEyA/NteFI3uXm9U/s1600/twitter-little-bird-white.png") no-repeat right top;
162
+ }
163
+ .sw-click-to-tweet .sw-ctt-btn:hover {
164
+ text-decoration: none;
165
+ color: #FFF;
166
+ text-transform: uppercase;
167
+ }
functions/admin/assets/css/styles.css CHANGED
@@ -1,170 +1,170 @@
1
- .tm-tweet-clear {
2
- zoom: 1;
3
- }
4
- .tm-tweet-clear:after {
5
- display: block;
6
- visibility: hidden;
7
- height: 0;
8
- clear: both;
9
- content: ".";
10
- }
11
- .tm-click-to-tweet {
12
- display: block;
13
- background-color: #fff;
14
- margin: 0;
15
- padding: 0;
16
- position: relative;
17
- border: 1px solid #dddddd;
18
- -moz-border-radius: 4px;
19
- border-radius: 4px;
20
- padding: 15px 30px;
21
- margin: 15px 0px;
22
- zoom: 1;
23
- }
24
- .tm-click-to-tweet .clearfix {
25
- zoom: 1;
26
- }
27
- .tm-click-to-tweet .clearfix:after {
28
- display: block;
29
- visibility: hidden;
30
- height: 0;
31
- clear: both;
32
- content: ".";
33
- }
34
- .tm-click-to-tweet .clear {
35
- clear: both;
36
- }
37
- .tm-click-to-tweet .f-left {
38
- float: left;
39
- display: inline-block;
40
- position: relative;
41
- }
42
- .tm-click-to-tweet .f-right {
43
- float: right;
44
- display: inline-block;
45
- position: relative;
46
- }
47
- .tm-click-to-tweet .list-reset {
48
- list-style: none;
49
- margin: 0;
50
- padding: 0;
51
- }
52
- .tm-click-to-tweet .list-reset li {
53
- list-style: none;
54
- margin: 0;
55
- padding: 0;
56
- }
57
- .tm-click-to-tweet .list-float {
58
- zoom: 1;
59
- }
60
- .tm-click-to-tweet .list-float:after {
61
- display: block;
62
- visibility: hidden;
63
- height: 0;
64
- clear: both;
65
- content: ".";
66
- }
67
- .tm-click-to-tweet .list-float li {
68
- float: left;
69
- display: inline-block;
70
- }
71
- .tm-click-to-tweet .kill-box-shadow {
72
- box-shadow: none;
73
- -webkit-box-shadow: none;
74
- -moz-box-shadow: none;
75
- }
76
- .tm-click-to-tweet .alignright {
77
- float: right;
78
- margin-bottom: 10px;
79
- margin-left: 10px;
80
- text-align: right;
81
- }
82
- .tm-click-to-tweet .alignleft {
83
- float: left;
84
- margin-bottom: 10px;
85
- margin-right: 10px;
86
- text-align: right;
87
- }
88
- .tm-click-to-tweet:after {
89
- content: ".";
90
- display: block;
91
- clear: both;
92
- visibility: hidden;
93
- line-height: 0;
94
- height: 0;
95
- }
96
- .tm-click-to-tweet .tm-ctt-reset {
97
- margin: 0;
98
- padding: 0;
99
- position: relative;
100
- }
101
- .tm-click-to-tweet:after {
102
- display: block;
103
- visibility: hidden;
104
- height: 0;
105
- clear: both;
106
- content: ".";
107
- }
108
- .tm-click-to-tweet a {
109
- text-decoration: none;
110
- text-transform: none;
111
- }
112
- .tm-click-to-tweet a:hover {
113
- text-decoration: none;
114
- }
115
- .tm-click-to-tweet .tm-ctt-text {
116
- margin: 0;
117
- padding: 0;
118
- position: relative;
119
- margin-bottom: 10px;
120
- word-wrap: break-word;
121
- }
122
- .tm-click-to-tweet .tm-ctt-text a {
123
- margin: 0;
124
- padding: 0;
125
- position: relative;
126
- color: #999999;
127
- font-size: 24px;
128
- line-height: 140%;
129
- text-transform: none;
130
- font-weight: 500;
131
- text-decoration: none;
132
- text-transform: none;
133
- }
134
- .tm-click-to-tweet .tm-ctt-text a:hover {
135
- text-decoration: none;
136
- color: #666666;
137
- }
138
- .tm-click-to-tweet a.tm-ctt-btn {
139
- margin: 0;
140
- padding: 0;
141
- position: relative;
142
- display: block;
143
- text-transform: uppercase;
144
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
145
- font-size: 12px;
146
- font-weight: bold;
147
- line-height: 100%;
148
- color: #999999;
149
- float: right;
150
- padding-right: 24px;
151
- text-decoration: none;
152
- background: transparent url(../img/twitter-little-bird.png) no-repeat right top;
153
- }
154
- .tm-click-to-tweet a.tm-ctt-btn:hover {
155
- text-decoration: none;
156
- color: #666666;
157
- text-transform: uppercase;
158
- }
159
- .tm-click-to-tweet .tm-powered-by {
160
- font-size: 10px;
161
- color: #999999;
162
- }
163
- .tm-click-to-tweet .tm-powered-by a {
164
- font-size: 10px;
165
- color: #999999 !important;
166
- }
167
- .tm-click-to-tweet .tm-powered-by a:hover {
168
- color: #999999 !important;
169
- text-decoration: underline !important;
170
- }
1
+ .tm-tweet-clear {
2
+ zoom: 1;
3
+ }
4
+ .tm-tweet-clear:after {
5
+ display: block;
6
+ visibility: hidden;
7
+ height: 0;
8
+ clear: both;
9
+ content: ".";
10
+ }
11
+ .tm-click-to-tweet {
12
+ display: block;
13
+ background-color: #fff;
14
+ margin: 0;
15
+ padding: 0;
16
+ position: relative;
17
+ border: 1px solid #dddddd;
18
+ -moz-border-radius: 4px;
19
+ border-radius: 4px;
20
+ padding: 15px 30px;
21
+ margin: 15px 0px;
22
+ zoom: 1;
23
+ }
24
+ .tm-click-to-tweet .clearfix {
25
+ zoom: 1;
26
+ }
27
+ .tm-click-to-tweet .clearfix:after {
28
+ display: block;
29
+ visibility: hidden;
30
+ height: 0;
31
+ clear: both;
32
+ content: ".";
33
+ }
34
+ .tm-click-to-tweet .clear {
35
+ clear: both;
36
+ }
37
+ .tm-click-to-tweet .f-left {
38
+ float: left;
39
+ display: inline-block;
40
+ position: relative;
41
+ }
42
+ .tm-click-to-tweet .f-right {
43
+ float: right;
44
+ display: inline-block;
45
+ position: relative;
46
+ }
47
+ .tm-click-to-tweet .list-reset {
48
+ list-style: none;
49
+ margin: 0;
50
+ padding: 0;
51
+ }
52
+ .tm-click-to-tweet .list-reset li {
53
+ list-style: none;
54
+ margin: 0;
55
+ padding: 0;
56
+ }
57
+ .tm-click-to-tweet .list-float {
58
+ zoom: 1;
59
+ }
60
+ .tm-click-to-tweet .list-float:after {
61
+ display: block;
62
+ visibility: hidden;
63
+ height: 0;
64
+ clear: both;
65
+ content: ".";
66
+ }
67
+ .tm-click-to-tweet .list-float li {
68
+ float: left;
69
+ display: inline-block;
70
+ }
71
+ .tm-click-to-tweet .kill-box-shadow {
72
+ box-shadow: none;
73
+ -webkit-box-shadow: none;
74
+ -moz-box-shadow: none;
75
+ }
76
+ .tm-click-to-tweet .alignright {
77
+ float: right;
78
+ margin-bottom: 10px;
79
+ margin-left: 10px;
80
+ text-align: right;
81
+ }
82
+ .tm-click-to-tweet .alignleft {
83
+ float: left;
84
+ margin-bottom: 10px;
85
+ margin-right: 10px;
86
+ text-align: right;
87
+ }
88
+ .tm-click-to-tweet:after {
89
+ content: ".";
90
+ display: block;
91
+ clear: both;
92
+ visibility: hidden;
93
+ line-height: 0;
94
+ height: 0;
95
+ }
96
+ .tm-click-to-tweet .tm-ctt-reset {
97
+ margin: 0;
98
+ padding: 0;
99
+ position: relative;
100
+ }
101
+ .tm-click-to-tweet:after {
102
+ display: block;
103
+ visibility: hidden;
104
+ height: 0;
105
+ clear: both;
106
+ content: ".";
107
+ }
108
+ .tm-click-to-tweet a {
109
+ text-decoration: none;
110
+ text-transform: none;
111
+ }
112
+ .tm-click-to-tweet a:hover {
113
+ text-decoration: none;
114
+ }
115
+ .tm-click-to-tweet .tm-ctt-text {
116
+ margin: 0;
117
+ padding: 0;
118
+ position: relative;
119
+ margin-bottom: 10px;
120
+ word-wrap: break-word;
121
+ }
122
+ .tm-click-to-tweet .tm-ctt-text a {
123
+ margin: 0;
124
+ padding: 0;
125
+ position: relative;
126
+ color: #999999;
127
+ font-size: 24px;
128
+ line-height: 140%;
129
+ text-transform: none;
130
+ font-weight: 500;
131
+ text-decoration: none;
132
+ text-transform: none;
133
+ }
134
+ .tm-click-to-tweet .tm-ctt-text a:hover {
135
+ text-decoration: none;
136
+ color: #666666;
137
+ }
138
+ .tm-click-to-tweet a.tm-ctt-btn {
139
+ margin: 0;
140
+ padding: 0;
141
+ position: relative;
142
+ display: block;
143
+ text-transform: uppercase;
144
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
145
+ font-size: 12px;
146
+ font-weight: bold;
147
+ line-height: 100%;
148
+ color: #999999;
149
+ float: right;
150
+ padding-right: 24px;
151
+ text-decoration: none;
152
+ background: transparent url(../img/twitter-little-bird.png) no-repeat right top;
153
+ }
154
+ .tm-click-to-tweet a.tm-ctt-btn:hover {
155
+ text-decoration: none;
156
+ color: #666666;
157
+ text-transform: uppercase;
158
+ }
159
+ .tm-click-to-tweet .tm-powered-by {
160
+ font-size: 10px;
161
+ color: #999999;
162
+ }
163
+ .tm-click-to-tweet .tm-powered-by a {
164
+ font-size: 10px;
165
+ color: #999999 !important;
166
+ }
167
+ .tm-click-to-tweet .tm-powered-by a:hover {
168
+ color: #999999 !important;
169
+ text-decoration: underline !important;
170
+ }
functions/admin/assets/js/clickToTweet.js CHANGED
@@ -1,135 +1,135 @@
1
- /* globals socialWarfareAdmin */
2
-
3
-
4
- (function() {
5
- tinymce.PluginManager.add('click_to_tweet', function( editor, url ) {
6
- editor.addButton( 'click_to_tweet', {
7
- title: 'Click to Tweet by Social Warfare',
8
- icon: 'sw sw swp_twitter_icon',
9
- onclick: function() {
10
- editor.windowManager.open( {
11
- title: 'Build Your "Click to Tweet"',
12
- class: 'swp_ctt',
13
- body: [
14
- {
15
- type: 'textbox',
16
- multiline: true,
17
- style: 'height:50px',
18
- name: 'tweet',
19
- label: 'The Tweet that will be sent out on Twitter.',
20
- onkeyup: function() {
21
- var value = jQuery( '.mce-first textarea' ).val();
22
- var strLength = value.length;
23
- var handle = jQuery( '#social_warfare .twitterIDWrapper label' ).html();
24
-
25
- if (value.indexOf( 'http' ) > -1 || value.indexOf( 'https' ) > -1) {
26
- linkSpace = 0;
27
- } else {
28
- linkSpace = 23;
29
- };
30
-
31
- if (typeof handle === 'undefined') {
32
- var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace;
33
- } else {
34
- var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace - handle.length - 6;
35
- }
36
- if (remaining > 1 || remaining == 0) {
37
- jQuery( '.tweetCounter' ).css( {'color':'green'} ).text( remaining + ' characters' );
38
- } else if (remaining == 1) {
39
- jQuery( '.tweetCounter' ).css( {'color':'green'} ).text( remaining + ' character' );
40
- } else if (remaining < 0) {
41
- jQuery( '.tweetCounter' ).css( {'color':'red'} ).text( remaining + ' characters' );
42
- }
43
- },
44
- class: 'tweetCounting'
45
- },
46
- {
47
- type: 'label',
48
- name: 'someHelpText',
49
- onPostRender : function() {
50
- var value = jQuery( '.mce-first textarea' ).val();
51
- var strLength = value.length;
52
- var handle = jQuery( '#social_warfare .twitterIDWrapper label' ).html();
53
-
54
- if (value.indexOf( 'http' ) > -1 || value.indexOf( 'https' ) > -1) {
55
- linkSpace = 0;
56
- } else {
57
- linkSpace = 23;
58
- };
59
-
60
- if (typeof handle === 'undefined') {
61
- var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace;
62
- } else {
63
- var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace - handle.length - 6;
64
- }
65
- if ( 'undefined' === typeof handle ) {
66
- this.getEl().innerHTML = '<span style="float:right;">Based on a link being added and the current content above, you have <span class="tweetCounter" style="color:green">' + remaining + ' characters</span> remaining.</span>';
67
- } else {
68
- this.getEl().innerHTML = '<span style="float:right;">Based on your username (' + handle + '), a link being added, and the current content above, you have <span class="tweetCounter" style="color:green">' + remaining + ' characters</span> remaining.</span>';
69
- }
70
- },
71
- text: ''},
72
- {
73
- type: 'textbox',
74
- multiline: true,
75
- style: 'height:50px',
76
- name: 'quote',
77
- label: 'The quote as it will appear in your article.'
78
- },{
79
- type: 'label',
80
- name: 'someHelpText2',
81
- onPostRender : function() {
82
- this.getEl().innerHTML =
83
- '<div style="width:650px;">&nbsp;</div>';},
84
- text: ''},
85
-
86
- {type: 'listbox',
87
- name: 'theme',
88
- label: 'Visual Theme',
89
- 'values': [
90
- {text: 'Default', value: 'default'},
91
- {text: 'Send Her My Love', value: 'style1'},
92
- {text: 'Roll With The Changes', value: 'style2'},
93
- {text: 'Free Bird', value: 'style3'},
94
- {text: 'Don\'t Stop Believin\'', value: 'style4'},
95
- {text: 'Thunderstruck', value: 'style5'},
96
- {text: 'Livin\' On A Prayer', value: 'style6'},
97
- ],
98
- },
99
- ],
100
- onsubmit: function( e ) {
101
-
102
- var value = jQuery( '.mce-first textarea' ).val();
103
- var strLength = value.length;
104
- var handle = jQuery( '#social_warfare .twitterIDWrapper label' ).html();
105
-
106
- if (value.indexOf( 'http' ) > -1 || value.indexOf( 'https' ) > -1) {
107
- linkSpace = 0;
108
- } else {
109
- linkSpace = 23;
110
- };
111
-
112
- if (typeof handle === 'undefined') {
113
- var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace;
114
- } else {
115
- var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace - handle.length - 6;
116
- }
117
-
118
- if (e.data.tweet === '' || e.data.quote === '') {
119
- editor.windowManager.alert( 'Please, fill in both fields.' );
120
- return false;
121
- } else if (remaining < 0) {
122
- editor.windowManager.alert( 'You have too many characters in your tweet.' );
123
- return false;
124
- }
125
- if (e.data.theme == 'default') {
126
- editor.insertContent( '[click_to_tweet tweet="' + e.data.tweet.replace( /"/g,'\'' ) + '" quote="' + e.data.quote.replace( /"/g,'\'' ) + '"]' );
127
- } else {
128
- editor.insertContent( '[click_to_tweet tweet="' + e.data.tweet.replace( /"/g,'\'' ) + '" quote="' + e.data.quote.replace( /"/g,'\'' ) + '" theme="' + e.data.theme + '"]' );
129
- }
130
- }
131
- });
132
- }
133
- });
134
- });
135
- })();
1
+ /* globals socialWarfareAdmin */
2
+
3
+
4
+ (function() {
5
+ tinymce.PluginManager.add('click_to_tweet', function( editor, url ) {
6
+ editor.addButton( 'click_to_tweet', {
7
+ title: 'Click to Tweet by Social Warfare',
8
+ icon: 'sw sw swp_twitter_icon',
9
+ onclick: function() {
10
+ editor.windowManager.open( {
11
+ title: 'Build Your "Click to Tweet"',
12
+ class: 'swp_ctt',
13
+ body: [
14
+ {
15
+ type: 'textbox',
16
+ multiline: true,
17
+ style: 'height:50px',
18
+ name: 'tweet',
19
+ label: 'The Tweet that will be sent out on Twitter.',
20
+ onkeyup: function() {
21
+ var value = jQuery( '.mce-first textarea' ).val();
22
+ var strLength = value.length;
23
+ var handle = jQuery( '#social_warfare .twitterIDWrapper label' ).html();
24
+
25
+ if (value.indexOf( 'http' ) > -1 || value.indexOf( 'https' ) > -1) {
26
+ linkSpace = 0;
27
+ } else {
28
+ linkSpace = 23;
29
+ };
30
+
31
+ if (typeof handle === 'undefined') {
32
+ var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace;
33
+ } else {
34
+ var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace - handle.length - 6;
35
+ }
36
+ if (remaining > 1 || remaining == 0) {
37
+ jQuery( '.tweetCounter' ).css( {'color':'green'} ).text( remaining + ' characters' );
38
+ } else if (remaining == 1) {
39
+ jQuery( '.tweetCounter' ).css( {'color':'green'} ).text( remaining + ' character' );
40
+ } else if (remaining < 0) {
41
+ jQuery( '.tweetCounter' ).css( {'color':'red'} ).text( remaining + ' characters' );
42
+ }
43
+ },
44
+ class: 'tweetCounting'
45
+ },
46
+ {
47
+ type: 'label',
48
+ name: 'someHelpText',
49
+ onPostRender : function() {
50
+ var value = jQuery( '.mce-first textarea' ).val();
51
+ var strLength = value.length;
52
+ var handle = jQuery( '#social_warfare .twitterIDWrapper label' ).html();
53
+
54
+ if (value.indexOf( 'http' ) > -1 || value.indexOf( 'https' ) > -1) {
55
+ linkSpace = 0;
56
+ } else {
57
+ linkSpace = 23;
58
+ };
59
+
60
+ if (typeof handle === 'undefined') {
61
+ var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace;
62
+ } else {
63
+ var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace - handle.length - 6;
64
+ }
65
+ if ( 'undefined' === typeof handle ) {
66
+ this.getEl().innerHTML = '<span style="float:right;">Based on a link being added and the current content above, you have <span class="tweetCounter" style="color:green">' + remaining + ' characters</span> remaining.</span>';
67
+ } else {
68
+ this.getEl().innerHTML = '<span style="float:right;">Based on your username (' + handle + '), a link being added, and the current content above, you have <span class="tweetCounter" style="color:green">' + remaining + ' characters</span> remaining.</span>';
69
+ }
70
+ },
71
+ text: ''},
72
+ {
73
+ type: 'textbox',
74
+ multiline: true,
75
+ style: 'height:50px',
76
+ name: 'quote',
77
+ label: 'The quote as it will appear in your article.'
78
+ },{
79
+ type: 'label',
80
+ name: 'someHelpText2',
81
+ onPostRender : function() {
82
+ this.getEl().innerHTML =
83
+ '<div style="width:650px;">&nbsp;</div>';},
84
+ text: ''},
85
+
86
+ {type: 'listbox',
87
+ name: 'theme',
88
+ label: 'Visual Theme',
89
+ 'values': [
90
+ {text: 'Default', value: 'default'},
91
+ {text: 'Send Her My Love', value: 'style1'},
92
+ {text: 'Roll With The Changes', value: 'style2'},
93
+ {text: 'Free Bird', value: 'style3'},
94
+ {text: 'Don\'t Stop Believin\'', value: 'style4'},
95
+ {text: 'Thunderstruck', value: 'style5'},
96
+ {text: 'Livin\' On A Prayer', value: 'style6'},
97
+ ],
98
+ },
99
+ ],
100
+ onsubmit: function( e ) {
101
+
102
+ var value = jQuery( '.mce-first textarea' ).val();
103
+ var strLength = value.length;
104
+ var handle = jQuery( '#social_warfare .twitterIDWrapper label' ).html();
105
+
106
+ if (value.indexOf( 'http' ) > -1 || value.indexOf( 'https' ) > -1) {
107
+ linkSpace = 0;
108
+ } else {
109
+ linkSpace = 23;
110
+ };
111
+
112
+ if (typeof handle === 'undefined') {
113
+ var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace;
114
+ } else {
115
+ var remaining = 280 - socialWarfareAdmin.linkLength( value ) - linkSpace - handle.length - 6;
116
+ }
117
+
118
+ if (e.data.tweet === '' || e.data.quote === '') {
119
+ editor.windowManager.alert( 'Please, fill in both fields.' );
120
+ return false;
121
+ } else if (remaining < 0) {
122
+ editor.windowManager.alert( 'You have too many characters in your tweet.' );
123
+ return false;
124
+ }
125
+ if (e.data.theme == 'default') {
126
+ editor.insertContent( '[click_to_tweet tweet="' + e.data.tweet.replace( /"/g,'\'' ) + '" quote="' + e.data.quote.replace( /"/g,'\'' ) + '"]' );
127
+ } else {
128
+ editor.insertContent( '[click_to_tweet tweet="' + e.data.tweet.replace( /"/g,'\'' ) + '" quote="' + e.data.quote.replace( /"/g,'\'' ) + '" theme="' + e.data.theme + '"]' );
129
+ }
130
+ }
131
+ });
132
+ }
133
+ });
134
+ });
135
+ })();
functions/admin/assets/js/tmclicktotweet_plugin.js CHANGED
@@ -1,28 +1,28 @@
1
- (function() {
2
- tinymce.create('tinymce.plugins.TMClickToTweet', {
3
- init: function(ed, url) {
4
- ed.addButton('tmclicktotweet', {
5
- title: 'tmclicktotweet.quickaddd',
6
- image: url.replace( "/js", "" ) + '/img/twitter-little-bird-button.png',
7
- onclick: function() {
8
- var m = prompt( "Click To Tweet", "Enter your tweets" );
9
- if (m != null && m != 'undefined' && m != 'Enter your tweets' && m != '') { ed.execCommand( 'mceInsertContent', false, '[Tweet "' + m + '"]' );
10
- }
11
- }
12
- });
13
- },
14
- createControl: function(n, cm) {
15
- return null;
16
- },
17
- getInfo: function() {
18
- return {
19
- longname: "Click To Tweet by Todaymade",
20
- author: 'Todaymade',
21
- authorurl: 'http://coschedule.com/',
22
- infourl: 'http://coschedule.com/click-to-tweet',
23
- version: "1.0"
24
- };
25
- }
26
- });
27
- tinymce.PluginManager.add( 'tmclicktotweet', tinymce.plugins.TMClickToTweet );
28
- })();
1
+ (function() {
2
+ tinymce.create('tinymce.plugins.TMClickToTweet', {
3
+ init: function(ed, url) {
4
+ ed.addButton('tmclicktotweet', {
5
+ title: 'tmclicktotweet.quickaddd',
6
+ image: url.replace( "/js", "" ) + '/img/twitter-little-bird-button.png',
7
+ onclick: function() {
8
+ var m = prompt( "Click To Tweet", "Enter your tweets" );
9
+ if (m != null && m != 'undefined' && m != 'Enter your tweets' && m != '') { ed.execCommand( 'mceInsertContent', false, '[Tweet "' + m + '"]' );
10
+ }
11
+ }
12
+ });
13
+ },
14
+ createControl: function(n, cm) {
15
+ return null;
16
+ },
17
+ getInfo: function() {
18
+ return {
19
+ longname: "Click To Tweet by Todaymade",
20
+ author: 'Todaymade',
21
+ authorurl: 'http://coschedule.com/',
22
+ infourl: 'http://coschedule.com/click-to-tweet',
23
+ version: "1.0"
24
+ };
25
+ }
26
+ });
27
+ tinymce.PluginManager.add( 'tmclicktotweet', tinymce.plugins.TMClickToTweet );
28
+ })();
functions/admin/options-fetch.php CHANGED
@@ -1,156 +1,156 @@
1
- <?php
2
- /**
3
- * Functions for getting and setting the plugin's options.
4
- *
5
- * @package SocialWarfare\Functions
6
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
- * @license GPL-3.0+
8
- * @since 1.0.0
9
- */
10
-
11
- defined( 'WPINC' ) || die;
12
-
13
- // Set the global options variable
14
- global $swp_user_options;
15
-
16
- /**
17
- * $swp_user_options Fetch the available options that the user has set
18
- * @var array An array of available options from the options page
19
- */
20
- $swp_user_options = swp_get_user_options( is_admin() );
21
-
22
- /**
23
- * A function to adjust the options and ensure that defaults are set
24
- *
25
- * @param boolean $admin A boolean value to determine if it's being called in the admin or elsewhere
26
- * @return array $options The modified options array
27
- */
28
- function swp_get_user_options( $admin = false ) {
29
- $options = get_option( 'social_warfare_settings', array() );
30
- return $options;
31
-
32
-
33
- if(isset($options['activate_tweet_counts']) && true == $options['activate_tweet_counts'] && !isset($options['tweet_count_source']) ) {
34
- $options['tweet_count_source'] = 'newsharecounts';
35
- }
36
-
37
- /**
38
- * Set the default og:type values for each post type
39
- *
40
- */
41
- $swp_post_types = swp_get_post_types();
42
-
43
- // Make the side custom absorb the main custom color if they haven't set one yet.
44
- if(empty($options['single_custom_color']) ):
45
- $options['single_custom_color'] = $options['custom_color'];
46
- endif;
47
-
48
- // Force the plugin off on certain post types.
49
- $options['locationattachment'] = 'none';
50
- $options['locationrevision'] = 'none';
51
- $options['nav_menu_item'] = 'none';
52
- $options['shop_order'] = 'none';
53
- $options['shop_order_refund'] = 'none';
54
- $options['shop_coupon'] = 'none';
55
- $options['shop_webhook'] = 'none';
56
-
57
- if( function_exists('is_swp_registered') ):
58
- $swp_registration = is_swp_addon_registered('pro');
59
- else:
60
- $swp_registration = false;
61
- endif;
62
-
63
- if ( $admin || true === $swp_registration ) :
64
- if ( 'total_shares' === $options['totals_alignment'] ) :
65
- $options['totals_alignment'] = 'totals_right';
66
- endif;
67
- else:
68
- $options['twitter_cards'] = false;
69
- $options['button_shape'] = 'flat_fresh';
70
- $options['default_colors'] = 'full_color';
71
- $options['single_colors'] = 'full_color';
72
- $options['hover_colors'] = 'full_color';
73
- $options['float_default_colors'] = 'full_color';
74
- $options['float_single_colors'] = 'full_color';
75
- $options['float_hover_colors'] = 'full_color';
76
- $options['float_style_source'] = true;
77
- $options['button_size'] = 1;
78
- $options['button_alignment'] = 'full_width';
79
- $options['ctt_theme'] = 'style1';
80
- $options['ctt_css'] = "";
81
- $options['twitter_shares'] = false;
82
- $options['recover_shares'] = false;
83
- $options['google_analtyics'] = false;
84
- $options['bitly_authentication'] = false;
85
- $options['minimum_shares'] = 0;
86
- $options['swp_click_tracking'] = false;
87
- $options['order_of_icons'] = 'manual';
88
- $options['pinit_toggle'] = false;
89
- $options['pinit_location_horizontal'] = 'center';
90
- $options['pinit_location_vertical'] = 'top';
91
- $options['emphasize_icons'] = 0;
92
- $options['float_mobile'] = 'off';
93
- $options['pin_browser_extension'] = false;
94
- $options['pinterest_image_location'] = 'hidden';
95
- $options['pinterest_fallback'] = 'all';
96
- endif;
97
-
98
- if(isset($options['order_of_icons']['active'])) {
99
- unset($options['order_of_icons']['active']);
100
- }
101
-
102
- /**
103
- * Unset any buttons that may have been put into the options but are no longer actually available
104
- *
105
- */
106
- }
107
-
108
- /**
109
- * Fetch a single option
110
- *
111
- * @since unknown
112
- * @param string $key The key to pull from the array of options.
113
- * @return mixed $options The value of the desired option
114
- */
115
- function swp_get_single_option( $key ) {
116
- global $swp_user_options;
117
-
118
- if ( isset( $swp_user_options[ $key ] ) ) {
119
- return $swp_user_options[ $key ];
120
- }
121
-
122
- return false;
123
- }
124
-
125
- /**
126
- * Update the main plugin options.
127
- *
128
- * @since 2.1.0
129
- * @param array $options The option values to be set.
130
- * @return bool True if the option has been updated.
131
- */
132
- function swp_update_options( $options ) {
133
- if ( ! is_array( $options ) ) {
134
- return false;
135
- }
136
-
137
- unset( $options['orderOfIcons'] );
138
-
139
- return update_option( 'social_warfare_settings', $options );
140
- }
141
-
142
- /**
143
- * Update a single option.
144
- *
145
- * @since 2.1.0
146
- * @param string $key The key to set in the array of options.
147
- * @param mixed $value The option value to be set.
148
- * @return bool True if the option has been updated.
149
- */
150
- function swp_update_option( $key, $value ) {
151
- $options = get_option( 'social_warfare_settings', array() );
152
-
153
- $options[ $key ] = $value;
154
-
155
- return swp_update_options( $options );
156
- }
1
+ <?php
2
+ /**
3
+ * Functions for getting and setting the plugin's options.
4
+ *
5
+ * @package SocialWarfare\Functions
6
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
+ * @license GPL-3.0+
8
+ * @since 1.0.0
9
+ */
10
+
11
+ defined( 'WPINC' ) || die;
12
+
13
+ // Set the global options variable
14
+ global $swp_user_options;
15
+
16
+ /**
17
+ * $swp_user_options Fetch the available options that the user has set
18
+ * @var array An array of available options from the options page
19
+ */
20
+ $swp_user_options = swp_get_user_options( is_admin() );
21
+
22
+ /**
23
+ * A function to adjust the options and ensure that defaults are set
24
+ *
25
+ * @param boolean $admin A boolean value to determine if it's being called in the admin or elsewhere
26
+ * @return array $options The modified options array
27
+ */
28
+ function swp_get_user_options( $admin = false ) {
29
+ $options = get_option( 'social_warfare_settings', array() );
30
+ return $options;
31
+
32
+
33
+ if(isset($options['activate_tweet_counts']) && true == $options['activate_tweet_counts'] && !isset($options['tweet_count_source']) ) {
34
+ $options['tweet_count_source'] = 'newsharecounts';
35
+ }
36
+
37
+ /**
38
+ * Set the default og:type values for each post type
39
+ *
40
+ */
41
+ $swp_post_types = swp_get_post_types();
42
+
43
+ // Make the side custom absorb the main custom color if they haven't set one yet.
44
+ if(empty($options['single_custom_color']) ):
45
+ $options['single_custom_color'] = $options['custom_color'];
46
+ endif;
47
+
48
+ // Force the plugin off on certain post types.
49
+ $options['locationattachment'] = 'none';
50
+ $options['locationrevision'] = 'none';
51
+ $options['nav_menu_item'] = 'none';
52
+ $options['shop_order'] = 'none';
53
+ $options['shop_order_refund'] = 'none';
54
+ $options['shop_coupon'] = 'none';
55
+ $options['shop_webhook'] = 'none';
56
+
57
+ if( function_exists('is_swp_registered') ):
58
+ $swp_registration = is_swp_addon_registered('pro');
59
+ else:
60
+ $swp_registration = false;
61
+ endif;
62
+
63
+ if ( $admin || true === $swp_registration ) :
64
+ if ( 'total_shares' === $options['totals_alignment'] ) :
65
+ $options['totals_alignment'] = 'totals_right';
66
+ endif;
67
+ else:
68
+ $options['twitter_cards'] = false;
69
+ $options['button_shape'] = 'flat_fresh';
70
+ $options['default_colors'] = 'full_color';
71
+ $options['single_colors'] = 'full_color';
72
+ $options['hover_colors'] = 'full_color';
73
+ $options['float_default_colors'] = 'full_color';
74
+ $options['float_single_colors'] = 'full_color';
75
+ $options['float_hover_colors'] = 'full_color';
76
+ $options['float_style_source'] = true;
77
+ $options['button_size'] = 1;
78
+ $options['button_alignment'] = 'full_width';
79
+ $options['ctt_theme'] = 'style1';
80
+ $options['ctt_css'] = "";
81
+ $options['twitter_shares'] = false;
82
+ $options['recover_shares'] = false;
83
+ $options['google_analtyics'] = false;
84
+ $options['bitly_authentication'] = false;
85
+ $options['minimum_shares'] = 0;
86
+ $options['swp_click_tracking'] = false;
87
+ $options['order_of_icons'] = 'manual';
88
+ $options['pinit_toggle'] = false;
89
+ $options['pinit_location_horizontal'] = 'center';
90
+ $options['pinit_location_vertical'] = 'top';
91
+ $options['emphasize_icons'] = 0;
92
+ $options['float_mobile'] = 'off';
93
+ $options['pin_browser_extension'] = false;
94
+ $options['pinterest_image_location'] = 'hidden';
95
+ $options['pinterest_fallback'] = 'all';
96
+ endif;
97
+
98
+ if(isset($options['order_of_icons']['active'])) {
99
+ unset($options['order_of_icons']['active']);
100
+ }
101
+
102
+ /**
103
+ * Unset any buttons that may have been put into the options but are no longer actually available
104
+ *
105
+ */
106
+ }
107
+
108
+ /**
109
+ * Fetch a single option
110
+ *
111
+ * @since unknown
112
+ * @param string $key The key to pull from the array of options.
113
+ * @return mixed $options The value of the desired option
114
+ */
115
+ function swp_get_single_option( $key ) {
116
+ global $swp_user_options;
117
+
118
+ if ( isset( $swp_user_options[ $key ] ) ) {
119
+ return $swp_user_options[ $key ];
120
+ }
121
+
122
+ return false;
123
+ }
124
+
125
+ /**
126
+ * Update the main plugin options.
127
+ *
128
+ * @since 2.1.0
129
+ * @param array $options The option values to be set.
130
+ * @return bool True if the option has been updated.
131
+ */
132
+ function swp_update_options( $options ) {
133
+ if ( ! is_array( $options ) ) {
134
+ return false;
135
+ }
136
+
137
+ unset( $options['orderOfIcons'] );
138
+
139
+ return update_option( 'social_warfare_settings', $options );
140
+ }
141
+
142
+ /**
143
+ * Update a single option.
144
+ *
145
+ * @since 2.1.0
146
+ * @param string $key The key to set in the array of options.
147
+ * @param mixed $value The option value to be set.
148
+ * @return bool True if the option has been updated.
149
+ */
150
+ function swp_update_option( $key, $value ) {
151
+ $options = get_option( 'social_warfare_settings', array() );
152
+
153
+ $options[ $key ] = $value;
154
+
155
+ return swp_update_options( $options );
156
+ }
functions/admin/options-registration.php CHANGED
@@ -1,87 +1,87 @@
1
- <?php
2
- /**
3
- * Functions for loading the admin options page.
4
- *
5
- * @package SocialWarfare\Admin\Functions
6
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
- * @license GPL-3.0+
8
- * @since 1.0.0
9
- */
10
-
11
- $premium_code = '';
12
- $email = '';
13
-
14
- // Fetch the registration keys from pro and all other addons
15
- $array = array();
16
- $registrations = apply_filters('swp_registrations' , $array);
17
-
18
- foreach($registrations as $registration):
19
- if ( ! empty( $swp_user_options[$registration['key'].'_license_key'] ) ) {
20
- $license_key = $swp_user_options[$registration['key'].'_license_key'];
21
- $registered = 1;
22
- } else {
23
- $license_key = '';
24
- $registered = 0;
25
- }
26
- ?>
27
-
28
- <div class="registration-wrapper <?php echo $registration['key'] ?>" registration="<?php echo $registered; ?>">
29
-
30
- <h2><?php esc_html_e( $registration['plugin_name'].' Registration' , 'social-warfare' ); ?></h2>
31
-
32
- <div class="sw-grid sw-col-940 swp_is_not_registered">
33
-
34
- <div class="sw-red-notice">
35
- <?php _e( 'This copy of '.$registration['plugin_name'].' is NOT registered. <a target="_blank" href="https://warfareplugins.com">Click here</a> to purchase a license or add your account info below.' , 'social-warfare' ); ?>
36
- </div>
37
-
38
- <p class="sw-subtitle sw-registration-text">
39
- <?php esc_html_e( 'Enter your registration key for '.$registration['plugin_name'] .' and then click Register Plugin.' , 'social-warfare' ); ?>
40
- </p>
41
-
42
- <div class="sw-grid sw-col-300">
43
- <p class="sw-input-label">
44
- <?php esc_html_e( $registration['plugin_name'].' License Key' , 'social-warfare' ); ?>
45
- </p>
46
- </div>
47
-
48
- <div class="sw-grid sw-col-300">
49
- <input name="<?php echo $registration['key'] ?>_license_key" type="text" class="sw-admin-input" placeholder="License Key" value="<?php echo $license_key; ?>" />
50
- </div>
51
-
52
- <div class="sw-grid sw-col-300 sw-fit register_button_grid">
53
- <a href="#" class="register-plugin button sw-navy-button" swp-addon="<?php echo $registration['key']; ?>" swp-item-id="<?php echo $registration["product_id"]; ?>">
54
- <?php esc_html_e( 'Register Plugin' , 'social-warfare' ); ?>
55
- </a>
56
- </div>
57
-
58
- <div class="sw-clearfix"></div>
59
- </div>
60
-
61
- <div class="sw-grid sw-col-940 swp_is_registered">
62
-
63
- <div class="sw-green-notice">
64
- <?php esc_html_e( 'This copy of '.$registration['plugin_name'].' is registered. Wah-hoo!', 'social-warfare' ); ?>
65
- </div>
66
-
67
- <p class="sw-subtitle sw-registration-text">
68
- <?php esc_html_e( 'To unregister your license click the button below to free it up for use on another domain.' , 'social-warfare' ); ?>
69
- </p>
70
-
71
- <div class="sw-grid sw-col-300">
72
- <p class="sw-authenticate-label">
73
- <?php esc_html_e( 'Deactivate Registration' , 'social-warfare' ); ?>
74
- </p>
75
- </div>
76
-
77
- <div class="sw-grid sw-col-300">
78
- <a href="#" class="unregister-plugin button sw-navy-button" swp-addon="<?php echo $registration['key']; ?>" swp-item-id="<?php echo $registration["product_id"]; ?>">
79
- <?php esc_html_e( 'Unregister Plugin' , 'social-warfare' ); ?>
80
- </a>
81
- </div>
82
- <div class="sw-grid sw-col-300 sw-fit"></div>
83
-
84
- </div>
85
-
86
- </div>
87
- <?php endforeach; ?>
1
+ <?php
2
+ /**
3
+ * Functions for loading the admin options page.
4
+ *
5
+ * @package SocialWarfare\Admin\Functions
6
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
+ * @license GPL-3.0+
8
+ * @since 1.0.0
9
+ */
10
+
11
+ $premium_code = '';
12
+ $email = '';
13
+
14
+ // Fetch the registration keys from pro and all other addons
15
+ $array = array();
16
+ $registrations = apply_filters('swp_registrations' , $array);
17
+
18
+ foreach($registrations as $registration):
19
+ if ( ! empty( $swp_user_options[$registration['key'].'_license_key'] ) ) {
20
+ $license_key = $swp_user_options[$registration['key'].'_license_key'];
21
+ $registered = 1;
22
+ } else {
23
+ $license_key = '';
24
+ $registered = 0;
25
+ }
26
+ ?>
27
+
28
+ <div class="registration-wrapper <?php echo $registration['key'] ?>" registration="<?php echo $registered; ?>">
29
+
30
+ <h2><?php esc_html_e( $registration['plugin_name'].' Registration' , 'social-warfare' ); ?></h2>
31
+
32
+ <div class="sw-grid sw-col-940 swp_is_not_registered">
33
+
34
+ <div class="sw-red-notice">
35
+ <?php _e( 'This copy of '.$registration['plugin_name'].' is NOT registered. <a target="_blank" href="https://warfareplugins.com">Click here</a> to purchase a license or add your account info below.' , 'social-warfare' ); ?>
36
+ </div>
37
+
38
+ <p class="sw-subtitle sw-registration-text">
39
+ <?php esc_html_e( 'Enter your registration key for '.$registration['plugin_name'] .' and then click Register Plugin.' , 'social-warfare' ); ?>
40
+ </p>
41
+
42
+ <div class="sw-grid sw-col-300">
43
+ <p class="sw-input-label">
44
+ <?php esc_html_e( $registration['plugin_name'].' License Key' , 'social-warfare' ); ?>
45
+ </p>
46
+ </div>
47
+
48
+ <div class="sw-grid sw-col-300">
49
+ <input name="<?php echo $registration['key'] ?>_license_key" type="text" class="sw-admin-input" placeholder="License Key" value="<?php echo $license_key; ?>" />
50
+ </div>
51
+
52
+ <div class="sw-grid sw-col-300 sw-fit register_button_grid">
53
+ <a href="#" class="register-plugin button sw-navy-button" swp-addon="<?php echo $registration['key']; ?>" swp-item-id="<?php echo $registration["product_id"]; ?>">
54
+ <?php esc_html_e( 'Register Plugin' , 'social-warfare' ); ?>
55
+ </a>
56
+ </div>
57
+
58
+ <div class="sw-clearfix"></div>
59
+ </div>
60
+
61
+ <div class="sw-grid sw-col-940 swp_is_registered">
62
+
63
+ <div class="sw-green-notice">
64
+ <?php esc_html_e( 'This copy of '.$registration['plugin_name'].' is registered. Wah-hoo!', 'social-warfare' ); ?>
65
+ </div>
66
+
67
+ <p class="sw-subtitle sw-registration-text">
68
+ <?php esc_html_e( 'To unregister your license click the button below to free it up for use on another domain.' , 'social-warfare' ); ?>
69
+ </p>
70
+
71
+ <div class="sw-grid sw-col-300">
72
+ <p class="sw-authenticate-label">
73
+ <?php esc_html_e( 'Deactivate Registration' , 'social-warfare' ); ?>
74
+ </p>
75
+ </div>
76
+
77
+ <div class="sw-grid sw-col-300">
78
+ <a href="#" class="unregister-plugin button sw-navy-button" swp-addon="<?php echo $registration['key']; ?>" swp-item-id="<?php echo $registration["product_id"]; ?>">
79
+ <?php esc_html_e( 'Unregister Plugin' , 'social-warfare' ); ?>
80
+ </a>
81
+ </div>
82
+ <div class="sw-grid sw-col-300 sw-fit"></div>
83
+
84
+ </div>
85
+
86
+ </div>
87
+ <?php endforeach; ?>
functions/admin/registration.php CHANGED
@@ -1,347 +1,347 @@
1
- <?php
2
- /**
3
- * Functions for getting and setting the plugin's registration status.
4
- *
5
- * @package SocialWarfare\Functions
6
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
- * @license GPL-3.0+
8
- * @since 1.0.0
9
- */
10
-
11
- /**
12
- * A function to be used to make cURL requests
13
- * @param string $url The URL to be fetched
14
- * @return string The response from the server
15
- *
16
- */
17
- function swpp_file_get_contents_curl( $url ) {
18
- $ch = curl_init();
19
- curl_setopt( $ch, CURLOPT_URL, $url );
20
- curl_setopt( $ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
21
- curl_setopt( $ch, CURLOPT_FAILONERROR, 0 );
22
- curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 0 );
23
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER,1 );
24
- curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
25
- curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
26
- curl_setopt( $ch, CURLOPT_TIMEOUT, 5 );
27
- curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 5 );
28
- curl_setopt( $ch, CURLOPT_NOSIGNAL, 1 );
29
- curl_setopt( $ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
30
- $cont = @curl_exec( $ch );
31
- $curl_errno = curl_errno( $ch );
32
- curl_close( $ch );
33
- if ( $curl_errno > 0 ) {
34
- return false;
35
- }
36
- return $cont;
37
- }
38
-
39
- /**
40
- * Check to see if the plugin has been registered once per page load.
41
- *
42
- * @since 2.1.0
43
- * @param string $domain The current site's domain.
44
- * @param string $context The context where the key will be used.
45
- * @return string A registration key based on the site's domain.
46
- */
47
- function swp_get_registration_key( $domain, $context = 'api' ) {
48
- $key = md5( $domain );
49
-
50
- if ( 'db' === $context ) {
51
- $key = md5( $key );
52
- }
53
-
54
- return $key;
55
- }
56
-
57
- /**
58
- * Check to see if an addon has been registered once per page load.
59
- * Once per week, we'll ping our server to ask if the license key is still valid.
60
- *
61
- * @since 2.3.3 - Created the function to work for all addons, not just the pro addon
62
- * @since 3.0.6 | 14 MAY 2018 | Added check for array key to prevent undefined index notice.
63
- * @param string The unique key for the addon
64
- * @return bool True if the plugin is registered, false otherwise.
65
- */
66
- function is_swp_addon_registered($key) {
67
-
68
- // Get the plugin options from the database
69
- $options = get_option( 'social_warfare_settings' );
70
- $is_registered = false;
71
-
72
- // Get the timestamps setup for comparison to see if a week has passed since our last check
73
- $current_time = time();
74
- if(!isset($options[$key.'_license_key_timestamp'])):
75
- $timestamp = 0;
76
- else:
77
- $timestamp = $options[$key.'_license_key_timestamp'];
78
- endif;
79
- $time_to_recheck = $timestamp + 604800;
80
-
81
- // If they have a key and a week hasn't passed since the last check, just return true...the plugin is registered.
82
- if( !empty($options[$key.'_license_key']) && $current_time < $time_to_recheck ) {
83
-
84
- $is_registered = true;
85
-
86
- // If a week has indeed passed since the last check, ping our API to check the validity of the license key
87
- } elseif( !empty($options[$key.'_license_key']) ){
88
-
89
- // Setup the API parameters
90
- $license = $options[$key.'_license_key'];
91
- $site_url = swp_get_site_url();
92
- $store_url = 'https://warfareplugins.com';
93
- $registration_array = array();
94
- $registration_array = apply_filters( 'swp_registrations' , $registration_array );
95
-
96
- if ( !array_key_exists( $key, $registration_array ) ) :
97
- return $is_registered;
98
- endif;
99
-
100
- $item_id = $registration_array[$key]['product_id'];
101
-
102
-
103
- $api_params = array(
104
- 'edd_action' => 'check_license',
105
- 'item_id' => $item_id,
106
- 'license' => $license,
107
- 'url' => $site_url,
108
- );
109
-
110
- $response = wp_remote_retrieve_body( wp_remote_post( $store_url , array('body' => $api_params, 'timeout' => 10 ) ) );
111
-
112
- if( false != $response ) {
113
-
114
- // Parse the response into an object
115
- $license_data = json_decode( $response );
116
-
117
- // If the license was invalid
118
- if( isset($license_data->license) && 'invalid' == $license_data->license) {
119
- $is_registered = false;
120
- $options[$key.'_license_key'] = '';
121
- $options[$key.'_license_key_timestamp'] = $current_time;
122
- update_option( 'social_warfare_settings' , $options );
123
-
124
- // If the property is some other status, just go with it.
125
- } else {
126
- $options[$key.'_license_key_timestamp'] = $current_time;
127
- update_option( 'social_warfare_settings' , $options );
128
- $is_registered = true;
129
- }
130
-
131
- // If we recieved no response from the server, we'll just check again next week
132
- } else {
133
- $options[$key.'_license_key_timestamp'] = $current_time;
134
- update_option( 'social_warfare_settings' , $options );
135
- $is_registered = true;
136
- }
137
- }
138
-
139
- // Return the registration value true/false
140
- return $is_registered;
141
- }
142
-
143
- /**
144
- * Check to see if the plugin has been registered once per page load.
145
- * Once per week, we'll ping our server to ask if the license key is still valid.
146
- *
147
- * @since unknown
148
- * @since 2.3.3 Forward the request to the is_swp_addon_registered() function.
149
- * @return bool True if the plugin is registered, false otherwise.
150
- */
151
- function is_swp_registered($timeline = false) {
152
-
153
- return is_swp_addon_registered('pro');
154
-
155
- }
156
-
157
- /**
158
- * Attempt to register the plugin.
159
- *
160
- * @since 2.1.0
161
- * @since 2.3.0 Hooked registration into the new EDD Software Licensing API
162
- * @param none
163
- * @return JSON Encoded Array (Echoed) - The Response from the EDD API
164
- *
165
- */
166
- add_action( 'wp_ajax_swp_register_plugin', 'swp_register_plugin' );
167
- function swp_register_plugin() {
168
-
169
- // Check to ensure that license key was passed into the function
170
- if(!empty($_POST['license_key'])) {
171
-
172
- // Grab the license key so we can use it below
173
- $name_key = $_POST['name_key'];
174
- $license = $_POST['license_key'];
175
- $item_id = $_POST['item_id'];
176
- $site_url = swp_get_site_url();
177
- $store_url = 'https://warfareplugins.com';
178
-
179
- $api_params = array(
180
- 'edd_action' => 'activate_license',
181
- 'item_id' => $item_id,
182
- 'license' => $license,
183
- 'url' => $site_url
184
- );
185
-
186
- $response = wp_remote_retrieve_body( wp_remote_post( $store_url, array( 'body' => $api_params, 'timeout' => 10 ) ) );
187
-
188
- // $url ='https://warfareplugins.com/?edd_action=activate_license&item_id='.$item_id.'&license='.$license.'&url='.swp_get_site_url();
189
- // $response = swpp_file_get_contents_curl( $url );
190
-
191
- if(false != $response){
192
-
193
- // Parse the response into an object
194
- $license_data = json_decode( $response );
195
-
196
- // If the license is valid store it in the database
197
- if( isset($license_data->license) && 'valid' == $license_data->license ) {
198
-
199
- $current_time = time();
200
- $options = get_option( 'social_warfare_settings' );
201
- $options[$name_key.'_license_key'] = $license;
202
- $options[$name_key.'_license_key_timestamp'] = $current_time;
203
- update_option( 'social_warfare_settings' , $options );
204
-
205
- echo json_encode($license_data);
206
- wp_die();
207
-
208
- // If the license is not valid
209
- } elseif( isset($license_data->license) && 'invalid' == $license_data->license ) {
210
- echo json_encode($license_data);
211
- wp_die();
212
-
213
- // If some other status was returned
214
- } else {
215
- $license_data['success'] = false;
216
- $license_data['data'] = 'Invaid response from the registration server.';
217
- echo json_encode($license_data);
218
- wp_die();
219
- }
220
-
221
- // If we didn't get a response from the registration server
222
- } else {
223
- $license_data['success'] = false;
224
- $license_data['data'] = 'Failed to connect to registration server.';
225
- echo json_encode($license_data);
226
- wp_die();
227
- }
228
- } else {
229
- $license_data['success'] = false;
230
- $license_data['data'] = 'Admin Ajax did not receive valid POST data.';
231
- echo json_encode($license_data);
232
- wp_die();
233
- }
234
-
235
- wp_die();
236
-
237
- }
238
-
239
- /**
240
- * Attempt to unregister the plugin.
241
- *
242
- * @since 2.1.0
243
- * @since 2.3.0 Hooked into the EDD Software Licensing API
244
- * @param none
245
- * @return JSON Encoded Array (Echoed) - The Response from the EDD API
246
- */
247
- add_action( 'wp_ajax_swp_unregister_plugin', 'swp_unregister_plugin' );
248
- function swp_unregister_plugin() {
249
-
250
- // Setup the variables needed for processing
251
- $options = get_option( 'social_warfare_settings' );
252
- $name_key = $_POST['name_key'];
253
- $item_id = $_POST['item_id'];
254
- $site_url = swp_get_site_url();
255
- $store_url = 'https://warfareplugins.com';
256
-
257
- // Check to see if the license key is even in the options
258
- if(empty($options[$name_key.'_license_key'])) {
259
- $response['success'] = true;
260
- echo json_encode($response);
261
- } else {
262
-
263
- // Grab the license key so we can use it below
264
- $license = $options[$name_key.'_license_key'];
265
-
266
- // Setup the API request parameters
267
- $api_params = array(
268
- 'edd_action' => 'deactivate_license',
269
- 'item_id' => $item_id,
270
- 'license' => $license,
271
- 'url' => $site_url,
272
- );
273
-
274
- $response = wp_remote_retrieve_body( wp_remote_post( $store_url, array( 'body' => $api_params, 'timeout' => 10 ) ) );
275
-
276
- // Parse the response into an object
277
- $license_data = json_decode( $response );
278
-
279
- // If the deactivation was valid update the database
280
- if( isset($license_data->license) && $license_data->license == 'valid' ) {
281
-
282
- $options = get_option( 'social_warfare_settings' );
283
- $options[$name_key.'_license_key'] = '';
284
- update_option( 'social_warfare_settings' , $options );
285
- echo json_encode($license_data);
286
- wp_die();
287
-
288
- // If the API request didn't work, just deactivate locally anyways
289
- } else {
290
-
291
- $options = get_option( 'social_warfare_settings' );
292
- $options[$name_key.'_license_key'] = '';
293
- update_option( 'social_warfare_settings' , $options );
294
- echo json_encode($license_data);
295
- wp_die();
296
- }
297
- }
298
-
299
- wp_die();
300
- }
301
-
302
- add_action( 'wp_ajax_swp_ajax_passthrough', 'swp_ajax_passthrough' );
303
- /**
304
- * Pass ajax responses to a remote HTTP request.
305
- *
306
- * @since 2.0.0
307
- * @return void
308
- */
309
- function swp_ajax_passthrough() {
310
- if ( ! check_ajax_referer( 'swp_plugin_registration', 'security', false ) ) {
311
- wp_send_json_error( esc_html__( 'Security failed.', 'social-warfare' ) );
312
- die;
313
- }
314
-
315
- $data = wp_unslash( $_POST ); // Input var okay.
316
-
317
- if ( ! isset( $data['activity'], $data['email'] ) ) {
318
- wp_send_json_error( esc_html__( 'Required fields missing.', 'social-warfare' ) );
319
- die;
320
- }
321
-
322
- if ( 'register' === $data['activity'] ) {
323
- $response = swp_register_plugin( $data['email'], swp_get_site_url() );
324
-
325
- if ( ! $response ) {
326
- wp_send_json_error( esc_html__( 'Plugin could not be registered.', 'social-warfare' ) );
327
- die;
328
- }
329
-
330
- $response['message'] = esc_html__( 'Plugin successfully registered!', 'social-warfare' );
331
- }
332
-
333
- if ( 'unregister' === $data['activity'] && isset( $data['key'] ) ) {
334
- $response = swp_unregister_plugin( $data['email'], $data['key'] );
335
-
336
- if ( ! $response ) {
337
- wp_send_json_error( esc_html__( 'Plugin could not be unregistered.', 'social-warfare' ) );
338
- die;
339
- }
340
-
341
- $response['message'] = esc_html__( 'Plugin successfully unregistered!', 'social-warfare' );
342
- }
343
-
344
- wp_send_json_success( $response );
345
-
346
- die;
347
- }
1
+ <?php
2
+ /**
3
+ * Functions for getting and setting the plugin's registration status.
4
+ *
5
+ * @package SocialWarfare\Functions
6
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
+ * @license GPL-3.0+
8
+ * @since 1.0.0
9
+ */
10
+
11
+ /**
12
+ * A function to be used to make cURL requests
13
+ * @param string $url The URL to be fetched
14
+ * @return string The response from the server
15
+ *
16
+ */
17
+ function swpp_file_get_contents_curl( $url ) {
18
+ $ch = curl_init();
19
+ curl_setopt( $ch, CURLOPT_URL, $url );
20
+ curl_setopt( $ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
21
+ curl_setopt( $ch, CURLOPT_FAILONERROR, 0 );
22
+ curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 0 );
23
+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER,1 );
24
+ curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
25
+ curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
26
+ curl_setopt( $ch, CURLOPT_TIMEOUT, 5 );
27
+ curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 5 );
28
+ curl_setopt( $ch, CURLOPT_NOSIGNAL, 1 );
29
+ curl_setopt( $ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
30
+ $cont = @curl_exec( $ch );
31
+ $curl_errno = curl_errno( $ch );
32
+ curl_close( $ch );
33
+ if ( $curl_errno > 0 ) {
34
+ return false;
35
+ }
36
+ return $cont;
37
+ }
38
+
39
+ /**
40
+ * Check to see if the plugin has been registered once per page load.
41
+ *
42
+ * @since 2.1.0
43
+ * @param string $domain The current site's domain.
44
+ * @param string $context The context where the key will be used.
45
+ * @return string A registration key based on the site's domain.
46
+ */
47
+ function swp_get_registration_key( $domain, $context = 'api' ) {
48
+ $key = md5( $domain );
49
+
50
+ if ( 'db' === $context ) {
51
+ $key = md5( $key );
52
+ }
53
+
54
+ return $key;
55
+ }
56
+
57
+ /**
58
+ * Check to see if an addon has been registered once per page load.
59
+ * Once per week, we'll ping our server to ask if the license key is still valid.
60
+ *
61
+ * @since 2.3.3 - Created the function to work for all addons, not just the pro addon
62
+ * @since 3.0.6 | 14 MAY 2018 | Added check for array key to prevent undefined index notice.
63
+ * @param string The unique key for the addon
64
+ * @return bool True if the plugin is registered, false otherwise.
65
+ */
66
+ function is_swp_addon_registered($key) {
67
+
68
+ // Get the plugin options from the database
69
+ $options = get_option( 'social_warfare_settings' );
70
+ $is_registered = false;
71
+
72
+ // Get the timestamps setup for comparison to see if a week has passed since our last check
73
+ $current_time = time();
74
+ if(!isset($options[$key.'_license_key_timestamp'])):
75
+ $timestamp = 0;
76
+ else:
77
+ $timestamp = $options[$key.'_license_key_timestamp'];
78
+ endif;
79
+ $time_to_recheck = $timestamp + 604800;
80
+
81
+ // If they have a key and a week hasn't passed since the last check, just return true...the plugin is registered.
82
+ if( !empty($options[$key.'_license_key']) && $current_time < $time_to_recheck ) {
83
+
84
+ $is_registered = true;
85
+
86
+ // If a week has indeed passed since the last check, ping our API to check the validity of the license key
87
+ } elseif( !empty($options[$key.'_license_key']) ){
88
+
89
+ // Setup the API parameters
90
+ $license = $options[$key.'_license_key'];
91
+ $site_url = swp_get_site_url();
92
+ $store_url = 'https://warfareplugins.com';
93
+ $registration_array = array();
94
+ $registration_array = apply_filters( 'swp_registrations' , $registration_array );
95
+
96
+ if ( !array_key_exists( $key, $registration_array ) ) :
97
+ return $is_registered;
98
+ endif;
99
+
100
+ $item_id = $registration_array[$key]['product_id'];
101
+
102
+
103
+ $api_params = array(
104
+ 'edd_action' => 'check_license',
105
+ 'item_id' => $item_id,
106
+ 'license' => $license,
107
+ 'url' => $site_url,
108
+ );
109
+
110
+ $response = wp_remote_retrieve_body( wp_remote_post( $store_url , array('body' => $api_params, 'timeout' => 10 ) ) );
111
+
112
+ if( false != $response ) {
113
+
114
+ // Parse the response into an object
115
+ $license_data = json_decode( $response );
116
+
117
+ // If the license was invalid
118
+ if( isset($license_data->license) && 'invalid' == $license_data->license) {
119
+ $is_registered = false;
120
+ $options[$key.'_license_key'] = '';
121
+ $options[$key.'_license_key_timestamp'] = $current_time;
122
+ update_option( 'social_warfare_settings' , $options );
123
+
124
+ // If the property is some other status, just go with it.
125
+ } else {
126
+ $options[$key.'_license_key_timestamp'] = $current_time;
127
+ update_option( 'social_warfare_settings' , $options );
128
+ $is_registered = true;
129
+ }
130
+
131
+ // If we recieved no response from the server, we'll just check again next week
132
+ } else {
133
+ $options[$key.'_license_key_timestamp'] = $current_time;
134
+ update_option( 'social_warfare_settings' , $options );
135
+ $is_registered = true;
136
+ }
137
+ }
138
+
139
+ // Return the registration value true/false
140
+ return $is_registered;
141
+ }
142
+
143
+ /**
144
+ * Check to see if the plugin has been registered once per page load.
145
+ * Once per week, we'll ping our server to ask if the license key is still valid.
146
+ *
147
+ * @since unknown
148
+ * @since 2.3.3 Forward the request to the is_swp_addon_registered() function.
149
+ * @return bool True if the plugin is registered, false otherwise.
150
+ */
151
+ function is_swp_registered($timeline = false) {
152
+
153
+ return is_swp_addon_registered('pro');
154
+
155
+ }
156
+
157
+ /**
158
+ * Attempt to register the plugin.
159
+ *
160
+ * @since 2.1.0
161
+ * @since 2.3.0 Hooked registration into the new EDD Software Licensing API
162
+ * @param none
163
+ * @return JSON Encoded Array (Echoed) - The Response from the EDD API
164
+ *
165
+ */
166
+ add_action( 'wp_ajax_swp_register_plugin', 'swp_register_plugin' );
167
+ function swp_register_plugin() {
168
+
169
+ // Check to ensure that license key was passed into the function
170
+ if(!empty($_POST['license_key'])) {
171
+
172
+ // Grab the license key so we can use it below
173
+ $name_key = $_POST['name_key'];
174
+ $license = $_POST['license_key'];
175
+ $item_id = $_POST['item_id'];
176
+ $site_url = swp_get_site_url();
177
+ $store_url = 'https://warfareplugins.com';
178
+
179
+ $api_params = array(
180
+ 'edd_action' => 'activate_license',
181
+ 'item_id' => $item_id,
182
+ 'license' => $license,
183
+ 'url' => $site_url
184
+ );
185
+
186
+ $response = wp_remote_retrieve_body( wp_remote_post( $store_url, array( 'body' => $api_params, 'timeout' => 10 ) ) );
187
+
188
+ // $url ='https://warfareplugins.com/?edd_action=activate_license&item_id='.$item_id.'&license='.$license.'&url='.swp_get_site_url();
189
+ // $response = swpp_file_get_contents_curl( $url );
190
+
191
+ if(false != $response){
192
+
193
+ // Parse the response into an object
194
+ $license_data = json_decode( $response );
195
+
196
+ // If the license is valid store it in the database
197
+ if( isset($license_data->license) && 'valid' == $license_data->license ) {
198
+
199
+ $current_time = time();
200
+ $options = get_option( 'social_warfare_settings' );
201
+ $options[$name_key.'_license_key'] = $license;
202
+ $options[$name_key.'_license_key_timestamp'] = $current_time;
203
+ update_option( 'social_warfare_settings' , $options );
204
+
205
+ echo json_encode($license_data);
206
+ wp_die();
207
+
208
+ // If the license is not valid
209
+ } elseif( isset($license_data->license) && 'invalid' == $license_data->license ) {
210
+ echo json_encode($license_data);
211
+ wp_die();
212
+
213
+ // If some other status was returned
214
+ } else {
215
+ $license_data['success'] = false;
216
+ $license_data['data'] = 'Invaid response from the registration server.';
217
+ echo json_encode($license_data);
218
+ wp_die();
219
+ }
220
+
221
+ // If we didn't get a response from the registration server
222
+ } else {
223
+ $license_data['success'] = false;
224
+ $license_data['data'] = 'Failed to connect to registration server.';
225
+ echo json_encode($license_data);
226
+ wp_die();
227
+ }
228
+ } else {
229
+ $license_data['success'] = false;
230
+ $license_data['data'] = 'Admin Ajax did not receive valid POST data.';
231
+ echo json_encode($license_data);
232
+ wp_die();
233
+ }
234
+
235
+ wp_die();
236
+
237
+ }
238
+
239
+ /**
240
+ * Attempt to unregister the plugin.
241
+ *
242
+ * @since 2.1.0
243
+ * @since 2.3.0 Hooked into the EDD Software Licensing API
244
+ * @param none
245
+ * @return JSON Encoded Array (Echoed) - The Response from the EDD API
246
+ */
247
+ add_action( 'wp_ajax_swp_unregister_plugin', 'swp_unregister_plugin' );
248
+ function swp_unregister_plugin() {
249
+
250
+ // Setup the variables needed for processing
251
+ $options = get_option( 'social_warfare_settings' );
252
+ $name_key = $_POST['name_key'];
253
+ $item_id = $_POST['item_id'];
254
+ $site_url = swp_get_site_url();
255
+ $store_url = 'https://warfareplugins.com';
256
+
257
+ // Check to see if the license key is even in the options
258
+ if(empty($options[$name_key.'_license_key'])) {
259
+ $response['success'] = true;
260
+ echo json_encode($response);
261
+ } else {
262
+
263
+ // Grab the license key so we can use it below
264
+ $license = $options[$name_key.'_license_key'];
265
+
266
+ // Setup the API request parameters
267
+ $api_params = array(
268
+ 'edd_action' => 'deactivate_license',
269
+ 'item_id' => $item_id,
270
+ 'license' => $license,
271
+ 'url' => $site_url,
272
+ );
273
+
274
+ $response = wp_remote_retrieve_body( wp_remote_post( $store_url, array( 'body' => $api_params, 'timeout' => 10 ) ) );
275
+
276
+ // Parse the response into an object
277
+ $license_data = json_decode( $response );
278
+
279
+ // If the deactivation was valid update the database
280
+ if( isset($license_data->license) && $license_data->license == 'valid' ) {
281
+
282
+ $options = get_option( 'social_warfare_settings' );
283
+ $options[$name_key.'_license_key'] = '';
284
+ update_option( 'social_warfare_settings' , $options );
285
+ echo json_encode($license_data);
286
+ wp_die();
287
+
288
+ // If the API request didn't work, just deactivate locally anyways
289
+ } else {
290
+
291
+ $options = get_option( 'social_warfare_settings' );
292
+ $options[$name_key.'_license_key'] = '';
293
+ update_option( 'social_warfare_settings' , $options );
294
+ echo json_encode($license_data);
295
+ wp_die();
296
+ }
297
+ }
298
+
299
+ wp_die();
300
+ }
301
+
302
+ add_action( 'wp_ajax_swp_ajax_passthrough', 'swp_ajax_passthrough' );
303
+ /**
304
+ * Pass ajax responses to a remote HTTP request.
305
+ *
306
+ * @since 2.0.0
307
+ * @return void
308
+ */
309
+ function swp_ajax_passthrough() {
310
+ if ( ! check_ajax_referer( 'swp_plugin_registration', 'security', false ) ) {
311
+ wp_send_json_error( esc_html__( 'Security failed.', 'social-warfare' ) );
312
+ die;
313
+ }
314
+
315
+ $data = wp_unslash( $_POST ); // Input var okay.
316
+
317
+ if ( ! isset( $data['activity'], $data['email'] ) ) {
318
+ wp_send_json_error( esc_html__( 'Required fields missing.', 'social-warfare' ) );
319
+ die;
320
+ }
321
+
322
+ if ( 'register' === $data['activity'] ) {
323
+ $response = swp_register_plugin( $data['email'], swp_get_site_url() );
324
+
325
+ if ( ! $response ) {
326
+ wp_send_json_error( esc_html__( 'Plugin could not be registered.', 'social-warfare' ) );
327
+ die;
328
+ }
329
+
330
+ $response['message'] = esc_html__( 'Plugin successfully registered!', 'social-warfare' );
331
+ }
332
+
333
+ if ( 'unregister' === $data['activity'] && isset( $data['key'] ) ) {
334
+ $response = swp_unregister_plugin( $data['email'], $data['key'] );
335
+
336
+ if ( ! $response ) {
337
+ wp_send_json_error( esc_html__( 'Plugin could not be unregistered.', 'social-warfare' ) );
338
+ die;
339
+ }
340
+
341
+ $response['message'] = esc_html__( 'Plugin successfully unregistered!', 'social-warfare' );
342
+ }
343
+
344
+ wp_send_json_success( $response );
345
+
346
+ die;
347
+ }
functions/admin/swp_system_checker.php CHANGED
@@ -1,147 +1,147 @@
1
- <?php
2
- /**
3
- * A series of classes to check the user's system for minimum system requirements
4
- *
5
- * @package social-warfare\functions\admin
6
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
- * @license GPL-3.0+
8
- * @since 2.2.4 | Created | 1 MAY 2017
9
- */
10
-
11
- /**
12
- * A class for initializing the system checks
13
- *
14
- * @since 2.2.4 | Created | 1 MAY 2017
15
- * @access public
16
- */
17
- abstract class swp_custom_check
18
- {
19
- public $name = "";
20
- public $whats_wrong = "";
21
- public $how_to_fix= "";
22
- public $check_passed = null;
23
- public $additional_message = null;
24
-
25
- /**
26
- * Force children to have an executable run method.
27
- */
28
- abstract public function run();
29
- }
30
-
31
- /**
32
- * A series of classes to check the user's system for minimum system requirements
33
- *
34
- * @since 2.2.4 | Created | 6 March 2017
35
- * @access public
36
- * @return string The HTML for an error notice if triggered
37
- */
38
- class swp_system_checker
39
- {
40
- public static $custom_checks = array();
41
- public static $has_error = FALSE;
42
-
43
- public static function full_system_check()
44
- {
45
- swp_system_checker::load_all_checks();
46
- swp_system_checker::run_all_checks();
47
- swp_system_checker::print_all_errors();
48
-
49
- }
50
-
51
- public static function load_all_checks()
52
- {
53
- swp_system_checker::$custom_checks[ 'swp_php_check' ] = new swp_php_check();
54
- swp_system_checker::$custom_checks[ 'swp_curl_check' ] = new swp_curl_check();
55
- }
56
-
57
- public static function run_all_checks()
58
- {
59
- foreach( swp_system_checker::$custom_checks as $custom_check )
60
- {
61
- if( method_exists( $custom_check, 'run' ) ) {
62
- if( !$custom_check->run() && !$custom_check->check_passed ) {
63
- swp_system_checker::$has_error = true;
64
- }
65
- }
66
- }
67
- }
68
-
69
- public static function print_all_errors()
70
- {
71
- if( !isset( swp_system_checker::$has_error ) || empty( swp_system_checker::$has_error ) ) {
72
- return FALSE;
73
- }
74
-
75
- foreach( swp_system_checker::$custom_checks as $custom_check )
76
- {
77
- if( $custom_check->check_passed ) {
78
- continue;
79
- }
80
-
81
- echo '<div class="sw-red-notice">' . $custom_check->whats_wrong . $custom_check->how_to_fix . '</div>';
82
- }
83
- }
84
- }
85
-
86
- /**
87
- * A class to detect if the user is using a compatible version of PHP (5.3+) on their server
88
- *
89
- * @since 2.2.4 | Created | 1 MAY 2017
90
- * @access public
91
- * @return string The HTML for an error notice if triggered
92
- */
93
- class swp_php_check extends swp_custom_check
94
- {
95
- public function __construct()
96
- {
97
- $this->name = 'PHP Check';
98
- }
99
-
100
- public function run()
101
- {
102
- if( version_compare( PHP_VERSION, '5.2.0' ) >= 0 )
103
- {
104
- $this->check_passed = true;
105
- }
106
- else
107
- {
108
- $this->check_passed = false;
109
- $this->whats_wrong = 'Your server is currently using PHP version '.PHP_VERSION.'. In order for our plugin to fetch share counts properly, you must be using PHP 5.3 or newer.';
110
- $this->how_to_fix = 'To fix this, simply contact your hosting provider and ask them to update your server to the latest stable version of PHP.';
111
- }
112
-
113
- return $this->check_passed;
114
- }
115
- }
116
-
117
- /**
118
- * A class to detect if the user has cURL enabled on their server. cURL is a requirement of the plugin.
119
- *
120
- * @since 2.2.4 | Created | 1 MAY 2017
121
- * @access public
122
- * @return string The HTML for an error notice if triggered
123
- */
124
- class swp_curl_check extends swp_custom_check
125
- {
126
- public function __construct()
127
- {
128
- $this->name = 'Curl Check';
129
- }
130
-
131
- public function run()
132
- {
133
-
134
- if( function_exists( 'curl_version' ) )
135
- {
136
- $this->check_passed = true;
137
- }
138
- else
139
- {
140
- $this->check_passed = false;
141
- $this->whats_wrong = 'Your server has cURL disabled. In order for our plugin to fetch share counts, you must have cURL enabled on your server.';
142
- $this->how_to_fix = 'To fix this, simply contact your hosting provider and ask them to activate cURL on your server.';
143
- }
144
-
145
- return $this->check_passed;
146
- }
147
- }
1
+ <?php
2
+ /**
3
+ * A series of classes to check the user's system for minimum system requirements
4
+ *
5
+ * @package social-warfare\functions\admin
6
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
+ * @license GPL-3.0+
8
+ * @since 2.2.4 | Created | 1 MAY 2017
9
+ */
10
+
11
+ /**
12
+ * A class for initializing the system checks
13
+ *
14
+ * @since 2.2.4 | Created | 1 MAY 2017
15
+ * @access public
16
+ */
17
+ abstract class swp_custom_check
18
+ {
19
+ public $name = "";
20
+ public $whats_wrong = "";
21
+ public $how_to_fix= "";
22
+ public $check_passed = null;
23
+ public $additional_message = null;
24
+
25
+ /**
26
+ * Force children to have an executable run method.
27
+ */
28
+ abstract public function run();
29
+ }
30
+
31
+ /**
32
+ * A series of classes to check the user's system for minimum system requirements
33
+ *
34
+ * @since 2.2.4 | Created | 6 March 2017
35
+ * @access public
36
+ * @return string The HTML for an error notice if triggered
37
+ */
38
+ class swp_system_checker
39
+ {
40
+ public static $custom_checks = array();
41
+ public static $has_error = FALSE;
42
+
43
+ public static function full_system_check()
44
+ {
45
+ swp_system_checker::load_all_checks();
46
+ swp_system_checker::run_all_checks();
47
+ swp_system_checker::print_all_errors();
48
+
49
+ }
50
+
51
+ public static function load_all_checks()
52
+ {
53
+ swp_system_checker::$custom_checks[ 'swp_php_check' ] = new swp_php_check();
54
+ swp_system_checker::$custom_checks[ 'swp_curl_check' ] = new swp_curl_check();
55
+ }
56
+
57
+ public static function run_all_checks()
58
+ {
59
+ foreach( swp_system_checker::$custom_checks as $custom_check )
60
+ {
61
+ if( method_exists( $custom_check, 'run' ) ) {
62
+ if( !$custom_check->run() && !$custom_check->check_passed ) {
63
+ swp_system_checker::$has_error = true;
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+ public static function print_all_errors()
70
+ {
71
+ if( !isset( swp_system_checker::$has_error ) || empty( swp_system_checker::$has_error ) ) {
72
+ return FALSE;
73
+ }
74
+
75
+ foreach( swp_system_checker::$custom_checks as $custom_check )
76
+ {
77
+ if( $custom_check->check_passed ) {
78
+ continue;
79
+ }
80
+
81
+ echo '<div class="sw-red-notice">' . $custom_check->whats_wrong . $custom_check->how_to_fix . '</div>';
82
+ }
83
+ }
84
+ }
85
+
86
+ /**
87
+ * A class to detect if the user is using a compatible version of PHP (5.3+) on their server
88
+ *
89
+ * @since 2.2.4 | Created | 1 MAY 2017
90
+ * @access public
91
+ * @return string The HTML for an error notice if triggered
92
+ */
93
+ class swp_php_check extends swp_custom_check
94
+ {
95
+ public function __construct()
96
+ {
97
+ $this->name = 'PHP Check';
98
+ }
99
+
100
+ public function run()
101
+ {
102
+ if( version_compare( PHP_VERSION, '5.2.0' ) >= 0 )
103
+ {
104
+ $this->check_passed = true;
105
+ }
106
+ else
107
+ {
108
+ $this->check_passed = false;
109
+ $this->whats_wrong = 'Your server is currently using PHP version '.PHP_VERSION.'. In order for our plugin to fetch share counts properly, you must be using PHP 5.3 or newer.';
110
+ $this->how_to_fix = 'To fix this, simply contact your hosting provider and ask them to update your server to the latest stable version of PHP.';
111
+ }
112
+
113
+ return $this->check_passed;
114
+ }
115
+ }
116
+
117
+ /**
118
+ * A class to detect if the user has cURL enabled on their server. cURL is a requirement of the plugin.
119
+ *
120
+ * @since 2.2.4 | Created | 1 MAY 2017
121
+ * @access public
122
+ * @return string The HTML for an error notice if triggered
123
+ */
124
+ class swp_curl_check extends swp_custom_check
125
+ {
126
+ public function __construct()
127
+ {
128
+ $this->name = 'Curl Check';
129
+ }
130
+
131
+ public function run()
132
+ {
133
+
134
+ if( function_exists( 'curl_version' ) )
135
+ {
136
+ $this->check_passed = true;
137
+ }
138
+ else
139
+ {
140
+ $this->check_passed = false;
141
+ $this->whats_wrong = 'Your server has cURL disabled. In order for our plugin to fetch share counts, you must have cURL enabled on your server.';
142
+ $this->how_to_fix = 'To fix this, simply contact your hosting provider and ask them to activate cURL on your server.';
143
+ }
144
+
145
+ return $this->check_passed;
146
+ }
147
+ }
functions/frontend-output/SWP_Buttons_Panel.php CHANGED
@@ -1,940 +1,925 @@
1
- <?php
2
- /**
3
- * Creates the Panel of share buttons based on options and settings.
4
- *
5
- * @package SocialWarfare\Functions
6
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
- * @license GPL-3.0+
8
- * @since 1.0.0
9
- */
10
- class SWP_Buttons_Panel {
11
- /**
12
- * Options
13
- *
14
- * We're using a local property to clone in the global $swp_user_options array. As a local options
15
- * we and other developers accessing this object can use getters and setters to change any options
16
- * possibly imaginable without affecting the global options.
17
- *
18
- * @var array
19
- *
20
- */
21
- public $options = array();
22
-
23
-
24
- /**
25
- * The Post ID
26
- *
27
- * @var int
28
- *
29
- */
30
- public $post_id;
31
-
32
-
33
- /**
34
- * The location of the buttons in relation to the content.
35
- *
36
- * @var string above | below | both | none
37
- *
38
- */
39
- public $location = 'above';
40
-
41
-
42
- /**
43
- * Arguments
44
- *
45
- * A temporary property used to store and access any arguments passed into
46
- * the constructor. These will then be processed into the other properties
47
- * as possible.
48
- *
49
- * @var array $args;
50
- *
51
- */
52
- public $args = array();
53
-
54
-
55
- /**
56
- * The Content
57
- *
58
- * The WordPress content to which we are going to append the HTML of these buttons.
59
- *
60
- * @var string $content;
61
- *
62
- */
63
- public $content = '';
64
-
65
-
66
- /**
67
- * The fully qualified HTML for the Buttons Panel.
68
- *
69
- * @var string $html;
70
- */
71
- public $html = '';
72
-
73
-
74
- /**
75
- * The array of active buttons for $this Social Panel.
76
- *
77
- * @var array $active_buttons;
78
- */
79
- public $active_buttons = array();
80
-
81
-
82
- /**
83
- * The sum of share counts across active networks.
84
- *
85
- * @var integer $total_shares;
86
- */
87
- public $total_shares = 0;
88
-
89
- /**
90
- * The Construct Method
91
- *
92
- * @param optional array $args The arguments passed in via shortcode.
93
- * @since 3.0.0 | 01 MAR 2018 | Created
94
- * @since 3.1.0 | 05 JUL 2018 | Created debug() & establish_post_data() methods.
95
- * @param optional array $args The arguments passed in via shortcode.
96
- * @param optional boolean $shortcode If a shortcode is calling this class.
97
- * @return void
98
- *
99
- */
100
- public function __construct( $args = array(), $shortcode = false ) {
101
- global $swp_social_networks;
102
-
103
- $this->networks = $swp_social_networks;
104
- $this->args = $args;
105
- $this->content = isset( $args['content'] ) ? $args['content'] : '';
106
- $this->is_shortcode = $shortcode;
107
-
108
- $this->establish_post_id();
109
- $this->establish_post_data();
110
-
111
- if ( !isset( $this->post_id ) ) :
112
- return;
113
- endif;
114
-
115
- $this->localize_options();
116
- $this->establish_share_data();
117
- $this->establish_location();
118
- $this->establish_permalink();
119
- $this->establish_active_buttons();
120
- $this->debug();
121
-
122
- add_action( 'wp_footer', array( $this, 'print_js_variables' ) );
123
- }
124
-
125
-
126
- /**
127
- * Localize the global options
128
- *
129
- * The goal here is to move the global $swp_options array into a local property so that the options
130
- * for this specific instantiation of the buttons panel can have the options manipulated prior to
131
- * rendering the HTML for the panel. We can do this by using getters and setters or by passing in
132
- * arguments.
133
- *
134
- * @since 3.0.0 | 09 APR 2018 | Created
135
- * @param array $args Arguments that can be used to change the options of the buttons panel.
136
- * @return none
137
- * @access private
138
- *
139
- */
140
- private function localize_options() {
141
- global $swp_user_options;
142
- $this->options = array_merge( $swp_user_options, $this->args );
143
- $this->post_data['options'] = $swp_user_options;
144
- }
145
-
146
-
147
- /**
148
- * Set an option
149
- *
150
- * This method allows you to change one of the options for the buttons panel.
151
- *
152
- * @since 3.0.0 | 09 APR 2018 | Created
153
- * @param string $option The key of the option to be set.
154
- * @param mixed $value The value to which we will set that option.
155
- * @return object $this Allows for method chaining.
156
- * @access public
157
- *
158
- */
159
- public function set_option( $option , $value ) {
160
- $this->options[$this->options] = $value;
161
- return $this;
162
- }
163
-
164
-
165
- /**
166
- * Set multiple options
167
- *
168
- * This method allows you to change multiple options for the buttons panel.
169
- *
170
- * @since 3.0.0 | 09 APR 2018 | Created
171
- * @param array $this->options An array of options to be merged into the existing options.
172
- * @return object $this Allows for method chaining.
173
- * @access public
174
- *
175
- */
176
- public function set_options( $options ) {
177
- array_merge( $this->options , $options );
178
- return $this;
179
- }
180
-
181
-
182
- /**
183
- * Set the post ID for this buttons panel.
184
- *
185
- * We want to use the global post ID for whichever post is being looped
186
- * through unless the post ID has been passed in as an argument.
187
- *
188
- * @since 3.0.0 | 09 APR 2018 | Created
189
- * @param array $args The array of args passed in.
190
- * @return none
191
- * @access public
192
- *
193
- */
194
- public function establish_post_id() {
195
- // Legacy support.
196
- if ( isset( $this->args['postID'] ) ) :
197
- $this->post_id = $this->args['postID'];
198
- return;
199
- endif;
200
-
201
- // Current argument.
202
- if ( isset( $this->args['post_id'] ) ) :
203
- $this->post_id = $this->args['post_id'];
204
- return;
205
- endif;
206
-
207
- if ( isset ( $this->args['id'] ) ) :
208
- $this->post_id = $this->args['id'];
209
- return;
210
- endif;
211
-
212
- global $post;
213
-
214
- if ( is_object( $post ) ) :
215
- $this->post_id = $post->ID;
216
- endif;
217
- }
218
-
219
-
220
- /**
221
- * Set the post data for this buttons panel.
222
- *
223
- * @since 3.1.0 | 05 JUL 2018 | Created
224
- * @return none
225
- * @access public
226
- * @param void
227
- * @return void
228
- *
229
- */
230
- public function establish_post_data() {
231
- if( !empty( $this->post_id ) ):
232
- $post = get_post( $this->post_id );
233
- endif;
234
-
235
- if ( is_object( $post ) ) :
236
- $this->post_data = array(
237
- 'ID' => $post->ID,
238
- 'post_type' => $post->post_type,
239
- 'permalink' => get_the_permalink( $post->ID ),
240
- 'post_title' => $post->post_title,
241
- 'post_status' => $post->post_status,
242
- 'post_content' => $post->post_content
243
- );
244
- endif;
245
- }
246
-
247
-
248
- /**
249
- * Instantiates the share data from a given post ID.
250
- *
251
- * @since 3.1.0 | 25 JUN 2018 | Created the method.
252
- * @return void
253
- * @access public
254
- *
255
- */
256
- public function establish_share_data() {
257
- global $SWP_Post_Caches;
258
- $this->shares = $SWP_Post_Caches->get_post_cache( $this->post_id )->get_shares();
259
- return $this;
260
- }
261
-
262
-
263
- /**
264
- * Establish the post content
265
- *
266
- * Take the content passed in via the $args and move it into a
267
- * local property.
268
- *
269
- * @since 3.0.0 | 18 APR 2018 | Created
270
- * @param none
271
- * @return none Everything is stored in a local property.
272
- *
273
- */
274
- public function establish_post_content() {
275
- if( isset( $this->args['content'] ) ):
276
- $this->content = $args['content'];
277
- endif;
278
- }
279
-
280
-
281
- /**
282
- * Establish Location
283
- *
284
- * A method to handle figuring out where in the content these buttons are
285
- * supposed to appear. It has to check the global options, the options set
286
- * on the post, and be able to tell if this is being called without any
287
- * content to which to append.
288
- *
289
- * @since 3.0.0 | 10 APR 2018 | Created
290
- * @since 3.0.7 | 15 MAY 2018 | Added conditionals to ensure $post_setting isn't an array.
291
- * @param none
292
- * @return none All values are stored in local properties.
293
- * @access public
294
- *
295
- */
296
- public function establish_location() {
297
- //* Establish a default.
298
- $this->location = 'none';
299
-
300
- // Return with the location set to none if we are on attachment pages.
301
- if( is_attachment() ):
302
- return;
303
- endif;
304
-
305
- // If there is no content, this must be called directly via function or shortcode.
306
- if ( empty( $this->content ) && is_singular() ):
307
- $this->location = 'above';
308
- endif;
309
-
310
- /**
311
- * Location from the Post Options
312
- *
313
- * If the location was specified on the post options, we'll make sure
314
- * to use this instead of the global options.
315
- *
316
- */
317
- $post_setting = get_post_meta( $this->post_id, 'swp_post_location', true );
318
-
319
- if( is_array($post_setting) ) :
320
- $post_setting = $post_setting[0];
321
- endif;
322
-
323
- // If the location is set in the post options, use that.
324
- if ( !empty( $post_setting ) && 'default' != $post_setting ) {
325
- $this->location = $post_setting;
326
-
327
- //* Exit early because this is a priority.
328
- return;
329
- };
330
-
331
-
332
- /**
333
- * Global Location Settings
334
- *
335
- * Decide which post type we're on and pull the location setting
336
- * for that type from the global options.
337
- *
338
- */
339
- // If we are on the home page
340
- if( is_front_page() ):
341
- $home = $this->options['location_home'];
342
- $this->location = isset( $home ) ? $home : 'none';
343
- endif;
344
-
345
- // If we are on a singular page
346
- if ( is_singular() && !is_front_page() ) :
347
- $location = $this->options[ 'location_' . $this->post_data['post_type'] ];
348
- if ( isset( $location ) ) :
349
- $this->location = $location;
350
- endif;
351
- endif;
352
-
353
- if ( is_archive() || is_home() ) :
354
- $this->location = $this->options['location_archive_categories'];
355
- endif;
356
- }
357
-
358
-
359
- /**
360
- * Takes a display name and returns the snake_cased key of that name.
361
- *
362
- * This is used to convert a network's name, such as Google Plus,
363
- * to the database-friendly key of google_plus.
364
- *
365
- * @since 3.0.0 | 18 APR 2018 | Created
366
- * @param string $name The string to convert.
367
- * @return string The converted string.
368
- *
369
- */
370
- public function display_name_to_key( $string ) {
371
- return preg_replace( '/[\s]+/', '_', strtolower( trim ( $string ) ) );
372
- }
373
-
374
-
375
- protected function establish_permalink() {
376
- $this->permalink = get_permalink( $this->post_id );
377
- }
378
-
379
-
380
- /**
381
- * When we have known incompatability with other themes/plugins,
382
- * we can put those checks in here.
383
- *
384
- * Checks for known conflicts with other plugins and themes.
385
- *
386
- * If there is a fatal conflict, returns true and exits printing.
387
- * If there are other conflicts, they are silently handled and can still
388
- * print.
389
- *
390
- * @since 3.0.0 | 01 MAR 2018 | Created
391
- * @param void
392
- * @return bool $conflict True iff the conflict is fatal.
393
- *
394
- */
395
- protected function has_plugin_conflict() {
396
-
397
- // Disable subtitles plugin to prevent it from injecting subtitles
398
- // into our share titles.
399
- if ( is_plugin_active( 'subtitles/subtitles.php' ) && class_exists( 'Subtitles' ) ) :
400
- remove_filter( 'the_title', array( Subtitles::getinstance(), 'the_subtitle' ), 10, 2 );
401
- endif;
402
-
403
- //* Disable on BuddyPress pages.
404
- if ( function_exists( 'is_buddypress' ) && is_buddypress() ) :
405
- return true;
406
- endif;
407
-
408
- return false;
409
- }
410
-
411
-
412
- /**
413
- * Tells you true/false if the buttons should print on this page.
414
- *
415
- * Each variable is a boolean value. For the buttons to eligible for printing,
416
- * each of the variables must evaluate to true.
417
- *
418
- * $user_settings: Options editable by the Admin user.
419
- * $desired_conditions: WordPress conditions we require for the buttons.
420
- * $undesired_conditions: WordPress pages where we do not display the buttons.
421
- *
422
- *
423
- * @return Boolean True if the buttons are okay to print, else false.
424
- * @since 3.0.8 | 21 MAY 2018 | Added extra condition to check for content
425
- * (for calls to social_warfare()).
426
- * @param void
427
- * @return void
428
- *
429
- */
430
- public function should_print() {
431
-
432
- //* WordPress requires title and content. This indicates the buttons are called via social_warfare().
433
- if ( empty( $this->content ) && !isset( $this->args['content'] ) ) :
434
- return true;
435
- endif;
436
-
437
- $user_settings = $this->location !== 'none';
438
-
439
- $desired_conditions = is_main_query() && in_the_loop() && get_post_status( $this->post_id ) === 'publish';
440
-
441
- $undesired_conditions = is_admin() || is_feed() || is_search() || is_attachment();
442
-
443
- return $user_settings && $desired_conditions && !$undesired_conditions;
444
- }
445
-
446
-
447
- /**
448
- * The method that renderes the button panel HTML.
449
- *
450
- * @since 3.0.0 | 25 APR 2018 | Created
451
- * @since 3.0.3 | 09 MAY 2018 | Switched the button locations to use the
452
- * location methods instead of the raw options value.
453
- * @since 3.0.6 | 15 MAY 2018 | Uses $this->option() method to prevent undefined index error.
454
- * @param boolean $echo Echo's the content or returns it if false.
455
- * @return string The string of HTML.
456
- *
457
- */
458
- public function render_HTML( $echo = false ) {
459
- if ( !isset( $this->post_id ) ) :
460
- return;
461
- endif;
462
-
463
- if ( !$this->should_print() ) :
464
- return $this->content;
465
- endif;
466
-
467
- $total_shares_html = $this->render_total_shares_html();
468
- $buttons = $this->render_buttons_html();
469
-
470
- // Create the HTML Buttons panel wrapper
471
- $container = '<div class="swp_social_panel swp_' . $this->option('button_shape') .
472
- ' swp_default_' . $this->option('default_colors') .
473
- ' swp_individual_' . $this->option('single_colors') .
474
- ' swp_other_' . $this->option('hover_colors') .
475
- ' scale-' . $this->option('button_size') * 100 .
476
- ' scale-' . $this->option('button_alignment') .
477
- '" data-min-width="' . $this->option('float_screen_width') .
478
- '" data-panel-position="' . $this->option('location_post') .
479
- '" data-float="' . $this->get_float_location() .
480
- '" data-float-mobile="' . $this->get_mobile_float_location() .
481
- '" data-count="' . $this->total_shares .
482
- '" data-float-color="' . $this->option('float_background_color') . '
483
- ">';
484
- //* This should be inserted via addon, not here.
485
- //'" data-emphasize="'.$this->option('emphasize_icons').'
486
-
487
- if ($this->option('totals_alignment') === 'totals_left') :
488
- $buttons = $total_shares_html . $buttons;
489
- else:
490
- $buttons .= $total_shares_html;
491
- endif;
492
-
493
- $html = $container . $buttons . '</div>';
494
- $this->html = $html;
495
- if ( $echo ) :
496
- if( true == _swp_is_debug('buttons_output')):
497
- echo 'Echoing, not returning. In SWP_Buttons_Panel on line '.__LINE__;
498
- endif;
499
- echo $html;
500
- endif;
501
-
502
- return $html;
503
- }
504
-
505
-
506
- /**
507
- * A function to avoid getting undefined index notices.
508
- *
509
- * @since 3.0.5 | 10 MAY 2018 | Created
510
- * @param string $key The name of the option.
511
- * @return mixed The value of that option.
512
- *
513
- */
514
- private function option($key) {
515
-
516
- $defaults = array();
517
- $defaults = apply_filters('swp_options_page_defaults' , $defaults );
518
-
519
- if( isset( $this->options[$key] ) ):
520
- return $this->options[$key];
521
- elseif( isset( $defaults[$key] ) ):
522
- return $defaults[$key];
523
- else:
524
- return false;
525
- endif;
526
- }
527
-
528
-
529
- /**
530
- * A Method to determine the location of the floating buttons
531
- *
532
- * This method was created because we can't just use the option as it is set
533
- * in the options page. Instead, we must first check that we are on a single.php
534
- * page and second we must check that the floating buttons toggle is turned on.
535
- * Then and only then will we check the actual floating location and return it.
536
- *
537
- * @since 3.0.0 | 09 MAY 2018 | Created
538
- * @since 3.0.4 | 09 MAY 2018 | Added check for the global post type on/off toggle.
539
- * @param none
540
- * @return string A string containing the float bar location.
541
- *
542
- */
543
- public function get_float_location() {
544
- $post_on = false;
545
-
546
- if( is_home() && !is_front_page() || !isset( $this->post_id ) ):
547
- return 'none';
548
- endif;
549
-
550
- $post_setting = get_post_meta( $this->post_id, 'swp_float_location', true );
551
-
552
- if( is_array( $post_setting ) ) :
553
- $post_setting = $post_setting[0];
554
- endif;
555
-
556
- // If the location is set in the post options, use that.
557
- if ( !empty( $post_setting ) && 'default' != $post_setting ) {
558
- if( 'off' === $post_setting) :
559
- return 'none';
560
- endif;
561
-
562
- $post_on = true;
563
- };
564
-
565
- if ( $post_on || is_singular() && true === $this->option('floating_panel') && 'on' === $this->option('float_location_' . $this->post_data['post_type'] ) ) :
566
- return $this->option('float_location');
567
- endif;
568
-
569
- return 'none';
570
- }
571
-
572
-
573
- /**
574
- * A Method to determine the location of the floating buttons on mobile devices
575
- *
576
- * This method was created because we can't just use the option as it is set
577
- * in the options page. Instead, we must first check that we are on a single.php
578
- * page and second we must check that the floating buttons toggle is turned on.
579
- * Then and only then will we check the actual floating location and return it.
580
- *
581
- * @since 3.0.0 | 09 MAY 2018 | Created
582
- * @since 3.0.4 | 09 MAY 2018 | Added check for the global post type on/off toggle.
583
- * @param none
584
- * @return string A string containing the float bar location.
585
- *
586
- */
587
- public function get_mobile_float_location() {
588
- if( is_home() || is_front_page() ):
589
- return 'none';
590
- elseif( is_single() && true == $this->option('floating_panel') && 'on' == $this->option('float_location_' . $this->post_data['post_type'] ) ):
591
- return $this->option('float_mobile');
592
- else:
593
- return 'none';
594
- endif;
595
- }
596
-
597
-
598
- /**
599
- * Creates the fully qualified markup for floating button panel.
600
- *
601
- * @since 3.0.0 | 01 MAR 2018 | Created
602
- * @since 3.0.8 | 22 MAY 2018 | Added the $blacklist and in_array conditional.
603
- * @param boolean $echo Whether or not to immediately echo the HTML.
604
- * @return string $html The qualified markup for the panel.
605
- *
606
- */
607
- public function render_floating_HTML( $echo = true ) {
608
- $blacklist = ['none', 'top', 'bottom'];
609
-
610
- if ( in_array( $this->option('float_location'), $blacklist ) ) :
611
- return '';
612
- endif;
613
-
614
- if( is_singular() && 'none' !== $this->get_float_location() ):
615
-
616
- //* BEGIN Old boilerplate that needs to be refactored.
617
- $class = "";
618
- $size = $this->option('float_size') * 100;
619
- $side = $this->option('float_location');
620
- $max_buttons = $this->option( 'float_button_count' );
621
-
622
- if( false == $max_buttons || 0 == $max_buttons ):
623
- $max_buttons = 5;
624
- endif;
625
-
626
- // Acquire the social stats from the networks
627
- if ( isset( $array['url'] ) ) :
628
- $buttonsArray['url'] = $array['url'];
629
- else :
630
- $buttonsArray['url'] = get_permalink( $this->post_id );
631
- endif;
632
-
633
- if ( 'none' != $this->get_float_location() ) :
634
- $float_location = $this->option('float_location');
635
- $class = "swp_float_" . $this->option('float_location');
636
- else :
637
- // $float_location = 'ignore';
638
- endif;
639
-
640
- if ( $this->options['float_style_source'] == true ) :
641
- $this->options['float_default_colors'] = $this->option('default_colors');
642
- $this->options['float_single_colors'] = $this->option('single_colors');
643
- $this->options['float_hover_colors'] = $this->option('hover_colors');
644
- endif;
645
-
646
- // *Get the vertical position
647
- if ($this->option('float_alignment') ) :
648
- $class .= " swp_side_" . $this->option('float_alignment');
649
- endif;
650
-
651
- // *Set button size
652
- if ( isset($this->options['float_size']) ) :
653
- $position = $this->option('float_alignment');
654
- $class .= " scale-${size} float-position-${position}-${side}";
655
- endif;
656
-
657
- //* END old boilerplate.
658
-
659
- $share_counts = $this->render_total_shares_HTML();
660
- $buttons = $this->render_buttons_HTML( (int) $max_buttons );
661
-
662
- $container = '<div class="swp_social_panelSide swp_social_panel swp_'. $this->option('float_button_shape') .
663
- ' swp_default_' . $this->option('float_default_colors') .
664
- ' swp_individual_' . $this->option('float_single_colors') .
665
- ' swp_other_' . $this->option('float_hover_colors') . '
666
- ' . $this->option('transition') . '
667
- ' . $class . '
668
- ' . '" data-panel-position="' . $this->option('location_post') .
669
- ' scale-' . $this->option('float_size') * 100 .
670
- '" data-float="' . $float_location .
671
- '" data-count="' . count($this->networks) .
672
- '" data-float-color="' . $this->option('float_background_color') .
673
- '" data-min-width="' . $this->option('float_screen_width') .
674
- '" data-transition="' . $this->option('transition') .
675
- '" data-float-mobile="' . $this->get_mobile_float_location() .'">';
676
-
677
- if ($this->option('totals_alignment') === 'totals_left') :
678
- $buttons = $share_counts . $buttons;
679
- else:
680
- $buttons .= $share_counts;
681
- endif;
682
-
683
- $html = $container . $buttons . '</div>';
684
- $this->html = $html;
685
-
686
- if ( $echo ) :
687
- echo $html;
688
- endif;
689
-
690
- return $html;
691
- endif;
692
-
693
- }
694
-
695
-
696
- /**
697
- * A method to establish the active buttons for this panel.
698
- *
699
- * First it will check to see if user arguments have been passed in. If not, it will
700
- * check to see if they are set to manual or dynamic sorting. If manual, we will use
701
- * the buttons in the order they were stored in the options array (they were set in
702
- * this order on the options page.) If dynamic, we will look at the share counts and
703
- * order them with the largest share counts appearing first.
704
- *
705
- * The results will be stored as an ordered array of network objects in the
706
- * $this->networks property.
707
- *
708
- * @since 3.0.0 | 04 MAY 2018 | Created
709
- * @param none
710
- * @return object $this Allows for method chaining.
711
- *
712
- */
713
- public function establish_active_buttons() {
714
- $network_objects = array();
715
-
716
- //* Specified buttons take precedence to global options.
717
- if ( isset( $this->args['buttons'] ) ) :
718
- $this->args['buttons'] = explode( ',', $this->args['buttons'] );
719
-
720
- foreach ( $this->args['buttons'] as $counts_key ) {
721
- $network_key = $this->display_name_to_key( $counts_key );
722
- foreach( $this->networks as $key => $network ):
723
- if( $network_key === $key ):
724
- $network_objects[] = $network;
725
- endif;
726
- endforeach;
727
- }
728
-
729
- //* Use global button settings.
730
- else :
731
-
732
- // Order manually using the user's specified order.
733
- if ( $this->options['order_of_icons_method'] === 'manual' ) :
734
- $order = $this->options['order_of_icons'];
735
-
736
- // Order them dynamically according to share counts.
737
- else :
738
- $order = $this->get_dynamic_buttons_order();
739
- endif;
740
-
741
- $network_objects = $this->order_network_objects($order);
742
- endif;
743
-
744
- $this->networks = $network_objects;
745
- return $this;
746
- }
747
-
748
-
749
- /**
750
- * A method to order the networks dynamically.
751
- *
752
- * @since 3.0.0 | 04 MAY 2018 | Created
753
- * @param none
754
- * @return object An ordered array containing the social network objects.
755
- *
756
- */
757
- protected function get_dynamic_buttons_order() {
758
- $order = array();
759
- if( !empty( $this->shares ) && is_array( $this->shares ) ):
760
- arsort( $this->shares );
761
- foreach( $this->shares as $key => $value ):
762
- if($key !== 'total_shares'):
763
- $order[$key] = $key;
764
- endif;
765
- endforeach;
766
- $this->options['order_of_icons'] = $order;
767
- else:
768
- $order = $this->options['order_of_icons'];
769
- endif;
770
- return $order;
771
- }
772
-
773
-
774
- /**
775
- * A method to shuffle the array of network objects.
776
- *
777
- * @since 3.0.0 | 04 MAY 2018 | Created
778
- * @param array $order An ordered array of network keys.
779
- * @return array An ordered array of network objects.
780
- *
781
- */
782
- public function order_network_objects( $order ) {
783
- $network_objects = array();
784
- foreach( $order as $network_key ) {
785
- foreach( $this->networks as $key => $network ) :
786
- if ( $key === $network_key ) :
787
- $network_objects[$key] = $network;
788
- endif;
789
- endforeach;
790
- }
791
- return $network_objects;
792
- }
793
-
794
-
795
- public function render_buttons_HTML( $max_count = null) {
796
- $html = '';
797
- $count = 0;
798
-
799
- foreach( $this->networks as $key => $network ) {
800
- if ( isset( $max_count) && $count === $max_count) :
801
- return $html;
802
- endif;
803
-
804
- // Pass in some context for this specific panel of buttons
805
- $context['shares'] = $this->shares;
806
- $context['options'] = $this->options;
807
- $context['post_data'] = $this->post_data;
808
- $html .= $network->render_HTML( $context );
809
- $count++;
810
- }
811
- return $html;
812
- }
813
-
814
-
815
- /**
816
- * The Total Shares Count
817
- *
818
- * If share counts are active, renders the Total Share Counts HTML.
819
- *
820
- * @since 3.0.0 | 18 APR 2018 | Created
821
- * @param none
822
- * @return string $html The fully qualified HTML to display share counts.
823
- * @todo Simplify that conditional. Maybe break it into another method.
824
- *
825
- */
826
- public function render_total_shares_html() {
827
- $buttons = isset( $this->args['buttons'] ) ? $this->args['buttons'] : array();
828
-
829
- $totals_argument = in_array( 'total', $buttons ) || in_array( 'totals', $buttons );
830
-
831
- if ( empty( $this->shares['total_shares'])
832
- || $this->shares['total_shares'] < $this->option('minimum_shares')
833
- || false == $this->option('total_shares')
834
- || $this->is_shortcode && !$totals_argument ) {
835
- return '';
836
- }
837
-
838
- $html = '<div class="nc_tweetContainer total_shares total_sharesalt" >';
839
- $html .= '<span class="swp_count ">' . swp_kilomega( $this->shares['total_shares'] ) . ' <span class="swp_label">' . __( 'Shares','social-warfare' ) . '</span></span>';
840
- $html .= '</div>';
841
-
842
- return $html;
843
- }
844
-
845
-
846
- /**
847
- * Handles whether to echo the HTML or return it as a string.
848
- *
849
- * @since 3.0.6 | 14 MAY 2018 | Removed the swp-content-locator div.
850
- * @param void
851
- * @return mixed null if set to echo, else a string of HTML.
852
- *
853
- */
854
- public function do_print() {
855
-
856
- $this->render_HTML();
857
-
858
- //* Add the Panel markup based on the location.
859
- if ( $this->location === 'both' ) :
860
- $content = $this->html . $this->content . $this->html;
861
- elseif ( $this->location === 'above' ) :
862
- $content = $this->html . $this->content;
863
- else :
864
- $content = $this->content . $this->html;
865
- endif;
866
-
867
- $this->content = $content;
868
-
869
- if ( isset( $this->args['echo']) && true === $this->args['echo'] ) {
870
-
871
- echo $this->content;
872
- }
873
-
874
- return $this->content;
875
- }
876
-
877
-
878
- /**
879
- * Runs checks before ordering a set of buttons.
880
- *
881
- * @since 3.0.6 | 14 MAY 2018 | Removed the swp-content-locator div.
882
- * @param string $content The WordPress content, if passed in.
883
- * @return function @see $this->do_print
884
- *
885
- */
886
- public function the_buttons( $content = null ) {
887
- if ( empty( $this->content ) ) :
888
- return $this->do_print();
889
- endif;
890
-
891
- if ( ! $this->should_print() ) :
892
- return $this->args['content'];
893
- endif;
894
-
895
- if ( null !== $content && gettype( $content ) === 'string' ) :
896
- $this->args['content'] = $content;
897
- endif;
898
-
899
- if ( $this->has_plugin_conflict() ) {
900
- return;
901
- }
902
-
903
- return $this->do_print();
904
- }
905
-
906
-
907
- /**
908
- * Echoes selected admin settings from the database to javascript.
909
- *
910
- * @since 3.1.0 | 27 JUN 2018 | Created the method.
911
- * @access public
912
- * @return void
913
- *
914
- */
915
- public function print_js_variables() {
916
- global $swp_user_options;
917
- $float_before_content = $swp_user_options['float_before_content'];
918
-
919
- echo '<script type="text/javascript">
920
- var swpFloatBeforeContent = ' . json_encode($float_before_content) . ';
921
- </script>';
922
- }
923
-
924
-
925
- /**
926
- * Holds the query paramters for debugging.
927
- *
928
- * @since 3.1.0 | 05 JUL 2018 | Created the method.
929
- * @param void
930
- * @return void
931
- *
932
- */
933
- public function debug() {
934
- if ( true === _swp_is_debug( 'buttons_panel' ) ) :
935
- echo "<pre>";
936
- var_dump($this);
937
- echo "</pre>";
938
- endif;
939
- }
940
- }
1
+ <?php
2
+ /**
3
+ * Creates the Panel of share buttons based on options and settings.
4
+ *
5
+ * @package SocialWarfare\Functions
6
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
+ * @license GPL-3.0+
8
+ * @since 1.0.0
9
+ */
10
+ class SWP_Buttons_Panel {
11
+ /**
12
+ * Options
13
+ *
14
+ * We're using a local property to clone in the global $swp_user_options array. As a local options
15
+ * we and other developers accessing this object can use getters and setters to change any options
16
+ * possibly imaginable without affecting the global options.
17
+ *
18
+ * @var array
19
+ *
20
+ */
21
+ public $options = array();
22
+
23
+
24
+ /**
25
+ * The Post ID
26
+ *
27
+ * @var int
28
+ *
29
+ */
30
+ public $post_id;
31
+
32
+
33
+ /**
34
+ * The location of the buttons in relation to the content.
35
+ *
36
+ * @var string above | below | both | none
37
+ *
38
+ */
39
+ public $location = 'above';
40
+
41
+
42
+ /**
43
+ * Arguments
44
+ *
45
+ * A temporary property used to store and access any arguments passed into
46
+ * the constructor. These will then be processed into the other properties
47
+ * as possible.
48
+ *
49
+ * @var array $args;
50
+ *
51
+ */
52
+ public $args = array();
53
+
54
+
55
+ /**
56
+ * The Content
57
+ *
58
+ * The WordPress content to which we are going to append the HTML of these buttons.
59
+ *
60
+ * @var string $content;
61
+ *
62
+ */
63
+ public $content = '';
64
+
65
+
66
+ /**
67
+ * The fully qualified HTML for the Buttons Panel.
68
+ *
69
+ * @var string $html;
70
+ */
71
+ public $html = '';
72
+
73
+
74
+ /**
75
+ * The array of active buttons for $this Social Panel.
76
+ *
77
+ * @var array $active_buttons;
78
+ */
79
+ public $active_buttons = array();
80
+
81
+
82
+ /**
83
+ * The sum of share counts across active networks.
84
+ *
85
+ * @var integer $total_shares;
86
+ */
87
+ public $total_shares = 0;
88
+
89
+ /**
90
+ * The Construct Method
91
+ *
92
+ * @param optional array $args The arguments passed in via shortcode.
93
+ * @since 3.0.0 | 01 MAR 2018 | Created
94
+ * @since 3.1.0 | 05 JUL 2018 | Created debug() & establish_post_data() methods.
95
+ * @param optional array $args The arguments passed in via shortcode.
96
+ * @param optional boolean $shortcode If a shortcode is calling this class.
97
+ * @return void
98
+ *
99
+ */
100
+ public function __construct( $args = array(), $shortcode = false ) {
101
+ global $swp_social_networks;
102
+
103
+ $this->networks = $swp_social_networks;
104
+ $this->args = $args;
105
+ $this->content = isset( $args['content'] ) ? $args['content'] : '';
106
+ $this->is_shortcode = $shortcode;
107
+
108
+ $this->establish_post_id();
109
+ $this->establish_post_data();
110
+
111
+ if ( !isset( $this->post_id ) ) :
112
+ return;
113
+ endif;
114
+
115
+ $this->localize_options();
116
+ $this->establish_share_data();
117
+ $this->establish_location();
118
+ $this->establish_permalink();
119
+ $this->establish_active_buttons();
120
+ $this->debug();
121
+ }
122
+
123
+
124
+ /**
125
+ * Localize the global options
126
+ *
127
+ * The goal here is to move the global $swp_options array into a local property so that the options
128
+ * for this specific instantiation of the buttons panel can have the options manipulated prior to
129
+ * rendering the HTML for the panel. We can do this by using getters and setters or by passing in
130
+ * arguments.
131
+ *
132
+ * @since 3.0.0 | 09 APR 2018 | Created
133
+ * @param array $args Arguments that can be used to change the options of the buttons panel.
134
+ * @return none
135
+ * @access private
136
+ *
137
+ */
138
+ private function localize_options() {
139
+ global $swp_user_options;
140
+ $this->options = array_merge( $swp_user_options, $this->args );
141
+ $this->post_data['options'] = $swp_user_options;
142
+ }
143
+
144
+
145
+ /**
146
+ * Set an option
147
+ *
148
+ * This method allows you to change one of the options for the buttons panel.
149
+ *
150
+ * @since 3.0.0 | 09 APR 2018 | Created
151
+ * @param string $option The key of the option to be set.
152
+ * @param mixed $value The value to which we will set that option.
153
+ * @return object $this Allows for method chaining.
154
+ * @access public
155
+ *
156
+ */
157
+ public function set_option( $option , $value ) {
158
+ $this->options[$this->options] = $value;
159
+ return $this;
160
+ }
161
+
162
+
163
+ /**
164
+ * Set multiple options
165
+ *
166
+ * This method allows you to change multiple options for the buttons panel.
167
+ *
168
+ * @since 3.0.0 | 09 APR 2018 | Created
169
+ * @param array $this->options An array of options to be merged into the existing options.
170
+ * @return object $this Allows for method chaining.
171
+ * @access public
172
+ *
173
+ */
174
+ public function set_options( $options ) {
175
+ array_merge( $this->options , $options );
176
+ return $this;
177
+ }
178
+
179
+
180
+ /**
181
+ * Set the post ID for this buttons panel.
182
+ *
183
+ * We want to use the global post ID for whichever post is being looped
184
+ * through unless the post ID has been passed in as an argument.
185
+ *
186
+ * @since 3.0.0 | 09 APR 2018 | Created
187
+ * @param array $args The array of args passed in.
188
+ * @return none
189
+ * @access public
190
+ *
191
+ */
192
+ public function establish_post_id() {
193
+ // Legacy support.
194
+ if ( isset( $this->args['postID'] ) ) :
195
+ $this->post_id = $this->args['postID'];
196
+ return;
197
+ endif;
198
+
199
+ // Current argument.
200
+ if ( isset( $this->args['post_id'] ) ) :
201
+ $this->post_id = $this->args['post_id'];
202
+ return;
203
+ endif;
204
+
205
+ if ( isset ( $this->args['id'] ) ) :
206
+ $this->post_id = $this->args['id'];
207
+ return;
208
+ endif;
209
+
210
+ global $post;
211
+
212
+ if ( is_object( $post ) ) :
213
+ $this->post_id = $post->ID;
214
+ endif;
215
+ }
216
+
217
+
218
+ /**
219
+ * Set the post data for this buttons panel.
220
+ *
221
+ * @since 3.1.0 | 05 JUL 2018 | Created
222
+ * @return none
223
+ * @access public
224
+ * @param void
225
+ * @return void
226
+ *
227
+ */
228
+ public function establish_post_data() {
229
+ if( !empty( $this->post_id ) ):
230
+ $post = get_post( $this->post_id );
231
+ endif;
232
+
233
+ if ( is_object( $post ) ) :
234
+ $this->post_data = array(
235
+ 'ID' => $post->ID,
236
+ 'post_type' => $post->post_type,
237
+ 'permalink' => get_the_permalink( $post->ID ),
238
+ 'post_title' => $post->post_title,
239
+ 'post_status' => $post->post_status,
240
+ 'post_content' => $post->post_content
241
+ );
242
+ endif;
243
+ }
244
+
245
+
246
+ /**
247
+ * Instantiates the share data from a given post ID.
248
+ *
249
+ * @since 3.1.0 | 25 JUN 2018 | Created the method.
250
+ * @return void
251
+ * @access public
252
+ *
253
+ */
254
+ public function establish_share_data() {
255
+ global $SWP_Post_Caches;
256
+ $this->shares = $SWP_Post_Caches->get_post_cache( $this->post_id )->get_shares();
257
+ return $this;
258
+ }
259
+
260
+
261
+ /**
262
+ * Establish the post content
263
+ *
264
+ * Take the content passed in via the $args and move it into a
265
+ * local property.
266
+ *
267
+ * @since 3.0.0 | 18 APR 2018 | Created
268
+ * @param none
269
+ * @return none Everything is stored in a local property.
270
+ *
271
+ */
272
+ public function establish_post_content() {
273
+ if( isset( $this->args['content'] ) ):
274
+ $this->content = $args['content'];
275
+ endif;
276
+ }
277
+
278
+
279
+ /**
280
+ * Establish Location
281
+ *
282
+ * A method to handle figuring out where in the content these buttons are
283
+ * supposed to appear. It has to check the global options, the options set
284
+ * on the post, and be able to tell if this is being called without any
285
+ * content to which to append.
286
+ *
287
+ * @since 3.0.0 | 10 APR 2018 | Created
288
+ * @since 3.0.7 | 15 MAY 2018 | Added conditionals to ensure $post_setting isn't an array.
289
+ * @param none
290
+ * @return none All values are stored in local properties.
291
+ * @access public
292
+ *
293
+ */
294
+ public function establish_location() {
295
+ //* Establish a default.
296
+ $this->location = 'none';
297
+
298
+ // Return with the location set to none if we are on attachment pages.
299
+ if( is_attachment() ):
300
+ return;
301
+ endif;
302
+
303
+ // If there is no content, this must be called directly via function or shortcode.
304
+ if ( empty( $this->content ) && is_singular() ):
305
+ $this->location = 'above';
306
+ endif;
307
+
308
+ /**
309
+ * Location from the Post Options
310
+ *
311
+ * If the location was specified on the post options, we'll make sure
312
+ * to use this instead of the global options.
313
+ *
314
+ */
315
+ $post_setting = get_post_meta( $this->post_id, 'swp_post_location', true );
316
+
317
+ if( is_array($post_setting) ) :
318
+ $post_setting = $post_setting[0];
319
+ endif;
320
+
321
+ // If the location is set in the post options, use that.
322
+ if ( !empty( $post_setting ) && 'default' != $post_setting ) {
323
+ $this->location = $post_setting;
324
+
325
+ //* Exit early because this is a priority.
326
+ return;
327
+ };
328
+
329
+
330
+ /**
331
+ * Global Location Settings
332
+ *
333
+ * Decide which post type we're on and pull the location setting
334
+ * for that type from the global options.
335
+ *
336
+ */
337
+ // If we are on the home page
338
+ if( is_front_page() ):
339
+ $home = $this->options['location_home'];
340
+ $this->location = isset( $home ) ? $home : 'none';
341
+ endif;
342
+
343
+ // If we are on a singular page
344
+ if ( is_singular() && !is_front_page() ) :
345
+ $location = $this->options[ 'location_' . $this->post_data['post_type'] ];
346
+ if ( isset( $location ) ) :
347
+ $this->location = $location;
348
+ endif;
349
+ endif;
350
+
351
+ if ( is_archive() || is_home() ) :
352
+ $this->location = $this->options['location_archive_categories'];
353
+ endif;
354
+ }
355
+
356
+
357
+ /**
358
+ * Takes a display name and returns the snake_cased key of that name.
359
+ *
360
+ * This is used to convert a network's name, such as Google Plus,
361
+ * to the database-friendly key of google_plus.
362
+ *
363
+ * @since 3.0.0 | 18 APR 2018 | Created
364
+ * @param string $name The string to convert.
365
+ * @return string The converted string.
366
+ *
367
+ */
368
+ public function display_name_to_key( $string ) {
369
+ return preg_replace( '/[\s]+/', '_', strtolower( trim ( $string ) ) );
370
+ }
371
+
372
+
373
+ protected function establish_permalink() {
374
+ $this->permalink = get_permalink( $this->post_id );
375
+ }
376
+
377
+
378
+ /**
379
+ * When we have known incompatability with other themes/plugins,
380
+ * we can put those checks in here.
381
+ *
382
+ * Checks for known conflicts with other plugins and themes.
383
+ *
384
+ * If there is a fatal conflict, returns true and exits printing.
385
+ * If there are other conflicts, they are silently handled and can still
386
+ * print.
387
+ *
388
+ * @since 3.0.0 | 01 MAR 2018 | Created
389
+ * @param void
390
+ * @return bool $conflict True iff the conflict is fatal.
391
+ *
392
+ */
393
+ protected function has_plugin_conflict() {
394
+
395
+ // Disable subtitles plugin to prevent it from injecting subtitles
396
+ // into our share titles.
397
+ if ( is_plugin_active( 'subtitles/subtitles.php' ) && class_exists( 'Subtitles' ) ) :
398
+ remove_filter( 'the_title', array( Subtitles::getinstance(), 'the_subtitle' ), 10, 2 );
399
+ endif;
400
+
401
+ //* Disable on BuddyPress pages.
402
+ if ( function_exists( 'is_buddypress' ) && is_buddypress() ) :
403
+ return true;
404
+ endif;
405
+
406
+ return false;
407
+ }
408
+
409
+
410
+ /**
411
+ * Tells you true/false if the buttons should print on this page.
412
+ *
413
+ * Each variable is a boolean value. For the buttons to eligible for printing,
414
+ * each of the variables must evaluate to true.
415
+ *
416
+ * $user_settings: Options editable by the Admin user.
417
+ * $desired_conditions: WordPress conditions we require for the buttons.
418
+ * $undesired_conditions: WordPress pages where we do not display the buttons.
419
+ *
420
+ *
421
+ * @return Boolean True if the buttons are okay to print, else false.
422
+ * @since 3.0.8 | 21 MAY 2018 | Added extra condition to check for content
423
+ * (for calls to social_warfare()).
424
+ * @param void
425
+ * @return void
426
+ *
427
+ */
428
+ public function should_print() {
429
+
430
+ //* WordPress requires title and content. This indicates the buttons are called via social_warfare().
431
+ if ( empty( $this->content ) && !isset( $this->args['content'] ) ) :
432
+ return true;
433
+ endif;
434
+
435
+ $user_settings = $this->location !== 'none';
436
+
437
+ $desired_conditions = is_main_query() && in_the_loop() && get_post_status( $this->post_id ) === 'publish';
438
+
439
+ $undesired_conditions = is_admin() || is_feed() || is_search() || is_attachment();
440
+
441
+ return $user_settings && $desired_conditions && !$undesired_conditions;
442
+ }
443
+
444
+
445
+ /**
446
+ * The method that renderes the button panel HTML.
447
+ *
448
+ * @since 3.0.0 | 25 APR 2018 | Created
449
+ * @since 3.0.3 | 09 MAY 2018 | Switched the button locations to use the
450
+ * location methods instead of the raw options value.
451
+ * @since 3.0.6 | 15 MAY 2018 | Uses $this->option() method to prevent undefined index error.
452
+ * @param boolean $echo Echo's the content or returns it if false.
453
+ * @return string The string of HTML.
454
+ *
455
+ */
456
+ public function render_HTML( $echo = false ) {
457
+ if ( !isset( $this->post_id ) ) :
458
+ return;
459
+ endif;
460
+
461
+ if ( !$this->should_print() ) :
462
+ return $this->content;
463
+ endif;
464
+
465
+ $total_shares_html = $this->render_total_shares_html();
466
+ $buttons = $this->render_buttons_html();
467
+
468
+ // Create the HTML Buttons panel wrapper
469
+ $container = '<div class="swp_social_panel swp_' . $this->option('button_shape') .
470
+ ' swp_default_' . $this->option('default_colors') .
471
+ ' swp_individual_' . $this->option('single_colors') .
472
+ ' swp_other_' . $this->option('hover_colors') .
473
+ ' scale-' . $this->option('button_size') * 100 .
474
+ ' scale-' . $this->option('button_alignment') .
475
+ '" data-min-width="' . $this->option('float_screen_width') .
476
+ '" data-panel-position="' . $this->option('location_post') .
477
+ '" data-float="' . $this->get_float_location() .
478
+ '" data-float-mobile="' . $this->get_mobile_float_location() .
479
+ '" data-count="' . $this->total_shares .
480
+ '" data-float-color="' . $this->option('float_background_color') . '
481
+ ">';
482
+ //* This should be inserted via addon, not here.
483
+ //'" data-emphasize="'.$this->option('emphasize_icons').'
484
+
485
+ if ($this->option('totals_alignment') === 'totals_left') :
486
+ $buttons = $total_shares_html . $buttons;
487
+ else:
488
+ $buttons .= $total_shares_html;
489
+ endif;
490
+
491
+ $html = $container . $buttons . '</div>';
492
+ $this->html = $html;
493
+ if ( $echo ) :
494
+ if( true == _swp_is_debug('buttons_output')):
495
+ echo 'Echoing, not returning. In SWP_Buttons_Panel on line '.__LINE__;
496
+ endif;
497
+ echo $html;
498
+ endif;
499
+
500
+ return $html;
501
+ }
502
+
503
+
504
+ /**
505
+ * A function to avoid getting undefined index notices.
506
+ *
507
+ * @since 3.0.5 | 10 MAY 2018 | Created
508
+ * @param string $key The name of the option.
509
+ * @return mixed The value of that option.
510
+ *
511
+ */
512
+ private function option($key) {
513
+
514
+ $defaults = array();
515
+ $defaults = apply_filters('swp_options_page_defaults' , $defaults );
516
+
517
+ if( isset( $this->options[$key] ) ):
518
+ return $this->options[$key];
519
+ elseif( isset( $defaults[$key] ) ):
520
+ return $defaults[$key];
521
+ else:
522
+ return false;
523
+ endif;
524
+ }
525
+
526
+
527
+ /**
528
+ * A Method to determine the location of the floating buttons
529
+ *
530
+ * This method was created because we can't just use the option as it is set
531
+ * in the options page. Instead, we must first check that we are on a single.php
532
+ * page and second we must check that the floating buttons toggle is turned on.
533
+ * Then and only then will we check the actual floating location and return it.
534
+ *
535
+ * @since 3.0.0 | 09 MAY 2018 | Created
536
+ * @since 3.0.4 | 09 MAY 2018 | Added check for the global post type on/off toggle.
537
+ * @param none
538
+ * @return string A string containing the float bar location.
539
+ *
540
+ */
541
+ public function get_float_location() {
542
+ $post_on = false;
543
+
544
+ if( is_home() && !is_front_page() || !isset( $this->post_id ) ):
545
+ return 'none';
546
+ endif;
547
+
548
+ $post_setting = get_post_meta( $this->post_id, 'swp_float_location', true );
549
+
550
+ if( is_array( $post_setting ) ) :
551
+ $post_setting = $post_setting[0];
552
+ endif;
553
+
554
+ // If the location is set in the post options, use that.
555
+ if ( !empty( $post_setting ) && 'default' != $post_setting ) {
556
+ if( 'off' === $post_setting) :
557
+ return 'none';
558
+ endif;
559
+
560
+ $post_on = true;
561
+ };
562
+
563
+ if ( $post_on || is_singular() && true === $this->option('floating_panel') && 'on' === $this->option('float_location_' . $this->post_data['post_type'] ) ) :
564
+ return $this->option('float_location');
565
+ endif;
566
+
567
+ return 'none';
568
+ }
569
+
570
+
571
+ /**
572
+ * A Method to determine the location of the floating buttons on mobile devices
573
+ *
574
+ * This method was created because we can't just use the option as it is set
575
+ * in the options page. Instead, we must first check that we are on a single.php
576
+ * page and second we must check that the floating buttons toggle is turned on.
577
+ * Then and only then will we check the actual floating location and return it.
578
+ *
579
+ * @since 3.0.0 | 09 MAY 2018 | Created
580
+ * @since 3.0.4 | 09 MAY 2018 | Added check for the global post type on/off toggle.
581
+ * @param none
582
+ * @return string A string containing the float bar location.
583
+ *
584
+ */
585
+ public function get_mobile_float_location() {
586
+ if( is_home() || is_front_page() ):
587
+ return 'none';
588
+ elseif( is_single() && true == $this->option('floating_panel') && 'on' == $this->option('float_location_' . $this->post_data['post_type'] ) ):
589
+ return $this->option('float_mobile');
590
+ else:
591
+ return 'none';
592
+ endif;
593
+ }
594
+
595
+
596
+ /**
597
+ * Creates the fully qualified markup for floating button panel.
598
+ *
599
+ * @since 3.0.0 | 01 MAR 2018 | Created
600
+ * @since 3.0.8 | 22 MAY 2018 | Added the $blacklist and in_array conditional.
601
+ * @param boolean $echo Whether or not to immediately echo the HTML.
602
+ * @return string $html The qualified markup for the panel.
603
+ *
604
+ */
605
+ public function render_floating_HTML( $echo = true ) {
606
+ $blacklist = ['none', 'top', 'bottom'];
607
+
608
+ if ( in_array( $this->option('float_location'), $blacklist ) ) :
609
+ return '';
610
+ endif;
611
+
612
+ if( is_singular() && 'none' !== $this->get_float_location() ):
613
+
614
+ //* BEGIN Old boilerplate that needs to be refactored.
615
+ $class = "";
616
+ $size = $this->option('float_size') * 100;
617
+ $side = $this->option('float_location');
618
+ $max_buttons = $this->option( 'float_button_count' );
619
+
620
+ if( false == $max_buttons || 0 == $max_buttons ):
621
+ $max_buttons = 5;
622
+ endif;
623
+
624
+ // Acquire the social stats from the networks
625
+ if ( isset( $array['url'] ) ) :
626
+ $buttonsArray['url'] = $array['url'];
627
+ else :
628
+ $buttonsArray['url'] = get_permalink( $this->post_id );
629
+ endif;
630
+
631
+ if ( 'none' != $this->get_float_location() ) :
632
+ $float_location = $this->option('float_location');
633
+ $class = "swp_float_" . $this->option('float_location');
634
+ else :
635
+ // $float_location = 'ignore';
636
+ endif;
637
+
638
+ if ( $this->options['float_style_source'] == true ) :
639
+ $this->options['float_default_colors'] = $this->option('default_colors');
640
+ $this->options['float_single_colors'] = $this->option('single_colors');
641
+ $this->options['float_hover_colors'] = $this->option('hover_colors');
642
+ endif;
643
+
644
+ // *Get the vertical position
645
+ if ($this->option('float_alignment') ) :
646
+ $class .= " swp_side_" . $this->option('float_alignment');
647
+ endif;
648
+
649
+ // *Set button size
650
+ if ( isset($this->options['float_size']) ) :
651
+ $position = $this->option('float_alignment');
652
+ $class .= " scale-${size} float-position-${position}-${side}";
653
+ endif;
654
+
655
+ //* END old boilerplate.
656
+
657
+ $share_counts = $this->render_total_shares_HTML();
658
+ $buttons = $this->render_buttons_HTML( (int) $max_buttons );
659
+
660
+ $container = '<div class="swp_social_panelSide swp_social_panel swp_'. $this->option('float_button_shape') .
661
+ ' swp_default_' . $this->option('float_default_colors') .
662
+ ' swp_individual_' . $this->option('float_single_colors') .
663
+ ' swp_other_' . $this->option('float_hover_colors') . '
664
+ ' . $this->option('transition') . '
665
+ ' . $class . '
666
+ ' . '" data-panel-position="' . $this->option('location_post') .
667
+ ' scale-' . $this->option('float_size') * 100 .
668
+ '" data-float="' . $float_location .
669
+ '" data-count="' . count($this->networks) .
670
+ '" data-float-color="' . $this->option('float_background_color') .
671
+ '" data-min-width="' . $this->option('float_screen_width') .
672
+ '" data-transition="' . $this->option('transition') .
673
+ '" data-float-mobile="' . $this->get_mobile_float_location() .'">';
674
+
675
+ if ($this->option('totals_alignment') === 'totals_left') :
676
+ $buttons = $share_counts . $buttons;
677
+ else:
678
+ $buttons .= $share_counts;
679
+ endif;
680
+
681
+ $html = $container . $buttons . '</div>';
682
+ $this->html = $html;
683
+
684
+ if ( $echo ) :
685
+ echo $html;
686
+ endif;
687
+
688
+ return $html;
689
+ endif;
690
+
691
+ }
692
+
693
+
694
+ /**
695
+ * A method to establish the active buttons for this panel.
696
+ *
697
+ * First it will check to see if user arguments have been passed in. If not, it will
698
+ * check to see if they are set to manual or dynamic sorting. If manual, we will use
699
+ * the buttons in the order they were stored in the options array (they were set in
700
+ * this order on the options page.) If dynamic, we will look at the share counts and
701
+ * order them with the largest share counts appearing first.
702
+ *
703
+ * The results will be stored as an ordered array of network objects in the
704
+ * $this->networks property.
705
+ *
706
+ * @since 3.0.0 | 04 MAY 2018 | Created
707
+ * @param none
708
+ * @return object $this Allows for method chaining.
709
+ *
710
+ */
711
+
712
+ public function establish_active_buttons() {
713
+ $network_objects = array();
714
+
715
+ //* Specified buttons take precedence to global options.
716
+ if ( isset( $this->args['buttons'] ) ) :
717
+ $this->args['buttons'] = explode( ',', $this->args['buttons'] );
718
+
719
+ foreach ( $this->args['buttons'] as $counts_key ) {
720
+ $network_key = $this->display_name_to_key( $counts_key );
721
+ foreach( $this->networks as $key => $network ):
722
+ if( $network_key === $key ):
723
+ $network_objects[] = $network;
724
+ endif;
725
+ endforeach;
726
+ }
727
+
728
+ //* Use global button settings.
729
+ else :
730
+
731
+ // Order manually using the user's specified order.
732
+ if ( $this->options['order_of_icons_method'] === 'manual' ) :
733
+ $order = $this->options['order_of_icons'];
734
+
735
+ // Order them dynamically according to share counts.
736
+ else :
737
+ $order = $this->get_dynamic_buttons_order();
738
+ endif;
739
+
740
+ $network_objects = $this->order_network_objects($order);
741
+ endif;
742
+
743
+ $this->networks = $network_objects;
744
+ return $this;
745
+ }
746
+
747
+
748
+ /**
749
+ * A method to order the networks dynamically.
750
+ *
751
+ * @since 3.0.0 | 04 MAY 2018 | Created
752
+ * @param none
753
+ * @return object An ordered array containing the social network objects.
754
+ *
755
+ */
756
+ protected function get_dynamic_buttons_order() {
757
+ global $swp_social_networks;
758
+ $buttons = $this->options['order_of_icons'];
759
+ $order = array();
760
+
761
+ if( !empty( $this->shares ) && is_array( $this->shares ) ):
762
+ arsort( $this->shares );
763
+ foreach( $this->shares as $key => $value ):
764
+ if($key !== 'total_shares' && in_array($key, $buttons)):
765
+
766
+ $order[$key] = $key;
767
+ endif;
768
+ endforeach;
769
+ $this->options['order_of_icons'] = $order;
770
+ else:
771
+ $order = $this->options['order_of_icons'];
772
+ endif;
773
+ return $order;
774
+ }
775
+
776
+
777
+ /**
778
+ * A method to shuffle the array of network objects.
779
+ *
780
+ * @since 3.0.0 | 04 MAY 2018 | Created
781
+ * @param array $order An ordered array of network keys.
782
+ * @return array An ordered array of network objects.
783
+ *
784
+ */
785
+ public function order_network_objects( $order ) {
786
+ $network_objects = array();
787
+ foreach( $order as $network_key ) {
788
+ foreach( $this->networks as $key => $network ) :
789
+ if ( $key === $network_key ) :
790
+ $network_objects[$key] = $network;
791
+ endif;
792
+ endforeach;
793
+ }
794
+ return $network_objects;
795
+ }
796
+
797
+
798
+ public function render_buttons_HTML( $max_count = null) {
799
+ $html = '';
800
+ $count = 0;
801
+
802
+ foreach( $this->networks as $key => $network ) {
803
+ if ( isset( $max_count) && $count === $max_count) :
804
+ return $html;
805
+ endif;
806
+
807
+ // Pass in some context for this specific panel of buttons
808
+ $context['shares'] = $this->shares;
809
+ $context['options'] = $this->options;
810
+ $context['post_data'] = $this->post_data;
811
+ $html .= $network->render_HTML( $context );
812
+ $count++;
813
+ }
814
+ return $html;
815
+ }
816
+
817
+
818
+ /**
819
+ * The Total Shares Count
820
+ *
821
+ * If share counts are active, renders the Total Share Counts HTML.
822
+ *
823
+ * @since 3.0.0 | 18 APR 2018 | Created
824
+ * @param none
825
+ * @return string $html The fully qualified HTML to display share counts.
826
+ * @todo Simplify that conditional. Maybe break it into another method.
827
+ *
828
+ */
829
+ public function render_total_shares_html() {
830
+ $buttons = isset( $this->args['buttons'] ) ? $this->args['buttons'] : array();
831
+
832
+ $totals_argument = in_array( 'total', $buttons ) || in_array( 'totals', $buttons );
833
+
834
+ if ( empty( $this->shares['total_shares'])
835
+ || $this->shares['total_shares'] < $this->option('minimum_shares')
836
+ || false == $this->option('total_shares')
837
+ || $this->is_shortcode && !$totals_argument ) {
838
+ return '';
839
+ }
840
+
841
+ $html = '<div class="nc_tweetContainer total_shares total_sharesalt" >';
842
+ $html .= '<span class="swp_count ">' . swp_kilomega( $this->shares['total_shares'] ) . ' <span class="swp_label">' . __( 'Shares','social-warfare' ) . '</span></span>';
843
+ $html .= '</div>';
844
+
845
+ return $html;
846
+ }
847
+
848
+
849
+ /**
850
+ * Handles whether to echo the HTML or return it as a string.
851
+ *
852
+ * @since 3.0.6 | 14 MAY 2018 | Removed the swp-content-locator div.
853
+ * @param void
854
+ * @return mixed null if set to echo, else a string of HTML.
855
+ *
856
+ */
857
+ public function do_print() {
858
+
859
+ $this->render_HTML();
860
+
861
+ //* Add the Panel markup based on the location.
862
+ if ( $this->location === 'both' ) :
863
+ $content = $this->html . $this->content . $this->html;
864
+ elseif ( $this->location === 'above' ) :
865
+ $content = $this->html . $this->content;
866
+ else :
867
+ $content = $this->content . $this->html;
868
+ endif;
869
+
870
+ $this->content = $content;
871
+
872
+ if ( isset( $this->args['echo']) && true === $this->args['echo'] ) {
873
+
874
+ echo $this->content;
875
+ }
876
+
877
+ return $this->content;
878
+ }
879
+
880
+
881
+ /**
882
+ * Runs checks before ordering a set of buttons.
883
+ *
884
+ * @since 3.0.6 | 14 MAY 2018 | Removed the swp-content-locator div.
885
+ * @param string $content The WordPress content, if passed in.
886
+ * @return function @see $this->do_print
887
+ *
888
+ */
889
+ public function the_buttons( $content = null ) {
890
+ if ( empty( $this->content ) ) :
891
+ return $this->do_print();
892
+ endif;
893
+
894
+ if ( ! $this->should_print() ) :
895
+ return $this->args['content'];
896
+ endif;
897
+
898
+ if ( null !== $content && gettype( $content ) === 'string' ) :
899
+ $this->args['content'] = $content;
900
+ endif;
901
+
902
+ if ( $this->has_plugin_conflict() ) {
903
+ return;
904
+ }
905
+
906
+ return $this->do_print();
907
+ }
908
+
909
+
910
+ /**
911
+ * Holds the query paramters for debugging.
912
+ *
913
+ * @since 3.1.0 | 05 JUL 2018 | Created the method.
914
+ * @param void
915
+ * @return void
916
+ *
917
+ */
918
+ public function debug() {
919
+ if ( true === _swp_is_debug( 'buttons_panel' ) ) :
920
+ echo "<pre>";
921
+ var_dump($this);
922
+ echo "</pre>";
923
+ endif;
924
+ }
925
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/frontend-output/SWP_Display.php CHANGED
@@ -1,177 +1,177 @@
1
- <?php
2
- /**
3
- * Functions to load the front end display for the
4
- *
5
- * @package SocialWarfare\Functions
6
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
- * @license GPL-3.0+
8
- * @since 1.0.0
9
- * @since 3.0.0 | 21 FEB 2018 | Refactored into a class-based system.
10
- * @since 3.1.0 | 18 JUN 2018 | Replaced brack array notation.
11
- *
12
- */
13
- class SWP_Display {
14
-
15
-
16
- /**
17
- * A global for storing post ID's to prevent duplicate processing on the
18
- * same posts. Array of post ID's that have been processed during this
19
- * pageload.
20
- *
21
- * @since 2.1.4
22
- *
23
- * @var array
24
- *
25
- */
26
- public $already_printed;
27
-
28
-
29
- /**
30
- * Options
31
- *
32
- * This property takes the global $swp_user_options array and stores it
33
- * into a local class property.
34
- *
35
- * @var array
36
- */
37
- public $options;
38
-
39
-
40
- /**
41
- * The class constructor.
42
- *
43
- * @since 3.1.0 | Changed priority for wp_footer. Makes the buttons loads
44
- * This post data instead of data in the loop.
45
- *
46
- */
47
- public function __construct() {
48
-
49
-
50
- // The global array of posts that have already been processed.
51
- global $swp_already_print;
52
-
53
- // The global array of the user-selected options.
54
- global $swp_user_options;
55
-
56
- // Declare var as array if not already done so.
57
- if ( !is_array( $swp_already_print ) ) {
58
- $swp_already_print = array();
59
- }
60
-
61
- // Move these two globals into local properties.
62
- $this->already_printed = $swp_already_print;
63
- $this->options = $swp_user_options;
64
-
65
- // Hook into the template_redirect so that is_singular() conditionals will be ready
66
- add_action( 'template_redirect', array( $this, 'activate_buttons' ) );
67
- add_action( 'wp_footer', array( $this, 'floating_buttons' ) , 20 );
68
- }
69
-
70
-
71
- /**
72
- * A function to add the buttons
73
- *
74
- * @since 2.1.4 | 01 JAN 2017 | Created
75
- * @since 3.0.6 | 14 MAY 2018 | Added second filter for the_content.
76
- * @param void
77
- * @return void
78
- *
79
- */
80
- public function activate_buttons() {
81
- // Fetch the user's settings
82
- global $swp_user_options;
83
-
84
- // Only hook into the_content filter if is_singular() is true or
85
- // they don't use excerpts on the archive pages.
86
- if( true === is_singular() || true === $swp_user_options['full_content'] ):
87
- add_filter( 'the_content', array( $this, 'social_warfare_wrapper' ) , 20 );
88
- add_filter( 'the_content', array( $this, 'add_content_locator' ), 20);
89
- endif;
90
-
91
- // If we're not on is_singlular, we'll hook into the excerpt.
92
- if (false === is_singular() && false === $swp_user_options['full_content']) {
93
- // Add the buttons to the excerpts
94
- add_filter( 'the_excerpt', array( $this, 'social_warfare_wrapper' ) );
95
- }
96
- }
97
-
98
-
99
- /**
100
- * Inserts the empty div for locating Pin images (with javascript).
101
- *
102
- * @since 3.0.6 | 14 MAY | Created the method.
103
- * @param string $content The WordPress content passed via filter.
104
- * @return void
105
- *
106
- */
107
- public function add_content_locator( $content ) {
108
- $content .= '<div class="swp-content-locator"></div>';
109
- return $content;
110
- }
111
-
112
-
113
- /**
114
- * A wrapper function for adding the buttons, content, or excerpt.
115
- *
116
- * @since 1.0.0
117
- * @param string $content The content.
118
- * @return string $content The modified content
119
- *
120
- */
121
- public function social_warfare_wrapper( $content ) {
122
-
123
- // The global WordPress post object.
124
- global $post;
125
-
126
- // Ensure it's not an embedded post
127
- if (true === is_singular() && $post->ID !== get_queried_object_id()) {
128
- return $content;
129
- }
130
-
131
- // Pass the content to the buttons constructor to place them inside.
132
- $buttons_panel = new SWP_Buttons_Panel( array( 'content' => $content ) );
133
- return $buttons_panel->the_buttons( $content );
134
- }
135
-
136
-
137
- /**
138
- * A function to add the side floating buttons to a post.
139
- *
140
- * @since 2.0.0
141
- * @param void
142
- * @return void
143
- *
144
- */
145
- function floating_buttons() {
146
-
147
- // Instantiate a new Buttons Panel.
148
- $side_panel = new SWP_Buttons_Panel( array( 'content' => "" ) );
149
-
150
- // Determine where the buttons are supposed to appear.
151
- $location = $side_panel->get_float_location();
152
- if ( 'none' === $location || 'ignore' === $location ) {
153
- return;
154
- }
155
-
156
- // Render the html to output to the screen.
157
- $side_panel->render_floating_HTML( $echo = true );
158
-
159
- return;
160
- }
161
-
162
-
163
- /**
164
- * The main social_warfare function used to create the buttons.
165
- *
166
- * @since 1.4.0
167
- * @param array $array An array of options and information to pass into the
168
- * buttons function.
169
- * @return string The modified content
170
- *
171
- */
172
- public static function social_warfare( $args = array() ) {
173
-
174
- $Buttons_Panel = new SWP_Buttons_Panel( $args );
175
- echo $Buttons_Panel->render_HTML();
176
- }
177
- }
1
+ <?php
2
+ /**
3
+ * Functions to load the front end display for the
4
+ *
5
+ * @package SocialWarfare\Functions
6
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
+ * @license GPL-3.0+
8
+ * @since 1.0.0
9
+ * @since 3.0.0 | 21 FEB 2018 | Refactored into a class-based system.
10
+ * @since 3.1.0 | 18 JUN 2018 | Replaced brack array notation.
11
+ *
12
+ */
13
+ class SWP_Display {
14
+
15
+
16
+ /**
17
+ * A global for storing post ID's to prevent duplicate processing on the
18
+ * same posts. Array of post ID's that have been processed during this
19
+ * pageload.
20
+ *
21
+ * @since 2.1.4
22
+ *
23
+ * @var array
24
+ *
25
+ */
26
+ public $already_printed;
27
+
28
+
29
+ /**
30
+ * Options
31
+ *
32
+ * This property takes the global $swp_user_options array and stores it
33
+ * into a local class property.
34
+ *
35
+ * @var array
36
+ */
37
+ public $options;
38
+
39
+
40
+ /**
41
+ * The class constructor.
42
+ *
43
+ * @since 3.1.0 | Changed priority for wp_footer. Makes the buttons loads
44
+ * This post data instead of data in the loop.
45
+ *
46
+ */
47
+ public function __construct() {
48
+
49
+
50
+ // The global array of posts that have already been processed.
51
+ global $swp_already_print;
52
+
53
+ // The global array of the user-selected options.
54
+ global $swp_user_options;
55
+
56
+ // Declare var as array if not already done so.
57
+ if ( !is_array( $swp_already_print ) ) {
58
+ $swp_already_print = array();
59
+ }
60
+
61
+ // Move these two globals into local properties.
62
+ $this->already_printed = $swp_already_print;
63
+ $this->options = $swp_user_options;
64
+
65
+ // Hook into the template_redirect so that is_singular() conditionals will be ready
66
+ add_action( 'template_redirect', array( $this, 'activate_buttons' ) );
67
+ add_action( 'wp_footer', array( $this, 'floating_buttons' ) , 20 );
68
+ }
69
+
70
+
71
+ /**
72
+ * A function to add the buttons
73
+ *
74
+ * @since 2.1.4 | 01 JAN 2017 | Created
75
+ * @since 3.0.6 | 14 MAY 2018 | Added second filter for the_content.
76
+ * @param void
77
+ * @return void
78
+ *
79
+ */
80
+ public function activate_buttons() {
81
+ // Fetch the user's settings
82
+ global $swp_user_options;
83
+
84
+ // Only hook into the_content filter if is_singular() is true or
85
+ // they don't use excerpts on the archive pages.
86
+ if( true === is_singular() || true === $swp_user_options['full_content'] ):
87
+ add_filter( 'the_content', array( $this, 'social_warfare_wrapper' ) , 20 );
88
+ add_filter( 'the_content', array( $this, 'add_content_locator' ), 20);
89
+ endif;
90
+
91
+ // If we're not on is_singlular, we'll hook into the excerpt.
92
+ if (false === is_singular() && false === $swp_user_options['full_content']) {
93
+ // Add the buttons to the excerpts
94
+ add_filter( 'the_excerpt', array( $this, 'social_warfare_wrapper' ) );
95
+ }
96
+ }
97
+
98
+
99
+ /**
100
+ * Inserts the empty div for locating Pin images (with javascript).
101
+ *
102
+ * @since 3.0.6 | 14 MAY | Created the method.
103
+ * @param string $content The WordPress content passed via filter.
104
+ * @return void
105
+ *
106
+ */
107
+ public function add_content_locator( $content ) {
108
+ $content .= '<div class="swp-content-locator"></div>';
109
+ return $content;
110
+ }
111
+
112
+
113
+ /**
114
+ * A wrapper function for adding the buttons, content, or excerpt.
115
+ *
116
+ * @since 1.0.0
117
+ * @param string $content The content.
118
+ * @return string $content The modified content
119
+ *
120
+ */
121
+ public function social_warfare_wrapper( $content ) {
122
+
123
+ // The global WordPress post object.
124
+ global $post;
125
+
126
+ // Ensure it's not an embedded post
127
+ if (true === is_singular() && $post->ID !== get_queried_object_id()) {
128
+ return $content;
129
+ }
130
+
131
+ // Pass the content to the buttons constructor to place them inside.
132
+ $buttons_panel = new SWP_Buttons_Panel( array( 'content' => $content ) );
133
+ return $buttons_panel->the_buttons( $content );
134
+ }
135
+
136
+
137
+ /**
138
+ * A function to add the side floating buttons to a post.
139
+ *
140
+ * @since 2.0.0
141
+ * @param void
142
+ * @return void
143
+ *
144
+ */
145
+ function floating_buttons() {
146
+
147
+ // Instantiate a new Buttons Panel.
148
+ $side_panel = new SWP_Buttons_Panel( array( 'content' => "" ) );
149
+
150
+ // Determine where the buttons are supposed to appear.
151
+ $location = $side_panel->get_float_location();
152
+ if ( 'none' === $location || 'ignore' === $location ) {
153
+ return;
154
+ }
155
+
156
+ // Render the html to output to the screen.
157
+ $side_panel->render_floating_HTML( $echo = true );
158
+
159
+ return;
160
+ }
161
+
162
+
163
+ /**
164
+ * The main social_warfare function used to create the buttons.
165
+ *
166
+ * @since 1.4.0
167
+ * @param array $array An array of options and information to pass into the
168
+ * buttons function.
169
+ * @return string The modified content
170
+ *
171
+ */
172
+ public static function social_warfare( $args = array() ) {
173
+
174
+ $Buttons_Panel = new SWP_Buttons_Panel( $args );
175
+ echo $Buttons_Panel->render_HTML();
176
+ }
177
+ }
functions/frontend-output/SWP_Header_Output.php CHANGED
@@ -1,152 +1,152 @@
1
- <?php
2
-
3
- /**
4
- * Register and output open graph tags, Twitter cards, custom color CSS, and the icon fonts.
5
- *
6
- * @package SocialWarfare\Functions\Frontend-Output
7
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
- * @license GPL-3.0+
9
- * @since 1.0.0
10
- * @since 3.0.0 | 21 FEB 2018 | Updated to a class.
11
- *
12
- */
13
- class SWP_Header_Output {
14
-
15
-
16
- /**
17
- * The global user options array.
18
- *
19
- * @since 3.0.0
20
- * @var array $swp_user_options An array of options as set by the WordPress admin.
21
- *
22
- */
23
-
24
-
25
- /**
26
- * The local user options array.
27
- *
28
- * @since 3.0.0
29
- * @var array $swp_user_options An array of options as set by the WordPress admin.
30
- *
31
- */
32
- public $options;
33
-
34
-
35
- /**
36
- * This is the magic method that instatiates this class.
37
- *
38
- * We pull the global user options into a local property so that we don't have to keep
39
- * pulling in the global in each method in which it is needed.
40
- *
41
- * @since 3.0.0 | 21 FEB 2018 | Created
42
- *
43
- */
44
- public function __construct() {
45
- global $swp_user_options;
46
- $this->options = $swp_user_options;
47
- $this->init();
48
- }
49
-
50
- private function init() {
51
- add_action( 'wp_head' , array( $this, 'add_header_output' ), 1 );
52
- add_filter( 'swp_header_html' , array( $this, 'output_font_css' ), 20 );
53
- add_action( 'admin_head' , array( $this, 'output_font_css' ), 20 );
54
- }
55
-
56
-
57
- /**
58
- * The function that we're hooking into the header
59
- *
60
- * All other items being added to the header will be hooked into
61
- * swp_meta_tags which we will call and print via this function.
62
- *
63
- * @since 1.4.0
64
- * @access public
65
- * @param none
66
- * @return none
67
- *
68
- */
69
- function add_header_output() {
70
-
71
- // Get the global options and the post ID
72
- $info['postID'] = get_the_ID();
73
- $info['html_output'] = '';
74
-
75
-
76
- /**
77
- * Create and return the values to be used in the header meta tags
78
- *
79
- * We use our own proprietary header filter so that anything being added to the head
80
- * across our plugin or across any of our addons will all be output at the same time.
81
- * Once the filter has been run and the string is fully compiled, then we will use
82
- * the WordPress head hook to output the compiled string.
83
- *
84
- * @since 2.1.4
85
- * @access public
86
- * @var array $info An array of information
87
- * @return array $info The modified array with the 'meta_tag_values' index populated
88
- *
89
- */
90
- $info = apply_filters( 'swp_header_values' , $info );
91
-
92
-
93
- /**
94
- * A filter to take the values from above and compile them into their html format
95
- *
96
- * This filter will take the values from $info['meta_tag_values'] and compile
97
- * them into html stored at $info['html_output']. $info['html_output'] is
98
- * a string that gets added (.=) to by each hook.
99
- *
100
- * Note: Each meta tag should begin with PHP_EOL for clean structured HTML output
101
- *
102
- * @since 2.1.4
103
- * @access public
104
- * @var array $info An array of information
105
- * @return array $info The modified array with the 'html_output' index populated.
106
- *
107
- */
108
- $info = apply_filters( 'swp_header_html' , $info );
109
-
110
- if ( $info['html_output'] ) :
111
- echo PHP_EOL . '<!-- Social Warfare v' . SWP_VERSION . ' https://warfareplugins.com -->';
112
- echo $info['html_output'];
113
- echo PHP_EOL . '<!-- Social Warfare v' . SWP_VERSION . ' https://warfareplugins.com -->' . PHP_EOL . PHP_EOL;
114
- endif;
115
- }
116
-
117
-
118
- /**
119
- * Output the CSS to include the icon font.
120
- *
121
- * Note: This is done in the header rather than in a CSS file to
122
- * avoid having the fonts called from a CDN, 95% of which do not
123
- * support the necessary mime & cross-origin access types to deliver them.
124
- *
125
- * @since 1.0.0
126
- * @access public
127
- * @param array $info An array of information about the post
128
- * @return array $info The modified array
129
- *
130
- */
131
- function output_font_css( $info = array() ) {
132
- //* Make sure we only output the style once.
133
- if ( !empty( $info['html_output'] ) && strpos( $info['html_output'], 'font-family: "sw-icon-font"' ) ) :
134
- return $info;
135
- endif;
136
-
137
- $style = '<style>@font-face {font-family: "sw-icon-font";src:url("' . SWP_PLUGIN_URL . '/fonts/sw-icon-font.eot?ver=' . SWP_VERSION . '");src:url("' . SWP_PLUGIN_URL . '/fonts/sw-icon-font.eot?ver=' . SWP_VERSION . '#iefix") format("embedded-opentype"),url("' . SWP_PLUGIN_URL . '/fonts/sw-icon-font.woff?ver=' . SWP_VERSION . '") format("woff"),
138
- url("' . SWP_PLUGIN_URL . '/fonts/sw-icon-font.ttf?ver=' . SWP_VERSION . '") format("truetype"),url("' . SWP_PLUGIN_URL . '/fonts/sw-icon-font.svg?ver=' . SWP_VERSION . '#1445203416") format("svg");font-weight: normal;font-style: normal;}</style>';
139
-
140
- if ( true === is_admin() ) {
141
- echo $style;
142
- } else {
143
- if ( empty( $info['html_output'] ) ) :
144
- $info['html_output'] = '';
145
- endif;
146
-
147
- $info['html_output'] .= $style;
148
- }
149
-
150
- return $info;
151
- }
152
- }
1
+ <?php
2
+
3
+ /**
4
+ * Register and output open graph tags, Twitter cards, custom color CSS, and the icon fonts.
5
+ *
6
+ * @package SocialWarfare\Functions\Frontend-Output
7
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
+ * @license GPL-3.0+
9
+ * @since 1.0.0
10
+ * @since 3.0.0 | 21 FEB 2018 | Updated to a class.
11
+ *
12
+ */
13
+ class SWP_Header_Output {
14
+
15
+
16
+ /**
17
+ * The global user options array.
18
+ *
19
+ * @since 3.0.0
20
+ * @var array $swp_user_options An array of options as set by the WordPress admin.
21
+ *
22
+ */
23
+
24
+
25
+ /**
26
+ * The local user options array.
27
+ *
28
+ * @since 3.0.0
29
+ * @var array $swp_user_options An array of options as set by the WordPress admin.
30
+ *
31
+ */
32
+ public $options;
33
+
34
+
35
+ /**
36
+ * This is the magic method that instatiates this class.
37
+ *
38
+ * We pull the global user options into a local property so that we don't have to keep
39
+ * pulling in the global in each method in which it is needed.
40
+ *
41
+ * @since 3.0.0 | 21 FEB 2018 | Created
42
+ *
43
+ */
44
+ public function __construct() {
45
+ global $swp_user_options;
46
+ $this->options = $swp_user_options;
47
+ $this->init();
48
+ }
49
+
50
+ private function init() {
51
+ add_action( 'wp_head' , array( $this, 'add_header_output' ), 1 );
52
+ add_filter( 'swp_header_html' , array( $this, 'output_font_css' ), 20 );
53
+ add_action( 'admin_head' , array( $this, 'output_font_css' ), 20 );
54
+ }
55
+
56
+
57
+ /**
58
+ * The function that we're hooking into the header
59
+ *
60
+ * All other items being added to the header will be hooked into
61
+ * swp_meta_tags which we will call and print via this function.
62
+ *
63
+ * @since 1.4.0
64
+ * @access public
65
+ * @param none
66
+ * @return none
67
+ *
68
+ */
69
+ function add_header_output() {
70
+
71
+ // Get the global options and the post ID
72
+ $info['postID'] = get_the_ID();
73
+ $info['html_output'] = '';
74
+
75
+
76
+ /**
77
+ * Create and return the values to be used in the header meta tags
78
+ *
79
+ * We use our own proprietary header filter so that anything being added to the head
80
+ * across our plugin or across any of our addons will all be output at the same time.
81
+ * Once the filter has been run and the string is fully compiled, then we will use
82
+ * the WordPress head hook to output the compiled string.
83
+ *
84
+ * @since 2.1.4
85
+ * @access public
86
+ * @var array $info An array of information
87
+ * @return array $info The modified array with the 'meta_tag_values' index populated
88
+ *
89
+ */
90
+ $info = apply_filters( 'swp_header_values' , $info );
91
+
92
+
93
+ /**
94
+ * A filter to take the values from above and compile them into their html format
95
+ *
96
+ * This filter will take the values from $info['meta_tag_values'] and compile
97
+ * them into html stored at $info['html_output']. $info['html_output'] is
98
+ * a string that gets added (.=) to by each hook.
99
+ *
100
+ * Note: Each meta tag should begin with PHP_EOL for clean structured HTML output
101
+ *
102
+ * @since 2.1.4
103
+ * @access public
104
+ * @var array $info An array of information
105
+ * @return array $info The modified array with the 'html_output' index populated.
106
+ *
107
+ */
108
+ $info = apply_filters( 'swp_header_html' , $info );
109
+
110
+ if ( $info['html_output'] ) :
111
+ echo PHP_EOL . '<!-- Social Warfare v' . SWP_VERSION . ' https://warfareplugins.com -->';
112
+ echo $info['html_output'];
113
+ echo PHP_EOL . '<!-- Social Warfare v' . SWP_VERSION . ' https://warfareplugins.com -->' . PHP_EOL . PHP_EOL;
114
+ endif;
115
+ }
116
+
117
+
118
+ /**
119
+ * Output the CSS to include the icon font.
120
+ *
121
+ * Note: This is done in the header rather than in a CSS file to
122
+ * avoid having the fonts called from a CDN, 95% of which do not
123
+ * support the necessary mime & cross-origin access types to deliver them.
124
+ *
125
+ * @since 1.0.0
126
+ * @access public
127
+ * @param array $info An array of information about the post
128
+ * @return array $info The modified array
129
+ *
130
+ */
131
+ function output_font_css( $info = array() ) {
132
+ //* Make sure we only output the style once.
133
+ if ( !empty( $info['html_output'] ) && strpos( $info['html_output'], 'font-family: "sw-icon-font"' ) ) :
134
+ return $info;
135
+ endif;
136
+
137
+ $style = '<style>@font-face {font-family: "sw-icon-font";src:url("' . SWP_PLUGIN_URL . '/fonts/sw-icon-font.eot?ver=' . SWP_VERSION . '");src:url("' . SWP_PLUGIN_URL . '/fonts/sw-icon-font.eot?ver=' . SWP_VERSION . '#iefix") format("embedded-opentype"),url("' . SWP_PLUGIN_URL . '/fonts/sw-icon-font.woff?ver=' . SWP_VERSION . '") format("woff"),
138
+ url("' . SWP_PLUGIN_URL . '/fonts/sw-icon-font.ttf?ver=' . SWP_VERSION . '") format("truetype"),url("' . SWP_PLUGIN_URL . '/fonts/sw-icon-font.svg?ver=' . SWP_VERSION . '#1445203416") format("svg");font-weight: normal;font-style: normal;}</style>';
139
+
140
+ if ( true === is_admin() ) {
141
+ echo $style;
142
+ } else {
143
+ if ( empty( $info['html_output'] ) ) :
144
+ $info['html_output'] = '';
145
+ endif;
146
+
147
+ $info['html_output'] .= $style;
148
+ }
149
+
150
+ return $info;
151
+ }
152
+ }
functions/frontend-output/SWP_Option_Page_Registration.php CHANGED
@@ -1,32 +1,32 @@
1
- <?php
2
-
3
- class SWP_Option_Page_Registration extends SWP_Abstract {
4
- public $addon;
5
-
6
- public function __construct() {
7
- apply_filters( 'swp_registrations', array() );
8
- }
9
-
10
- /**
11
- * Create the HTML for registration sections.
12
- *
13
- * $local_vars are the variables needed to properly set $file's HTML.
14
- *
15
- * @param String $file The template file to include.
16
- * @param array $local_vars Variables found inside the file. Stored as
17
- * [ 'var_name' => value ]
18
- * @return Void Void
19
- */
20
- public function render( $file, $local_vars ) {
21
- $path = PLUGIN_DIR . '/includes/' . $file;
22
-
23
- if ( !file_exists( $path ) ) {
24
- $this->_throw( 'Missing template file to render HTML.' );
25
- }
26
-
27
- ob_start();
28
- extract( $local_vars );
29
- include( $file );
30
- ob_flush();
31
- }
32
- }
1
+ <?php
2
+
3
+ class SWP_Option_Page_Registration extends SWP_Abstract {
4
+ public $addon;
5
+
6
+ public function __construct() {
7
+ apply_filters( 'swp_registrations', array() );
8
+ }
9
+
10
+ /**
11
+ * Create the HTML for registration sections.
12
+ *
13
+ * $local_vars are the variables needed to properly set $file's HTML.
14
+ *
15
+ * @param String $file The template file to include.
16
+ * @param array $local_vars Variables found inside the file. Stored as
17
+ * [ 'var_name' => value ]
18
+ * @return Void Void
19
+ */
20
+ public function render( $file, $local_vars ) {
21
+ $path = PLUGIN_DIR . '/includes/' . $file;
22
+
23
+ if ( !file_exists( $path ) ) {
24
+ $this->_throw( 'Missing template file to render HTML.' );
25
+ }
26
+
27
+ ob_start();
28
+ extract( $local_vars );
29
+ include( $file );
30
+ ob_flush();
31
+ }
32
+ }
functions/frontend-output/SWP_Script.php CHANGED
@@ -1,275 +1,294 @@
1
- <?php
2
-
3
- /**
4
- * Register and enqueue plugin scripts and styles.
5
- *
6
- * @package SocialWarfare\Functions
7
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
- * @license GPL-3.0+
9
- * @since 1.0.0
10
- */
11
- class SWP_Script {
12
-
13
- /**
14
- * The magic method used to instatiate our class and queue up all of the
15
- * add_action and add_filter functions as well as fix a known compatibility
16
- * issue with LightSpeed cache.
17
- *
18
- * @since 1.0.0
19
- * @since 3.1.0 | 18 JUNE 2018 | Created add_hooks() and fix_compatability().
20
- * @access public
21
- * @param none
22
- * @return none
23
- *
24
- */
25
- public function __construct() {
26
- $this->add_hooks();
27
- $this->fix_litespeed_compatibility();
28
- }
29
-
30
-
31
- /**
32
- * Add this classes methods to the appropiate hooks.
33
- *
34
- * @since 3.1.0 | 18 JUNE 2018 | Created
35
- * @param void
36
- * @return void
37
- *
38
- */
39
- public function add_hooks() {
40
-
41
- // Queue up our footer hook function
42
- add_filter( 'swp_footer_scripts' , array( $this, 'nonce' ) );
43
- add_filter( 'swp_footer_scripts' , array( $this, 'frame_buster' ) );
44
-
45
- // Queue up our footer hook function
46
- add_filter( 'swp_footer_scripts' , array( $this, 'click_tracking' ) );
47
-
48
- // Queue up the Social Warfare scripts and styles
49
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
50
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
51
-
52
- // Queue up our hook function
53
- add_action( 'wp_footer' , array( $this, 'footer_functions' ) , 99 );
54
-
55
- }
56
-
57
-
58
- /**
59
- * Helper function for getting the script/style `.min` suffix for minified files.
60
- *
61
- * @since 1.0.0
62
- * @access public
63
- * @return string
64
- *
65
- */
66
- public static function get_suffix() {
67
- $debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
68
-
69
- if ( _swp_is_debug( 'script' ) ) {
70
- $debug = true;
71
- }
72
-
73
- $enabled = (bool) apply_filters( 'swp_enable_suffix', ! $debug );
74
-
75
- return $enabled ? '.min' : '';
76
- }
77
-
78
-
79
- /**
80
- * Load front end scripts and styles.
81
- *
82
- * @since 1.0.0
83
- * @access public
84
- * @global $swp_user_options
85
- * @param void
86
- * @return void
87
- */
88
- public function enqueue_scripts() {
89
- global $swp_user_options;
90
-
91
- $suffix = SWP_Script::get_suffix();
92
-
93
- wp_enqueue_style(
94
- 'social_warfare',
95
- SWP_PLUGIN_URL . "/css/style{$suffix}.css",
96
- array(),
97
- SWP_VERSION
98
- );
99
-
100
- wp_enqueue_script(
101
- 'social_warfare_script',
102
- SWP_PLUGIN_URL . "/js/script{$suffix}.js",
103
- array( 'jquery' ),
104
- SWP_VERSION,
105
- true
106
- );
107
-
108
- }
109
-
110
-
111
- /**
112
- * Load admin scripts and styles.
113
- *
114
- * @since 1.0.0
115
- * @access public
116
- * @param string $screen The ID of the current admin screen.
117
- * @return void
118
- *
119
- */
120
- public function enqueue_admin_scripts( $screen ) {
121
-
122
- $this->enqueue_scripts();
123
-
124
- $suffix = SWP_Script::get_suffix();
125
-
126
- wp_enqueue_style(
127
- 'social_warfare_admin',
128
- SWP_PLUGIN_URL . "/css/admin{$suffix}.css",
129
- array(),
130
- SWP_VERSION
131
- );
132
-
133
- wp_enqueue_script(
134
- 'social_warfare_admin_script',
135
- SWP_PLUGIN_URL . "/js/admin{$suffix}.js",
136
- array( 'jquery' ),
137
- SWP_VERSION
138
- );
139
-
140
- wp_localize_script( 'social_warfare_admin_script', 'swp_localize_admin',
141
- array(
142
- 'swp_characters_remaining' => __( 'Characters Remaining', 'social-warfare' ),
143
- )
144
- );
145
- }
146
-
147
-
148
- /**
149
- * Queue up our javscript for options and whatnot
150
- *
151
- * @since 1.4.0
152
- * @param Void
153
- * @return Void. Echo results directly to the screen.
154
- *
155
- */
156
- public function footer_functions() {
157
-
158
- global $swp_user_options;
159
-
160
- // Fetch a few variables.
161
- $info['postID'] = get_the_ID();
162
- $info['swp_user_options'] = $swp_user_options;
163
- $info['footer_output'] = '';
164
-
165
- // Pass the array through our custom filters.
166
- $info = apply_filters( 'swp_footer_scripts' , $info );
167
-
168
- // If we have output, output it.
169
- if ( $info['footer_output'] ) {
170
- echo '<script type="text/javascript">';
171
- echo $info['footer_output'];
172
- echo '</script>';
173
- }
174
- }
175
-
176
-
177
- /**
178
- * Enable click tracking in Google Analytics.
179
- *
180
- * @since 1.4
181
- * @access public
182
- * @param array $info An array of footer script information.
183
- * @return array $info A modified array of footer script information.
184
- *
185
- */
186
- public function click_tracking( $info ) {
187
-
188
- // Output the JS variable for click tracking if it is turned on.
189
- if ( isset( $info['swp_user_options']['click_tracking'] ) && true === $info['swp_user_options']['click_tracking'] ) {
190
- $info['footer_output'] .= 'var swpClickTracking = true;';
191
- } else {
192
- $info['footer_output'] .= 'var swpClickTracking = false;';
193
- }
194
-
195
- return $info;
196
- }
197
-
198
-
199
- /**
200
- * The Frame Buster Option
201
- *
202
- * @since 1.4.0
203
- * @access public
204
- * @param array $info An array of footer script information.
205
- * @return array $info A modified array of footer script information.
206
- *
207
- */
208
- public function frame_buster( $info ) {
209
-
210
- global $swp_user_options;
211
-
212
- if ( true === $swp_user_options['frame_buster'] ) :
213
- $info['footer_output'] .= PHP_EOL . 'function parentIsEvil() { var html = null; try { var doc = top.location.pathname; } catch(err){ }; if(typeof doc === "undefined") { return true } else { return false }; }; if (parentIsEvil()) { top.location = self.location.href; };var url = "' . get_permalink() . '";if(url.indexOf("stfi.re") != -1) { var canonical = ""; var links = document.getElementsByTagName("link"); for (var i = 0; i < links.length; i ++) { if (links[i].getAttribute("rel") === "canonical") { canonical = links[i].getAttribute("href")}}; canonical = canonical.replace("?sfr=1", "");top.location = canonical; console.log(canonical);};';
214
- endif;
215
-
216
- return $info;
217
- }
218
-
219
-
220
- /**
221
- * A method to fix compatibility with LiteSpeed Cache plugin.
222
- *
223
- * @since 3.1.0 | 18 JUN 2018 | Created
224
- * @param void
225
- * @return void
226
- *
227
- */
228
- public function fix_litespeed_compatibility() {
229
- if ( method_exists( 'LiteSpeed_Cache_API', 'esi_enabled' ) && LiteSpeed_Cache_API::esi_enabled() ) :
230
- LiteSpeed_Cache_API::hook_tpl_esi( 'swp_esi', array( $this, 'hook_esi' ) );
231
- endif;
232
- }
233
-
234
-
235
- /**
236
- * Create a nonce for added security
237
- *
238
- * @since 2.1.4
239
- * @access public
240
- * @param array $info An array of footer script information.
241
- * @return array $info A modified array of footer script information.
242
- *
243
- */
244
- public function nonce( $info ) {
245
-
246
- // To make sure LSCWP ESI is on
247
- if( method_exists( 'LiteSpeed_Cache_API', 'esi_enabled' ) && LiteSpeed_Cache_API::esi_enabled() ) {
248
- // To make sure is using the compatible API version
249
- if ( method_exists( 'LiteSpeed_Cache_API', 'v' ) && LiteSpeed_Cache_API::v( '1.3' ) ) {
250
- // Let's turn this block to ESI and return
251
- $info['footer_output'] .= LiteSpeed_Cache_API::esi_url( 'swp_esi', 'Social Warfare', array(), 'default', true );
252
- return $info;
253
- }
254
- }
255
-
256
- // Create a nonce
257
- $info['footer_output'] .= ' var swp_nonce = "'.wp_create_nonce().'";';
258
- return $info;
259
- }
260
-
261
-
262
- /**
263
- * Add LiteSpeed ESI hook for nonce cache
264
- *
265
- * @access public
266
- * @param void
267
- * @return void
268
- *
269
- */
270
- public function hook_esi() {
271
- echo ' var swp_nonce = "'.wp_create_nonce().'";';
272
- exit;
273
- }
274
-
275
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Register and enqueue plugin scripts and styles.
5
+ *
6
+ * @package SocialWarfare\Functions
7
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
+ * @license GPL-3.0+
9
+ * @since 1.0.0
10
+ */
11
+ class SWP_Script {
12
+
13
+ /**
14
+ * The magic method used to instatiate our class and queue up all of the
15
+ * add_action and add_filter functions as well as fix a known compatibility
16
+ * issue with LightSpeed cache.
17
+ *
18
+ * @since 1.0.0
19
+ * @since 3.1.0 | 18 JUNE 2018 | Created add_hooks() and fix_compatability().
20
+ * @access public
21
+ * @param none
22
+ * @return none
23
+ *
24
+ */
25
+ public function __construct() {
26
+ $this->add_hooks();
27
+ $this->fix_litespeed_compatibility();
28
+ }
29
+
30
+
31
+ /**
32
+ * Add this classes methods to the appropiate hooks.
33
+ *
34
+ * @since 3.1.0 | 18 JUNE 2018 | Created
35
+ * @param void
36
+ * @return void
37
+ *
38
+ */
39
+ public function add_hooks() {
40
+
41
+ // Queue up our footer hook function
42
+ add_filter( 'swp_footer_scripts', array( $this, 'nonce' ) );
43
+ add_filter( 'swp_footer_scripts', array( $this, 'frame_buster' ) );
44
+ add_filter( 'swp_footer_scripts', array( $this, 'float_before_content' ) );
45
+
46
+ // Queue up our footer hook function
47
+ add_filter( 'swp_footer_scripts', array( $this, 'click_tracking' ) );
48
+
49
+ // Queue up the Social Warfare scripts and styles
50
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
51
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
52
+
53
+ // Queue up our hook function
54
+ add_action( 'wp_footer' , array( $this, 'footer_functions' ) , 99 );
55
+
56
+ }
57
+
58
+
59
+ /**
60
+ * Helper function for getting the script/style `.min` suffix for minified files.
61
+ *
62
+ * @since 1.0.0
63
+ * @access public
64
+ * @return string
65
+ *
66
+ */
67
+ public static function get_suffix() {
68
+ $debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
69
+
70
+ if ( _swp_is_debug( 'script' ) ) {
71
+ $debug = true;
72
+ }
73
+
74
+ $enabled = (bool) apply_filters( 'swp_enable_suffix', ! $debug );
75
+
76
+ return $enabled ? '.min' : '';
77
+ }
78
+
79
+
80
+ /**
81
+ * Load front end scripts and styles.
82
+ *
83
+ * @since 1.0.0
84
+ * @access public
85
+ * @global $swp_user_options
86
+ * @param void
87
+ * @return void
88
+ */
89
+ public function enqueue_scripts() {
90
+ global $swp_user_options;
91
+
92
+ $suffix = SWP_Script::get_suffix();
93
+
94
+ wp_enqueue_style(
95
+ 'social_warfare',
96
+ SWP_PLUGIN_URL . "/css/style{$suffix}.css",
97
+ array(),
98
+ SWP_VERSION
99
+ );
100
+
101
+ wp_enqueue_script(
102
+ 'social_warfare_script',
103
+ SWP_PLUGIN_URL . "/js/script{$suffix}.js",
104
+ array( 'jquery' ),
105
+ SWP_VERSION,
106
+ true
107
+ );
108
+
109
+ }
110
+
111
+
112
+ /**
113
+ * Load admin scripts and styles.
114
+ *
115
+ * @since 1.0.0
116
+ * @access public
117
+ * @param string $screen The ID of the current admin screen.
118
+ * @return void
119
+ *
120
+ */
121
+ public function enqueue_admin_scripts( $screen ) {
122
+
123
+ $this->enqueue_scripts();
124
+
125
+ $suffix = SWP_Script::get_suffix();
126
+
127
+ wp_enqueue_style(
128
+ 'social_warfare_admin',
129
+ SWP_PLUGIN_URL . "/css/admin{$suffix}.css",
130
+ array(),
131
+ SWP_VERSION
132
+ );
133
+
134
+ wp_enqueue_script(
135
+ 'social_warfare_admin_script',
136
+ SWP_PLUGIN_URL . "/js/admin{$suffix}.js",
137
+ array( 'jquery' ),
138
+ SWP_VERSION
139
+ );
140
+
141
+ wp_localize_script( 'social_warfare_admin_script', 'swp_localize_admin',
142
+ array(
143
+ 'swp_characters_remaining' => __( 'Characters Remaining', 'social-warfare' ),
144
+ )
145
+ );
146
+ }
147
+
148
+
149
+ /**
150
+ * Queue up our javscript for options and whatnot
151
+ *
152
+ * @since 1.4.0
153
+ * @param Void
154
+ * @return Void. Echo results directly to the screen.
155
+ *
156
+ */
157
+ public function footer_functions() {
158
+
159
+ global $swp_user_options;
160
+
161
+ // Fetch a few variables.
162
+ $info['postID'] = get_the_ID();
163
+ $info['swp_user_options'] = $swp_user_options;
164
+ $info['footer_output'] = '';
165
+
166
+ // Pass the array through our custom filters.
167
+ $info = apply_filters( 'swp_footer_scripts' , $info );
168
+
169
+ // If we have output, output it.
170
+ if ( $info['footer_output'] ) {
171
+ echo '<script type="text/javascript">';
172
+ echo $info['footer_output'];
173
+ echo '</script>';
174
+ }
175
+ }
176
+
177
+
178
+ /**
179
+ * Enable click tracking in Google Analytics.
180
+ *
181
+ * @since 1.4
182
+ * @access public
183
+ * @param array $info An array of footer script information.
184
+ * @return array $info A modified array of footer script information.
185
+ *
186
+ */
187
+ public function click_tracking( $info ) {
188
+
189
+ // Output the JS variable for click tracking if it is turned on.
190
+ if ( isset( $info['swp_user_options']['click_tracking'] ) && true === $info['swp_user_options']['click_tracking'] ) {
191
+ $info['footer_output'] .= 'var swpClickTracking = true;';
192
+ } else {
193
+ $info['footer_output'] .= 'var swpClickTracking = false;';
194
+ }
195
+
196
+ return $info;
197
+ }
198
+
199
+
200
+ /**
201
+ * The Frame Buster Option
202
+ *
203
+ * @since 1.4.0
204
+ * @access public
205
+ * @param array $info An array of footer script information.
206
+ * @return array $info A modified array of footer script information.
207
+ *
208
+ */
209
+ public function frame_buster( $info ) {
210
+
211
+ global $swp_user_options;
212
+
213
+ if ( true === $swp_user_options['frame_buster'] ) :
214
+ $info['footer_output'] .= PHP_EOL . 'function parentIsEvil() { var html = null; try { var doc = top.location.pathname; } catch(err){ }; if(typeof doc === "undefined") { return true } else { return false }; }; if (parentIsEvil()) { top.location = self.location.href; };var url = "' . get_permalink() . '";if(url.indexOf("stfi.re") != -1) { var canonical = ""; var links = document.getElementsByTagName("link"); for (var i = 0; i < links.length; i ++) { if (links[i].getAttribute("rel") === "canonical") { canonical = links[i].getAttribute("href")}}; canonical = canonical.replace("?sfr=1", "");top.location = canonical; console.log(canonical);};';
215
+ endif;
216
+
217
+ return $info;
218
+ }
219
+
220
+
221
+ /**
222
+ * A method to fix compatibility with LiteSpeed Cache plugin.
223
+ *
224
+ * @since 3.1.0 | 18 JUN 2018 | Created
225
+ * @param void
226
+ * @return void
227
+ *
228
+ */
229
+ public function fix_litespeed_compatibility() {
230
+ if ( method_exists( 'LiteSpeed_Cache_API', 'esi_enabled' ) && LiteSpeed_Cache_API::esi_enabled() ) :
231
+ LiteSpeed_Cache_API::hook_tpl_esi( 'swp_esi', array( $this, 'hook_esi' ) );
232
+ endif;
233
+ }
234
+
235
+
236
+ /**
237
+ * Create a nonce for added security
238
+ *
239
+ * @since 2.1.4
240
+ * @access public
241
+ * @param array $info An array of footer script information.
242
+ * @return array $info A modified array of footer script information.
243
+ *
244
+ */
245
+ public function nonce( $info ) {
246
+
247
+ // To make sure LSCWP ESI is on
248
+ if( method_exists( 'LiteSpeed_Cache_API', 'esi_enabled' ) && LiteSpeed_Cache_API::esi_enabled() ) {
249
+ // To make sure is using the compatible API version
250
+ if ( method_exists( 'LiteSpeed_Cache_API', 'v' ) && LiteSpeed_Cache_API::v( '1.3' ) ) {
251
+ // Let's turn this block to ESI and return
252
+ $info['footer_output'] .= LiteSpeed_Cache_API::esi_url( 'swp_esi', 'Social Warfare', array(), 'default', true );
253
+ return $info;
254
+ }
255
+ }
256
+
257
+ // Create a nonce
258
+ $info['footer_output'] .= ' var swp_nonce = "'.wp_create_nonce().'";';
259
+ return $info;
260
+ }
261
+
262
+
263
+ /**
264
+ * Echoes selected admin settings from the database to javascript.
265
+ *
266
+ * @since 3.1.0 | 27 JUN 2018 | Created the method.
267
+ * @access public
268
+ * @return void
269
+ *
270
+ */
271
+ public function float_before_content( $vars ) {
272
+ global $swp_user_options;
273
+ $float_before_content = $swp_user_options['float_before_content'];
274
+
275
+ $vars['footer_output'] = "var swpFloatBeforeContent = " . json_encode($float_before_content) . ";";
276
+
277
+ return $vars;
278
+ }
279
+
280
+
281
+ /**
282
+ * Add LiteSpeed ESI hook for nonce cache
283
+ *
284
+ * @access public
285
+ * @param void
286
+ * @return void
287
+ *
288
+ */
289
+ public function hook_esi() {
290
+ echo ' var swp_nonce = "'.wp_create_nonce().'";';
291
+ exit;
292
+ }
293
+
294
+ }
functions/frontend-output/SWP_Shortcode.php CHANGED
@@ -1,190 +1,190 @@
1
- <?php
2
-
3
- /**
4
- * A class of functions used to render shortcodes for the user
5
- *
6
- * The SWP_Shortcodes Class used to add our shorcodes to WordPress
7
- * registry of registered functions.
8
- *
9
- * @package SocialWarfare\Frontend-Output
10
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
11
- * @license GPL-3.0+
12
- * @since 1.0.0
13
- * @since 3.0.0 | 19 FEB 2018 | Refactored into a class-based system
14
- *
15
- */
16
- class SWP_Shortcode {
17
- /**
18
- * Constructs a new SWP_Shortcodes instance
19
- *
20
- * This function is used to add our shortcodes to WordPress' registry of
21
- * shortcodes and to map our functions to each one.
22
- *
23
- * @since 3.0.0
24
- * @param none
25
- * @return none
26
- *
27
- */
28
- public function __construct() {
29
- add_shortcode( 'social_warfare', array( $this , 'buttons_shortcode' ) );
30
- add_shortcode( 'total_shares', array ( $this , 'post_total_shares' ) );
31
- add_shortcode( 'sitewide_shares', array ( $this , 'sitewide_total_shares' ) );
32
- add_shortcode( 'click_to_tweet', array( $this , 'click_to_tweet' ) );
33
-
34
- /**
35
- * These are old legacy shortcodes that have been replaced with the ones seen above.
36
- * We're leaving these here to ensure that it won't break for anyone who has used these
37
- * ones in the past. The ones above adhere to our code style guide.
38
- *
39
- */
40
- add_shortcode( 'clickToTweet', array($this, 'click_to_tweet' ) );
41
- add_shortcode( 'socialWarfare', array($this, 'buttons_shortcode_legacy' ) );
42
-
43
- }
44
-
45
-
46
- /**
47
- * Processing the shortcodes that populate a
48
- * set of social sharing buttons directly in a WordPress post.
49
- *
50
- * This function will accept an array of arguments which WordPress
51
- * will create from the shortcode attributes.
52
- *
53
- * @since 3.0.0
54
- * @param $atts Array An array converted from shortcode attributes.
55
- *
56
- * content: The content for the Social Warfare function to filter. In the case of
57
- * shortcodes, this will be blank since this isn't a content filter.
58
- *
59
- * where: The buttons are designed to be appended to the content. This default
60
- * tells the buttons to append after the content. Since shortcodes don't have
61
- * any content, they'll just produce and return the HTML without any content.
62
- * This will likely never actually be set by the shortcode, but is necessary
63
- * for the HTML generator to know what to do.
64
- *
65
- * echo: True echos the HTML to the screen. False returns the HTML as a string.
66
- *
67
- * @return string The HTML of the Social Warfare buttons.
68
- *
69
- */
70
- public function buttons_shortcode( $args ) {
71
-
72
- if( !is_array($args) ):
73
- $args = array();
74
- endif;
75
-
76
- $buttons_panel = new SWP_Buttons_Panel( $args, true );
77
- return $buttons_panel->render_HTML();
78
- }
79
-
80
-
81
- /**
82
- * This is the legacy version of the social warfare button
83
- * shortcodes. It is used for nothing more than to call the
84
- * new version of the function. See above: $this->buttons_shortcode().
85
- *
86
- * This function will accept an array of arguments which WordPress
87
- * will create from the shortcode attributes.
88
- *
89
- * @since 3.0.0
90
- * @param $atts Array An array converted from shortcode attributes.
91
- * @return string The HTML of the Social Warfare buttons.
92
- *
93
- */
94
- public function buttons_shortcode_legacy( $settings ) {
95
-
96
- return $this->buttons_shortcode( array() );
97
- }
98
-
99
-
100
- /**
101
- * This is used to process the total shares across all tracked
102
- * social networks for any given WordPress post.
103
- *
104
- * This function will accept an array of arguments which WordPress
105
- * will create from the shortcode attributes. However, it doesn't actually
106
- * use any parameters. It is only included to prevent throwing an error
107
- * in the event that someone tries to input a parameter on it.
108
- *
109
- * @since 3.0.0
110
- * @param $atts Array An array converted from shortcode attributes.
111
- * @return string A string of text representing the total shares for the post.
112
- *
113
- */
114
- public function post_total_shares( $settings ) {
115
- $total_shares = get_post_meta( get_the_ID() , '_total_shares', true );
116
- $total_shares = swp_kilomega( $total_shares );
117
- return $total_shares;
118
- }
119
-
120
-
121
- /**
122
- * This is used to process the total shares across all tracked
123
- * social networks for all posts across the site as an aggragate count.
124
- *
125
- * This function will accept an array of arguments which WordPress
126
- * will create from the shortcode attributes. However, it doesn't actually
127
- * use any parameters. It is only included to prevent throwing an error
128
- * in the event that someone tries to input a parameter on it.
129
- *
130
- * @since 3.0.0
131
- * @param $atts Array An array converted from shortcode attributes.
132
- * @return string A string of text representing the total sitewide shares.
133
- *
134
- */
135
- public function sitewide_total_shares( $settings ) {
136
- global $wpdb;
137
- $sum = $wpdb->get_results( "SELECT SUM(meta_value) AS total FROM $wpdb->postmeta WHERE meta_key = '_total_shares'" );
138
- return swp_kilomega( $sum[0]->total );
139
- }
140
-
141
- /**
142
- * The function to build the click to tweets
143
- *
144
- * @param array $atts The shortcode key/value attributes.
145
- * @return string The html of a click to tweet
146
- */
147
- function click_to_tweet( $atts ) {
148
- global $swp_user_options;
149
- $this->options = $swp_user_options;
150
-
151
- $url = SWP_URL_Management::process_url( get_permalink() , 'twitter' , get_the_ID() );
152
- (strpos( $atts['tweet'],'http' ) !== false ? $urlParam = '&url=/' : $urlParam = '&url=' . $url );
153
- $atts['tweet'] = rtrim( $atts['tweet'] );
154
-
155
- $user_twitter_handle = get_post_meta( get_the_ID() , 'swp_twitter_username' , true );
156
-
157
- if ( ! $user_twitter_handle ) :
158
- $user_twitter_handle = $this->options['twitter_id'];
159
- endif;
160
-
161
- if ( isset( $atts['theme'] ) && $atts['theme'] != 'default' ) :
162
- $theme = $atts['theme'];
163
- else :
164
- $theme = $this->options['ctt_theme'];
165
- endif;
166
-
167
- $text = urlencode( html_entity_decode( $atts['tweet'], ENT_COMPAT, 'UTF-8' ) ) . $urlParam ;
168
- $via = ($user_twitter_handle ? '&via=' . str_replace( '@','',$user_twitter_handle ) : '');
169
-
170
-
171
- $html = '<div class="sw-tweet-clear"></div>';
172
- $html .= '<a class="swp_CTT ' . $theme;
173
- $html .= '" href="https://twitter.com/share?text=' . $text . $via;
174
- $html .= '" data-link="https://twitter.com/share?text=' . $text . $via;
175
- $html .= '" rel="nofollow noreferrer noopener" target="_blank">';
176
- $html .= '<span class="sw-click-to-tweet">';
177
- $html .= '<span class="sw-ctt-text">';
178
- $html .= $atts['quote'];
179
- $html .= '</span>';
180
- $html .= '<span class="sw-ctt-btn">';
181
- $html .= __( 'Click To Tweet','social-warfare' );
182
- $html .= '<i class="sw swp_twitter_icon"></i>';
183
- $html .= '</span>';
184
- $html .= '</span>';
185
- $html .= '</a>';
186
-
187
- return $html;
188
- }
189
-
190
- }
1
+ <?php
2
+
3
+ /**
4
+ * A class of functions used to render shortcodes for the user
5
+ *
6
+ * The SWP_Shortcodes Class used to add our shorcodes to WordPress
7
+ * registry of registered functions.
8
+ *
9
+ * @package SocialWarfare\Frontend-Output
10
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
11
+ * @license GPL-3.0+
12
+ * @since 1.0.0
13
+ * @since 3.0.0 | 19 FEB 2018 | Refactored into a class-based system
14
+ *
15
+ */
16
+ class SWP_Shortcode {
17
+ /**
18
+ * Constructs a new SWP_Shortcodes instance
19
+ *
20
+ * This function is used to add our shortcodes to WordPress' registry of
21
+ * shortcodes and to map our functions to each one.
22
+ *
23
+ * @since 3.0.0
24
+ * @param none
25
+ * @return none
26
+ *
27
+ */
28
+ public function __construct() {
29
+ add_shortcode( 'social_warfare', array( $this , 'buttons_shortcode' ) );
30
+ add_shortcode( 'total_shares', array ( $this , 'post_total_shares' ) );
31
+ add_shortcode( 'sitewide_shares', array ( $this , 'sitewide_total_shares' ) );
32
+ add_shortcode( 'click_to_tweet', array( $this , 'click_to_tweet' ) );
33
+
34
+ /**
35
+ * These are old legacy shortcodes that have been replaced with the ones seen above.
36
+ * We're leaving these here to ensure that it won't break for anyone who has used these
37
+ * ones in the past. The ones above adhere to our code style guide.
38
+ *
39
+ */
40
+ add_shortcode( 'clickToTweet', array($this, 'click_to_tweet' ) );
41
+ add_shortcode( 'socialWarfare', array($this, 'buttons_shortcode_legacy' ) );
42
+
43
+ }
44
+
45
+
46
+ /**
47
+ * Processing the shortcodes that populate a
48
+ * set of social sharing buttons directly in a WordPress post.
49
+ *
50
+ * This function will accept an array of arguments which WordPress
51
+ * will create from the shortcode attributes.
52
+ *
53
+ * @since 3.0.0
54
+ * @param $atts Array An array converted from shortcode attributes.
55
+ *
56
+ * content: The content for the Social Warfare function to filter. In the case of
57
+ * shortcodes, this will be blank since this isn't a content filter.
58
+ *
59
+ * where: The buttons are designed to be appended to the content. This default
60
+ * tells the buttons to append after the content. Since shortcodes don't have
61
+ * any content, they'll just produce and return the HTML without any content.
62
+ * This will likely never actually be set by the shortcode, but is necessary
63
+ * for the HTML generator to know what to do.
64
+ *
65
+ * echo: True echos the HTML to the screen. False returns the HTML as a string.
66
+ *
67
+ * @return string The HTML of the Social Warfare buttons.
68
+ *
69
+ */
70
+ public function buttons_shortcode( $args ) {
71
+
72
+ if( !is_array($args) ):
73
+ $args = array();
74
+ endif;
75
+
76
+ $buttons_panel = new SWP_Buttons_Panel( $args, true );
77
+ return $buttons_panel->render_HTML();
78
+ }
79
+
80
+
81
+ /**
82
+ * This is the legacy version of the social warfare button
83
+ * shortcodes. It is used for nothing more than to call the
84
+ * new version of the function. See above: $this->buttons_shortcode().
85
+ *
86
+ * This function will accept an array of arguments which WordPress
87
+ * will create from the shortcode attributes.
88
+ *
89
+ * @since 3.0.0
90
+ * @param $atts Array An array converted from shortcode attributes.
91
+ * @return string The HTML of the Social Warfare buttons.
92
+ *
93
+ */
94
+ public function buttons_shortcode_legacy( $settings ) {
95
+
96
+ return $this->buttons_shortcode( array() );
97
+ }
98
+
99
+
100
+ /**
101
+ * This is used to process the total shares across all tracked
102
+ * social networks for any given WordPress post.
103
+ *
104
+ * This function will accept an array of arguments which WordPress
105
+ * will create from the shortcode attributes. However, it doesn't actually
106
+ * use any parameters. It is only included to prevent throwing an error
107
+ * in the event that someone tries to input a parameter on it.
108
+ *
109
+ * @since 3.0.0
110
+ * @param $atts Array An array converted from shortcode attributes.
111
+ * @return string A string of text representing the total shares for the post.
112
+ *
113
+ */
114
+ public function post_total_shares( $settings ) {
115
+ $total_shares = get_post_meta( get_the_ID() , '_total_shares', true );
116
+ $total_shares = swp_kilomega( $total_shares );
117
+ return $total_shares;
118
+ }
119
+
120
+
121
+ /**
122
+ * This is used to process the total shares across all tracked
123
+ * social networks for all posts across the site as an aggragate count.
124
+ *
125
+ * This function will accept an array of arguments which WordPress
126
+ * will create from the shortcode attributes. However, it doesn't actually
127
+ * use any parameters. It is only included to prevent throwing an error
128
+ * in the event that someone tries to input a parameter on it.
129
+ *
130
+ * @since 3.0.0
131
+ * @param $atts Array An array converted from shortcode attributes.
132
+ * @return string A string of text representing the total sitewide shares.
133
+ *
134
+ */
135
+ public function sitewide_total_shares( $settings ) {
136
+ global $wpdb;
137
+ $sum = $wpdb->get_results( "SELECT SUM(meta_value) AS total FROM $wpdb->postmeta WHERE meta_key = '_total_shares'" );
138
+ return swp_kilomega( $sum[0]->total );
139
+ }
140
+
141
+ /**
142
+ * The function to build the click to tweets
143
+ *
144
+ * @param array $atts The shortcode key/value attributes.
145
+ * @return string The html of a click to tweet
146
+ */
147
+ function click_to_tweet( $atts ) {
148
+ global $swp_user_options;
149
+ $this->options = $swp_user_options;
150
+
151
+ $url = SWP_URL_Management::process_url( get_permalink() , 'twitter' , get_the_ID() );
152
+ (strpos( $atts['tweet'],'http' ) !== false ? $urlParam = '&url=/' : $urlParam = '&url=' . $url );
153
+ $atts['tweet'] = rtrim( $atts['tweet'] );
154
+
155
+ $user_twitter_handle = get_post_meta( get_the_ID() , 'swp_twitter_username' , true );
156
+
157
+ if ( ! $user_twitter_handle ) :
158
+ $user_twitter_handle = $this->options['twitter_id'];
159
+ endif;
160
+
161
+ if ( isset( $atts['theme'] ) && $atts['theme'] != 'default' ) :
162
+ $theme = $atts['theme'];
163
+ else :
164
+ $theme = $this->options['ctt_theme'];
165
+ endif;
166
+
167
+ $text = urlencode( html_entity_decode( $atts['tweet'], ENT_COMPAT, 'UTF-8' ) ) . $urlParam ;
168
+ $via = ($user_twitter_handle ? '&via=' . str_replace( '@','',$user_twitter_handle ) : '');
169
+
170
+
171
+ $html = '<div class="sw-tweet-clear"></div>';
172
+ $html .= '<a class="swp_CTT ' . $theme;
173
+ $html .= '" href="https://twitter.com/share?text=' . $text . $via;
174
+ $html .= '" data-link="https://twitter.com/share?text=' . $text . $via;
175
+ $html .= '" rel="nofollow noreferrer noopener" target="_blank">';
176
+ $html .= '<span class="sw-click-to-tweet">';
177
+ $html .= '<span class="sw-ctt-text">';
178
+ $html .= $atts['quote'];
179
+ $html .= '</span>';
180
+ $html .= '<span class="sw-ctt-btn">';
181
+ $html .= __( 'Click To Tweet','social-warfare' );
182
+ $html .= '<i class="sw swp_twitter_icon"></i>';
183
+ $html .= '</span>';
184
+ $html .= '</span>';
185
+ $html .= '</a>';
186
+
187
+ return $html;
188
+ }
189
+
190
+ }
functions/includes/SWP_Addon.php CHANGED
@@ -1,271 +1,271 @@
1
- <?php
2
-
3
- class SWP_Addon extends Social_Warfare {
4
- public function __construct() {
5
- parent::__construct();
6
- $this->name = '';
7
- $this->product_id = 0;
8
- $this->key = '';
9
- $this->version = '';
10
- $this->core_required = '3.0.0';
11
- $this->store_url = 'https://warfareplugins.com';
12
- $this->site_url = swp_get_site_url();
13
- add_action( 'wp_ajax_swp_register_plugin', [$this, 'register_plugin'] );
14
- add_action( 'wp_ajax_swp_unregister_plugin', [$this, 'unregister_plugin'] );
15
- add_action( 'wp_ajax_swp_ajax_passthrough', [$this, 'ajax_passthrough'] );
16
- }
17
-
18
-
19
- /**
20
- * The callback function used to add a new instance of this /**
21
- * to our swp_registrations filter.
22
- *
23
- * This should be the last item called in an addon's main file.
24
- *
25
- * @param array $addons The array of addons currently activated.
26
- */
27
- public function add_self( $addons ) {
28
- $this->establish_license_key();
29
- $this->registered = $this->is_registered();
30
-
31
- $addons[] = $this;
32
-
33
- return $addons;
34
- }
35
-
36
- public function register_plugin() {
37
- // Check to ensure that license key was passed into the function
38
- if ( !empty( $_POST['license_key'] ) ) :
39
-
40
- // Grab the license key so we can use it below
41
- $key = $_POST['name_key'];
42
- $license = $_POST['license_key'];
43
- $item_id = $_POST['item_id'];
44
- $this->store_url = 'https://warfareplugins.com';
45
-
46
- $api_params = array(
47
- 'edd_action' => 'activate_license',
48
- 'item_id' => $item_id,
49
- 'license' => $license,
50
- 'url' => $this->site_url
51
- );
52
-
53
- $response = wp_remote_retrieve_body( wp_remote_post( $this->store_url, array( 'body' => $api_params, 'timeout' => 10 ) ) );
54
-
55
- if ( false != $response ) :
56
-
57
- // Parse the response into an object
58
- $license_data = json_decode( $response );
59
-
60
- // If the license is valid store it in the database
61
- if( isset($license_data->license) && 'valid' == $license_data->license ) :
62
-
63
- $current_time = time();
64
- $options = get_option( 'social_warfare_settings' );
65
- $options[$key.'_license_key'] = $license;
66
- $options[$key.'_license_key_timestamp'] = $current_time;
67
- update_option( 'social_warfare_settings' , $options );
68
-
69
- echo json_encode($license_data);
70
- wp_die();
71
-
72
- // If the license is not valid
73
- elseif( isset($license_data->license) && 'invalid' == $license_data->license ) :
74
- echo json_encode($license_data);
75
- wp_die();
76
-
77
- // If some other status was returned
78
- else :
79
- $license_data['success'] = false;
80
- $license_data['data'] = 'Invaid response from the registration server.';
81
- echo json_encode($license_data);
82
- wp_die();
83
- endif;
84
-
85
- // If we didn't get a response from the registration server
86
- else :
87
- $license_data['success'] = false;
88
- $license_data['data'] = 'Failed to connect to registration server.';
89
- echo json_encode($license_data);
90
- wp_die();
91
- endif;
92
- endif;
93
-
94
- $license_data['success'] = false;
95
- $license_data['data'] = 'Admin Ajax did not receive valid POST data.';
96
- echo json_encode($license_data);
97
- wp_die();
98
-
99
- }
100
-
101
- public function establish_license_key() {
102
- $options = get_option( 'social_warfare_settings' );
103
-
104
- if ( isset ( $options[ $this->key . '_license_key'] ) ) :
105
- $this->license_key = $options[ $this->key . '_license_key'];
106
- endif;
107
-
108
- $this->license_key = '';
109
- }
110
-
111
- public function is_registered() {
112
- // Get the plugin options from the database
113
- $options = get_option( 'social_warfare_settings', false );
114
- $old_options = get_option( 'socialWarfareOptions', false );
115
-
116
- if ( isset( $options[$this->key . '_license_key'] ) ) :
117
- $this->license_key = $options[$this->key . '_license_key'];
118
- elseif ( isset( $old_options[$this->key . '_license_key'] ) ) :
119
- $this->license_key = $old_options[$this->key . '_license_key'];
120
- else:
121
- $this->license_key = '';
122
- endif;
123
-
124
-
125
- // Get the timestamps setup for comparison to see if a week has passed since our last check
126
- $current_time = time();
127
-
128
- if ( isset($options[$this->key.'_license_key_timestamp'] ) ) {
129
- $timestamp = $options[$this->key . '_license_key_timestamp'];
130
- }
131
-
132
- $timestamp = isset ( $timestamp ) ? $timestamp : 0;
133
-
134
- $time_to_recheck = $timestamp + 604800;
135
-
136
- // If they have a key and a week hasn't passed since the last check, just return true...the plugin is registered.
137
- if( !empty( $this->license_key) && $current_time < $time_to_recheck ) :
138
- return true;
139
- endif;
140
-
141
- // If a week has passed since the last check, ping our API to check the validity of the license key
142
- if ( !empty( $this->license_key) ) :
143
-
144
- $data = array(
145
- 'edd_action' => 'check_license',
146
- 'item_id' => $this->product_id,
147
- 'license' => $this->license_key,
148
- 'url' => $this->site_url,
149
- );
150
-
151
- $response = wp_remote_retrieve_body( wp_remote_post( $this->store_url , array('body' => $data, 'timeout' => 10 ) ) );
152
-
153
- if( false !== $response ) :
154
-
155
- // Parse the response into an object
156
- $license_data = json_decode( $response );
157
-
158
- $options[$this->key . '_license_key_timestamp'] = $current_time;
159
-
160
- // If the license was invalid
161
- if ( isset( $license_data->license ) && 'invalid' === $license_data->license ) :
162
- $is_registered = false;
163
- $this->license_key = '';
164
-
165
- $options[$this->key . '_license_key'] = '';
166
-
167
- update_option( 'social_warfare_settings' , $options );
168
-
169
- return false;
170
-
171
- // If the property is some other status, just go with it.
172
- else :
173
- $is_registered = true;
174
- update_option( 'social_warfare_settings' , $options );
175
-
176
- return true;
177
-
178
- endif;
179
-
180
- // If we recieved no response from the server, we'll just check again next week
181
- else :
182
- $options[$key.'_license_key_timestamp'] = $current_time;
183
- update_option( 'social_warfare_settings' , $options );
184
-
185
- return true;
186
- endif;
187
- endif;
188
-
189
-
190
- return false;
191
- }
192
-
193
- public function check_for_updates() {
194
- if ( version_compare(SWP_VERSION, $this->core_required) >= 0 ) :
195
-
196
- endif;
197
- }
198
-
199
- public function unregister_plugin() {
200
- // Setup the variables needed for processing
201
- $options = get_option( 'social_warfare_settings' );
202
- $key = $_POST['name_key'];
203
- $item_id = $_POST['item_id'];
204
-
205
- // Check to see if the license key is even in the options
206
- if ( empty( $options[$key.'_license_key'] ) ) :
207
- $response['success'] = true;
208
- echo json_encode($response);
209
- else :
210
- // Grab the license key so we can use it below
211
- $license = $options[$key.'_license_key'];
212
-
213
- // Setup the API request parameters
214
- $api_params = array(
215
- 'edd_action' => 'deactivate_license',
216
- 'item_id' => $item_id,
217
- 'license' => $license,
218
- 'url' => $this->site_url,
219
- );
220
-
221
- $response = wp_remote_retrieve_body( wp_remote_post( $this->store_url, array( 'body' => $api_params, 'timeout' => 10 ) ) );
222
-
223
- $options = get_option( 'social_warfare_settings' );
224
- $options[$key.'_license_key'] = '';
225
- update_option( 'social_warfare_settings' , $options );
226
- echo json_encode($license_data);
227
- endif;
228
-
229
- wp_die();
230
- }
231
-
232
- public function ajax_passthrough() {
233
- if ( ! check_ajax_referer( 'swp_plugin_registration', 'security', false ) ) {
234
- wp_send_json_error( esc_html__( 'Security failed.', 'social-warfare' ) );
235
- die;
236
- }
237
-
238
- $data = wp_unslash( $_POST ); // Input var okay.
239
-
240
- if ( ! isset( $data['activity'], $data['email'] ) ) {
241
- wp_send_json_error( esc_html__( 'Required fields missing.', 'social-warfare' ) );
242
- die;
243
- }
244
-
245
- if ( 'register' === $data['activity'] ) {
246
- $response = swp_register_plugin( $data['email'], swp_get_site_url() );
247
-
248
- if ( ! $response ) {
249
- wp_send_json_error( esc_html__( 'Plugin could not be registered.', 'social-warfare' ) );
250
- die;
251
- }
252
-
253
- $response['message'] = esc_html__( 'Plugin successfully registered!', 'social-warfare' );
254
- }
255
-
256
- if ( 'unregister' === $data['activity'] && isset( $data['key'] ) ) {
257
- $response = swp_unregister_plugin( $data['email'], $data['key'] );
258
-
259
- if ( ! $response ) {
260
- wp_send_json_error( esc_html__( 'Plugin could not be unregistered.', 'social-warfare' ) );
261
- die;
262
- }
263
-
264
- $response['message'] = esc_html__( 'Plugin successfully unregistered!', 'social-warfare' );
265
- }
266
-
267
- wp_send_json_success( $response );
268
-
269
- die;
270
- }
271
- }
1
+ <?php
2
+
3
+ class SWP_Addon extends Social_Warfare {
4
+ public function __construct() {
5
+ parent::__construct();
6
+ $this->name = '';
7
+ $this->product_id = 0;
8
+ $this->key = '';
9
+ $this->version = '';
10
+ $this->core_required = '3.0.0';
11
+ $this->store_url = 'https://warfareplugins.com';
12
+ $this->site_url = swp_get_site_url();
13
+ add_action( 'wp_ajax_swp_register_plugin', [$this, 'register_plugin'] );
14
+ add_action( 'wp_ajax_swp_unregister_plugin', [$this, 'unregister_plugin'] );
15
+ add_action( 'wp_ajax_swp_ajax_passthrough', [$this, 'ajax_passthrough'] );
16
+ }
17
+
18
+
19
+ /**
20
+ * The callback function used to add a new instance of this /**
21
+ * to our swp_registrations filter.
22
+ *
23
+ * This should be the last item called in an addon's main file.
24
+ *
25
+ * @param array $addons The array of addons currently activated.
26
+ */
27
+ public function add_self( $addons ) {
28
+ $this->establish_license_key();
29
+ $this->registered = $this->is_registered();
30
+
31
+ $addons[] = $this;
32
+
33
+ return $addons;
34
+ }
35
+
36
+ public function register_plugin() {
37
+ // Check to ensure that license key was passed into the function
38
+ if ( !empty( $_POST['license_key'] ) ) :
39
+
40
+ // Grab the license key so we can use it below
41
+ $key = $_POST['name_key'];
42
+ $license = $_POST['license_key'];
43
+ $item_id = $_POST['item_id'];
44
+ $this->store_url = 'https://warfareplugins.com';
45
+
46
+ $api_params = array(
47
+ 'edd_action' => 'activate_license',
48
+ 'item_id' => $item_id,
49
+ 'license' => $license,
50
+ 'url' => $this->site_url
51
+ );
52
+
53
+ $response = wp_remote_retrieve_body( wp_remote_post( $this->store_url, array( 'body' => $api_params, 'timeout' => 10 ) ) );
54
+
55
+ if ( false != $response ) :
56
+
57
+ // Parse the response into an object
58
+ $license_data = json_decode( $response );
59
+
60
+ // If the license is valid store it in the database
61
+ if( isset($license_data->license) && 'valid' == $license_data->license ) :
62
+
63
+ $current_time = time();
64
+ $options = get_option( 'social_warfare_settings' );
65
+ $options[$key.'_license_key'] = $license;
66
+ $options[$key.'_license_key_timestamp'] = $current_time;
67
+ update_option( 'social_warfare_settings' , $options );
68
+
69
+ echo json_encode($license_data);
70
+ wp_die();
71
+
72
+ // If the license is not valid
73
+ elseif( isset($license_data->license) && 'invalid' == $license_data->license ) :
74
+ echo json_encode($license_data);
75
+ wp_die();
76
+
77
+ // If some other status was returned
78
+ else :
79
+ $license_data['success'] = false;
80
+ $license_data['data'] = 'Invaid response from the registration server.';
81
+ echo json_encode($license_data);
82
+ wp_die();
83
+ endif;
84
+
85
+ // If we didn't get a response from the registration server
86
+ else :
87
+ $license_data['success'] = false;
88
+ $license_data['data'] = 'Failed to connect to registration server.';
89
+ echo json_encode($license_data);
90
+ wp_die();
91
+ endif;
92
+ endif;
93
+
94
+ $license_data['success'] = false;
95
+ $license_data['data'] = 'Admin Ajax did not receive valid POST data.';
96
+ echo json_encode($license_data);
97
+ wp_die();
98
+
99
+ }
100
+
101
+ public function establish_license_key() {
102
+ $options = get_option( 'social_warfare_settings' );
103
+
104
+ if ( isset ( $options[ $this->key . '_license_key'] ) ) :
105
+ $this->license_key = $options[ $this->key . '_license_key'];
106
+ endif;
107
+
108
+ $this->license_key = '';
109
+ }
110
+
111
+ public function is_registered() {
112
+ // Get the plugin options from the database
113
+ $options = get_option( 'social_warfare_settings', false );
114
+ $old_options = get_option( 'socialWarfareOptions', false );
115
+
116
+ if ( isset( $options[$this->key . '_license_key'] ) ) :
117
+ $this->license_key = $options[$this->key . '_license_key'];
118
+ elseif ( isset( $old_options[$this->key . '_license_key'] ) ) :
119
+ $this->license_key = $old_options[$this->key . '_license_key'];
120
+ else:
121
+ $this->license_key = '';
122
+ endif;
123
+
124
+
125
+ // Get the timestamps setup for comparison to see if a week has passed since our last check
126
+ $current_time = time();
127
+
128
+ if ( isset($options[$this->key.'_license_key_timestamp'] ) ) {
129
+ $timestamp = $options[$this->key . '_license_key_timestamp'];
130
+ }
131
+
132
+ $timestamp = isset ( $timestamp ) ? $timestamp : 0;
133
+
134
+ $time_to_recheck = $timestamp + 604800;
135
+
136
+ // If they have a key and a week hasn't passed since the last check, just return true...the plugin is registered.
137
+ if( !empty( $this->license_key) && $current_time < $time_to_recheck ) :
138
+ return true;
139
+ endif;
140
+
141
+ // If a week has passed since the last check, ping our API to check the validity of the license key
142
+ if ( !empty( $this->license_key) ) :
143
+
144
+ $data = array(
145
+ 'edd_action' => 'check_license',
146
+ 'item_id' => $this->product_id,
147
+ 'license' => $this->license_key,
148
+ 'url' => $this->site_url,
149
+ );
150
+
151
+ $response = wp_remote_retrieve_body( wp_remote_post( $this->store_url , array('body' => $data, 'timeout' => 10 ) ) );
152
+
153
+ if( false !== $response ) :
154
+
155
+ // Parse the response into an object
156
+ $license_data = json_decode( $response );
157
+
158
+ $options[$this->key . '_license_key_timestamp'] = $current_time;
159
+
160
+ // If the license was invalid
161
+ if ( isset( $license_data->license ) && 'invalid' === $license_data->license ) :
162
+ $is_registered = false;
163
+ $this->license_key = '';
164
+
165
+ $options[$this->key . '_license_key'] = '';
166
+
167
+ update_option( 'social_warfare_settings' , $options );
168
+
169
+ return false;
170
+
171
+ // If the property is some other status, just go with it.
172
+ else :
173
+ $is_registered = true;
174
+ update_option( 'social_warfare_settings' , $options );
175
+
176
+ return true;
177
+
178
+ endif;
179
+
180
+ // If we recieved no response from the server, we'll just check again next week
181
+ else :
182
+ $options[$key.'_license_key_timestamp'] = $current_time;
183
+ update_option( 'social_warfare_settings' , $options );
184
+
185
+ return true;
186
+ endif;
187
+ endif;
188
+
189
+
190
+ return false;
191
+ }
192
+
193
+ public function check_for_updates() {
194
+ if ( version_compare(SWP_VERSION, $this->core_required) >= 0 ) :
195
+
196
+ endif;
197
+ }
198
+
199
+ public function unregister_plugin() {
200
+ // Setup the variables needed for processing
201
+ $options = get_option( 'social_warfare_settings' );
202
+ $key = $_POST['name_key'];
203
+ $item_id = $_POST['item_id'];
204
+
205
+ // Check to see if the license key is even in the options
206
+ if ( empty( $options[$key.'_license_key'] ) ) :
207
+ $response['success'] = true;
208
+ echo json_encode($response);
209
+ else :
210
+ // Grab the license key so we can use it below
211
+ $license = $options[$key.'_license_key'];
212
+
213
+ // Setup the API request parameters
214
+ $api_params = array(
215
+ 'edd_action' => 'deactivate_license',
216
+ 'item_id' => $item_id,
217
+ 'license' => $license,
218
+ 'url' => $this->site_url,
219
+ );
220
+
221
+ $response = wp_remote_retrieve_body( wp_remote_post( $this->store_url, array( 'body' => $api_params, 'timeout' => 10 ) ) );
222
+
223
+ $options = get_option( 'social_warfare_settings' );
224
+ $options[$key.'_license_key'] = '';
225
+ update_option( 'social_warfare_settings' , $options );
226
+ echo json_encode($license_data);
227
+ endif;
228
+
229
+ wp_die();
230
+ }
231
+
232
+ public function ajax_passthrough() {
233
+ if ( ! check_ajax_referer( 'swp_plugin_registration', 'security', false ) ) {
234
+ wp_send_json_error( esc_html__( 'Security failed.', 'social-warfare' ) );
235
+ die;
236
+ }
237
+
238
+ $data = wp_unslash( $_POST ); // Input var okay.
239
+
240
+ if ( ! isset( $data['activity'], $data['email'] ) ) {
241
+ wp_send_json_error( esc_html__( 'Required fields missing.', 'social-warfare' ) );
242
+ die;
243
+ }
244
+
245
+ if ( 'register' === $data['activity'] ) {
246
+ $response = swp_register_plugin( $data['email'], swp_get_site_url() );
247
+
248
+ if ( ! $response ) {
249
+ wp_send_json_error( esc_html__( 'Plugin could not be registered.', 'social-warfare' ) );
250
+ die;
251
+ }
252
+
253
+ $response['message'] = esc_html__( 'Plugin successfully registered!', 'social-warfare' );
254
+ }
255
+
256
+ if ( 'unregister' === $data['activity'] && isset( $data['key'] ) ) {
257
+ $response = swp_unregister_plugin( $data['email'], $data['key'] );
258
+
259
+ if ( ! $response ) {
260
+ wp_send_json_error( esc_html__( 'Plugin could not be unregistered.', 'social-warfare' ) );
261
+ die;
262
+ }
263
+
264
+ $response['message'] = esc_html__( 'Plugin successfully unregistered!', 'social-warfare' );
265
+ }
266
+
267
+ wp_send_json_success( $response );
268
+
269
+ die;
270
+ }
271
+ }
functions/includes/registration.php CHANGED
@@ -1,59 +1,59 @@
1
- <div class="registration-wrapper <?php echo $registration['key'] ?>" registration="<?php echo $registered; ?>">
2
-
3
- <h2><?php esc_html_e( $registration['plugin_name'].' Registration' , 'social-warfare' ); ?></h2>
4
-
5
- <div class="sw-grid sw-col-940 swp_is_not_registered">
6
-
7
- <div class="sw-red-notice">
8
- <?php _e( 'This copy of '.$registration['plugin_name'].' is NOT registered. <a target="_blank" href="https://warfareplugins.com">Click here</a> to purchase a license or add your account info below.' , 'social-warfare' ); ?>
9
- </div>
10
-
11
- <p class="sw-subtitle sw-registration-text">
12
- <?php esc_html_e( 'Enter your registration key for '.$registration['plugin_name'] .' and then click Register Plugin.' , 'social-warfare' ); ?>
13
- </p>
14
-
15
- <div class="sw-grid sw-col-300">
16
- <p class="sw-input-label">
17
- <?php esc_html_e( $registration['plugin_name'].' License Key' , 'social-warfare' ); ?>
18
- </p>
19
- </div>
20
-
21
- <div class="sw-grid sw-col-300">
22
- <input name="<?php echo $registration['key'] ?>_license_key" type="text" class="sw-admin-input" placeholder="License Key" value="<?php echo $license_key; ?>" />
23
- </div>
24
-
25
- <div class="sw-grid sw-col-300 sw-fit register_button_grid">
26
- <a href="#" class="register-plugin button sw-navy-button" swp-addon="<?php echo $registration['key']; ?>" swp-item-id="<?php echo $registration["product_id"]; ?>">
27
- <?php esc_html_e( 'Register Plugin' , 'social-warfare' ); ?>
28
- </a>
29
- </div>
30
-
31
- <div class="sw-clearfix"></div>
32
- </div>
33
-
34
- <div class="sw-grid sw-col-940 swp_is_registered">
35
-
36
- <div class="sw-green-notice">
37
- <?php esc_html_e( 'This copy of '.$registration['plugin_name'].' is registered. Wah-hoo!', 'social-warfare' ); ?>
38
- </div>
39
-
40
- <p class="sw-subtitle sw-registration-text">
41
- <?php esc_html_e( 'To unregister your license click the button below to free it up for use on another domain.' , 'social-warfare' ); ?>
42
- </p>
43
-
44
- <div class="sw-grid sw-col-300">
45
- <p class="sw-authenticate-label">
46
- <?php esc_html_e( 'Deactivate Registration' , 'social-warfare' ); ?>
47
- </p>
48
- </div>
49
-
50
- <div class="sw-grid sw-col-300">
51
- <a href="#" class="unregister-plugin button sw-navy-button" swp-addon="<?php echo $registration['key']; ?>" swp-item-id="<?php echo $registration["product_id"]; ?>">
52
- <?php esc_html_e( 'Unregister Plugin' , 'social-warfare' ); ?>
53
- </a>
54
- </div>
55
- <div class="sw-grid sw-col-300 sw-fit"></div>
56
-
57
- </div>
58
-
59
- </div>
1
+ <div class="registration-wrapper <?php echo $registration['key'] ?>" registration="<?php echo $registered; ?>">
2
+
3
+ <h2><?php esc_html_e( $registration['plugin_name'].' Registration' , 'social-warfare' ); ?></h2>
4
+
5
+ <div class="sw-grid sw-col-940 swp_is_not_registered">
6
+
7
+ <div class="sw-red-notice">
8
+ <?php _e( 'This copy of '.$registration['plugin_name'].' is NOT registered. <a target="_blank" href="https://warfareplugins.com">Click here</a> to purchase a license or add your account info below.' , 'social-warfare' ); ?>
9
+ </div>
10
+
11
+ <p class="sw-subtitle sw-registration-text">
12
+ <?php esc_html_e( 'Enter your registration key for '.$registration['plugin_name'] .' and then click Register Plugin.' , 'social-warfare' ); ?>
13
+ </p>
14
+
15
+ <div class="sw-grid sw-col-300">
16
+ <p class="sw-input-label">
17
+ <?php esc_html_e( $registration['plugin_name'].' License Key' , 'social-warfare' ); ?>
18
+ </p>
19
+ </div>
20
+
21
+ <div class="sw-grid sw-col-300">
22
+ <input name="<?php echo $registration['key'] ?>_license_key" type="text" class="sw-admin-input" placeholder="License Key" value="<?php echo $license_key; ?>" />
23
+ </div>
24
+
25
+ <div class="sw-grid sw-col-300 sw-fit register_button_grid">
26
+ <a href="#" class="register-plugin button sw-navy-button" swp-addon="<?php echo $registration['key']; ?>" swp-item-id="<?php echo $registration["product_id"]; ?>">
27
+ <?php esc_html_e( 'Register Plugin' , 'social-warfare' ); ?>
28
+ </a>
29
+ </div>
30
+
31
+ <div class="sw-clearfix"></div>
32
+ </div>
33
+
34
+ <div class="sw-grid sw-col-940 swp_is_registered">
35
+
36
+ <div class="sw-green-notice">
37
+ <?php esc_html_e( 'This copy of '.$registration['plugin_name'].' is registered. Wah-hoo!', 'social-warfare' ); ?>
38
+ </div>
39
+
40
+ <p class="sw-subtitle sw-registration-text">
41
+ <?php esc_html_e( 'To unregister your license click the button below to free it up for use on another domain.' , 'social-warfare' ); ?>
42
+ </p>
43
+
44
+ <div class="sw-grid sw-col-300">
45
+ <p class="sw-authenticate-label">
46
+ <?php esc_html_e( 'Deactivate Registration' , 'social-warfare' ); ?>
47
+ </p>
48
+ </div>
49
+
50
+ <div class="sw-grid sw-col-300">
51
+ <a href="#" class="unregister-plugin button sw-navy-button" swp-addon="<?php echo $registration['key']; ?>" swp-item-id="<?php echo $registration["product_id"]; ?>">
52
+ <?php esc_html_e( 'Unregister Plugin' , 'social-warfare' ); ?>
53
+ </a>
54
+ </div>
55
+ <div class="sw-grid sw-col-300 sw-fit"></div>
56
+
57
+ </div>
58
+
59
+ </div>
functions/legacy/update-checker.php CHANGED
@@ -1,491 +1,491 @@
1
- <?php
2
-
3
- // Exit if accessed directly
4
- if ( ! defined( 'ABSPATH' ) ) exit;
5
-
6
- /**
7
- * Allows plugins to use their own update API.
8
- *
9
- * @author Easy Digital Downloads
10
- * @version 1.6.14
11
- */
12
- class SW_EDD_SL_Plugin_Updater {
13
-
14
- private $api_url = '';
15
- private $api_data = array();
16
- private $name = '';
17
- private $slug = '';
18
- private $version = '';
19
- private $wp_override = false;
20
- private $cache_key = '';
21
-
22
- /**
23
- * Class constructor.
24
- *
25
- * @uses plugin_basename()
26
- * @uses hook()
27
- *
28
- * @param string $_api_url The URL pointing to the custom API endpoint.
29
- * @param string $_plugin_file Path to the plugin file.
30
- * @param array $_api_data Optional data to send with API calls.
31
- */
32
- public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
-
34
- global $edd_plugin_data;
35
-
36
- $this->api_url = trailingslashit( $_api_url );
37
- $this->api_data = $_api_data;
38
- $this->name = plugin_basename( $_plugin_file );
39
- $this->slug = basename( $_plugin_file, '.php' );
40
- $this->version = $_api_data['version'];
41
- $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
42
- $this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
43
- $this->cache_key = md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
44
-
45
- $edd_plugin_data[ $this->slug ] = $this->api_data;
46
-
47
- // Set up hooks.
48
- $this->init();
49
-
50
- }
51
-
52
- /**
53
- * Set up WordPress filters to hook into WP's update process.
54
- *
55
- * @uses add_filter()
56
- *
57
- * @return void
58
- */
59
- public function init() {
60
-
61
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
62
- add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
63
- remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
64
- add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
65
- add_action( 'admin_init', array( $this, 'show_changelog' ) );
66
-
67
- }
68
-
69
- /**
70
- * Check for Updates at the defined API endpoint and modify the update array.
71
- *
72
- * This function dives into the update API just when WordPress creates its update array,
73
- * then adds a custom API call and injects the custom plugin data retrieved from the API.
74
- * It is reassembled from parts of the native WordPress plugin update code.
75
- * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
76
- *
77
- * @uses api_request()
78
- *
79
- * @param array $_transient_data Update array build by WordPress.
80
- * @return array Modified update array with custom plugin data.
81
- */
82
- public function check_update( $_transient_data ) {
83
-
84
- global $pagenow;
85
-
86
- if ( ! is_object( $_transient_data ) ) {
87
- $_transient_data = new stdClass;
88
- }
89
-
90
- if ( 'plugins.php' == $pagenow && is_multisite() ) {
91
- return $_transient_data;
92
- }
93
-
94
- if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
95
- return $_transient_data;
96
- }
97
-
98
- $version_info = $this->get_cached_version_info();
99
-
100
- if ( false === $version_info ) {
101
- $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
102
-
103
- $this->set_version_info_cache( $version_info );
104
-
105
- }
106
-
107
- if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
108
-
109
- if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
110
-
111
- $_transient_data->response[ $this->name ] = $version_info;
112
-
113
- }
114
-
115
- $_transient_data->last_checked = current_time( 'timestamp' );
116
- $_transient_data->checked[ $this->name ] = $this->version;
117
-
118
- }
119
-
120
- return $_transient_data;
121
- }
122
-
123
- /**
124
- * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
125
- *
126
- * @param string $file
127
- * @param array $plugin
128
- */
129
- public function show_update_notification( $file, $plugin ) {
130
-
131
- if ( is_network_admin() ) {
132
- return;
133
- }
134
-
135
- if( ! current_user_can( 'update_plugins' ) ) {
136
- return;
137
- }
138
-
139
- if( ! is_multisite() ) {
140
- return;
141
- }
142
-
143
- if ( $this->name != $file ) {
144
- return;
145
- }
146
-
147
- // Remove our filter on the site transient
148
- remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
149
-
150
- $update_cache = get_site_transient( 'update_plugins' );
151
-
152
- $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
153
-
154
- if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
155
-
156
- $version_info = $this->get_cached_version_info();
157
-
158
- if ( false === $version_info ) {
159
- $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
160
-
161
- $this->set_version_info_cache( $version_info );
162
- }
163
-
164
- if ( ! is_object( $version_info ) ) {
165
- return;
166
- }
167
-
168
- if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
169
-
170
- $update_cache->response[ $this->name ] = $version_info;
171
-
172
- }
173
-
174
- $update_cache->last_checked = current_time( 'timestamp' );
175
- $update_cache->checked[ $this->name ] = $this->version;
176
-
177
- set_site_transient( 'update_plugins', $update_cache );
178
-
179
- } else {
180
-
181
- $version_info = $update_cache->response[ $this->name ];
182
-
183
- }
184
-
185
- // Restore our filter
186
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
187
-
188
- if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
189
-
190
- // build a plugin list row, with update notification
191
- $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
192
- # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
193
- echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
194
- echo '<td colspan="3" class="plugin-update colspanchange">';
195
- echo '<div class="update-message notice inline notice-warning notice-alt">';
196
-
197
- $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
198
-
199
- if ( empty( $version_info->download_link ) ) {
200
- printf(
201
- __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
202
- esc_html( $version_info->name ),
203
- '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
204
- esc_html( $version_info->new_version ),
205
- '</a>'
206
- );
207
- } else {
208
- printf(
209
- __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
210
- esc_html( $version_info->name ),
211
- '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
212
- esc_html( $version_info->new_version ),
213
- '</a>',
214
- '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
215
- '</a>'
216
- );
217
- }
218
-
219
- do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
220
-
221
- echo '</div></td></tr>';
222
- }
223
- }
224
-
225
- /**
226
- * Updates information on the "View version x.x details" page with custom data.
227
- *
228
- * @uses api_request()
229
- *
230
- * @param mixed $_data
231
- * @param string $_action
232
- * @param object $_args
233
- * @return object $_data
234
- */
235
- public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
236
-
237
- if ( $_action != 'plugin_information' ) {
238
-
239
- return $_data;
240
-
241
- }
242
-
243
- if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
244
-
245
- return $_data;
246
-
247
- }
248
-
249
- $to_send = array(
250
- 'slug' => $this->slug,
251
- 'is_ssl' => is_ssl(),
252
- 'fields' => array(
253
- 'banners' => array(),
254
- 'reviews' => false
255
- )
256
- );
257
-
258
- $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
259
-
260
- // Get the transient where we store the api request for this plugin for 24 hours
261
- $edd_api_request_transient = $this->get_cached_version_info( $cache_key );
262
-
263
- //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
264
- if ( empty( $edd_api_request_transient ) ) {
265
-
266
- $api_response = $this->api_request( 'plugin_information', $to_send );
267
-
268
- // Expires in 3 hours
269
- $this->set_version_info_cache( $api_response, $cache_key );
270
-
271
- if ( false !== $api_response ) {
272
- $_data = $api_response;
273
- }
274
-
275
- } else {
276
- $_data = $edd_api_request_transient;
277
- }
278
-
279
- // Convert sections into an associative array, since we're getting an object, but Core expects an array.
280
- if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
281
- $new_sections = array();
282
- foreach ( $_data->sections as $key => $value ) {
283
- $new_sections[ $key ] = $value;
284
- }
285
-
286
- $_data->sections = $new_sections;
287
- }
288
-
289
- // Convert banners into an associative array, since we're getting an object, but Core expects an array.
290
- if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
291
- $new_banners = array();
292
- foreach ( $_data->banners as $key => $value ) {
293
- $new_banners[ $key ] = $value;
294
- }
295
-
296
- $_data->banners = $new_banners;
297
- }
298
-
299
- return $_data;
300
- }
301
-
302
- /**
303
- * Disable SSL verification in order to prevent download update failures
304
- *
305
- * @param array $args
306
- * @param string $url
307
- * @return object $array
308
- */
309
- public function http_request_args( $args, $url ) {
310
-
311
- $verify_ssl = $this->verify_ssl();
312
- if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
313
- $args['sslverify'] = $verify_ssl;
314
- }
315
- return $args;
316
-
317
- }
318
-
319
- /**
320
- * Calls the API and, if successfull, returns the object delivered by the API.
321
- *
322
- * @uses get_bloginfo()
323
- * @uses wp_remote_post()
324
- * @uses is_wp_error()
325
- *
326
- * @param string $_action The requested action.
327
- * @param array $_data Parameters for the API action.
328
- * @return false|object
329
- */
330
- private function api_request( $_action, $_data ) {
331
-
332
- global $wp_version;
333
-
334
- $data = array_merge( $this->api_data, $_data );
335
-
336
- if ( $data['slug'] != $this->slug ) {
337
- return;
338
- }
339
-
340
- if( $this->api_url == trailingslashit (home_url() ) ) {
341
- return false; // Don't allow a plugin to ping itself
342
- }
343
-
344
- $api_params = array(
345
- 'edd_action' => 'get_version',
346
- 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
347
- 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
348
- 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
349
- 'version' => isset( $data['version'] ) ? $data['version'] : false,
350
- 'slug' => $data['slug'],
351
- 'author' => $data['author'],
352
- 'url' => home_url(),
353
- 'beta' => ! empty( $data['beta'] ),
354
- );
355
-
356
- $verify_ssl = $this->verify_ssl();
357
- $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
358
-
359
- if ( ! is_wp_error( $request ) ) {
360
- $request = json_decode( wp_remote_retrieve_body( $request ) );
361
- }
362
-
363
- if ( $request && isset( $request->sections ) ) {
364
- $request->sections = maybe_unserialize( $request->sections );
365
- } else {
366
- $request = false;
367
- }
368
-
369
- if ( $request && isset( $request->banners ) ) {
370
- $request->banners = maybe_unserialize( $request->banners );
371
- }
372
-
373
- if( ! empty( $request->sections ) ) {
374
- foreach( $request->sections as $key => $section ) {
375
- $request->$key = (array) $section;
376
- }
377
- }
378
-
379
- return $request;
380
- }
381
-
382
- public function show_changelog() {
383
-
384
- global $edd_plugin_data;
385
-
386
- if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
387
- return;
388
- }
389
-
390
- if( empty( $_REQUEST['plugin'] ) ) {
391
- return;
392
- }
393
-
394
- if( empty( $_REQUEST['slug'] ) ) {
395
- return;
396
- }
397
-
398
- if( ! current_user_can( 'update_plugins' ) ) {
399
- wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
400
- }
401
-
402
- $data = $edd_plugin_data[ $_REQUEST['slug'] ];
403
- $beta = ! empty( $data['beta'] ) ? true : false;
404
- $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
405
- $version_info = $this->get_cached_version_info( $cache_key );
406
-
407
- if( false === $version_info ) {
408
-
409
- $api_params = array(
410
- 'edd_action' => 'get_version',
411
- 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
412
- 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
413
- 'slug' => $_REQUEST['slug'],
414
- 'author' => $data['author'],
415
- 'url' => home_url(),
416
- 'beta' => ! empty( $data['beta'] )
417
- );
418
-
419
- $verify_ssl = $this->verify_ssl();
420
- $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
421
-
422
- if ( ! is_wp_error( $request ) ) {
423
- $version_info = json_decode( wp_remote_retrieve_body( $request ) );
424
- }
425
-
426
-
427
- if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
428
- $version_info->sections = maybe_unserialize( $version_info->sections );
429
- } else {
430
- $version_info = false;
431
- }
432
-
433
- if( ! empty( $version_info ) ) {
434
- foreach( $version_info->sections as $key => $section ) {
435
- $version_info->$key = (array) $section;
436
- }
437
- }
438
-
439
- $this->set_version_info_cache( $version_info, $cache_key );
440
-
441
- }
442
-
443
- if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
444
- echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
445
- }
446
-
447
- exit;
448
- }
449
-
450
- public function get_cached_version_info( $cache_key = '' ) {
451
-
452
- if( empty( $cache_key ) ) {
453
- $cache_key = $this->cache_key;
454
- }
455
-
456
- $cache = get_option( $cache_key );
457
-
458
- if( empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) {
459
- return false; // Cache is expired
460
- }
461
-
462
- return json_decode( $cache['value'] );
463
-
464
- }
465
-
466
- public function set_version_info_cache( $value = '', $cache_key = '' ) {
467
-
468
- if( empty( $cache_key ) ) {
469
- $cache_key = $this->cache_key;
470
- }
471
-
472
- $data = array(
473
- 'timeout' => strtotime( '+3 hours', current_time( 'timestamp' ) ),
474
- 'value' => json_encode( $value )
475
- );
476
-
477
- update_option( $cache_key, $data, 'no' );
478
-
479
- }
480
-
481
- /**
482
- * Returns if the SSL of the store should be verified.
483
- *
484
- * @since 1.6.13
485
- * @return bool
486
- */
487
- private function verify_ssl() {
488
- return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
489
- }
490
-
491
- }
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ /**
7
+ * Allows plugins to use their own update API.
8
+ *
9
+ * @author Easy Digital Downloads
10
+ * @version 1.6.14
11
+ */
12
+ class SW_EDD_SL_Plugin_Updater {
13
+
14
+ private $api_url = '';
15
+ private $api_data = array();
16
+ private $name = '';
17
+ private $slug = '';
18
+ private $version = '';
19
+ private $wp_override = false;
20
+ private $cache_key = '';
21
+
22
+ /**
23
+ * Class constructor.
24
+ *
25
+ * @uses plugin_basename()
26
+ * @uses hook()
27
+ *
28
+ * @param string $_api_url The URL pointing to the custom API endpoint.
29
+ * @param string $_plugin_file Path to the plugin file.
30
+ * @param array $_api_data Optional data to send with API calls.
31
+ */
32
+ public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
+
34
+ global $edd_plugin_data;
35
+
36
+ $this->api_url = trailingslashit( $_api_url );
37
+ $this->api_data = $_api_data;
38
+ $this->name = plugin_basename( $_plugin_file );
39
+ $this->slug = basename( $_plugin_file, '.php' );
40
+ $this->version = $_api_data['version'];
41
+ $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
42
+ $this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
43
+ $this->cache_key = md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
44
+
45
+ $edd_plugin_data[ $this->slug ] = $this->api_data;
46
+
47
+ // Set up hooks.
48
+ $this->init();
49
+
50
+ }
51
+
52
+ /**
53
+ * Set up WordPress filters to hook into WP's update process.
54
+ *
55
+ * @uses add_filter()
56
+ *
57
+ * @return void
58
+ */
59
+ public function init() {
60
+
61
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
62
+ add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
63
+ remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
64
+ add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
65
+ add_action( 'admin_init', array( $this, 'show_changelog' ) );
66
+
67
+ }
68
+
69
+ /**
70
+ * Check for Updates at the defined API endpoint and modify the update array.
71
+ *
72
+ * This function dives into the update API just when WordPress creates its update array,
73
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
74
+ * It is reassembled from parts of the native WordPress plugin update code.
75
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
76
+ *
77
+ * @uses api_request()
78
+ *
79
+ * @param array $_transient_data Update array build by WordPress.
80
+ * @return array Modified update array with custom plugin data.
81
+ */
82
+ public function check_update( $_transient_data ) {
83
+
84
+ global $pagenow;
85
+
86
+ if ( ! is_object( $_transient_data ) ) {
87
+ $_transient_data = new stdClass;
88
+ }
89
+
90
+ if ( 'plugins.php' == $pagenow && is_multisite() ) {
91
+ return $_transient_data;
92
+ }
93
+
94
+ if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
95
+ return $_transient_data;
96
+ }
97
+
98
+ $version_info = $this->get_cached_version_info();
99
+
100
+ if ( false === $version_info ) {
101
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
102
+
103
+ $this->set_version_info_cache( $version_info );
104
+
105
+ }
106
+
107
+ if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
108
+
109
+ if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
110
+
111
+ $_transient_data->response[ $this->name ] = $version_info;
112
+
113
+ }
114
+
115
+ $_transient_data->last_checked = current_time( 'timestamp' );
116
+ $_transient_data->checked[ $this->name ] = $this->version;
117
+
118
+ }
119
+
120
+ return $_transient_data;
121
+ }
122
+
123
+ /**
124
+ * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
125
+ *
126
+ * @param string $file
127
+ * @param array $plugin
128
+ */
129
+ public function show_update_notification( $file, $plugin ) {
130
+
131
+ if ( is_network_admin() ) {
132
+ return;
133
+ }
134
+
135
+ if( ! current_user_can( 'update_plugins' ) ) {
136
+ return;
137
+ }
138
+
139
+ if( ! is_multisite() ) {
140
+ return;
141
+ }
142
+
143
+ if ( $this->name != $file ) {
144
+ return;
145
+ }
146
+
147
+ // Remove our filter on the site transient
148
+ remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
149
+
150
+ $update_cache = get_site_transient( 'update_plugins' );
151
+
152
+ $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
153
+
154
+ if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
155
+
156
+ $version_info = $this->get_cached_version_info();
157
+
158
+ if ( false === $version_info ) {
159
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
160
+
161
+ $this->set_version_info_cache( $version_info );
162
+ }
163
+
164
+ if ( ! is_object( $version_info ) ) {
165
+ return;
166
+ }
167
+
168
+ if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
169
+
170
+ $update_cache->response[ $this->name ] = $version_info;
171
+
172
+ }
173
+
174
+ $update_cache->last_checked = current_time( 'timestamp' );
175
+ $update_cache->checked[ $this->name ] = $this->version;
176
+
177
+ set_site_transient( 'update_plugins', $update_cache );
178
+
179
+ } else {
180
+
181
+ $version_info = $update_cache->response[ $this->name ];
182
+
183
+ }
184
+
185
+ // Restore our filter
186
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
187
+
188
+ if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
189
+
190
+ // build a plugin list row, with update notification
191
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
192
+ # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
193
+ echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
194
+ echo '<td colspan="3" class="plugin-update colspanchange">';
195
+ echo '<div class="update-message notice inline notice-warning notice-alt">';
196
+
197
+ $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
198
+
199
+ if ( empty( $version_info->download_link ) ) {
200
+ printf(
201
+ __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
202
+ esc_html( $version_info->name ),
203
+ '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
204
+ esc_html( $version_info->new_version ),
205
+ '</a>'
206
+ );
207
+ } else {
208
+ printf(
209
+ __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
210
+ esc_html( $version_info->name ),
211
+ '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
212
+ esc_html( $version_info->new_version ),
213
+ '</a>',
214
+ '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
215
+ '</a>'
216
+ );
217
+ }
218
+
219
+ do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
220
+
221
+ echo '</div></td></tr>';
222
+ }
223
+ }
224
+
225
+ /**
226
+ * Updates information on the "View version x.x details" page with custom data.
227
+ *
228
+ * @uses api_request()
229
+ *
230
+ * @param mixed $_data
231
+ * @param string $_action
232
+ * @param object $_args
233
+ * @return object $_data
234
+ */
235
+ public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
236
+
237
+ if ( $_action != 'plugin_information' ) {
238
+
239
+ return $_data;
240
+
241
+ }
242
+
243
+ if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
244
+
245
+ return $_data;
246
+
247
+ }
248
+
249
+ $to_send = array(
250
+ 'slug' => $this->slug,
251
+ 'is_ssl' => is_ssl(),
252
+ 'fields' => array(
253
+ 'banners' => array(),
254
+ 'reviews' => false
255
+ )
256
+ );
257
+
258
+ $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
259
+
260
+ // Get the transient where we store the api request for this plugin for 24 hours
261
+ $edd_api_request_transient = $this->get_cached_version_info( $cache_key );
262
+
263
+ //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
264
+ if ( empty( $edd_api_request_transient ) ) {
265
+
266
+ $api_response = $this->api_request( 'plugin_information', $to_send );
267
+
268
+ // Expires in 3 hours
269
+ $this->set_version_info_cache( $api_response, $cache_key );
270
+
271
+ if ( false !== $api_response ) {
272
+ $_data = $api_response;
273
+ }
274
+
275
+ } else {
276
+ $_data = $edd_api_request_transient;
277
+ }
278
+
279
+ // Convert sections into an associative array, since we're getting an object, but Core expects an array.
280
+ if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
281
+ $new_sections = array();
282
+ foreach ( $_data->sections as $key => $value ) {
283
+ $new_sections[ $key ] = $value;
284
+ }
285
+
286
+ $_data->sections = $new_sections;
287
+ }
288
+
289
+ // Convert banners into an associative array, since we're getting an object, but Core expects an array.
290
+ if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
291
+ $new_banners = array();
292
+ foreach ( $_data->banners as $key => $value ) {
293
+ $new_banners[ $key ] = $value;
294
+ }
295
+
296
+ $_data->banners = $new_banners;
297
+ }
298
+
299
+ return $_data;
300
+ }
301
+
302
+ /**
303
+ * Disable SSL verification in order to prevent download update failures
304
+ *
305
+ * @param array $args
306
+ * @param string $url
307
+ * @return object $array
308
+ */
309
+ public function http_request_args( $args, $url ) {
310
+
311
+ $verify_ssl = $this->verify_ssl();
312
+ if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
313
+ $args['sslverify'] = $verify_ssl;
314
+ }
315
+ return $args;
316
+
317
+ }
318
+
319
+ /**
320
+ * Calls the API and, if successfull, returns the object delivered by the API.
321
+ *
322
+ * @uses get_bloginfo()
323
+ * @uses wp_remote_post()
324
+ * @uses is_wp_error()
325
+ *
326
+ * @param string $_action The requested action.
327
+ * @param array $_data Parameters for the API action.
328
+ * @return false|object
329
+ */
330
+ private function api_request( $_action, $_data ) {
331
+
332
+ global $wp_version;
333
+
334
+ $data = array_merge( $this->api_data, $_data );
335
+
336
+ if ( $data['slug'] != $this->slug ) {
337
+ return;
338
+ }
339
+
340
+ if( $this->api_url == trailingslashit (home_url() ) ) {
341
+ return false; // Don't allow a plugin to ping itself
342
+ }
343
+
344
+ $api_params = array(
345
+ 'edd_action' => 'get_version',
346
+ 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
347
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
348
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
349
+ 'version' => isset( $data['version'] ) ? $data['version'] : false,
350
+ 'slug' => $data['slug'],
351
+ 'author' => $data['author'],
352
+ 'url' => home_url(),
353
+ 'beta' => ! empty( $data['beta'] ),
354
+ );
355
+
356
+ $verify_ssl = $this->verify_ssl();
357
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
358
+
359
+ if ( ! is_wp_error( $request ) ) {
360
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
361
+ }
362
+
363
+ if ( $request && isset( $request->sections ) ) {
364
+ $request->sections = maybe_unserialize( $request->sections );
365
+ } else {
366
+ $request = false;
367
+ }
368
+
369
+ if ( $request && isset( $request->banners ) ) {
370
+ $request->banners = maybe_unserialize( $request->banners );
371
+ }
372
+
373
+ if( ! empty( $request->sections ) ) {
374
+ foreach( $request->sections as $key => $section ) {
375
+ $request->$key = (array) $section;
376
+ }
377
+ }
378
+
379
+ return $request;
380
+ }
381
+
382
+ public function show_changelog() {
383
+
384
+ global $edd_plugin_data;
385
+
386
+ if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
387
+ return;
388
+ }
389
+
390
+ if( empty( $_REQUEST['plugin'] ) ) {
391
+ return;
392
+ }
393
+
394
+ if( empty( $_REQUEST['slug'] ) ) {
395
+ return;
396
+ }
397
+
398
+ if( ! current_user_can( 'update_plugins' ) ) {
399
+ wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
400
+ }
401
+
402
+ $data = $edd_plugin_data[ $_REQUEST['slug'] ];
403
+ $beta = ! empty( $data['beta'] ) ? true : false;
404
+ $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
405
+ $version_info = $this->get_cached_version_info( $cache_key );
406
+
407
+ if( false === $version_info ) {
408
+
409
+ $api_params = array(
410
+ 'edd_action' => 'get_version',
411
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
412
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
413
+ 'slug' => $_REQUEST['slug'],
414
+ 'author' => $data['author'],
415
+ 'url' => home_url(),
416
+ 'beta' => ! empty( $data['beta'] )
417
+ );
418
+
419
+ $verify_ssl = $this->verify_ssl();
420
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
421
+
422
+ if ( ! is_wp_error( $request ) ) {
423
+ $version_info = json_decode( wp_remote_retrieve_body( $request ) );
424
+ }
425
+
426
+
427
+ if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
428
+ $version_info->sections = maybe_unserialize( $version_info->sections );
429
+ } else {
430
+ $version_info = false;
431
+ }
432
+
433
+ if( ! empty( $version_info ) ) {
434
+ foreach( $version_info->sections as $key => $section ) {
435
+ $version_info->$key = (array) $section;
436
+ }
437
+ }
438
+
439
+ $this->set_version_info_cache( $version_info, $cache_key );
440
+
441
+ }
442
+
443
+ if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
444
+ echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
445
+ }
446
+
447
+ exit;
448
+ }
449
+
450
+ public function get_cached_version_info( $cache_key = '' ) {
451
+
452
+ if( empty( $cache_key ) ) {
453
+ $cache_key = $this->cache_key;
454
+ }
455
+
456
+ $cache = get_option( $cache_key );
457
+
458
+ if( empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) {
459
+ return false; // Cache is expired
460
+ }
461
+
462
+ return json_decode( $cache['value'] );
463
+
464
+ }
465
+
466
+ public function set_version_info_cache( $value = '', $cache_key = '' ) {
467
+
468
+ if( empty( $cache_key ) ) {
469
+ $cache_key = $this->cache_key;
470
+ }
471
+
472
+ $data = array(
473
+ 'timeout' => strtotime( '+3 hours', current_time( 'timestamp' ) ),
474
+ 'value' => json_encode( $value )
475
+ );
476
+
477
+ update_option( $cache_key, $data, 'no' );
478
+
479
+ }
480
+
481
+ /**
482
+ * Returns if the SSL of the store should be verified.
483
+ *
484
+ * @since 1.6.13
485
+ * @return bool
486
+ */
487
+ private function verify_ssl() {
488
+ return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
489
+ }
490
+
491
+ }
functions/options/SWP_Addon_Registration.php CHANGED
@@ -1,116 +1,116 @@
1
- <?php
2
-
3
- class SWP_Addon_Registration extends SWP_Option {
4
- public $key = '';
5
- public $license_key = '';
6
- public $product_id = 0;
7
- public $registered = 0;
8
-
9
- public function __construct( $addon ) {
10
- parent::__construct( $addon->name, $addon->key );
11
- $this->display_name = $addon->name;
12
- $this->key = $addon->key;
13
- $this->license_key = $this->get_license_key();
14
- $this->product_id = $addon->product_id;
15
- $this->version = $addon->version;
16
- }
17
-
18
- public function render_HTML() {
19
- if ( !empty( $this->license_key ) ) :
20
- $this->registered = 1;
21
- endif;
22
-
23
- $html = '<div class="registration-wrapper '. $this->key . '" registration="' . $this->registered . '">';
24
- $html .= '<h2>' . __($this->name . ' Registration', 'social-warfare') . '</h2>';
25
-
26
- //* Print both types of HTML. Javascript determines which to display.
27
- $html .= $this->not_registered_HTML();
28
- $html .= $this->is_registered_HTML();
29
-
30
- $html .= '</div>';
31
-
32
- $this->html = $html;
33
-
34
- return $html;
35
- }
36
-
37
- public function get_license_key() {
38
- $license = $this->key . '_license_key';
39
-
40
- if ( isset( $this->user_options[$license] ) ) {
41
- return $this->user_options[$license];
42
- }
43
-
44
- return '';
45
- }
46
-
47
- protected function not_registered_HTML() {
48
- $html = '<div class="sw-grid sw-col-940 swp_is_not_registered">';
49
-
50
- $html .= '<div class="sw-red-notice">';
51
- $html .= __( 'This copy of '. $this->name .' is NOT registered. <a target="_blank" href="https://warfareplugins.com">Click here</a> to purchase a license or add your account info below.' , 'social-warfare' );
52
- $html .= '</div>';
53
-
54
- $html .= '<p class="sw-subtitle sw-registration-text">';
55
- $html .= __( 'Enter your registration key for '. $this->name .' and then click Register Plugin.' , 'social-warfare' );
56
- $html .= '</p>';
57
-
58
- $html .= '<div class="sw-grid sw-col-300">';
59
- $html .= '<p class="sw-input-label">';
60
- $html .= __( $this->name . ' License Key' , 'social-warfare' );
61
- $html .= '</p>';
62
- $html .= '</div>';
63
-
64
- $html .= '<div class="sw-grid sw-col-300">';
65
- $html .= '<input name="' . $this->key . '_license_key" type="text" class="sw-admin-input" placeholder="License Key" value="' . $this->license_key . '" />';
66
- $html .= '</div>';
67
-
68
- $html .= '<div class="sw-grid sw-col-300 sw-fit register_button_grid">';
69
- $html .= '<a href="#" class="register-plugin button sw-navy-button" swp-addon="' . $this->key . '" swp-item-id="' . $this->product_id . '">';
70
- $html .= __( 'Register Plugin' , 'social-warfare' );
71
- $html .= '</a>';
72
- $html .= '</div>';
73
-
74
- $html .= '<div class="sw-clearfix"></div>';
75
- $html .= '</div>';
76
-
77
- return $html;
78
- }
79
-
80
- protected function is_registered_HTML() {
81
- ob_start();
82
-
83
- ?>
84
-
85
- <div class="sw-grid sw-col-940 swp_is_registered">
86
-
87
- <div class="sw-green-notice">
88
- <?php _e( 'This copy of '. $this->name .' is registered. Wah-hoo!', 'social-warfare' ); ?>
89
- </div>
90
-
91
- <p class="sw-subtitle sw-registration-text">
92
- <?php _e( 'To unregister your license click the button below to free it up for use on another domain.' , 'social-warfare' ); ?>
93
- </p>
94
-
95
- <div class="sw-grid sw-col-300">
96
- <p class="sw-authenticate-label">
97
- <?php _e( 'Deactivate Registration' , 'social-warfare' ); ?>
98
- </p>
99
- </div>
100
-
101
- <div class="sw-grid sw-col-300">
102
- <a href="#" class="unregister-plugin button sw-navy-button" swp-addon="<?php echo $this->key ?>" swp-item-id="<?php echo $this->product_id; ?>">
103
- <?php _e( 'Unregister Plugin' , 'social-warfare' ); ?>
104
- </a>
105
- </div>
106
- <div class="sw-grid sw-col-300 sw-fit"></div>
107
-
108
- </div>
109
-
110
- <?php
111
-
112
- $html = ob_get_clean();
113
-
114
- return $html;
115
- }
116
- }
1
+ <?php
2
+
3
+ class SWP_Addon_Registration extends SWP_Option {
4
+ public $key = '';
5
+ public $license_key = '';
6
+ public $product_id = 0;
7
+ public $registered = 0;
8
+
9
+ public function __construct( $addon ) {
10
+ parent::__construct( $addon->name, $addon->key );
11
+ $this->display_name = $addon->name;
12
+ $this->key = $addon->key;
13
+ $this->license_key = $this->get_license_key();
14
+ $this->product_id = $addon->product_id;
15
+ $this->version = $addon->version;
16
+ }
17
+
18
+ public function render_HTML() {
19
+ if ( !empty( $this->license_key ) ) :
20
+ $this->registered = 1;
21
+ endif;
22
+
23
+ $html = '<div class="registration-wrapper '. $this->key . '" registration="' . $this->registered . '">';
24
+ $html .= '<h2>' . __($this->name . ' Registration', 'social-warfare') . '</h2>';
25
+
26
+ //* Print both types of HTML. Javascript determines which to display.
27
+ $html .= $this->not_registered_HTML();
28
+ $html .= $this->is_registered_HTML();
29
+
30
+ $html .= '</div>';
31
+
32
+ $this->html = $html;
33
+
34
+ return $html;
35
+ }
36
+
37
+ public function get_license_key() {
38
+ $license = $this->key . '_license_key';
39
+
40
+ if ( isset( $this->user_options[$license] ) ) {
41
+ return $this->user_options[$license];
42
+ }
43
+
44
+ return '';
45
+ }
46
+
47
+ protected function not_registered_HTML() {
48
+ $html = '<div class="sw-grid sw-col-940 swp_is_not_registered">';
49
+
50
+ $html .= '<div class="sw-red-notice">';
51
+ $html .= __( 'This copy of '. $this->name .' is NOT registered. <a target="_blank" href="https://warfareplugins.com">Click here</a> to purchase a license or add your account info below.' , 'social-warfare' );
52
+ $html .= '</div>';
53
+
54
+ $html .= '<p class="sw-subtitle sw-registration-text">';
55
+ $html .= __( 'Enter your registration key for '. $this->name .' and then click Register Plugin.' , 'social-warfare' );
56
+ $html .= '</p>';
57
+
58
+ $html .= '<div class="sw-grid sw-col-300">';
59
+ $html .= '<p class="sw-input-label">';
60
+ $html .= __( $this->name . ' License Key' , 'social-warfare' );
61
+ $html .= '</p>';
62
+ $html .= '</div>';
63
+
64
+ $html .= '<div class="sw-grid sw-col-300">';
65
+ $html .= '<input name="' . $this->key . '_license_key" type="text" class="sw-admin-input" placeholder="License Key" value="' . $this->license_key . '" />';
66
+ $html .= '</div>';
67
+
68
+ $html .= '<div class="sw-grid sw-col-300 sw-fit register_button_grid">';
69
+ $html .= '<a href="#" class="register-plugin button sw-navy-button" swp-addon="' . $this->key . '" swp-item-id="' . $this->product_id . '">';
70
+ $html .= __( 'Register Plugin' , 'social-warfare' );
71
+ $html .= '</a>';
72
+ $html .= '</div>';
73
+
74
+ $html .= '<div class="sw-clearfix"></div>';
75
+ $html .= '</div>';
76
+
77
+ return $html;
78
+ }
79
+
80
+ protected function is_registered_HTML() {
81
+ ob_start();
82
+
83
+ ?>
84
+
85
+ <div class="sw-grid sw-col-940 swp_is_registered">
86
+
87
+ <div class="sw-green-notice">
88
+ <?php _e( 'This copy of '. $this->name .' is registered. Wah-hoo!', 'social-warfare' ); ?>
89
+ </div>
90
+
91
+ <p class="sw-subtitle sw-registration-text">
92
+ <?php _e( 'To unregister your license click the button below to free it up for use on another domain.' , 'social-warfare' ); ?>
93
+ </p>
94
+
95
+ <div class="sw-grid sw-col-300">
96
+ <p class="sw-authenticate-label">
97
+ <?php _e( 'Deactivate Registration' , 'social-warfare' ); ?>
98
+ </p>
99
+ </div>
100
+
101
+ <div class="sw-grid sw-col-300">
102
+ <a href="#" class="unregister-plugin button sw-navy-button" swp-addon="<?php echo $this->key ?>" swp-item-id="<?php echo $this->product_id; ?>">
103
+ <?php _e( 'Unregister Plugin' , 'social-warfare' ); ?>
104
+ </a>
105
+ </div>
106
+ <div class="sw-grid sw-col-300 sw-fit"></div>
107
+
108
+ </div>
109
+
110
+ <?php
111
+
112
+ $html = ob_get_clean();
113
+
114
+ return $html;
115
+ }
116
+ }
functions/options/SWP_Option.php CHANGED
@@ -1,309 +1,309 @@
1
- <?php
2
-
3
- /**
4
- * The parent class for all Option_X types.
5
- *
6
- * This class is used to create each individual option throughout the options page.
7
- * It provides the framework for each of type of option that is available: input,
8
- * select, checkbox, and textarea. Each of these options is instantiated through
9
- * their respective class and then added to the option page section.
10
- *
11
- * @package SocialWarfare\Functions\Social-Networks
12
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
13
- * @license GPL-3.0+
14
- * @since 3.0.0 | Created | 02 MAR 2017
15
- * @access public
16
- *
17
- */
18
- class SWP_Option extends SWP_Abstract {
19
-
20
-
21
- /**
22
- * The type of HTML input element.
23
- *
24
- * Valid types are:
25
- * text, select, checkbox, textarea
26
- *
27
- * @var string $type
28
- *
29
- */
30
- public $type;
31
-
32
-
33
- /**
34
- * The CSS class representing the size (width) of the input.
35
- *
36
- * @see set_size()
37
- * @var string $size
38
- *
39
- */
40
- public $size;
41
-
42
-
43
- /**
44
- * The key for this option in the database.
45
- *
46
- * @var string $key
47
- *
48
- */
49
- public $key;
50
-
51
-
52
- /**
53
- * The default value for the given input.
54
- *
55
- * @var mixed $default. See the corresponding class's set_default() method.
56
- *
57
- */
58
- public $default = false;
59
-
60
-
61
- /**
62
- * The string of HTML which creates the element.
63
- *
64
- * @var string $html
65
- *
66
- */
67
- public $html;
68
-
69
-
70
- /**
71
- * Boolean indicating whether the plugin is registered or not.
72
- *
73
- * @var bool $swp_registration
74
- *
75
- */
76
- public $swp_registration;
77
-
78
-
79
- /**
80
- * The required constructor for PHP classes.
81
- *
82
- * @since 3.0.0 | 02 MAR 2018 | Created
83
- * @param string $name The display name for the toggle.
84
- * @param string $key The database key for the user setting.
85
- * @return void
86
- *
87
- */
88
- public function __construct( $name, $key ) {
89
- parent::__construct( $name );
90
-
91
- $this->swp_registration = true;
92
- $this->set_key( $key );
93
- $this->parent_size = ' sw-col-940 ';
94
- }
95
-
96
-
97
- /**
98
- * Fetches the css class to match a given size given as a string.
99
- *
100
- * @since 3.0.0 | 02 MAR 2018 | Created
101
- * @param string $size Optional: The size of the element using SWP sizing.
102
- * @return object $this Allows for method chaining.
103
- *
104
- */
105
- protected function get_css_size( $size = '' ) {
106
- $size = '' === $size ? $this->size : $size;
107
-
108
- $map = [
109
- 'two-fourths' => ' sw-col-460 ',
110
- 'two-thirds' => ' sw-col-300 ',
111
- 'four-fourths' => ' sw-col-620 ',
112
- ];
113
-
114
- if ( empty($size) ) :
115
- return $map['two-thirds'];
116
- endif;
117
-
118
- return $map[$size];
119
- }
120
-
121
-
122
- /**
123
- * Get the pre-defined value of the option.
124
- *
125
- * @since 3.0.0 | April 15 2018 | Created
126
- * @param void
127
- * @return mixed The current value of this option.
128
- *
129
- */
130
- protected function get_value() {
131
- if ( isset($this->value) ) {
132
- return $this->value;
133
- }
134
-
135
- if ( isset( $this->user_options[$this->key] ) ) {
136
- return $this->user_options[$this->key];
137
- }
138
-
139
- return $this->default;
140
- }
141
-
142
-
143
- /**
144
- * Creates HTML based on the option's properties and user settings.
145
- *
146
- * @since 3.0.0 | 02 MAR 2018 | Created
147
- * @param void
148
- * @return void
149
- *
150
- */
151
- public function render_HTML() {
152
- //* Intentionally left blank.
153
- //* Each child class should override this method.
154
- $this->_throw( "Should not be called from the parent class." );
155
- }
156
-
157
-
158
- /**
159
- * Set the default value of this option. This value will be used until the plugin user changes the value
160
- * to something else and saves the options.
161
- *
162
- * @since 3.0.0 | 02 MAR 2018 | Created
163
- * @param mixed The default value will vary based on the kind of option being generated.
164
- * @return object $this Allows for method chaining.
165
- *
166
- */
167
- public function set_default( $value ) {
168
- global $swp_user_options;
169
- $this->default = $value;
170
-
171
- // Add this to our global list of defaults
172
- add_filter('swp_options_page_defaults' , array( $this , 'register_default' ) );
173
-
174
- return $this;
175
- }
176
-
177
-
178
- /**
179
- * Register Default
180
- *
181
- * Add this to a global list of defaults so that if an option isn't set in the database,
182
- * then the method that pulls out the user option can just fall back to using this option's
183
- * default value.
184
- *
185
- * @since 3.0.0 | 24 APR 2018 | Created
186
- * @param array $defaults The array of defaults
187
- * @return array $defaults The modifed array of defaults.
188
- *
189
- */
190
- public function register_default( $defaults = array() ) {
191
- $defaults[$this->key] = $this->default;
192
- return $defaults;
193
- }
194
-
195
-
196
- /**
197
- * Force a child option to depend on a parent option.
198
- *
199
- * If the parent's value is one of the values passed in as $values,
200
- * the option will be visible ont the Settings page. Otherwise, the option
201
- * is hidden until the dependency is set to that value.
202
- *
203
- * @since 3.0.0 | 02 MAR 2018 | Created
204
- * @param string $parent The parent option's key.
205
- * @param array $values Values which enable this option to exist.
206
- * @return object $this Allows for method chaining.
207
- *
208
- */
209
- public function set_dependency( $parent, $values ) {
210
- if ( !is_string( $parent ) ) {
211
- $this->_throw( 'Argument $parent needs to be a string matching the key of another option.' );
212
- }
213
-
214
- if ( !isset( $values) ) {
215
- $this->_throw( 'Dependency values must passed in as the second argument.' );
216
- }
217
-
218
- if ( !is_array( $values ) ) {
219
- $values = array( $values );
220
-
221
- }
222
-
223
- $this->dependency = new stdClass();
224
- $this->dependency->parent = $parent;
225
- $this->dependency->values = $values;
226
-
227
- return $this;
228
- }
229
-
230
-
231
- /**
232
- * Assign the database key for this element.
233
- *
234
- * @since 3.0.0 | 02 MAR 2018 | Created
235
- * @param string $key The key which correlates to the input.
236
- * @return object $this The calling instance, for method chaining.
237
- *
238
- */
239
- public function set_key( $key ) {
240
- if ( !is_string( $key ) ) {
241
- $this->_throw( 'Please provide a key to the database as a string.' );
242
- }
243
-
244
- $this->key = $key;
245
-
246
- return $this;
247
- }
248
-
249
-
250
- /**
251
- * Some option types have multiple sizes that will determine their visual layout on the option
252
- * page. This setter allows you to declare which one you want to use.
253
- *
254
- * @since 3.0.0 | 02 MAR 2018 | Created
255
- * @param string The size of the option on the page (e.g. 'two-thirds').
256
- * @return object $this The calling instance, for method chaining.
257
- *
258
- */
259
- public function set_size( $size, $parent_size = ' sw-col-940 ') {
260
-
261
- if ( 0 !== strpos( $size, 'sw-col' ) ) {
262
- $sizes = PHP_EOL;
263
-
264
-
265
- $this->_throw( "Please enter a valid size. The string must begin with 'sw-col-', followed by either: 300, 460, or 620.'" );
266
- }
267
-
268
- $this->size = $size;
269
- $this->parent_size = $parent_size;
270
-
271
- return $this;
272
- }
273
-
274
-
275
- /**
276
- * Defines the placeholder for text inputs.
277
- *
278
- * @since 3.0.0 | 02 MAR 2018 | Created
279
- * @param string $placeholder The text to display as a placeholder.
280
- * @return object $this The calling instance, for method chaining.
281
- *
282
- */
283
- public function set_placeholder( $placeholder ) {
284
- if (!is_string( $placeholder ) && !is_numeric( $placeholder ) ) :
285
- $this->_throw( "Please set a string or number for the placeholder." );
286
- endif;
287
-
288
- $this->placeholder = $placeholder;
289
-
290
- return $this;
291
- }
292
-
293
-
294
- /**
295
- * Creates the HTML placeholder attribute if a placeholder is defined.
296
- *
297
- * @since 3.0.0 | 02 MAR 2018 | Created
298
- * @param void
299
- * @return string $placeholder The qualified HTML placeholder attribute.
300
- */
301
- public function render_placeholder() {
302
- if ( empty( $this->placeholder) ) :
303
- return "";
304
- endif;
305
-
306
- return ' placeholder="' . $this->placeholder . '"';
307
-
308
- }
309
- }
1
+ <?php
2
+
3
+ /**
4
+ * The parent class for all Option_X types.
5
+ *
6
+ * This class is used to create each individual option throughout the options page.
7
+ * It provides the framework for each of type of option that is available: input,
8
+ * select, checkbox, and textarea. Each of these options is instantiated through
9
+ * their respective class and then added to the option page section.
10
+ *
11
+ * @package SocialWarfare\Functions\Social-Networks
12
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
13
+ * @license GPL-3.0+
14
+ * @since 3.0.0 | Created | 02 MAR 2017
15
+ * @access public
16
+ *
17
+ */
18
+ class SWP_Option extends SWP_Abstract {
19
+
20
+
21
+ /**
22
+ * The type of HTML input element.
23
+ *
24
+ * Valid types are:
25
+ * text, select, checkbox, textarea
26
+ *
27
+ * @var string $type
28
+ *
29
+ */
30
+ public $type;
31
+
32
+
33
+ /**
34
+ * The CSS class representing the size (width) of the input.
35
+ *
36
+ * @see set_size()
37
+ * @var string $size
38
+ *
39
+ */
40
+ public $size;
41
+
42
+
43
+ /**
44
+ * The key for this option in the database.
45
+ *
46
+ * @var string $key
47
+ *
48
+ */
49
+ public $key;
50
+
51
+
52
+ /**
53
+ * The default value for the given input.
54
+ *
55
+ * @var mixed $default. See the corresponding class's set_default() method.
56
+ *
57
+ */
58
+ public $default = false;
59
+
60
+
61
+ /**
62
+ * The string of HTML which creates the element.
63
+ *
64
+ * @var string $html
65
+ *
66
+ */
67
+ public $html;
68
+
69
+
70
+ /**
71
+ * Boolean indicating whether the plugin is registered or not.
72
+ *
73
+ * @var bool $swp_registration
74
+ *
75
+ */
76
+ public $swp_registration;
77
+
78
+
79
+ /**
80
+ * The required constructor for PHP classes.
81
+ *
82
+ * @since 3.0.0 | 02 MAR 2018 | Created
83
+ * @param string $name The display name for the toggle.
84
+ * @param string $key The database key for the user setting.
85
+ * @return void
86
+ *
87
+ */
88
+ public function __construct( $name, $key ) {
89
+ parent::__construct( $name );
90
+
91
+ $this->swp_registration = true;
92
+ $this->set_key( $key );
93
+ $this->parent_size = ' sw-col-940 ';
94
+ }
95
+
96
+
97
+ /**
98
+ * Fetches the css class to match a given size given as a string.
99
+ *
100
+ * @since 3.0.0 | 02 MAR 2018 | Created
101
+ * @param string $size Optional: The size of the element using SWP sizing.
102
+ * @return object $this Allows for method chaining.
103
+ *
104
+ */
105
+ protected function get_css_size( $size = '' ) {
106
+ $size = '' === $size ? $this->size : $size;
107
+
108
+ $map = [
109
+ 'two-fourths' => ' sw-col-460 ',
110
+ 'two-thirds' => ' sw-col-300 ',
111
+ 'four-fourths' => ' sw-col-620 ',
112
+ ];
113
+
114
+ if ( empty($size) ) :
115
+ return $map['two-thirds'];
116
+ endif;
117
+
118
+ return $map[$size];
119
+ }
120
+
121
+
122
+ /**
123
+ * Get the pre-defined value of the option.
124
+ *
125
+ * @since 3.0.0 | April 15 2018 | Created
126
+ * @param void
127
+ * @return mixed The current value of this option.
128
+ *
129
+ */
130
+ protected function get_value() {
131
+ if ( isset($this->value) ) {
132
+ return $this->value;
133
+ }
134
+
135
+ if ( isset( $this->user_options[$this->key] ) ) {
136
+ return $this->user_options[$this->key];
137
+ }
138
+
139
+ return $this->default;
140
+ }
141
+
142
+
143
+ /**
144
+ * Creates HTML based on the option's properties and user settings.
145
+ *
146
+ * @since 3.0.0 | 02 MAR 2018 | Created
147
+ * @param void
148
+ * @return void
149
+ *
150
+ */
151
+ public function render_HTML() {
152
+ //* Intentionally left blank.
153
+ //* Each child class should override this method.
154
+ $this->_throw( "Should not be called from the parent class." );
155
+ }
156
+
157
+
158
+ /**
159
+ * Set the default value of this option. This value will be used until the plugin user changes the value
160
+ * to something else and saves the options.
161
+ *
162
+ * @since 3.0.0 | 02 MAR 2018 | Created
163
+ * @param mixed The default value will vary based on the kind of option being generated.
164
+ * @return object $this Allows for method chaining.
165
+ *
166
+ */
167
+ public function set_default( $value ) {
168
+ global $swp_user_options;
169
+ $this->default = $value;
170
+
171
+ // Add this to our global list of defaults
172
+ add_filter('swp_options_page_defaults' , array( $this , 'register_default' ) );
173
+
174
+ return $this;
175
+ }
176
+
177
+
178
+ /**
179
+ * Register Default
180
+ *
181
+ * Add this to a global list of defaults so that if an option isn't set in the database,
182
+ * then the method that pulls out the user option can just fall back to using this option's
183
+ * default value.
184
+ *
185
+ * @since 3.0.0 | 24 APR 2018 | Created
186
+ * @param array $defaults The array of defaults
187
+ * @return array $defaults The modifed array of defaults.
188
+ *
189
+ */
190
+ public function register_default( $defaults = array() ) {
191
+ $defaults[$this->key] = $this->default;
192
+ return $defaults;
193
+ }
194
+
195
+
196
+ /**
197
+ * Force a child option to depend on a parent option.
198
+ *
199
+ * If the parent's value is one of the values passed in as $values,
200
+ * the option will be visible ont the Settings page. Otherwise, the option
201
+ * is hidden until the dependency is set to that value.
202
+ *
203
+ * @since 3.0.0 | 02 MAR 2018 | Created
204
+ * @param string $parent The parent option's key.
205
+ * @param array $values Values which enable this option to exist.
206
+ * @return object $this Allows for method chaining.
207
+ *
208
+ */
209
+ public function set_dependency( $parent, $values ) {
210
+ if ( !is_string( $parent ) ) {
211
+ $this->_throw( 'Argument $parent needs to be a string matching the key of another option.' );
212
+ }
213
+
214
+ if ( !isset( $values) ) {
215
+ $this->_throw( 'Dependency values must passed in as the second argument.' );
216
+ }
217
+
218
+ if ( !is_array( $values ) ) {
219
+ $values = array( $values );
220
+
221
+ }
222
+
223
+ $this->dependency = new stdClass();
224
+ $this->dependency->parent = $parent;
225
+ $this->dependency->values = $values;
226
+
227
+ return $this;
228
+ }
229
+
230
+
231
+ /**
232
+ * Assign the database key for this element.
233
+ *
234
+ * @since 3.0.0 | 02 MAR 2018 | Created
235
+ * @param string $key The key which correlates to the input.
236
+ * @return object $this The calling instance, for method chaining.
237
+ *
238
+ */
239
+ public function set_key( $key ) {
240
+ if ( !is_string( $key ) ) {
241
+ $this->_throw( 'Please provide a key to the database as a string.' );
242
+ }
243
+
244
+ $this->key = $key;
245
+
246
+ return $this;
247
+ }
248
+
249
+
250
+ /**
251
+ * Some option types have multiple sizes that will determine their visual layout on the option
252
+ * page. This setter allows you to declare which one you want to use.
253
+ *
254
+ * @since 3.0.0 | 02 MAR 2018 | Created
255
+ * @param string The size of the option on the page (e.g. 'two-thirds').
256
+ * @return object $this The calling instance, for method chaining.
257
+ *
258
+ */
259
+ public function set_size( $size, $parent_size = ' sw-col-940 ') {
260
+
261
+ if ( 0 !== strpos( $size, 'sw-col' ) ) {
262
+ $sizes = PHP_EOL;
263
+
264
+
265
+ $this->_throw( "Please enter a valid size. The string must begin with 'sw-col-', followed by either: 300, 460, or 620.'" );
266
+ }
267
+
268
+ $this->size = $size;
269
+ $this->parent_size = $parent_size;
270
+
271
+ return $this;
272
+ }
273
+
274
+
275
+ /**
276
+ * Defines the placeholder for text inputs.
277
+ *
278
+ * @since 3.0.0 | 02 MAR 2018 | Created
279
+ * @param string $placeholder The text to display as a placeholder.
280
+ * @return object $this The calling instance, for method chaining.
281
+ *
282
+ */
283
+ public function set_placeholder( $placeholder ) {
284
+ if (!is_string( $placeholder ) && !is_numeric( $placeholder ) ) :
285
+ $this->_throw( "Please set a string or number for the placeholder." );
286
+ endif;
287
+
288
+ $this->placeholder = $placeholder;
289
+
290
+ return $this;
291
+ }
292
+
293
+
294
+ /**
295
+ * Creates the HTML placeholder attribute if a placeholder is defined.
296
+ *
297
+ * @since 3.0.0 | 02 MAR 2018 | Created
298
+ * @param void
299
+ * @return string $placeholder The qualified HTML placeholder attribute.
300
+ */
301
+ public function render_placeholder() {
302
+ if ( empty( $this->placeholder) ) :
303
+ return "";
304
+ endif;
305
+
306
+ return ' placeholder="' . $this->placeholder . '"';
307
+
308
+ }
309
+ }
functions/options/SWP_Option_Icons.php CHANGED
@@ -1,244 +1,244 @@
1
- <?PHP
2
-
3
- /**
4
- * SWP_Option_Icons: The class used to display available netowrks on the options
5
- * page.
6
- *
7
- * This class is used to create each individual nnetwork that is available to be
8
- * dragged and dropped between the active and inactive states.
9
- *
10
- * @package SocialWarfare\Functions\Options
11
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
12
- * @license GPL-3.0+
13
- * @since 3.0.0 | 02 MAR 2018 | Created
14
- * @access public
15
- *
16
- */
17
-
18
- class SWP_Option_Icons extends SWP_Option {
19
-
20
-
21
- /**
22
- * html
23
- *
24
- * This property will contain the string of rendered html for this panel of
25
- * icons.
26
- *
27
- * @var string
28
- *
29
- */
30
- public $html;
31
-
32
-
33
- /**
34
- * The magic construct method designed to instantiate this option object.
35
- *
36
- * @since 3.0.0 | 02 MAR 2018 | Created
37
- * @param string $name The name of this option object.
38
- * @param string $key The unique key of this option object.
39
- * @return void
40
- *
41
- */
42
- public function __construct( $name, $key ) {
43
- global $swp_user_options;
44
-
45
- parent::__construct( $name, $key );
46
- $this->user_options = $swp_user_options;
47
- }
48
-
49
-
50
- /**
51
- * A method to output the currently active icons.
52
- *
53
- * @since 3.0.0 | 02 MAR 2018 | Created
54
- * @param void
55
- * @return object $this Allows for method chaining.
56
- *
57
- */
58
- public function do_active_icons() {
59
- $this->is_active_icons = true;
60
- return $this;
61
- }
62
-
63
-
64
- /**
65
- * A method to output the currently inactive icons.
66
- *
67
- * @since 3.0.0 | 02 MAR 2018 | Created
68
- * @param void
69
- * @return object $this Allows for method chaining.
70
- *
71
- */
72
- public function do_inactive_icons() {
73
- $this->is_active_icons = false;
74
- return $this;
75
- }
76
-
77
-
78
- /**
79
- * The Active buttons UI in the Display tab.
80
- *
81
- * @since 3.0.0 | 02 MAR 2018 | Created
82
- * @param array $icons The array of currently selected icons.
83
- * @return object $this The calling instance, for method chaining.
84
- *
85
- */
86
- public function render_active_icons() {
87
- $all_icons = $this->get_all_icons();
88
- $user_icons = $this->get_user_icons();
89
- if ( empty($user_icons) ) :
90
- $user_icons = array();
91
- endif;
92
-
93
- $html = '<div class="sw-grid sw-col-300">';
94
- $html .= '<h3 class="sw-buttons-toggle">' . __( 'Active' , 'social-warfare' ) . '</h3>';
95
- $html .= '</div>';
96
-
97
- $html .= '<div class="sw-grid sw-col-620 sw-fit">';
98
- $html .= '<div class="sw-active sw-buttons-sort">';
99
-
100
- if ( count($user_icons) > 0 ):
101
- foreach( $user_icons as $network_key) {
102
-
103
- //* On updates, this is being passed as an object for some reason.
104
- if ( is_object( $network_key ) ) :
105
-
106
- $network_key = $network_key->key;
107
-
108
- //* This should not ever be reached. But if it does, fail gracefully.
109
- elseif ( !is_string( $network_key) ) :
110
- return;
111
- endif;
112
-
113
- if ( array_key_exists( $network_key, $all_icons ) && isset( $all_icons[$network_key]) ) :
114
- $network = $all_icons[$network_key];
115
-
116
- $html .= $this->render_icon_HTML( $network );
117
- endif;
118
- }
119
- endif;
120
-
121
- $html .= '</div>';
122
- $html .= '</div>';
123
- $html .= '<div class="sw-clearfix"></div>';
124
-
125
- $this->html = $html;
126
-
127
- return $this;
128
- }
129
-
130
-
131
- /**
132
- * The Inactive buttons UI in the Display tab.
133
- *
134
- * @since 3.0.0 | 02 MAR 2018 | Created
135
- * @param array $icons The array of currently selected icons.
136
- * @return object $this The calling instance, for method chaining.
137
- *
138
- */
139
- public function render_inactive_icons() {
140
- $all_icons = $this->get_all_icons();
141
- $user_icons = $this->get_user_icons();
142
-
143
- if ( empty( $user_icons ) ) :
144
- return $this;
145
- endif;
146
-
147
- $first = reset( $all_icons );
148
-
149
- if ( gettype( $first ) === 'object' ) :
150
-
151
- //* Get the keys first, then diff the array.
152
- $keys = array();
153
-
154
- foreach( $all_icons as $object) {
155
- $keys[] = $object->key;
156
- }
157
-
158
- $first = reset( $user_icons );
159
-
160
- if ( gettype( $first ) === 'object' ) :
161
- $temp = array();
162
-
163
- foreach( $user_icons as $object ) {
164
- $temp[] = $object->key;
165
- }
166
-
167
- $user_icons = $temp;
168
-
169
- endif;
170
-
171
- $inactive_icons = array_diff( $keys, $user_icons );
172
-
173
- elseif ( array_key_exists( 0, $all_icons) ) :
174
-
175
- //* If $all_icons is numerically indexed, just diff the array.
176
- $inactive_icons = array_diff( $all_icons, $user_icons );
177
-
178
- endif;
179
-
180
- $html = '<div class="sw-grid sw-col-300">';
181
- $html .= '<h3 class="sw-buttons-toggle">' . __( 'Inactive' , 'social-warfare' ) . '</h3>';
182
- $html .= '</div>';
183
-
184
- $html .= '<div class="sw-grid sw-col-620 sw-fit">';
185
- $html .= '<div class="sw-inactive sw-buttons-sort">';
186
- if ( count( $inactive_icons) > 0 ) :
187
- foreach( $inactive_icons as $network_key) {
188
- $network = $all_icons[$network_key];
189
-
190
- $html .= $this->render_icon_HTML( $network );
191
- }
192
- endif;
193
-
194
- $html .= '</div>';
195
- $html .= '</div>';
196
-
197
- $this->html = $html;
198
-
199
- return $this;
200
- }
201
-
202
-
203
- /**
204
- * Render the html for an individual icon.
205
- *
206
- * @since 3.0.0 | 02 MAR 2018 | Created
207
- * @param object $network The social network object
208
- * @return string The string of html with the new icon added.
209
- *
210
- */
211
- protected function render_icon_HTML( $network ) {
212
- $html = '<i class="sw-s sw-' . $network->key . '-icon" ';
213
- $html .= ' data-network="' . $network->key . '"';
214
-
215
- if ( !empty($network->premium) ) :
216
- $html .= ' premium="'.$network->premium.'"';
217
- endif;
218
-
219
- $html .= '></i>';
220
-
221
-
222
- return $html;
223
- }
224
-
225
-
226
- /**
227
- * Render the html for the icons panel.
228
- *
229
- * @since 3.0.0 | 02 MAR 2018 | Created
230
- * @param void
231
- * @return void Rendered html will be stored in local html property.
232
- *
233
- */
234
- public function render_HTML() {
235
- if ($this->is_active_icons) {
236
- $this->render_active_icons();
237
- } else {
238
- $this->render_inactive_icons();
239
- }
240
-
241
- return $this->html;
242
- }
243
-
244
- }
1
+ <?PHP
2
+
3
+ /**
4
+ * SWP_Option_Icons: The class used to display available netowrks on the options
5
+ * page.
6
+ *
7
+ * This class is used to create each individual nnetwork that is available to be
8
+ * dragged and dropped between the active and inactive states.
9
+ *
10
+ * @package SocialWarfare\Functions\Options
11
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
12
+ * @license GPL-3.0+
13
+ * @since 3.0.0 | 02 MAR 2018 | Created
14
+ * @access public
15
+ *
16
+ */
17
+
18
+ class SWP_Option_Icons extends SWP_Option {
19
+
20
+
21
+ /**
22
+ * html
23
+ *
24
+ * This property will contain the string of rendered html for this panel of
25
+ * icons.
26
+ *
27
+ * @var string
28
+ *
29
+ */
30
+ public $html;
31
+
32
+
33
+ /**
34
+ * The magic construct method designed to instantiate this option object.
35
+ *
36
+ * @since 3.0.0 | 02 MAR 2018 | Created
37
+ * @param string $name The name of this option object.
38
+ * @param string $key The unique key of this option object.
39
+ * @return void
40
+ *
41
+ */
42
+ public function __construct( $name, $key ) {
43
+ global $swp_user_options;
44
+
45
+ parent::__construct( $name, $key );
46
+ $this->user_options = $swp_user_options;
47
+ }
48
+
49
+
50
+ /**
51
+ * A method to output the currently active icons.
52
+ *
53
+ * @since 3.0.0 | 02 MAR 2018 | Created
54
+ * @param void
55
+ * @return object $this Allows for method chaining.
56
+ *
57
+ */
58
+ public function do_active_icons() {
59
+ $this->is_active_icons = true;
60
+ return $this;
61
+ }
62
+
63
+
64
+ /**
65
+ * A method to output the currently inactive icons.
66
+ *
67
+ * @since 3.0.0 | 02 MAR 2018 | Created
68
+ * @param void
69
+ * @return object $this Allows for method chaining.
70
+ *
71
+ */
72
+ public function do_inactive_icons() {
73
+ $this->is_active_icons = false;
74
+ return $this;
75
+ }
76
+
77
+
78
+ /**
79
+ * The Active buttons UI in the Display tab.
80
+ *
81
+ * @since 3.0.0 | 02 MAR 2018 | Created
82
+ * @param array $icons The array of currently selected icons.
83
+ * @return object $this The calling instance, for method chaining.
84
+ *
85
+ */
86
+ public function render_active_icons() {
87
+ $all_icons = $this->get_all_icons();
88
+ $user_icons = $this->get_user_icons();
89
+ if ( empty($user_icons) ) :
90
+ $user_icons = array();
91
+ endif;
92
+
93
+ $html = '<div class="sw-grid sw-col-300">';
94
+ $html .= '<h3 class="sw-buttons-toggle">' . __( 'Active' , 'social-warfare' ) . '</h3>';
95
+ $html .= '</div>';
96
+
97
+ $html .= '<div class="sw-grid sw-col-620 sw-fit">';
98
+ $html .= '<div class="sw-active sw-buttons-sort">';
99
+
100
+ if ( count($user_icons) > 0 ):
101
+ foreach( $user_icons as $network_key) {
102
+
103
+ //* On updates, this is being passed as an object for some reason.
104
+ if ( is_object( $network_key ) ) :
105
+
106
+ $network_key = $network_key->key;
107
+
108
+ //* This should not ever be reached. But if it does, fail gracefully.
109
+ elseif ( !is_string( $network_key) ) :
110
+ return;
111
+ endif;
112
+
113
+ if ( array_key_exists( $network_key, $all_icons ) && isset( $all_icons[$network_key]) ) :
114
+ $network = $all_icons[$network_key];
115
+
116
+ $html .= $this->render_icon_HTML( $network );
117
+ endif;
118
+ }
119
+ endif;
120
+
121
+ $html .= '</div>';
122
+ $html .= '</div>';
123
+ $html .= '<div class="sw-clearfix"></div>';
124
+
125
+ $this->html = $html;
126
+
127
+ return $this;
128
+ }
129
+
130
+
131
+ /**
132
+ * The Inactive buttons UI in the Display tab.
133
+ *
134
+ * @since 3.0.0 | 02 MAR 2018 | Created
135
+ * @param array $icons The array of currently selected icons.
136
+ * @return object $this The calling instance, for method chaining.
137
+ *
138
+ */
139
+ public function render_inactive_icons() {
140
+ $all_icons = $this->get_all_icons();
141
+ $user_icons = $this->get_user_icons();
142
+
143
+ if ( empty( $user_icons ) ) :
144
+ return $this;
145
+ endif;
146
+
147
+ $first = reset( $all_icons );
148
+
149
+ if ( gettype( $first ) === 'object' ) :
150
+
151
+ //* Get the keys first, then diff the array.
152
+ $keys = array();
153
+
154
+ foreach( $all_icons as $object) {
155
+ $keys[] = $object->key;
156
+ }
157
+
158
+ $first = reset( $user_icons );
159
+
160
+ if ( gettype( $first ) === 'object' ) :
161
+ $temp = array();
162
+
163
+ foreach( $user_icons as $object ) {
164
+ $temp[] = $object->key;
165
+ }
166
+
167
+ $user_icons = $temp;
168
+
169
+ endif;
170
+
171
+ $inactive_icons = array_diff( $keys, $user_icons );
172
+
173
+ elseif ( array_key_exists( 0, $all_icons) ) :
174
+
175
+ //* If $all_icons is numerically indexed, just diff the array.
176
+ $inactive_icons = array_diff( $all_icons, $user_icons );
177
+
178
+ endif;
179
+
180
+ $html = '<div class="sw-grid sw-col-300">';
181
+ $html .= '<h3 class="sw-buttons-toggle">' . __( 'Inactive' , 'social-warfare' ) . '</h3>';
182
+ $html .= '</div>';
183
+
184
+ $html .= '<div class="sw-grid sw-col-620 sw-fit">';
185
+ $html .= '<div class="sw-inactive sw-buttons-sort">';
186
+ if ( count( $inactive_icons) > 0 ) :
187
+ foreach( $inactive_icons as $network_key) {
188
+ $network = $all_icons[$network_key];
189
+
190
+ $html .= $this->render_icon_HTML( $network );
191
+ }
192
+ endif;
193
+
194
+ $html .= '</div>';
195
+ $html .= '</div>';
196
+
197
+ $this->html = $html;
198
+
199
+ return $this;
200
+ }
201
+
202
+
203
+ /**
204
+ * Render the html for an individual icon.
205
+ *
206
+ * @since 3.0.0 | 02 MAR 2018 | Created
207
+ * @param object $network The social network object
208
+ * @return string The string of html with the new icon added.
209
+ *
210
+ */
211
+ protected function render_icon_HTML( $network ) {
212
+ $html = '<i class="sw-s sw-' . $network->key . '-icon" ';
213
+ $html .= ' data-network="' . $network->key . '"';
214
+
215
+ if ( !empty($network->premium) ) :
216
+ $html .= ' premium="'.$network->premium.'"';
217
+ endif;
218
+
219
+ $html .= '></i>';
220
+
221
+
222
+ return $html;
223
+ }
224
+
225
+
226
+ /**
227
+ * Render the html for the icons panel.
228
+ *
229
+ * @since 3.0.0 | 02 MAR 2018 | Created
230
+ * @param void
231
+ * @return void Rendered html will be stored in local html property.
232
+ *
233
+ */
234
+ public function render_HTML() {
235
+ if ($this->is_active_icons) {
236
+ $this->render_active_icons();
237
+ } else {
238
+ $this->render_inactive_icons();
239
+ }
240
+
241
+ return $this->html;
242
+ }
243
+
244
+ }
functions/options/SWP_Option_Select.php CHANGED
@@ -1,193 +1,193 @@
1
- <?php
2
-
3
- /**
4
- * SWP_Ooption_Select: The class used to create select options.
5
- *
6
- * This class is used to create each select option needed on the options page.
7
- *
8
- * @since 3.0.0 | Created | 02 MAR 2017
9
- * @access public
10
- *
11
- */
12
- class SWP_Option_Select extends SWP_Option {
13
-
14
-
15
- /**
16
- * Choices
17
- *
18
- * Contains a key->value array designating the available
19
- * options that the plugin user can select from the select
20
- * dropdown box.
21
- *
22
- * @var array
23
- *
24
- */
25
- public $choices = array();
26
-
27
-
28
- /**
29
- * The required constructor for PHP classes.
30
- *
31
- * @param string $name The display name for the toggle.
32
- * @param string $key The database key for the user setting.
33
- *
34
- */
35
- public function __construct( $name, $key ) {
36
- parent::__construct( $name, $key );
37
-
38
- $this->choices = array();
39
- }
40
-
41
-
42
- /**
43
- * Add an option to the select.
44
- *
45
- * Additional addons may want to expand the choices available for
46
- * a given option.
47
- *
48
- * @since 3.0.0 | 02 MAR 2018 | Created
49
- * @param string $choice The choice to add to the select.
50
- * @return SWP_Option_Select $this The calling object with an updated chocies array.
51
- */
52
- public function add_choice( $choice ) {
53
- if ( !is_string( $choice ) ) {
54
- $this->_throw( "Please provide a choice to add to the select. The choice must be passed as a string." );
55
- }
56
-
57
- array_push( $this->choices, __( $choice, 'social-warfare' ) );
58
-
59
- return $this;
60
- }
61
-
62
-
63
- /**
64
- * Create the options for a select dropdown.
65
- *
66
- * @since 3.0.0 | 02 MAR 2018 | Created
67
- * @param array $choices Array of strings to be translated and made into options.
68
- * @return SWP_Option_Select $this The calling instance, for method chaining.
69
- *
70
- */
71
- public function add_choices( $choices ) {
72
-
73
- if ( !is_array( $choices ) ) {
74
- $this->_throw( "Please provide an array of choices. If you want to add a single choice, use add_choice()." );
75
- }
76
-
77
- foreach( $choices as $choice ) {
78
- $this->add_choice( $choice );
79
- }
80
-
81
- return $this;
82
- }
83
-
84
- /**
85
- * Render the HTML
86
- *
87
- * Renders the HTML to the options page based on what
88
- * the properties of this object have been set to.
89
- *
90
- * @since 3.0.0 | 02 MAR 2018 | Created
91
- * @param none
92
- * @return string The rendered HTML of this option.
93
- * @TODO: Make this method render soem HTML.
94
- *
95
- */
96
- public function render_HTML() {
97
- $html = '<div class="sw-grid ' . $this->parent_size . ' sw-option-container ' . $this->key . '_wrapper" ';
98
- $html .= $this->render_dependency();
99
- $html .= $this->render_premium();
100
- $html .= '>';
101
-
102
- $html .= '<div class="sw-grid ' . $this->size . '">';
103
- $html .= '<p class="sw-input-label">' . $this->name . '</p>';
104
- $html .= '</div>';
105
-
106
- $html .= '<div class="sw-grid ' . $this->size . ' ">';
107
-
108
- $html .= $this->render_HTML_element();
109
-
110
- $html .= '</div>';
111
- $html .= '</div>';
112
-
113
- $this->html = $html;
114
-
115
- return $html;
116
- }
117
-
118
- /**
119
- * Renders just the <select> part of the HTML.
120
- *
121
- * Pulled out from render_HTML for SWP_Section_HTML.
122
- *
123
- * @return string $html The fully qualified HTML for a select.
124
- */
125
- public function render_HTML_element() {
126
- $value = $this->get_value();
127
-
128
-
129
- if ( isset( $value) ) :
130
- //* As of 4-24-18, 'active_networks' is the only array.
131
- $value = is_array( $value ) ? '' : $value;
132
- else:
133
- $value = $this->default;
134
- endif;
135
-
136
- $html = '<select name=' . $this->key . '>';
137
-
138
- foreach ( $this->choices as $key => $display_name ) {
139
- $selected = selected( $key, $value, false );
140
- $html .= '<option value="' . $key . '"' . $selected . ' >' . $display_name . '</option>';
141
- }
142
-
143
- $html .= '</select>';
144
-
145
- return $html;
146
- }
147
-
148
-
149
- /**
150
- * A method for setting the available choices for this option.
151
- *
152
- * Accepts a $key->value set of options which will later be used to
153
- * generate the select dropdown boxes from which the plugin user can select.
154
- *
155
- * This method will overwrite any existing choices previously set. If you
156
- * want to add a choice, use add_choice() or add_choices() instead.
157
- *
158
- * @since 3.0.0 | 02 MAR 2018 | Created
159
- * @param array $choices
160
- * @return object $this Allows for method chaining
161
- *
162
- */
163
- public function set_choices( $choices ) {
164
- if ( !is_array( $choices ) ) :
165
- $this->_throw( "You must provide an array of choices to go into the select." );
166
- endif;
167
-
168
- $this->choices = $choices;
169
-
170
- return $this;
171
- }
172
-
173
-
174
- /**
175
- * Defines the default value among this select's choices.
176
- *
177
- *
178
- * @param string $value The key associated with the default option.
179
- * @return SWP_Option_Select $this The calling instance, for method chaining.
180
- *
181
- */
182
- public function set_default( $value ) {
183
- if ( is_bool( $value ) || is_numeric( $value ) ) :
184
- settype( $value, 'string' );
185
- endif;
186
-
187
- if ( !is_string( $value ) ) :
188
- $this->_throw( 'Please provide a default value as a string.' );
189
- endif;
190
-
191
- return parent::set_default( $value );
192
- }
193
- }
1
+ <?php
2
+
3
+ /**
4
+ * SWP_Ooption_Select: The class used to create select options.
5
+ *
6
+ * This class is used to create each select option needed on the options page.
7
+ *
8
+ * @since 3.0.0 | Created | 02 MAR 2017
9
+ * @access public
10
+ *
11
+ */
12
+ class SWP_Option_Select extends SWP_Option {
13
+
14
+
15
+ /**
16
+ * Choices
17
+ *
18
+ * Contains a key->value array designating the available
19
+ * options that the plugin user can select from the select
20
+ * dropdown box.
21
+ *
22
+ * @var array
23
+ *
24
+ */
25
+ public $choices = array();
26
+
27
+
28
+ /**
29
+ * The required constructor for PHP classes.
30
+ *
31
+ * @param string $name The display name for the toggle.
32
+ * @param string $key The database key for the user setting.
33
+ *
34
+ */
35
+ public function __construct( $name, $key ) {
36
+ parent::__construct( $name, $key );
37
+
38
+ $this->choices = array();
39
+ }
40
+
41
+
42
+ /**
43
+ * Add an option to the select.
44
+ *
45
+ * Additional addons may want to expand the choices available for
46
+ * a given option.
47
+ *
48
+ * @since 3.0.0 | 02 MAR 2018 | Created
49
+ * @param string $choice The choice to add to the select.
50
+ * @return SWP_Option_Select $this The calling object with an updated chocies array.
51
+ */
52
+ public function add_choice( $choice ) {
53
+ if ( !is_string( $choice ) ) {
54
+ $this->_throw( "Please provide a choice to add to the select. The choice must be passed as a string." );
55
+ }
56
+
57
+ array_push( $this->choices, __( $choice, 'social-warfare' ) );
58
+
59
+ return $this;
60
+ }
61
+
62
+
63
+ /**
64
+ * Create the options for a select dropdown.
65
+ *
66
+ * @since 3.0.0 | 02 MAR 2018 | Created
67
+ * @param array $choices Array of strings to be translated and made into options.
68
+ * @return SWP_Option_Select $this The calling instance, for method chaining.
69
+ *
70
+ */
71
+ public function add_choices( $choices ) {
72
+
73
+ if ( !is_array( $choices ) ) {
74
+ $this->_throw( "Please provide an array of choices. If you want to add a single choice, use add_choice()." );
75
+ }
76
+
77
+ foreach( $choices as $choice ) {
78
+ $this->add_choice( $choice );
79
+ }
80
+
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Render the HTML
86
+ *
87
+ * Renders the HTML to the options page based on what
88
+ * the properties of this object have been set to.
89
+ *
90
+ * @since 3.0.0 | 02 MAR 2018 | Created
91
+ * @param none
92
+ * @return string The rendered HTML of this option.
93
+ * @TODO: Make this method render soem HTML.
94
+ *
95
+ */
96
+ public function render_HTML() {
97
+ $html = '<div class="sw-grid ' . $this->parent_size . ' sw-option-container ' . $this->key . '_wrapper" ';
98
+ $html .= $this->render_dependency();
99
+ $html .= $this->render_premium();
100
+ $html .= '>';
101
+
102
+ $html .= '<div class="sw-grid ' . $this->size . '">';
103
+ $html .= '<p class="sw-input-label">' . $this->name . '</p>';
104
+ $html .= '</div>';
105
+
106
+ $html .= '<div class="sw-grid ' . $this->size . ' ">';
107
+
108
+ $html .= $this->render_HTML_element();
109
+
110
+ $html .= '</div>';
111
+ $html .= '</div>';
112
+
113
+ $this->html = $html;
114
+
115
+ return $html;
116
+ }
117
+
118
+ /**
119
+ * Renders just the <select> part of the HTML.
120
+ *
121
+ * Pulled out from render_HTML for SWP_Section_HTML.
122
+ *
123
+ * @return string $html The fully qualified HTML for a select.
124
+ */
125
+ public function render_HTML_element() {
126
+ $value = $this->get_value();
127
+
128
+
129
+ if ( isset( $value) ) :
130
+ //* As of 4-24-18, 'active_networks' is the only array.
131
+ $value = is_array( $value ) ? '' : $value;
132
+ else:
133
+ $value = $this->default;
134
+ endif;
135
+
136
+ $html = '<select name=' . $this->key . '>';
137
+
138
+ foreach ( $this->choices as $key => $display_name ) {
139
+ $selected = selected( $key, $value, false );
140
+ $html .= '<option value="' . $key . '"' . $selected . ' >' . $display_name . '</option>';
141
+ }
142
+
143
+ $html .= '</select>';
144
+
145
+ return $html;
146
+ }
147
+
148
+
149
+ /**
150
+ * A method for setting the available choices for this option.
151
+ *
152
+ * Accepts a $key->value set of options which will later be used to
153
+ * generate the select dropdown boxes from which the plugin user can select.
154
+ *
155
+ * This method will overwrite any existing choices previously set. If you
156
+ * want to add a choice, use add_choice() or add_choices() instead.
157
+ *
158
+ * @since 3.0.0 | 02 MAR 2018 | Created
159
+ * @param array $choices
160
+ * @return object $this Allows for method chaining
161
+ *
162
+ */
163
+ public function set_choices( $choices ) {
164
+ if ( !is_array( $choices ) ) :
165
+ $this->_throw( "You must provide an array of choices to go into the select." );
166
+ endif;
167
+
168
+ $this->choices = $choices;
169
+
170
+ return $this;
171
+ }
172
+
173
+
174
+ /**
175
+ * Defines the default value among this select's choices.
176
+ *
177
+ *
178
+ * @param string $value The key associated with the default option.
179
+ * @return SWP_Option_Select $this The calling instance, for method chaining.
180
+ *
181
+ */
182
+ public function set_default( $value ) {
183
+ if ( is_bool( $value ) || is_numeric( $value ) ) :
184
+ settype( $value, 'string' );
185
+ endif;
186
+
187
+ if ( !is_string( $value ) ) :
188
+ $this->_throw( 'Please provide a default value as a string.' );
189
+ endif;
190
+
191
+ return parent::set_default( $value );
192
+ }
193
+ }
functions/options/SWP_Option_Text.php CHANGED
@@ -1,90 +1,90 @@
1
- <?PHP
2
-
3
- /**
4
- * Used to create input options.
5
- *
6
- * This class is used to create each input option needed on the options page.
7
- *
8
- * @since 3.0.0 | Created | 02 MAR 2017
9
- * @access public
10
- */
11
- class SWP_Option_Text extends SWP_Option {
12
-
13
-
14
- /**
15
- * Default
16
- *
17
- * The default value for this input type="text".
18
- *
19
- * @var string $default
20
- *
21
- */
22
- public $default = '';
23
-
24
-
25
- /**
26
- * The required constructor for PHP classes.
27
- *
28
- * @param string $name The display name for the toggle.
29
- * @param string $key The database key for the user setting.
30
- *
31
- */
32
- public function __construct( $name, $key ) {
33
- parent::__construct( $name, $key );
34
- $this->set_default( '' );
35
- $this->value = $this->get_value();
36
- }
37
-
38
-
39
- /**
40
- * Renders the HTML to create the <input type="text" /> element.
41
- *
42
- * @return string $html The fully qualified HTML.
43
- *
44
- */
45
- public function render_HTML() {
46
- $html = '<div class="sw-grid ' . $this->parent_size . ' sw-option-container ' . $this->key . '_wrapper" ';
47
- $html .= $this->render_dependency();
48
- $html .= $this->render_premium();
49
- $html .= '>';
50
-
51
- $html .= '<div class="sw-grid ' . $this->size . '">';
52
- $html .= '<p class="sw-input-label">' . $this->name . '</p>';
53
- $html .= '</div>';
54
-
55
- $html .= '<div class="sw-grid ' . $this->size . '">';
56
- $html .= $this->render_HTML_element();
57
- $html .= '</div>';
58
-
59
- $html .= '</div>';
60
-
61
- $this->html = $html;
62
-
63
- return $html;
64
- }
65
-
66
- public function render_HTML_element() {
67
- return '<input name="' . $this->key . '" data-swp-name="' . $this->key . '" type="text" class="sw-admin-input" value="' . $this->value . '"' . $this->render_placeholder() . '/>';
68
- }
69
-
70
-
71
- /**
72
- * Defines the default value among this select's choices.
73
- *
74
- *
75
- * @param mixed $value The key associated with the default option.
76
- * @return SWP_Option_Select $this The calling instance, for method chaining.
77
- *
78
- */
79
- public function set_default( $default ) {
80
- if ( is_numeric( $default) ) :
81
- settype( $default, 'string' );
82
- endif;
83
-
84
- if ( !is_string( $default ) ) :
85
- $this->_throw( 'Please provide a default value as a string.' );
86
- endif;
87
-
88
- return parent::set_default( $default );
89
- }
90
- }
1
+ <?PHP
2
+
3
+ /**
4
+ * Used to create input options.
5
+ *
6
+ * This class is used to create each input option needed on the options page.
7
+ *
8
+ * @since 3.0.0 | Created | 02 MAR 2017
9
+ * @access public
10
+ */
11
+ class SWP_Option_Text extends SWP_Option {
12
+
13
+
14
+ /**
15
+ * Default
16
+ *
17
+ * The default value for this input type="text".
18
+ *
19
+ * @var string $default
20
+ *
21
+ */
22
+ public $default = '';
23
+
24
+
25
+ /**
26
+ * The required constructor for PHP classes.
27
+ *
28
+ * @param string $name The display name for the toggle.
29
+ * @param string $key The database key for the user setting.
30
+ *
31
+ */
32
+ public function __construct( $name, $key ) {
33
+ parent::__construct( $name, $key );
34
+ $this->set_default( '' );
35
+ $this->value = $this->get_value();
36
+ }
37
+
38
+
39
+ /**
40
+ * Renders the HTML to create the <input type="text" /> element.
41
+ *
42
+ * @return string $html The fully qualified HTML.
43
+ *
44
+ */
45
+ public function render_HTML() {
46
+ $html = '<div class="sw-grid ' . $this->parent_size . ' sw-option-container ' . $this->key . '_wrapper" ';
47
+ $html .= $this->render_dependency();
48
+ $html .= $this->render_premium();
49
+ $html .= '>';
50
+
51
+ $html .= '<div class="sw-grid ' . $this->size . '">';
52
+ $html .= '<p class="sw-input-label">' . $this->name . '</p>';
53
+ $html .= '</div>';
54
+
55
+ $html .= '<div class="sw-grid ' . $this->size . '">';
56
+ $html .= $this->render_HTML_element();
57
+ $html .= '</div>';
58
+
59
+ $html .= '</div>';
60
+
61
+ $this->html = $html;
62
+
63
+ return $html;
64
+ }
65
+
66
+ public function render_HTML_element() {
67
+ return '<input name="' . $this->key . '" data-swp-name="' . $this->key . '" type="text" class="sw-admin-input" value="' . $this->value . '"' . $this->render_placeholder() . '/>';
68
+ }
69
+
70
+
71
+ /**
72
+ * Defines the default value among this select's choices.
73
+ *
74
+ *
75
+ * @param mixed $value The key associated with the default option.
76
+ * @return SWP_Option_Select $this The calling instance, for method chaining.
77
+ *
78
+ */
79
+ public function set_default( $default ) {
80
+ if ( is_numeric( $default) ) :
81
+ settype( $default, 'string' );
82
+ endif;
83
+
84
+ if ( !is_string( $default ) ) :
85
+ $this->_throw( 'Please provide a default value as a string.' );
86
+ endif;
87
+
88
+ return parent::set_default( $default );
89
+ }
90
+ }
functions/options/SWP_Option_Textarea.php CHANGED
@@ -1,86 +1,86 @@
1
- <?PHP
2
-
3
- /**
4
- * Used to create input options.
5
- *
6
- * This class is used to create each input option needed on the options page.
7
- *
8
- * @since 3.0.0 | Created | 02 MAR 2017
9
- * @access public
10
- */
11
- class SWP_Option_Textarea extends SWP_Option {
12
-
13
-
14
- /**
15
- * Default
16
- *
17
- * The default value for this textarea.
18
- *
19
- * @var string $default
20
- *
21
- */
22
- public $default = '';
23
-
24
-
25
- /**
26
- * The required constructor for PHP classes.
27
- *
28
- * @param string $name The display name for the toggle.
29
- * @param string $key The database key for the user setting.
30
- *
31
- */
32
- public function __construct( $name, $key ) {
33
- parent::__construct( $name, $key );
34
- $this->default = '';
35
- }
36
-
37
-
38
- /**
39
- * Renders the HTML to create the <input type="text" /> element.
40
- *
41
- * @return string $html The fully qualified HTML.
42
- *
43
- */
44
- public function render_HTML() {
45
- $html = '<div class="sw-grid ' . $this->parent_size . ' sw-option-container ' . $this->key . '_wrapper" ';
46
- $html .= $this->render_dependency();
47
- $html .= $this->render_premium();
48
- $html .= '>';
49
-
50
- $html .= '<div class="sw-grid ' . $this->size . '">';
51
- $html .= '<p class="sw-input-label">' . $this->name . '</p>';
52
- $html .= '</div>';
53
-
54
- $html .= '<div class="sw-grid ' . $this->size . '">';
55
- $html .= '<textarea name="' . $this->key . '" data-swp-name="' . $this->key . '" class="sw-grid-textarea" >'. $this->get_value() . '</textarea>';
56
- $html .= '</div>';
57
-
58
- $html .= '</div>';
59
-
60
- $this->html = $html;
61
-
62
- return $html;
63
- }
64
-
65
-
66
- /**
67
- * Defines the default value among this select's choices.
68
- *
69
- *
70
- * @param mixed $value The key associated with the default option.
71
- * @return SWP_Option_Select $this The calling instance, for method chaining.
72
- *
73
- */
74
- public function set_default( $default ) {
75
- if ( is_numeric( $default) ) :
76
- settype( $default, 'string' );
77
- endif;
78
-
79
- if ( !is_string( $default ) ) :
80
- $this->_throw( 'Please provide a default value as a string.' );
81
- endif;
82
-
83
- return parent::set_default( $default );
84
-
85
- }
86
- }
1
+ <?PHP
2
+
3
+ /**
4
+ * Used to create input options.
5
+ *
6
+ * This class is used to create each input option needed on the options page.
7
+ *
8
+ * @since 3.0.0 | Created | 02 MAR 2017
9
+ * @access public
10
+ */
11
+ class SWP_Option_Textarea extends SWP_Option {
12
+
13
+
14
+ /**
15
+ * Default
16
+ *
17
+ * The default value for this textarea.
18
+ *
19
+ * @var string $default
20
+ *
21
+ */
22
+ public $default = '';
23
+
24
+
25
+ /**
26
+ * The required constructor for PHP classes.
27
+ *
28
+ * @param string $name The display name for the toggle.
29
+ * @param string $key The database key for the user setting.
30
+ *
31
+ */
32
+ public function __construct( $name, $key ) {
33
+ parent::__construct( $name, $key );
34
+ $this->default = '';
35
+ }
36
+
37
+
38
+ /**
39
+ * Renders the HTML to create the <input type="text" /> element.
40
+ *
41
+ * @return string $html The fully qualified HTML.
42
+ *
43
+ */
44
+ public function render_HTML() {
45
+ $html = '<div class="sw-grid ' . $this->parent_size . ' sw-option-container ' . $this->key . '_wrapper" ';
46
+ $html .= $this->render_dependency();
47
+ $html .= $this->render_premium();
48
+ $html .= '>';
49
+
50
+ $html .= '<div class="sw-grid ' . $this->size . '">';
51
+ $html .= '<p class="sw-input-label">' . $this->name . '</p>';
52
+ $html .= '</div>';
53
+
54
+ $html .= '<div class="sw-grid ' . $this->size . '">';
55
+ $html .= '<textarea name="' . $this->key . '" data-swp-name="' . $this->key . '" class="sw-grid-textarea" >'. $this->get_value() . '</textarea>';
56
+ $html .= '</div>';
57
+
58
+ $html .= '</div>';
59
+
60
+ $this->html = $html;
61
+
62
+ return $html;
63
+ }
64
+
65
+
66
+ /**
67
+ * Defines the default value among this select's choices.
68
+ *
69
+ *
70
+ * @param mixed $value The key associated with the default option.
71
+ * @return SWP_Option_Select $this The calling instance, for method chaining.
72
+ *
73
+ */
74
+ public function set_default( $default ) {
75
+ if ( is_numeric( $default) ) :
76
+ settype( $default, 'string' );
77
+ endif;
78
+
79
+ if ( !is_string( $default ) ) :
80
+ $this->_throw( 'Please provide a default value as a string.' );
81
+ endif;
82
+
83
+ return parent::set_default( $default );
84
+
85
+ }
86
+ }
functions/options/SWP_Option_Toggle.php CHANGED
@@ -1,83 +1,83 @@
1
- <?php
2
-
3
- class SWP_Option_Toggle extends SWP_Option {
4
-
5
-
6
- /**
7
- * Default
8
- *
9
- * The default value for this input type="checkbox".
10
- *
11
- * @var bool $default
12
- *
13
- */
14
- public $default = true;
15
-
16
-
17
- /**
18
- * The required constructor for PHP classes.
19
- *
20
- * @param string $name The display name for the toggle.
21
- * @param string $key The database key for the user setting.
22
- */
23
- public function __construct( $name, $key ) {
24
- parent::__construct( $name, $key );
25
- $this->default = true;
26
- }
27
-
28
-
29
- /**
30
- * Creates the fully qulaified HTML for the checkbox/toggle module.
31
- *
32
- * @return SWP_Option_Toggle $this The calling object, for method chaining.
33
- */
34
- public function render_HTML() {
35
- //* Map the default boolean to on/off.
36
- $status = $this->default ? 'on' : 'off';
37
-
38
- if ( isset( $this->user_options[$this->key] ) ) :
39
- $status = $this->user_options[$this->key] === true ? 'on' : 'off';
40
- endif;
41
-
42
- $checked = $status === 'on' ? ' checked ' : '';
43
-
44
- $html = '<div class="sw-grid ' . $this->parent_size . ' sw-fit sw-option-container ' . $this->key . '_wrapper" ';
45
- $html .= $this->render_dependency();
46
- $html .= $this->render_premium();
47
- $html .= '>';
48
-
49
- $html .= '<div class="sw-grid ' . $this->size . '">';
50
- $html .= '<p class="sw-checkbox-label">' . $this->name . '</p>';
51
- $html .= '</div>';
52
-
53
- $html .= '<div class="sw-grid ' . $this->size . '">';
54
- $html .= '<div class="sw-checkbox-toggle" status="' . $status . '" field="#' . $this->key . '">';
55
- $html .= '<div class="sw-checkbox-on">' . __( 'ON', 'social-warfare' ) . '</div>';
56
- $html .= '<div class="sw-checkbox-off">' . __( 'OFF', 'social-warfare' ) . '</div>';
57
- $html .= '</div>';
58
-
59
- $html .= '<input type="checkbox" id="' . $this->key . '" class="sw-hidden" name="' . $this->key . '"' . $checked . '/>';
60
- $html .= '</div>';
61
-
62
- $html .= '</div>';
63
-
64
- $this->html = $html;
65
-
66
- return $html;
67
- }
68
-
69
-
70
- /**
71
- * Override parent method to make this boolean-specific.
72
- *
73
- * @param boolean $value The boolean value to set as default.
74
- * @return SWP_Option_Toggle $this The calling object, for method chaining.
75
- */
76
- public function set_default( $value ) {
77
- if ( !is_bool( $value ) || !isset( $value ) ) {
78
- $this->_throw( 'Please provide a default value as a boolean.' );
79
- }
80
-
81
- return parent::set_default( $value );
82
- }
83
- }
1
+ <?php
2
+
3
+ class SWP_Option_Toggle extends SWP_Option {
4
+
5
+
6
+ /**
7
+ * Default
8
+ *
9
+ * The default value for this input type="checkbox".
10
+ *
11
+ * @var bool $default
12
+ *
13
+ */
14
+ public $default = true;
15
+
16
+
17
+ /**
18
+ * The required constructor for PHP classes.
19
+ *
20
+ * @param string $name The display name for the toggle.
21
+ * @param string $key The database key for the user setting.
22
+ */
23
+ public function __construct( $name, $key ) {
24
+ parent::__construct( $name, $key );
25
+ $this->default = true;
26
+ }
27
+
28
+
29
+ /**
30
+ * Creates the fully qulaified HTML for the checkbox/toggle module.
31
+ *
32
+ * @return SWP_Option_Toggle $this The calling object, for method chaining.
33
+ */
34
+ public function render_HTML() {
35
+ //* Map the default boolean to on/off.
36
+ $status = $this->default ? 'on' : 'off';
37
+
38
+ if ( isset( $this->user_options[$this->key] ) ) :
39
+ $status = $this->user_options[$this->key] === true ? 'on' : 'off';
40
+ endif;
41
+
42
+ $checked = $status === 'on' ? ' checked ' : '';
43
+
44
+ $html = '<div class="sw-grid ' . $this->parent_size . ' sw-fit sw-option-container ' . $this->key . '_wrapper" ';
45
+ $html .= $this->render_dependency();
46
+ $html .= $this->render_premium();
47
+ $html .= '>';
48
+
49
+ $html .= '<div class="sw-grid ' . $this->size . '">';
50
+ $html .= '<p class="sw-checkbox-label">' . $this->name . '</p>';
51
+ $html .= '</div>';
52
+
53
+ $html .= '<div class="sw-grid ' . $this->size . '">';
54
+ $html .= '<div class="sw-checkbox-toggle" status="' . $status . '" field="#' . $this->key . '">';
55
+ $html .= '<div class="sw-checkbox-on">' . __( 'ON', 'social-warfare' ) . '</div>';
56
+ $html .= '<div class="sw-checkbox-off">' . __( 'OFF', 'social-warfare' ) . '</div>';
57
+ $html .= '</div>';
58
+
59
+ $html .= '<input type="checkbox" id="' . $this->key . '" class="sw-hidden" name="' . $this->key . '"' . $checked . '/>';
60
+ $html .= '</div>';
61
+
62
+ $html .= '</div>';
63
+
64
+ $this->html = $html;
65
+
66
+ return $html;
67
+ }
68
+
69
+
70
+ /**
71
+ * Override parent method to make this boolean-specific.
72
+ *
73
+ * @param boolean $value The boolean value to set as default.
74
+ * @return SWP_Option_Toggle $this The calling object, for method chaining.
75
+ */
76
+ public function set_default( $value ) {
77
+ if ( !is_bool( $value ) || !isset( $value ) ) {
78
+ $this->_throw( 'Please provide a default value as a boolean.' );
79
+ }
80
+
81
+ return parent::set_default( $value );
82
+ }
83
+ }
functions/options/SWP_Options_Page.php CHANGED
@@ -1,816 +1,816 @@
1
- <?php
2
- //* For options whose database name has changed, it is notated as follows:
3
- //* prevOption => new_option
4
- //* @see SWP_Database_Migration
5
-
6
- /**
7
- * The core Social Warfare admin settings page.
8
- *
9
- * This extensive method instantiates each of the five main tabs:
10
- * Display, Styles, Social Identity, Advanced, and Registration.
11
- *
12
- * For each of these tabs all of the core sections and options
13
- * are also created.
14
- *
15
- * Addons, such as Pro, can hook into this object to add
16
- * their own sections and options by using the one of the
17
- *
18
- * @package SocialWarfare\Functions\Social-Networks
19
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
20
- * @license GPL-3.0+
21
- * @since 3.0.0 | Created | 02 MAR 2017
22
- * @access public
23
- * @todo Clean out all array bracket notations.
24
- *
25
- */
26
- class SWP_Options_Page extends SWP_Abstract {
27
- /**
28
- * The Options Page Tabs
29
- *
30
- * An object holding each of the tabs by index name.
31
- * The tab is required to be either an SWP_Options_Page_Tab
32
- * object, or a class which extends this object.
33
- *
34
- */
35
- public $tabs;
36
-
37
-
38
- /**
39
- * Boolean indicating whether the plugin is registered or not.
40
- *
41
- * @var bool $swp_registration
42
- *
43
- */
44
- public $swp_registration;
45
-
46
-
47
- /**
48
- * The user's selected icons to display.
49
- *
50
- * As defined in the Display tab on the settings page.
51
- *
52
- */
53
- public $icons = array();
54
-
55
-
56
- /**
57
- * The magic construct method to instatiate the options object.
58
- *
59
- * This class method provides the framework for the entire options page.
60
- * It outlines the chronology of loading order and makes it so that addons
61
- * can easily access this object to add their own tabs, sections, and
62
- * options as needed prior to the final output of the page and it's HTML.
63
- *
64
- * @since 3.0.0 | 01 MAR 2018 | Created
65
- * @param void
66
- * @return object $this The options page object. Allows for method chaining.
67
- *
68
- */
69
- public function __construct() {
70
-
71
- // Fetch the initial user-set options.
72
- $swp_user_options = swp_get_user_options( true );
73
-
74
- // Create a 'tabs' object to which we can begin adding tabs.
75
- $this->tabs = new stdClass();
76
-
77
-
78
- /**
79
- * STEP #1: We create the initial options object immediately when
80
- * this class is loaded which takes place while WordPress is loading
81
- * all of the installed plugins on the site.
82
- *
83
- */
84
- $this->init_display_tab()
85
- ->init_styles_tab()
86
- ->init_social_tab()
87
- ->init_advanced_tab();
88
-
89
- add_action('wp_loaded', [$this, 'load_deferred_options']);
90
-
91
-
92
- /**
93
- * STEP #2: Addons can now access this object to add their own
94
- * tabs, sections, and options prior to the page being rendered.
95
- * They will need to use the 'plugins_loaded' hook to ensure that
96
- * the first step above has already occurred.
97
- *
98
- */
99
-
100
-
101
- /**
102
- * STEP #3: We take the final options object and render the
103
- * options page and it's necessary HTML. We defer this step until
104
- * much later using the admin_menu hook to ensure that all addons
105
- * have had an opportunity to modify the options object as needed.
106
- *
107
- */
108
- add_action( 'admin_menu', array( $this, 'options_page') );
109
- }
110
-
111
-
112
- /**
113
- * Load Deferred Options
114
- *
115
- * The buttons position table needs deferred via a hook. This method
116
- * takes care of that.
117
- *
118
- * @since 3.0.0 | 01 MAR 2018 | Created
119
- * @param void
120
- * @return void
121
- */
122
- public function load_deferred_options() {
123
- $this->tabs->display->sections->button_position->options->button_position_table->do_button_position_table();
124
- }
125
-
126
-
127
- /**
128
- * Create the admin menu options page
129
- *
130
- * @since 3.0.0 | 01 MAR 2018 | Created
131
- * @param void
132
- * @return void
133
- *
134
- */
135
- public function options_page() {
136
-
137
- // Declare the menu link
138
- $swp_menu = add_menu_page(
139
- 'Social Warfare',
140
- 'Social Warfare',
141
- 'manage_options',
142
- 'social-warfare',
143
- array( $this, 'render_HTML'),
144
- SWP_PLUGIN_URL . '/images/admin-options-page/socialwarfare-20x20.png'
145
- );
146
-
147
- // Hook into the CSS and Javascript Enqueue process for this specific page
148
- add_action( 'admin_print_styles-' . $swp_menu, array( $this, 'admin_css' ) );
149
- add_action( 'admin_print_scripts-' . $swp_menu, array( $this, 'admin_js' ) );
150
- }
151
-
152
-
153
- /**
154
- * Add a tab to the Options Page object.
155
- *
156
- * @since 3.0.0 | 01 MAR 2018 | Created
157
- * @param object $tab The SWP_Options_Page_Tab object to add.
158
- * @return object $this The calling instance, for method chaining.
159
- *
160
- */
161
- public function add_tab( $tab ) {
162
- $class = get_class( $tab );
163
- if ( !( $class === 'SWP_Options_Page_Tab' || is_subclass_of( $class, 'SWP_Options_Page_Tab' ) ) ) :
164
- $this->_throw( 'Requires an instance of SWP_Options_Page_Tab or a class which inherits this class.' );
165
- endif;
166
-
167
- if ( empty( $tab->name ) ):
168
- $this->_throw( 'Tab name can not be empty.' );
169
- endif;
170
-
171
- $this->tabs[$tab->name] = $tab;
172
-
173
- return $this;
174
- }
175
-
176
-
177
- /**
178
- * Enqueue the Settings Page CSS & Javascript
179
- *
180
- * @since 3.0.0 | 01 MAR 2018 | Created
181
- * @see $this->options_page()
182
- * @param void
183
- * @return void
184
- *
185
- */
186
- public function admin_css() {
187
- $suffix = SWP_Script::get_suffix();
188
-
189
- wp_enqueue_style(
190
- 'swp_admin_options_css',
191
- SWP_PLUGIN_URL . "/css/admin-options-page{$suffix}.css",
192
- array(),
193
- SWP_VERSION
194
- );
195
- }
196
-
197
-
198
- /**
199
- * Enqueue the admin javascript
200
- *
201
- * @since 3.0.0 | 01 MAR 2018 | Created
202
- * @see $this->options_page()
203
- * @param void
204
- * @return void
205
- * @todo: Are we still using the tooltip for anything?
206
- *
207
- */
208
- public function admin_js() {
209
- $suffix = SWP_Script::get_suffix();
210
-
211
- wp_enqueue_script( 'jquery' );
212
- wp_enqueue_script( 'jquery-effects-core' );
213
- wp_enqueue_script( 'jquery-ui-core' );
214
- wp_enqueue_script( 'jquery-ui-sortable' );
215
- wp_enqueue_script( 'jquery-ui-tooltip' );
216
- wp_enqueue_media();
217
- wp_enqueue_script(
218
- 'swp_admin_options_js',
219
- SWP_PLUGIN_URL . "/js/admin-options-page{$suffix}.js",
220
- array( 'jquery' ),
221
- SWP_VERSION
222
- );
223
-
224
- wp_localize_script( 'swp_admin_options_js', 'swpAdminOptionsData', array(
225
- 'registerNonce' => wp_create_nonce( 'swp_plugin_registration' ),
226
- 'optionsNonce' => wp_create_nonce( 'swp_plugin_options_save' ),
227
- ));
228
- }
229
-
230
-
231
- /**
232
- * Creates the commonly used color choides for choice settings.
233
- *
234
- * @since 3.0.0 | 01 MAR 2018 | Created
235
- * @param void
236
- * @return array The key/value pairs of color choides.
237
- *
238
- */
239
- public static function get_color_choices_array() {
240
- return [
241
- 'full_color' => __( 'Full Color', 'social-warfare' ),
242
- 'light_gray' => __( 'Light Gray', 'social-warfare' ),
243
- 'medium_gray' => __( 'Medium Gray', 'social-warfare' ),
244
- 'dark_gray' => __( 'Dark Gray', 'social-warfare' ),
245
- 'light_gray_outlines' => __( 'Light Gray Outlines', 'social-warfare' ),
246
- 'medium_gray_outlines' => __( 'Medium Gray Outlines', 'social-warfare' ),
247
- 'dark_gray_outlines' => __( 'Dark Gray Outlines', 'social-warfare' ),
248
- 'color_outlines' => __( 'Color Outlines', 'social-warfare' ),
249
- 'custom_color' => __( 'Custom Color', 'social-warfare' ),
250
- 'custom_color_outlines' => __( 'Custom Color Outlines', 'social-warfare' )
251
- ];
252
- }
253
-
254
-
255
- /**
256
- * Calls rendering methods to assemble HTML for the Admin Settings page.
257
- *
258
- * @since 3.0.0 | 01 MAR 2018 | Created
259
- * @param void
260
- * @return object $this The calling object for method chaining.
261
- *
262
- */
263
- public function render_HTML() {
264
- $swp_user_options = swp_get_user_options( true );
265
-
266
- //* Fetch all the addons the user has installed,
267
- //* whether or not they are actively registered.
268
- $addons = apply_filters( 'swp_registrations', [] );
269
- $registrations = array();
270
- $registered = 0;
271
- $active_addons = '';
272
- $registered_addons = '';
273
-
274
- foreach( $addons as $addon ) {
275
- if ( gettype($addon) !== 'object' ) :
276
- continue;
277
- endif;
278
- $registrations[] = new SWP_Addon_Registration( $addon );
279
- $active_addons .= " $addon->key ";
280
-
281
- if ( true === $addon->registered ) :
282
- $registered_addons .= " $addon->key ";
283
- $registered = 1;
284
- endif;
285
- }
286
-
287
- $this->registered = $registered;
288
-
289
- $this->init_registration_tab( $registrations );
290
-
291
- $menu = $this->create_menu( $registrations );
292
- $tabs = $this->create_tabs( $active_addons, $registered_addons );
293
-
294
- $html = $menu . $tabs;
295
- $this->html = $html;
296
-
297
- echo $html;
298
-
299
- return $this;
300
- }
301
-
302
-
303
- /**
304
- * Handwritten list of OG Meta types.
305
- *
306
- * @since 3.0.0 | 01 MAR 2018 | Created
307
- * @since 3.1.0 | 13 JUN 2018 | Replaced array bracket notation.
308
- * @param void
309
- * @return array Custom Post Types.
310
- *
311
- */
312
- protected function get_og_post_types() {
313
- return array(
314
- 'article',
315
- 'book',
316
- 'books.author',
317
- 'books.book',
318
- 'books.genre',
319
- 'business.business',
320
- 'fitness.course',
321
- 'game.achievement',
322
- 'music.album',
323
- 'music.playlist',
324
- 'music.radio_station',
325
- 'music.song',
326
- 'place',
327
- 'product',
328
- 'product.group',
329
- 'product.item',
330
- 'profile',
331
- 'restaurant.menu',
332
- 'restaurant.menu_item',
333
- 'restaurant.menu_section',
334
- 'restaurant.restaurant',
335
- 'video.episode',
336
- 'video.movie',
337
- 'video.other',
338
- 'video.tv_show',
339
- );
340
- }
341
-
342
-
343
- /**
344
- * Provides the common placement choices for the buttons.
345
- *
346
- * @since 3.0.0 | 01 MAR 2018 | Created
347
- * @since 3.1.0 | 13 JUN 2018 | Replaced Array bracket notation.
348
- * @param void
349
- * @return array Key/Value pairs of button placement options.
350
- *
351
- */
352
- protected function get_static_options_array() {
353
- return array(
354
- 'above' => __( 'Above the Content', 'social-warfare' ),
355
- 'below' => __( 'Below the Content', 'social-warfare' ),
356
- 'both' => __( 'Both Above and Below the Content', 'social-warfare' ),
357
- 'none' => __( 'None/Manual Placement', 'social-warfare' )
358
- );
359
- }
360
-
361
-
362
- /**
363
- * Create the Advanced section of the display tab.
364
- *
365
- * This section offers miscellaneous advanced settings for finer control of the plugin.
366
- *
367
- * @since 3.0.0 | 01 MAR 2018 | Created
368
- * @param void
369
- * @return object $this The calling object for method chaining.
370
- *
371
- */
372
- protected function init_advanced_tab() {
373
-
374
- $advanced = new SWP_Options_Page_Tab( __( 'Advanced', 'social-warfare' ), 'advanced' );
375
- $advanced->set_priority( 40 );
376
-
377
- $frame_buster = new SWP_Options_Page_Section( __( 'Frame Buster', 'social-warfare' ), 'frame_buster' );
378
- $frame_buster->set_priority( 10 )
379
- ->set_description( __( 'If you want to stop content pirates from framing your content, turn this on.', 'social-warfare' ) )
380
- ->set_information_link( 'https://warfareplugins.com/support/options-page-advanced-tab-frame-buster/');
381
-
382
- //* sniplyBuster => frame_buster
383
- $frame_buster_toggle = new SWP_Option_Toggle( __( 'Frame Buster', 'social-warfare' ), 'frame_buster' );
384
- $frame_buster_toggle->set_default( true )
385
- ->set_size( 'sw-col-300' );
386
-
387
- $frame_buster->add_option( $frame_buster_toggle );
388
-
389
- // $caching_method = new SWP_Options_Page_Section( __( 'Caching Method', 'social-warfare' ), 'caching_method' );
390
- // $caching_method->set_priority( 60 );
391
- //
392
- // //* cacheMethod => cache_method
393
- // $cache_method = new SWP_Option_Select( __( 'Cache Rebuild Method', 'social-warfare' ), 'cache_method' );
394
- // $cache_method->set_choices( [
395
- // 'advanced' => __( 'Advanced Cache Triggering', 'social-warfare' ),
396
- // 'legacy' => __( 'Legacy Cache Rebuilding During Page Loads', 'social-warfare' )
397
- // ])
398
- // ->set_default( 'advanced' )
399
- // ->set_size( 'sw-col-300' );
400
- //
401
- // $caching_method->add_option( $cache_method );
402
-
403
- $full_content = new SWP_Options_Page_Section( __( 'Full Content vs. Excerpts', 'social-warfare' ), 'full_content' );
404
- $full_content->set_priority( 70 )
405
- ->set_description( __( 'If your theme does not use excerpts, but instead displays the full post content on archive, category, and home pages, activate this toggle to allow the buttons to appear in those areas.', 'social-warfare' ) )
406
- ->set_information_link( 'https://warfareplugins.com/support/options-page-advanced-tab-full-content-vs-excerpts/' );
407
-
408
- $full_content_toggle = new SWP_Option_Toggle( __( 'Full Content?', 'social-warfare' ), 'full_content' );
409
- $full_content_toggle->set_default( false )
410
- ->set_size( 'sw-col-300' );
411
-
412
- $full_content->add_option( $full_content_toggle );
413
-
414
- $advanced->add_sections( [$frame_buster, $full_content] );
415
-
416
- $this->tabs->advanced = $advanced;
417
-
418
- return $this;
419
- }
420
-
421
-
422
- /**
423
- * Create the Display section and its child options.
424
- *
425
- * This tab offers genereral layout setings for the front end of the site.
426
- *
427
- * @since 3.0.0 | 01 MAR 2018 | Created
428
- * @param void
429
- * @return object $this The calling object for method chaining.
430
- *
431
- */
432
- protected function init_display_tab() {
433
- $display = new SWP_Options_Page_Tab( __( 'Display', 'social-warfare' ), 'display' );
434
- $display->set_priority( 10 );
435
-
436
- $social_networks = new SWP_Options_Page_Section( __( 'Social Networks', 'social-warfare' ), 'social_networks' );
437
- $social_networks->set_priority( 10 )
438
- ->set_description( __( 'Drag & Drop to activate and order your share buttons.', 'social-warfare' ) )
439
- ->set_information_link( 'https://warfareplugins.com/support/options-page-display-tab-social-networks/' );
440
-
441
- //* These two sections are unique and need special HTML.
442
- $active = new SWP_Option_Icons( __( 'Active', 'social-warfare' ), 'active' );
443
- $active->do_active_icons()->set_priority( 10 );
444
-
445
- $inactive = new SWP_Option_Icons( __( 'Inactive', 'social-warfare' ), 'inactive' );
446
- $inactive->do_inactive_icons()->set_priority( 20 );
447
-
448
- $social_networks->add_options( [$active, $inactive] );
449
-
450
- $share_counts = new SWP_Options_Page_Section( __( 'Share Counts', 'social-warfare' ), 'share_counts' );
451
- $share_counts->set_description( __( 'Use the toggles below to determine how to display your social proof.', 'social-warfare' ) )
452
- ->set_priority( 20 )
453
- ->set_information_link( 'https://warfareplugins.com/support/options-page-display-tab-share-counts/' );
454
-
455
- //* toteseach => network_count
456
- $network_shares = new SWP_Option_Toggle( __( 'Button Counts', 'social-warfare' ), 'network_shares' );
457
- $network_shares->set_default( true )
458
- ->set_priority( 10 )
459
- ->set_size( 'sw-col-300' );
460
-
461
- //* totes => totals
462
- $total_shares = new SWP_Option_Toggle( __( 'Total Counts', 'social-warfare' ), 'total_shares' );
463
- $total_shares->set_default( true )
464
- ->set_priority( 20 )
465
- ->set_size( 'sw-col-300' );
466
-
467
- $share_counts->add_options( [$network_shares, $total_shares] );
468
-
469
- $button_position = new SWP_Options_Page_Section( __( 'Position Share Buttons', 'social-warfare' ), 'button_position' );
470
- $button_position->set_description( __( 'These settings let you decide where the share buttons should go for each post type.', 'social-warfare' ) )
471
- ->set_priority( 40 )
472
- ->set_information_link( 'https://warfareplugins.com/support/options-page-display-tab-position-share-buttons/' );
473
-
474
- $button_position_table = new SWP_Section_HTML( __( 'Position Table', 'social-warfare' ), 'button_position_table' );
475
- // $button_position_table->do_button_position_table();
476
-
477
- $button_position->add_option( $button_position_table );
478
-
479
-
480
-
481
- $display->add_sections( [$social_networks, $share_counts, $button_position] );
482
-
483
- $this->tabs->display = $display;
484
-
485
- return $this;
486
- }
487
-
488
-
489
- /**
490
- * Create the Registration section of the display tab.
491
- *
492
- * This section allows users to register activation keys for the premium plugin features.
493
- *
494
- * @since 3.0.0 | 01 MAR 2018 | Created
495
- * @param void
496
- * @return object $this The calling object for method chaining.
497
- *
498
- */
499
- protected function init_registration_tab( $addons ) {
500
- $registration = new SWP_Options_Page_Tab( __( 'Registration', 'social-warfare' ), 'registration' );
501
-
502
- $registration->set_priority( 50 );
503
-
504
- $wrap = new SWP_Options_Page_Section( __( 'Addon Registrations', 'social-warfare' ), 'addon_registrations' );
505
- $wrap->set_priority( 10 );
506
-
507
- foreach( $addons as $addon ) {
508
- $wrap->add_option( $addon );
509
- }
510
-
511
- $registration->add_section( $wrap );
512
-
513
- $this->tabs->registration = $registration;
514
-
515
- return $this;
516
- }
517
-
518
-
519
- /**
520
- * Create the Social Identity section of the display tab.
521
- *
522
- * This section allows the user to set social network handles and OG metadata.
523
- *
524
- * @since 3.0.0 | 01 MAR 2018 | Created
525
- * @param void
526
- * @return SWP_Options_Page $this The calling object for method chaining.
527
- *
528
- */
529
- protected function init_social_tab() {
530
- $social_identity = new SWP_Options_Page_Tab( __( 'Social Identity', 'social-warfare' ), 'social_identity' );
531
- $social_identity->set_priority( 30 );
532
-
533
- $sitewide_identity = new SWP_Options_Page_Section( 'Sitewide Identity', 'sitewide_identity' );
534
- $sitewide_identity->set_description( __( 'If you would like to set sitewide defaults for your social identity, add them below.', 'social-warfare' ) )
535
- ->set_information_link( 'https://warfareplugins.com/support/options-page-social-identity-tab-sitewide-identity/' );
536
-
537
- $twitter_id = new SWP_Option_Text( __( 'Twitter Username', 'social-warfare' ), 'twitter_id' );
538
- $twitter_id->set_size( 'sw-col-300' )
539
- ->set_priority( 10 )
540
- ->set_default( '' );
541
-
542
- //* pinterestID => pinterest_id
543
- $pinterest_id = new SWP_Option_Text( __( 'Pinterest Username', 'social-warfare' ), 'pinterest_id' );
544
- $pinterest_id->set_size( 'sw-col-300' )
545
- ->set_priority( 20 )
546
- ->set_default( '' );
547
-
548
- //* facebookPublisherUrl => facebook_publisher_url
549
- $facebook_publisher_url = new SWP_Option_Text( __( 'Facebook Page URL', 'social-warfare' ), 'facebook_publisher_url' );
550
- $facebook_publisher_url->set_size( 'sw-col-300' )
551
- ->set_priority( 30 )
552
- ->set_default( '' );
553
-
554
- //* facebookAppID => facebook_app_id
555
- $facebook_app_id = new SWP_Option_Text( __( 'Facebook App ID', 'social-warfare' ), 'facebook_app_id' );
556
- $facebook_app_id->set_size( 'sw-col-300' )
557
- ->set_priority( 40 )
558
- ->set_default( '' );
559
-
560
- $sitewide_identity->add_options( [$twitter_id, $pinterest_id, $facebook_publisher_url, $facebook_app_id] );
561
-
562
- $social_identity->add_section( $sitewide_identity );
563
-
564
- $this->tabs->social_identity = $social_identity;
565
-
566
- return $this;
567
- }
568
-
569
-
570
- /**
571
- * Create the Styles section of the display tab.
572
- *
573
- * This section allows the user to refine the look, feel, and placement of buttons.
574
- *
575
- * @since 3.0.0 | 01 MAR 2018 | Created
576
- * @param void
577
- * @return SWP_Options_Page $this The calling object for method chaining.
578
- *
579
- */
580
- protected function init_styles_tab() {
581
- $styles = new SWP_Options_Page_Tab( __( 'Styles' , 'social-warfare' ) , 'styles' );
582
- $styles->set_priority( 20 );
583
-
584
- $buttons_preview = new SWP_Section_HTML( __( 'Buttons Preview', 'social-warfare' ) );
585
- $buttons_preview->set_priority( 1000 )
586
- ->do_buttons_preview();
587
-
588
-
589
- $buttons_preview_section = new SWP_Options_Page_Section( __( 'Buttons Preview', 'social-warfare' ), 'buttons_preview_section' );
590
- $buttons_preview_section->add_option( $buttons_preview );
591
-
592
- $styles->add_section( $buttons_preview_section );
593
-
594
-
595
- $total_counts = new SWP_Options_Page_Section( __( 'Total Counts', 'social-warfare' ), 'total_counts' );
596
- $total_counts->set_description( __( 'Customize how the "Total Shares" section of your share buttons look.', 'social-warfare' ) )
597
- ->set_priority( 20 )
598
- ->set_information_link( 'https://warfareplugins.com/support/options-page-styles-tab-total-counts/' );
599
-
600
- //* swDecimals => decimals
601
- $decimals = new SWP_Option_Select( __( 'Decimal Places', 'social-warfare' ), 'decimals' );
602
- $decimals->set_choices( [
603
- '0' => 'Zero',
604
- '1' => 'One',
605
- '2' => 'Two',
606
- ])
607
- ->set_default( '0' )
608
- ->set_size( 'sw-col-460', 'sw-col-460 sw-fit' );
609
-
610
- //* swp_decimal_separator => decimal_separator
611
- $decimal_separator = new SWP_Option_Select( __( 'Decimal Separator', 'social-warfare' ), 'decimal_separator' );
612
- $decimal_separator->set_choices( [
613
- 'period' => 'Period',
614
- 'comma' => 'Comma',
615
- ])
616
- ->set_default( 'period' )
617
- ->set_size( 'sw-col-460', 'sw-col-460 sw-fit' );
618
-
619
- //* swTotesFormat => totals_alignment
620
- $totals_alignment = new SWP_Option_Select( __( 'Alignment', 'social-warfare' ), 'totals_alignment' );
621
- $totals_alignment->set_choices( [
622
- 'totals_right' => 'Right',
623
- 'totals_left' => 'Left'
624
- ])
625
- ->set_default( 'totals_right' )
626
- ->set_size( 'sw-col-460', 'sw-col-460 sw-fit' );
627
-
628
- $total_counts->add_options( [$decimals, $decimal_separator, $totals_alignment] );
629
-
630
- $floating_share_buttons = new SWP_Options_Page_Section( __( 'Floating Share Buttons', 'social-warfare' ), 'floating_share_buttons' );
631
- $floating_share_buttons->set_description( __( 'If you would like to activate floating share buttons, turn this on.', 'social-warfare' ) )
632
- ->set_priority( 30 )
633
- ->set_information_link( 'https://warfareplugins.com/support/options-page-styles-tab-floating-share-buttons/' );
634
-
635
- //* float => floating_panel
636
- $floating_panel = new SWP_Option_Toggle( __( 'Floating Share Buttons', 'social-warfare' ), 'floating_panel' );
637
- $floating_panel->set_default( false )
638
- ->set_size( 'sw-col-460', 'sw-col-460 sw-fit')
639
- ->set_priority( 10 );
640
-
641
- //* floatOption => float_location
642
- $float_location = new SWP_Option_Select( __( 'Float Position', 'social-warfare' ), 'float_location' );
643
- $float_location->set_choices( [
644
- 'top' => __( 'Top of the Page' , 'social-warfare' ),
645
- 'bottom' => __( 'Bottom of the Page' , 'social-warfare' ),
646
- 'left' => __( 'On the left side of the page' , 'social-warfare' ),
647
- 'right' => __( 'On the right side of the page' , 'social-warfare' )
648
- ] )
649
- ->set_default( 'bottom' )
650
- ->set_priority( 20 )
651
- ->set_size( 'sw-col-460', 'sw-col-460 sw-fit')
652
- ->set_dependency( 'floating_panel', [true] );
653
-
654
- //* floatBgColor => float_background_color
655
- $float_background_color = new SWP_Option_Text( __( 'Background Color', 'social-warfare' ), 'float_background_color' );
656
- $float_background_color->set_default( '#ffffff' )
657
- ->set_priority( 25 )
658
- ->set_size( 'sw-col-460', 'sw-col-460 sw-fit' )
659
- ->set_dependency( 'float_location', ['top', 'bottom'] );
660
-
661
- //* swp_float_scr_sz => float_screen_width
662
- $float_screen_width = new SWP_Option_Text( __( 'Minimum Screen Width', 'social-warfare' ), 'float_screen_width' );
663
- $float_screen_width->set_default( '1100' )
664
- ->set_priority( 30 )
665
- ->set_size( 'sw-col-460', 'sw-col-460 sw-fit' )
666
- ->set_dependency( 'float_location', ['left', 'right'] );
667
-
668
- //* sideReveal => transition
669
- $float_transition = new SWP_Option_Select( __( 'Transition', 'social-warfare' ), 'transition' );
670
- $float_transition->set_priority( 40 )
671
- ->set_choices( [
672
- 'slide' => __( 'Slide In / Slide Out' , 'social-warfare' ) ,
673
- 'fade' => __( 'Fade In / Fade Out' , 'social-warfare' )
674
- ] )
675
- ->set_default( 'slide' )
676
- ->set_size( 'sw-col-460', 'sw-col-460 sw-fit')
677
- ->set_dependency( 'float_location', ['left', 'right'] );
678
-
679
- $color_choices = $this::get_color_choices_array();
680
-
681
- $float_before_content = new SWP_Option_Toggle( __( 'Float Before Content', 'social-warfare' ), 'float_before_content');
682
- $float_before_content->set_default( true )
683
- ->set_priority( 140 )
684
- ->set_size( 'sw-col-460', 'sw-col-460 sw-fit')
685
- ->set_dependency( 'floating_panel', true );
686
-
687
- $floating_share_buttons->add_options( [$floating_panel, $float_location, $float_transition,
688
- $float_screen_width, $float_background_color, $float_before_content] );
689
-
690
-
691
-
692
- $styles->add_sections( [$total_counts, $floating_share_buttons] );
693
-
694
- $this->tabs->styles = $styles;
695
-
696
- return $this;
697
- }
698
-
699
-
700
- /**
701
- * Creates the HTML for the admin top menu (Logo, tabs, and save button).
702
- *
703
- * @since 3.0.0 | 01 MAR 2018 | Created
704
- * @param void
705
- * @return string $html The fully qualified HTML for the menu.
706
- *
707
- */
708
- private function create_menu( $addons ) {
709
- //* Open the admin top menu wrapper.
710
- $html = '<div class="sw-header-wrapper">';
711
- $html .= '<div class="sw-grid sw-col-940 sw-top-menu" sw-registered="' . $this->registered . '">';
712
-
713
- //* Menu wrapper and tabs.
714
- $html .= '<div class="sw-grid sw-col-700">';
715
- $html .= '<img class="sw-header-logo" src="' . SWP_PLUGIN_URL . '/images/admin-options-page/social-warfare-light.png" />';
716
- $html .= '<img class="sw-header-logo-pro" src="' . SWP_PLUGIN_URL . '/images/admin-options-page/social-warfare-pro-light.png" />';
717
- $html .= '<ul class="sw-header-menu">';
718
-
719
- $tab_map = $this->sort_by_priority( $this->tabs );
720
-
721
- $activated = true;
722
-
723
- foreach( $tab_map as $prioritized_tab) {
724
- foreach( $this->tabs as $index => $tab ) {
725
-
726
- if ( $prioritized_tab['key'] === $tab->key ) :
727
-
728
- //* Skip the registration tab if there are no addons.
729
- if ( 'registration' == $tab->key && 0 === count( $addons ) ) :
730
- continue;
731
- endif;
732
-
733
- $active = $activated ? 'sw-active-tab' : '';
734
- $activated = false;
735
-
736
- $html .= '<li class="' . $active . '">';
737
- $html .= '<a class="sw-tab-selector" href="#" data-link="swp_' . $tab->link . '">';
738
- $html .= '<span>' . $tab->name . '</span>';
739
- $html .= '</a>';
740
- $html .= '</li>';
741
-
742
- endif;
743
- }
744
- }
745
-
746
- $html .= '</ul>';
747
- $html .= '</div>';
748
-
749
- //* "Save Changes" button.
750
- $html .= '<div class="sw-grid sw-col-220 sw-fit">';
751
- $html .= '<a href="#" class="button sw-navy-button sw-save-settings">'. __( 'Save Changes' , 'social-warfare' ) .'</a>';
752
- $html .= '</div>';
753
-
754
- $html .= '<div class="sw-clearfix"></div>';
755
-
756
- $html .= '</div>';
757
- $html .= '</div>';
758
-
759
- return $html;
760
- }
761
-
762
-
763
- /**
764
- * Renders HTML for each tab and assembles for outputting.
765
- *
766
- * Note: We have to utilize a $map varaible for this and each
767
- * other render() method. This is because the data are all
768
- * stored as objects, when can not be iterated by index,
769
- * only by key. Since they keys are arbitrary (for a plugin
770
- * or addon, for example), this is no good, hence the map.
771
- *
772
- * @since 3.0.0 | 01 MAR 2018 | Created
773
- * @param void
774
- * @return string $container The Admin tab HTML container.
775
- *
776
- */
777
- private function create_tabs( $active_addons, $registered_addons ) {
778
- $sidebar = new SWP_Section_HTML( 'Sidebar' );
779
- $tab_map = $this->sort_by_priority( $this->tabs );
780
- $registered = false;
781
- $notices = apply_filters( 'swp_admin_notices', '' );
782
-
783
- $container = '<div class="sw-admin-wrapper" sw-registered="'. $this->registered .'" swp-addons="' . $active_addons . '" swp-registrations="' . $registered_addons . '">';
784
- $container .= '<div class="swp-notice-wrapper">';
785
- $container .= $notices;
786
- $container .= '</div>';
787
-
788
- $container .= '<form class="sw-admin-settings-form">';
789
- $container .= '<div class="sw-tabs-container sw-grid sw-col-700">';
790
-
791
- foreach( $tab_map as $prioritized_tab ) {
792
- $key = $prioritized_tab['key'];
793
-
794
- foreach( $this->tabs as $tab ) {
795
- if ( $key === $tab->key ) :
796
-
797
- if ( 'registration' === $key ) :
798
- $container .= $tab->render_HTML( $registered_addons );
799
- continue;
800
- endif;
801
-
802
- $container .= $tab->render_HTML();
803
-
804
- endif;
805
- }
806
- }
807
-
808
- $container .= '</div>';
809
- $container .= '</form>';
810
- $container .= $sidebar->do_admin_sidebar();
811
-
812
- $container .= '</div>';
813
-
814
- return $container;
815
- }
816
- }
1
+ <?php
2
+ //* For options whose database name has changed, it is notated as follows:
3
+ //* prevOption => new_option
4
+ //* @see SWP_Database_Migration
5
+
6
+ /**
7
+ * The core Social Warfare admin settings page.
8
+ *
9
+ * This extensive method instantiates each of the five main tabs:
10
+ * Display, Styles, Social Identity, Advanced, and Registration.
11
+ *
12
+ * For each of these tabs all of the core sections and options
13
+ * are also created.
14
+ *
15
+ * Addons, such as Pro, can hook into this object to add
16
+ * their own sections and options by using the one of the
17
+ *
18
+ * @package SocialWarfare\Functions\Social-Networks
19
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
20
+ * @license GPL-3.0+
21
+ * @since 3.0.0 | Created | 02 MAR 2017
22
+ * @access public
23
+ * @todo Clean out all array bracket notations.
24
+ *
25
+ */
26
+ class SWP_Options_Page extends SWP_Abstract {
27
+ /**
28
+ * The Options Page Tabs
29
+ *
30
+ * An object holding each of the tabs by index name.
31
+ * The tab is required to be either an SWP_Options_Page_Tab
32
+ * object, or a class which extends this object.
33
+ *
34
+ */
35
+ public $tabs;
36
+
37
+
38
+ /**
39
+ * Boolean indicating whether the plugin is registered or not.
40
+ *
41
+ * @var bool $swp_registration
42
+ *
43
+ */
44
+ public $swp_registration;
45
+
46
+
47
+ /**
48
+ * The user's selected icons to display.
49
+ *
50
+ * As defined in the Display tab on the settings page.
51
+ *
52
+ */
53
+ public $icons = array();
54
+
55
+
56
+ /**
57
+ * The magic construct method to instatiate the options object.
58
+ *
59
+ * This class method provides the framework for the entire options page.
60
+ * It outlines the chronology of loading order and makes it so that addons
61
+ * can easily access this object to add their own tabs, sections, and
62
+ * options as needed prior to the final output of the page and it's HTML.
63
+ *
64
+ * @since 3.0.0 | 01 MAR 2018 | Created
65
+ * @param void
66
+ * @return object $this The options page object. Allows for method chaining.
67
+ *
68
+ */
69
+ public function __construct() {
70
+
71
+ // Fetch the initial user-set options.
72
+ $swp_user_options = swp_get_user_options( true );
73
+
74
+ // Create a 'tabs' object to which we can begin adding tabs.
75
+ $this->tabs = new stdClass();
76
+
77
+
78
+ /**
79
+ * STEP #1: We create the initial options object immediately when
80
+ * this class is loaded which takes place while WordPress is loading
81
+ * all of the installed plugins on the site.
82
+ *
83
+ */
84
+ $this->init_display_tab()
85
+ ->init_styles_tab()
86
+ ->init_social_tab()
87
+ ->init_advanced_tab();
88
+
89
+ add_action('wp_loaded', [$this, 'load_deferred_options']);
90
+
91
+
92
+ /**
93
+ * STEP #2: Addons can now access this object to add their own
94
+ * tabs, sections, and options prior to the page being rendered.
95
+ * They will need to use the 'plugins_loaded' hook to ensure that
96
+ * the first step above has already occurred.
97
+ *
98
+ */
99
+
100
+
101
+ /**
102
+ * STEP #3: We take the final options object and render the
103
+ * options page and it's necessary HTML. We defer this step until
104
+ * much later using the admin_menu hook to ensure that all addons
105
+ * have had an opportunity to modify the options object as needed.
106
+ *
107
+ */
108
+ add_action( 'admin_menu', array( $this, 'options_page') );
109
+ }
110
+
111
+
112
+ /**
113
+ * Load Deferred Options
114
+ *
115
+ * The buttons position table needs deferred via a hook. This method
116
+ * takes care of that.
117
+ *
118
+ * @since 3.0.0 | 01 MAR 2018 | Created
119
+ * @param void
120
+ * @return void
121
+ */
122
+ public function load_deferred_options() {
123
+ $this->tabs->display->sections->button_position->options->button_position_table->do_button_position_table();
124
+ }
125
+
126
+
127
+ /**
128
+ * Create the admin menu options page
129
+ *
130
+ * @since 3.0.0 | 01 MAR 2018 | Created
131
+ * @param void
132
+ * @return void
133
+ *
134
+ */
135
+ public function options_page() {
136
+
137
+ // Declare the menu link
138
+ $swp_menu = add_menu_page(
139
+ 'Social Warfare',
140
+ 'Social Warfare',
141
+ 'manage_options',
142
+ 'social-warfare',
143
+ array( $this, 'render_HTML'),
144
+ SWP_PLUGIN_URL . '/images/admin-options-page/socialwarfare-20x20.png'
145
+ );
146
+
147
+ // Hook into the CSS and Javascript Enqueue process for this specific page
148
+ add_action( 'admin_print_styles-' . $swp_menu, array( $this, 'admin_css' ) );
149
+ add_action( 'admin_print_scripts-' . $swp_menu, array( $this, 'admin_js' ) );
150
+ }
151
+
152
+
153
+ /**
154
+ * Add a tab to the Options Page object.
155
+ *
156
+ * @since 3.0.0 | 01 MAR 2018 | Created
157
+ * @param object $tab The SWP_Options_Page_Tab object to add.
158
+ * @return object $this The calling instance, for method chaining.
159
+ *
160
+ */
161
+ public function add_tab( $tab ) {
162
+ $class = get_class( $tab );
163
+ if ( !( $class === 'SWP_Options_Page_Tab' || is_subclass_of( $class, 'SWP_Options_Page_Tab' ) ) ) :
164
+ $this->_throw( 'Requires an instance of SWP_Options_Page_Tab or a class which inherits this class.' );
165
+ endif;
166
+
167
+ if ( empty( $tab->name ) ):
168
+ $this->_throw( 'Tab name can not be empty.' );
169
+ endif;
170
+
171
+ $this->tabs[$tab->name] = $tab;
172
+
173
+ return $this;
174
+ }
175
+
176
+
177
+ /**
178
+ * Enqueue the Settings Page CSS & Javascript
179
+ *
180
+ * @since 3.0.0 | 01 MAR 2018 | Created
181
+ * @see $this->options_page()
182
+ * @param void
183
+ * @return void
184
+ *
185
+ */
186
+ public function admin_css() {
187
+ $suffix = SWP_Script::get_suffix();
188
+
189
+ wp_enqueue_style(
190
+ 'swp_admin_options_css',
191
+ SWP_PLUGIN_URL . "/css/admin-options-page{$suffix}.css",
192
+ array(),
193
+ SWP_VERSION
194
+ );
195
+ }
196
+
197
+
198
+ /**
199
+ * Enqueue the admin javascript
200
+ *
201
+ * @since 3.0.0 | 01 MAR 2018 | Created
202
+ * @see $this->options_page()
203
+ * @param void
204
+ * @return void
205
+ * @todo: Are we still using the tooltip for anything?
206
+ *
207
+ */
208
+ public function admin_js() {
209
+ $suffix = SWP_Script::get_suffix();
210
+
211
+ wp_enqueue_script( 'jquery' );
212
+ wp_enqueue_script( 'jquery-effects-core' );
213
+ wp_enqueue_script( 'jquery-ui-core' );
214
+ wp_enqueue_script( 'jquery-ui-sortable' );
215
+ wp_enqueue_script( 'jquery-ui-tooltip' );
216
+ wp_enqueue_media();
217
+ wp_enqueue_script(
218
+ 'swp_admin_options_js',
219
+ SWP_PLUGIN_URL . "/js/admin-options-page{$suffix}.js",
220
+ array( 'jquery' ),
221
+ SWP_VERSION
222
+ );
223
+
224
+ wp_localize_script( 'swp_admin_options_js', 'swpAdminOptionsData', array(
225
+ 'registerNonce' => wp_create_nonce( 'swp_plugin_registration' ),
226
+ 'optionsNonce' => wp_create_nonce( 'swp_plugin_options_save' ),
227
+ ));
228
+ }
229
+
230
+
231
+ /**
232
+ * Creates the commonly used color choides for choice settings.
233
+ *
234
+ * @since 3.0.0 | 01 MAR 2018 | Created
235
+ * @param void
236
+ * @return array The key/value pairs of color choides.
237
+ *
238
+ */
239
+ public static function get_color_choices_array() {
240
+ return [
241
+ 'full_color' => __( 'Full Color', 'social-warfare' ),
242
+ 'light_gray' => __( 'Light Gray', 'social-warfare' ),
243
+ 'medium_gray' => __( 'Medium Gray', 'social-warfare' ),
244
+ 'dark_gray' => __( 'Dark Gray', 'social-warfare' ),
245
+ 'light_gray_outlines' => __( 'Light Gray Outlines', 'social-warfare' ),
246
+ 'medium_gray_outlines' => __( 'Medium Gray Outlines', 'social-warfare' ),
247
+ 'dark_gray_outlines' => __( 'Dark Gray Outlines', 'social-warfare' ),
248
+ 'color_outlines' => __( 'Color Outlines', 'social-warfare' ),
249
+ 'custom_color' => __( 'Custom Color', 'social-warfare' ),
250
+ 'custom_color_outlines' => __( 'Custom Color Outlines', 'social-warfare' )
251
+ ];
252
+ }
253
+
254
+
255
+ /**
256
+ * Calls rendering methods to assemble HTML for the Admin Settings page.
257
+ *
258
+ * @since 3.0.0 | 01 MAR 2018 | Created
259
+ * @param void
260
+ * @return object $this The calling object for method chaining.
261
+ *
262
+ */
263
+ public function render_HTML() {
264
+ $swp_user_options = swp_get_user_options( true );
265
+
266
+ //* Fetch all the addons the user has installed,
267
+ //* whether or not they are actively registered.
268
+ $addons = apply_filters( 'swp_registrations', [] );
269
+ $registrations = array();
270
+ $registered = 0;
271
+ $active_addons = '';
272
+ $registered_addons = '';
273
+
274
+ foreach( $addons as $addon ) {
275
+ if ( gettype($addon) !== 'object' ) :
276
+ continue;
277
+ endif;
278
+ $registrations[] = new SWP_Addon_Registration( $addon );
279
+ $active_addons .= " $addon->key ";
280
+
281
+ if ( true === $addon->registered ) :
282
+ $registered_addons .= " $addon->key ";
283
+ $registered = 1;
284
+ endif;
285
+ }
286
+
287
+ $this->registered = $registered;
288
+
289
+ $this->init_registration_tab( $registrations );
290
+
291
+ $menu = $this->create_menu( $registrations );
292
+ $tabs = $this->create_tabs( $active_addons, $registered_addons );
293
+
294
+ $html = $menu . $tabs;
295
+ $this->html = $html;
296
+
297
+ echo $html;
298
+
299
+ return $this;
300
+ }
301
+
302
+
303
+ /**
304
+ * Handwritten list of OG Meta types.
305
+ *
306
+ * @since 3.0.0 | 01 MAR 2018 | Created
307
+ * @since 3.1.0 | 13 JUN 2018 | Replaced array bracket notation.
308
+ * @param void
309
+ * @return array Custom Post Types.
310
+ *
311
+ */
312
+ protected function get_og_post_types() {
313
+ return array(
314
+ 'article',
315
+ 'book',
316
+ 'books.author',
317
+ 'books.book',
318
+ 'books.genre',
319
+ 'business.business',
320
+ 'fitness.course',
321
+ 'game.achievement',
322
+ 'music.album',
323
+ 'music.playlist',
324
+ 'music.radio_station',
325
+ 'music.song',
326
+ 'place',
327
+ 'product',
328
+ 'product.group',
329
+ 'product.item',
330
+ 'profile',
331
+ 'restaurant.menu',
332
+ 'restaurant.menu_item',
333
+ 'restaurant.menu_section',
334
+ 'restaurant.restaurant',
335
+ 'video.episode',
336
+ 'video.movie',
337
+ 'video.other',
338
+ 'video.tv_show',
339
+ );
340
+ }
341
+
342
+
343
+ /**
344
+ * Provides the common placement choices for the buttons.
345
+ *
346
+ * @since 3.0.0 | 01 MAR 2018 | Created
347
+ * @since 3.1.0 | 13 JUN 2018 | Replaced Array bracket notation.
348
+ * @param void
349
+ * @return array Key/Value pairs of button placement options.
350
+ *
351
+ */
352
+ protected function get_static_options_array() {
353
+ return array(
354
+ 'above' => __( 'Above the Content', 'social-warfare' ),
355
+ 'below' => __( 'Below the Content', 'social-warfare' ),
356
+ 'both' => __( 'Both Above and Below the Content', 'social-warfare' ),
357
+ 'none' => __( 'None/Manual Placement', 'social-warfare' )
358
+ );
359
+ }
360
+
361
+
362
+ /**
363
+ * Create the Advanced section of the display tab.
364
+ *
365
+ * This section offers miscellaneous advanced settings for finer control of the plugin.
366
+ *
367
+ * @since 3.0.0 | 01 MAR 2018 | Created
368
+ * @param void
369
+ * @return object $this The calling object for method chaining.
370
+ *
371
+ */
372
+ protected function init_advanced_tab() {
373
+
374
+ $advanced = new SWP_Options_Page_Tab( __( 'Advanced', 'social-warfare' ), 'advanced' );
375
+ $advanced->set_priority( 40 );
376
+
377
+ $frame_buster = new SWP_Options_Page_Section( __( 'Frame Buster', 'social-warfare' ), 'frame_buster' );
378
+ $frame_buster->set_priority( 10 )
379
+ ->set_description( __( 'If you want to stop content pirates from framing your content, turn this on.', 'social-warfare' ) )
380
+ ->set_information_link( 'https://warfareplugins.com/support/options-page-advanced-tab-frame-buster/');
381
+
382
+ //* sniplyBuster => frame_buster
383
+ $frame_buster_toggle = new SWP_Option_Toggle( __( 'Frame Buster', 'social-warfare' ), 'frame_buster' );
384
+ $frame_buster_toggle->set_default( true )
385
+ ->set_size( 'sw-col-300' );
386
+
387
+ $frame_buster->add_option( $frame_buster_toggle );
388
+
389
+ // $caching_method = new SWP_Options_Page_Section( __( 'Caching Method', 'social-warfare' ), 'caching_method' );
390
+ // $caching_method->set_priority( 60 );
391
+ //
392
+ // //* cacheMethod => cache_method
393
+ // $cache_method = new SWP_Option_Select( __( 'Cache Rebuild Method', 'social-warfare' ), 'cache_method' );
394
+ // $cache_method->set_choices( [
395
+ // 'advanced' => __( 'Advanced Cache Triggering', 'social-warfare' ),
396
+ // 'legacy' => __( 'Legacy Cache Rebuilding During Page Loads', 'social-warfare' )
397
+ // ])
398
+ // ->set_default( 'advanced' )
399
+ // ->set_size( 'sw-col-300' );
400
+ //
401
+ // $caching_method->add_option( $cache_method );
402
+
403
+ $full_content = new SWP_Options_Page_Section( __( 'Full Content vs. Excerpts', 'social-warfare' ), 'full_content' );
404
+ $full_content->set_priority( 70 )
405
+ ->set_description( __( 'If your theme does not use excerpts, but instead displays the full post content on archive, category, and home pages, activate this toggle to allow the buttons to appear in those areas.', 'social-warfare' ) )
406
+ ->set_information_link( 'https://warfareplugins.com/support/options-page-advanced-tab-full-content-vs-excerpts/' );
407
+
408
+ $full_content_toggle = new SWP_Option_Toggle( __( 'Full Content?', 'social-warfare' ), 'full_content' );
409
+ $full_content_toggle->set_default( false )
410
+ ->set_size( 'sw-col-300' );
411
+
412
+ $full_content->add_option( $full_content_toggle );
413
+
414
+ $advanced->add_sections( [$frame_buster, $full_content] );
415
+
416
+ $this->tabs->advanced = $advanced;
417
+
418
+ return $this;
419
+ }
420
+
421
+
422
+ /**
423
+ * Create the Display section and its child options.
424
+ *
425
+ * This tab offers genereral layout setings for the front end of the site.
426
+ *
427
+ * @since 3.0.0 | 01 MAR 2018 | Created
428
+ * @param void
429
+ * @return object $this The calling object for method chaining.
430
+ *
431
+ */
432
+ protected function init_display_tab() {
433
+ $display = new SWP_Options_Page_Tab( __( 'Display', 'social-warfare' ), 'display' );
434
+ $display->set_priority( 10 );
435
+
436
+ $social_networks = new SWP_Options_Page_Section( __( 'Social Networks', 'social-warfare' ), 'social_networks' );
437
+ $social_networks->set_priority( 10 )
438
+ ->set_description( __( 'Drag & Drop to activate and order your share buttons.', 'social-warfare' ) )
439
+ ->set_information_link( 'https://warfareplugins.com/support/options-page-display-tab-social-networks/' );
440
+
441
+ //* These two sections are unique and need special HTML.
442
+ $active = new SWP_Option_Icons( __( 'Active', 'social-warfare' ), 'active' );
443
+ $active->do_active_icons()->set_priority( 10 );
444
+
445
+ $inactive = new SWP_Option_Icons( __( 'Inactive', 'social-warfare' ), 'inactive' );
446
+ $inactive->do_inactive_icons()->set_priority( 20 );
447
+
448
+ $social_networks->add_options( [$active, $inactive] );
449
+
450
+ $share_counts = new SWP_Options_Page_Section( __( 'Share Counts', 'social-warfare' ), 'share_counts' );
451
+ $share_counts->set_description( __( 'Use the toggles below to determine how to display your social proof.', 'social-warfare' ) )
452
+ ->set_priority( 20 )
453
+ ->set_information_link( 'https://warfareplugins.com/support/options-page-display-tab-share-counts/' );
454
+
455
+ //* toteseach => network_count
456
+ $network_shares = new SWP_Option_Toggle( __( 'Button Counts', 'social-warfare' ), 'network_shares' );
457
+ $network_shares->set_default( true )
458
+ ->set_priority( 10 )
459
+ ->set_size( 'sw-col-300' );
460
+
461
+ //* totes => totals
462
+ $total_shares = new SWP_Option_Toggle( __( 'Total Counts', 'social-warfare' ), 'total_shares' );
463
+ $total_shares->set_default( true )
464
+ ->set_priority( 20 )
465
+ ->set_size( 'sw-col-300' );
466
+
467
+ $share_counts->add_options( [$network_shares, $total_shares] );
468
+
469
+ $button_position = new SWP_Options_Page_Section( __( 'Position Share Buttons', 'social-warfare' ), 'button_position' );
470
+ $button_position->set_description( __( 'These settings let you decide where the share buttons should go for each post type.', 'social-warfare' ) )
471
+ ->set_priority( 40 )
472
+ ->set_information_link( 'https://warfareplugins.com/support/options-page-display-tab-position-share-buttons/' );
473
+
474
+ $button_position_table = new SWP_Section_HTML( __( 'Position Table', 'social-warfare' ), 'button_position_table' );
475
+ // $button_position_table->do_button_position_table();
476
+
477
+ $button_position->add_option( $button_position_table );
478
+
479
+
480
+
481
+ $display->add_sections( [$social_networks, $share_counts, $button_position] );
482
+
483
+ $this->tabs->display = $display;
484
+
485
+ return $this;
486
+ }
487
+
488
+
489
+ /**
490
+ * Create the Registration section of the display tab.
491
+ *
492
+ * This section allows users to register activation keys for the premium plugin features.
493
+ *
494
+ * @since 3.0.0 | 01 MAR 2018 | Created
495
+ * @param void
496
+ * @return object $this The calling object for method chaining.
497
+ *
498
+ */
499
+ protected function init_registration_tab( $addons ) {
500
+ $registration = new SWP_Options_Page_Tab( __( 'Registration', 'social-warfare' ), 'registration' );
501
+
502
+ $registration->set_priority( 50 );
503
+
504
+ $wrap = new SWP_Options_Page_Section( __( 'Addon Registrations', 'social-warfare' ), 'addon_registrations' );
505
+ $wrap->set_priority( 10 );
506
+
507
+ foreach( $addons as $addon ) {
508
+ $wrap->add_option( $addon );
509
+ }
510
+
511
+ $registration->add_section( $wrap );
512
+
513
+ $this->tabs->registration = $registration;
514
+
515
+ return $this;
516
+ }
517
+
518
+
519
+ /**
520
+ * Create the Social Identity section of the display tab.
521
+ *
522
+ * This section allows the user to set social network handles and OG metadata.
523
+ *
524
+ * @since 3.0.0 | 01 MAR 2018 | Created
525
+ * @param void
526
+ * @return SWP_Options_Page $this The calling object for method chaining.
527
+ *
528
+ */
529
+ protected function init_social_tab() {
530
+ $social_identity = new SWP_Options_Page_Tab( __( 'Social Identity', 'social-warfare' ), 'social_identity' );
531
+ $social_identity->set_priority( 30 );
532
+
533
+ $sitewide_identity = new SWP_Options_Page_Section( 'Sitewide Identity', 'sitewide_identity' );
534
+ $sitewide_identity->set_description( __( 'If you would like to set sitewide defaults for your social identity, add them below.', 'social-warfare' ) )
535
+ ->set_information_link( 'https://warfareplugins.com/support/options-page-social-identity-tab-sitewide-identity/' );
536
+
537
+ $twitter_id = new SWP_Option_Text( __( 'Twitter Username', 'social-warfare' ), 'twitter_id' );
538
+ $twitter_id->set_size( 'sw-col-300' )
539
+ ->set_priority( 10 )
540
+ ->set_default( '' );
541
+
542
+ //* pinterestID => pinterest_id
543
+ $pinterest_id = new SWP_Option_Text( __( 'Pinterest Username', 'social-warfare' ), 'pinterest_id' );
544
+ $pinterest_id->set_size( 'sw-col-300' )
545
+ ->set_priority( 20 )
546
+ ->set_default( '' );
547
+
548
+ //* facebookPublisherUrl => facebook_publisher_url
549
+ $facebook_publisher_url = new SWP_Option_Text( __( 'Facebook Page URL', 'social-warfare' ), 'facebook_publisher_url' );
550
+ $facebook_publisher_url->set_size( 'sw-col-300' )
551
+ ->set_priority( 30 )
552
+ ->set_default( '' );
553
+
554
+ //* facebookAppID => facebook_app_id
555
+ $facebook_app_id = new SWP_Option_Text( __( 'Facebook App ID', 'social-warfare' ), 'facebook_app_id' );
556
+ $facebook_app_id->set_size( 'sw-col-300' )
557
+ ->set_priority( 40 )
558
+ ->set_default( '' );
559
+
560
+ $sitewide_identity->add_options( [$twitter_id, $pinterest_id, $facebook_publisher_url, $facebook_app_id] );
561
+
562
+ $social_identity->add_section( $sitewide_identity );
563
+
564
+ $this->tabs->social_identity = $social_identity;
565
+
566
+ return $this;
567
+ }
568
+
569
+
570
+ /**
571
+ * Create the Styles section of the display tab.
572
+ *
573
+ * This section allows the user to refine the look, feel, and placement of buttons.
574
+ *
575
+ * @since 3.0.0 | 01 MAR 2018 | Created
576
+ * @param void
577
+ * @return SWP_Options_Page $this The calling object for method chaining.
578
+ *
579
+ */
580
+ protected function init_styles_tab() {
581
+ $styles = new SWP_Options_Page_Tab( __( 'Styles' , 'social-warfare' ) , 'styles' );
582
+ $styles->set_priority( 20 );
583
+
584
+ $buttons_preview = new SWP_Section_HTML( __( 'Buttons Preview', 'social-warfare' ) );
585
+ $buttons_preview->set_priority( 1000 )
586
+ ->do_buttons_preview();
587
+
588
+
589
+ $buttons_preview_section = new SWP_Options_Page_Section( __( 'Buttons Preview', 'social-warfare' ), 'buttons_preview_section' );
590
+ $buttons_preview_section->add_option( $buttons_preview );
591
+
592
+ $styles->add_section( $buttons_preview_section );
593
+
594
+
595
+ $total_counts = new SWP_Options_Page_Section( __( 'Total Counts', 'social-warfare' ), 'total_counts' );
596
+ $total_counts->set_description( __( 'Customize how the "Total Shares" section of your share buttons look.', 'social-warfare' ) )
597
+ ->set_priority( 20 )
598
+ ->set_information_link( 'https://warfareplugins.com/support/options-page-styles-tab-total-counts/' );
599
+
600
+ //* swDecimals => decimals
601
+ $decimals = new SWP_Option_Select( __( 'Decimal Places', 'social-warfare' ), 'decimals' );
602
+ $decimals->set_choices( [
603
+ '0' => 'Zero',
604
+ '1' => 'One',
605
+ '2' => 'Two',
606
+ ])
607
+ ->set_default( '0' )
608
+ ->set_size( 'sw-col-460', 'sw-col-460 sw-fit' );
609
+
610
+ //* swp_decimal_separator => decimal_separator
611
+ $decimal_separator = new SWP_Option_Select( __( 'Decimal Separator', 'social-warfare' ), 'decimal_separator' );
612
+ $decimal_separator->set_choices( [
613
+ 'period' => 'Period',
614
+ 'comma' => 'Comma',
615
+ ])
616
+ ->set_default( 'period' )
617
+ ->set_size( 'sw-col-460', 'sw-col-460 sw-fit' );
618
+
619
+ //* swTotesFormat => totals_alignment
620
+ $totals_alignment = new SWP_Option_Select( __( 'Alignment', 'social-warfare' ), 'totals_alignment' );
621
+ $totals_alignment->set_choices( [
622
+ 'totals_right' => 'Right',
623
+ 'totals_left' => 'Left'
624
+ ])
625
+ ->set_default( 'totals_right' )
626
+ ->set_size( 'sw-col-460', 'sw-col-460 sw-fit' );
627
+
628
+ $total_counts->add_options( [$decimals, $decimal_separator, $totals_alignment] );
629
+
630
+ $floating_share_buttons = new SWP_Options_Page_Section( __( 'Floating Share Buttons', 'social-warfare' ), 'floating_share_buttons' );
631
+ $floating_share_buttons->set_description( __( 'If you would like to activate floating share buttons, turn this on.', 'social-warfare' ) )
632
+ ->set_priority( 30 )
633
+ ->set_information_link( 'https://warfareplugins.com/support/options-page-styles-tab-floating-share-buttons/' );
634
+
635
+ //* float => floating_panel
636
+ $floating_panel = new SWP_Option_Toggle( __( 'Floating Share Buttons', 'social-warfare' ), 'floating_panel' );
637
+ $floating_panel->set_default( false )
638
+ ->set_size( 'sw-col-460', 'sw-col-460 sw-fit')
639
+ ->set_priority( 10 );
640
+
641
+ //* floatOption => float_location
642
+ $float_location = new SWP_Option_Select( __( 'Float Position', 'social-warfare' ), 'float_location' );
643
+ $float_location->set_choices( [
644
+ 'top' => __( 'Top of the Page' , 'social-warfare' ),
645
+ 'bottom' => __( 'Bottom of the Page' , 'social-warfare' ),
646
+ 'left' => __( 'On the left side of the page' , 'social-warfare' ),
647
+ 'right' => __( 'On the right side of the page' , 'social-warfare' )
648
+ ] )
649
+ ->set_default( 'bottom' )
650
+ ->set_priority( 20 )
651
+ ->set_size( 'sw-col-460', 'sw-col-460 sw-fit')
652
+ ->set_dependency( 'floating_panel', [true] );
653
+
654
+ //* floatBgColor => float_background_color
655
+ $float_background_color = new SWP_Option_Text( __( 'Background Color', 'social-warfare' ), 'float_background_color' );
656
+ $float_background_color->set_default( '#ffffff' )
657
+ ->set_priority( 25 )
658
+ ->set_size( 'sw-col-460', 'sw-col-460 sw-fit' )
659
+ ->set_dependency( 'float_location', ['top', 'bottom'] );
660
+
661
+ //* swp_float_scr_sz => float_screen_width
662
+ $float_screen_width = new SWP_Option_Text( __( 'Minimum Screen Width', 'social-warfare' ), 'float_screen_width' );
663
+ $float_screen_width->set_default( '1100' )
664
+ ->set_priority( 30 )
665
+ ->set_size( 'sw-col-460', 'sw-col-460 sw-fit' )
666
+ ->set_dependency( 'float_location', ['left', 'right'] );
667
+
668
+ //* sideReveal => transition
669
+ $float_transition = new SWP_Option_Select( __( 'Transition', 'social-warfare' ), 'transition' );
670
+ $float_transition->set_priority( 40 )
671
+ ->set_choices( [
672
+ 'slide' => __( 'Slide In / Slide Out' , 'social-warfare' ) ,
673
+ 'fade' => __( 'Fade In / Fade Out' , 'social-warfare' )
674
+ ] )
675
+ ->set_default( 'slide' )
676
+ ->set_size( 'sw-col-460', 'sw-col-460 sw-fit')
677
+ ->set_dependency( 'float_location', ['left', 'right'] );
678
+
679
+ $color_choices = $this::get_color_choices_array();
680
+
681
+ $float_before_content = new SWP_Option_Toggle( __( 'Float Before Content', 'social-warfare' ), 'float_before_content');
682
+ $float_before_content->set_default( false )
683
+ ->set_priority( 140 )
684
+ ->set_size( 'sw-col-460', 'sw-col-460 sw-fit')
685
+ ->set_dependency( 'floating_panel', true );
686
+
687
+ $floating_share_buttons->add_options( [$floating_panel, $float_location, $float_transition,
688
+ $float_screen_width, $float_background_color, $float_before_content] );
689
+
690
+
691
+
692
+ $styles->add_sections( [$total_counts, $floating_share_buttons] );
693
+
694
+ $this->tabs->styles = $styles;
695
+
696
+ return $this;
697
+ }
698
+
699
+
700
+ /**
701
+ * Creates the HTML for the admin top menu (Logo, tabs, and save button).
702
+ *
703
+ * @since 3.0.0 | 01 MAR 2018 | Created
704
+ * @param void
705
+ * @return string $html The fully qualified HTML for the menu.
706
+ *
707
+ */
708
+ private function create_menu( $addons ) {
709
+ //* Open the admin top menu wrapper.
710
+ $html = '<div class="sw-header-wrapper">';
711
+ $html .= '<div class="sw-grid sw-col-940 sw-top-menu" sw-registered="' . $this->registered . '">';
712
+
713
+ //* Menu wrapper and tabs.
714
+ $html .= '<div class="sw-grid sw-col-700">';
715
+ $html .= '<img class="sw-header-logo" src="' . SWP_PLUGIN_URL . '/images/admin-options-page/social-warfare-light.png" />';
716
+ $html .= '<img class="sw-header-logo-pro" src="' . SWP_PLUGIN_URL . '/images/admin-options-page/social-warfare-pro-light.png" />';
717
+ $html .= '<ul class="sw-header-menu">';
718
+
719
+ $tab_map = $this->sort_by_priority( $this->tabs );
720
+
721
+ $activated = true;
722
+
723
+ foreach( $tab_map as $prioritized_tab) {
724
+ foreach( $this->tabs as $index => $tab ) {
725
+
726
+ if ( $prioritized_tab['key'] === $tab->key ) :
727
+
728
+ //* Skip the registration tab if there are no addons.
729
+ if ( 'registration' == $tab->key && 0 === count( $addons ) ) :
730
+ continue;
731
+ endif;
732
+
733
+ $active = $activated ? 'sw-active-tab' : '';
734
+ $activated = false;
735
+
736
+ $html .= '<li class="' . $active . '">';
737
+ $html .= '<a class="sw-tab-selector" href="#" data-link="swp_' . $tab->link . '">';
738
+ $html .= '<span>' . $tab->name . '</span>';
739
+ $html .= '</a>';
740
+ $html .= '</li>';
741
+
742
+ endif;
743
+ }
744
+ }
745
+
746
+ $html .= '</ul>';
747
+ $html .= '</div>';
748
+
749
+ //* "Save Changes" button.
750
+ $html .= '<div class="sw-grid sw-col-220 sw-fit">';
751
+ $html .= '<a href="#" class="button sw-navy-button sw-save-settings">'. __( 'Save Changes' , 'social-warfare' ) .'</a>';
752
+ $html .= '</div>';
753
+
754
+ $html .= '<div class="sw-clearfix"></div>';
755
+
756
+ $html .= '</div>';
757
+ $html .= '</div>';
758
+
759
+ return $html;
760
+ }
761
+
762
+
763
+ /**
764
+ * Renders HTML for each tab and assembles for outputting.
765
+ *
766
+ * Note: We have to utilize a $map varaible for this and each
767
+ * other render() method. This is because the data are all
768
+ * stored as objects, when can not be iterated by index,
769
+ * only by key. Since they keys are arbitrary (for a plugin
770
+ * or addon, for example), this is no good, hence the map.
771
+ *
772
+ * @since 3.0.0 | 01 MAR 2018 | Created
773
+ * @param void
774
+ * @return string $container The Admin tab HTML container.
775
+ *
776
+ */
777
+ private function create_tabs( $active_addons, $registered_addons ) {
778
+ $sidebar = new SWP_Section_HTML( 'Sidebar' );
779
+ $tab_map = $this->sort_by_priority( $this->tabs );
780
+ $registered = false;
781
+ $notices = apply_filters( 'swp_admin_notices', '' );
782
+
783
+ $container = '<div class="sw-admin-wrapper" sw-registered="'. $this->registered .'" swp-addons="' . $active_addons . '" swp-registrations="' . $registered_addons . '">';
784
+ $container .= '<div class="swp-notice-wrapper">';
785
+ $container .= $notices;
786
+ $container .= '</div>';
787
+
788
+ $container .= '<form class="sw-admin-settings-form">';
789
+ $container .= '<div class="sw-tabs-container sw-grid sw-col-700">';
790
+
791
+ foreach( $tab_map as $prioritized_tab ) {
792
+ $key = $prioritized_tab['key'];
793
+
794
+ foreach( $this->tabs as $tab ) {
795
+ if ( $key === $tab->key ) :
796
+
797
+ if ( 'registration' === $key ) :
798
+ $container .= $tab->render_HTML( $registered_addons );
799
+ continue;
800
+ endif;
801
+
802
+ $container .= $tab->render_HTML();
803
+
804
+ endif;
805
+ }
806
+ }
807
+
808
+ $container .= '</div>';
809
+ $container .= '</form>';
810
+ $container .= $sidebar->do_admin_sidebar();
811
+
812
+ $container .= '</div>';
813
+
814
+ return $container;
815
+ }
816
+ }
functions/options/SWP_Options_Page_Section.php CHANGED
@@ -1,216 +1,216 @@
1
- <?php
2
-
3
-
4
- /**
5
- * The Options Page "Section" Class
6
- *
7
- * The options page is divided into tabs, sections and then actual options. This
8
- * class is the one used to create actual section objects. The section objects will
9
- * then be populated with the options that live within that particular section.
10
- *
11
- * @package SocialWarfare\Functions\Social-Networks
12
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
13
- * @license GPL-3.0+
14
- * @since 3.0.0 | 01 MAR 2018 | Created
15
- *
16
- */
17
- class SWP_Options_Page_Section extends SWP_Abstract {
18
-
19
-
20
- /**
21
- * The description printed on the Settings page under the title.
22
- *
23
- * @var string $description
24
- *
25
- */
26
- public $description;
27
-
28
-
29
- /**
30
- * The KnowledgeBase link printed on the Settings page near the title.
31
- *
32
- * @var string $link
33
- *
34
- */
35
- public $link;
36
-
37
- /**
38
- * The input elements reflecting configurable options to be set by the uesr.
39
- *
40
- * This is the array where each of the avialable option objects are stored.
41
- * The HTML for each of these options will be rendered within this section
42
- * on the options page.
43
- *
44
- * @var array Array of SWP_Option objects.
45
- *
46
- */
47
- public $options;
48
-
49
-
50
- /**
51
- * The magic construct method.
52
- *
53
- * In order to create a new section on the options page, it must contain at
54
- * least an name and a unique key that differentiates it from all of the other
55
- * sections on the options page.
56
- *
57
- * @since 3.0.0 | 01 MAR 2018 | Created
58
- * @param string $name The name of this section. Will be printed at the top.
59
- * @param string $key The unique key for this section of the options page.
60
- * @return void
61
- *
62
- */
63
- public function __construct( $name, $key ) {
64
- $this->options = new stdClass();
65
- $this->set_name( $name );
66
- $this->set_key( $key );
67
-
68
- }
69
-
70
-
71
- /**
72
- * The related link to our KnowledgeBase article.
73
- *
74
- * @since 3.0.0 | 01 MAR 2018 | Created
75
- * @param string $link The direct link to the article.
76
- * @return object $this Allows for method chaining.
77
- *
78
- */
79
- public function set_information_link( $link ) {
80
- if ( !is_string( $link ) || strpos( $link, 'http' ) === false ) {
81
- $this->_throw( $link . ' must be a valid URL.' );
82
- }
83
-
84
- $this->link = $link;
85
-
86
- return $this;
87
- }
88
-
89
-
90
- /**
91
- * The description text appearing under the section's name.
92
- *
93
- * @since 3.0.0 | 01 MAR 2018 | Created
94
- * @param string $description The full text to be displayed in the section.
95
- * @return object $this The updated object. Allows for method chaining.
96
- *
97
- */
98
- public function set_description( $description ) {
99
- if ( !is_string( $description ) ) {
100
- $this->_throw( 'Please pass the description as a string.' );
101
- }
102
-
103
- $this->description = $description;
104
-
105
- return $this;
106
- }
107
-
108
-
109
- /**
110
- * Adds a user setting option to the section.
111
- *
112
- * This is the method that allows us to add an actual option to this section
113
- * of the settings page. An SWP_Option needs to be created, and then this method
114
- * allows that option to be added to this section.
115
- *
116
- * @since 3.0.0 | 01 MAR 2018 | Created
117
- * @param mixed $option One of the SWP_Option child classes.
118
- * @return object $this The updated object. Allows for method chaining.
119
- *
120
- */
121
- public function add_option( $option ) {
122
- $types = ['SWP_Addon_Registration', 'SWP_Option_Toggle', 'SWP_Option_Select', 'SWP_Option_Text', 'SWP_Option_Textarea'];
123
-
124
- $type = get_class( $option );
125
-
126
- if ( !( in_array( $type, $types ) || is_subclass_of( $option, 'SWP_Option' ) ) ) {
127
- $this->_throw("Requres one of the SWP_Option child classes.");
128
- }
129
-
130
- $name = $option->key;
131
- $this->options->$name = $option;
132
-
133
- return $this;
134
- }
135
-
136
-
137
- /**
138
- * Adds multiple options at once.
139
- *
140
- * Option objects can be created inside of an array and then added to this
141
- * section via this method.
142
- *
143
- * @since 3.0.0 | 01 MAR 2018 | Created
144
- * @param array $options An array of SWP_Option child objects.
145
- * @return object $this The updated object. Allows for method chaining.
146
- *
147
- */
148
- public function add_options( $options ) {
149
- if ( !is_array( $options ) ) {
150
- $this->_throw( "Requires an array of SWP_Option objects." );
151
- }
152
-
153
- foreach ( $options as $option ) {
154
- $this->add_option( $option );
155
- }
156
-
157
- return $this;
158
- }
159
-
160
-
161
- /**
162
- * A method to render the html for each tab.
163
- *
164
- * @since 3.0.0 | 03 MAR 2018 | Created
165
- * @param void
166
- * @return string Fully qualified HTML for this tab.
167
- *
168
- */
169
- public function render_HTML() {
170
- //* The opening tag, which may or may not have dependencies or be premium.
171
- $html = '<div class="sw-section sw-grid sw-col-940 sw-fit sw-option-container ' . $this->key . '_title_wrapper" ';
172
- $html .= $this->render_dependency();
173
- $html .= $this->render_premium();
174
- $html .= '>';
175
-
176
- $html .= '<h2>';
177
- $html .= '<a target="_blank" class="swp_support_link" href="'. $this->link .'" title="Click here to learn more about these options.">i</a>';
178
- $html .= $this->name . '</h2>';
179
-
180
- $html .= '</div>';
181
-
182
- $html .= '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $this->key . '_description_wrapper">';
183
- $html .= '<p class="sw-subtitle">' . $this->description . '</p>';
184
- $html .= '</div>';
185
-
186
- // $html .= '<div class="sw-options-wrap">';
187
- $html .= $this->render_options();
188
- // $html .= '</div>';
189
-
190
- return $html;
191
- }
192
-
193
-
194
- /**
195
- * Renders the section's options HTML.
196
- *
197
- * @since 3.0.0 | 01 MAR 2018 | Created
198
- * @param void
199
- * @return string $options The fully qualified HTML for the sections options.
200
- *
201
- */
202
- private function render_options() {
203
- $map = $this->sort_by_priority($this->options);
204
- $options = '';
205
-
206
- foreach( $map as $prioritized ) {
207
- foreach( $this->options as $option) {
208
- if ( $option->key === $prioritized['key'] ) :
209
- $options .= $option->render_HTML();
210
- endif;
211
- }
212
- }
213
-
214
- return $options;
215
- }
216
- }
1
+ <?php
2
+
3
+
4
+ /**
5
+ * The Options Page "Section" Class
6
+ *
7
+ * The options page is divided into tabs, sections and then actual options. This
8
+ * class is the one used to create actual section objects. The section objects will
9
+ * then be populated with the options that live within that particular section.
10
+ *
11
+ * @package SocialWarfare\Functions\Social-Networks
12
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
13
+ * @license GPL-3.0+
14
+ * @since 3.0.0 | 01 MAR 2018 | Created
15
+ *
16
+ */
17
+ class SWP_Options_Page_Section extends SWP_Abstract {
18
+
19
+
20
+ /**
21
+ * The description printed on the Settings page under the title.
22
+ *
23
+ * @var string $description
24
+ *
25
+ */
26
+ public $description;
27
+
28
+
29
+ /**
30
+ * The KnowledgeBase link printed on the Settings page near the title.
31
+ *
32
+ * @var string $link
33
+ *
34
+ */
35
+ public $link;
36
+
37
+ /**
38
+ * The input elements reflecting configurable options to be set by the uesr.
39
+ *
40
+ * This is the array where each of the avialable option objects are stored.
41
+ * The HTML for each of these options will be rendered within this section
42
+ * on the options page.
43
+ *
44
+ * @var array Array of SWP_Option objects.
45
+ *
46
+ */
47
+ public $options;
48
+
49
+
50
+ /**
51
+ * The magic construct method.
52
+ *
53
+ * In order to create a new section on the options page, it must contain at
54
+ * least an name and a unique key that differentiates it from all of the other
55
+ * sections on the options page.
56
+ *
57
+ * @since 3.0.0 | 01 MAR 2018 | Created
58
+ * @param string $name The name of this section. Will be printed at the top.
59
+ * @param string $key The unique key for this section of the options page.
60
+ * @return void
61
+ *
62
+ */
63
+ public function __construct( $name, $key ) {
64
+ $this->options = new stdClass();
65
+ $this->set_name( $name );
66
+ $this->set_key( $key );
67
+
68
+ }
69
+
70
+
71
+ /**
72
+ * The related link to our KnowledgeBase article.
73
+ *
74
+ * @since 3.0.0 | 01 MAR 2018 | Created
75
+ * @param string $link The direct link to the article.
76
+ * @return object $this Allows for method chaining.
77
+ *
78
+ */
79
+ public function set_information_link( $link ) {
80
+ if ( !is_string( $link ) || strpos( $link, 'http' ) === false ) {
81
+ $this->_throw( $link . ' must be a valid URL.' );
82
+ }
83
+
84
+ $this->link = $link;
85
+
86
+ return $this;
87
+ }
88
+
89
+
90
+ /**
91
+ * The description text appearing under the section's name.
92
+ *
93
+ * @since 3.0.0 | 01 MAR 2018 | Created
94
+ * @param string $description The full text to be displayed in the section.
95
+ * @return object $this The updated object. Allows for method chaining.
96
+ *
97
+ */
98
+ public function set_description( $description ) {
99
+ if ( !is_string( $description ) ) {
100
+ $this->_throw( 'Please pass the description as a string.' );
101
+ }
102
+
103
+ $this->description = $description;
104
+
105
+ return $this;
106
+ }
107
+
108
+
109
+ /**
110
+ * Adds a user setting option to the section.
111
+ *
112
+ * This is the method that allows us to add an actual option to this section
113
+ * of the settings page. An SWP_Option needs to be created, and then this method
114
+ * allows that option to be added to this section.
115
+ *
116
+ * @since 3.0.0 | 01 MAR 2018 | Created
117
+ * @param mixed $option One of the SWP_Option child classes.
118
+ * @return object $this The updated object. Allows for method chaining.
119
+ *
120
+ */
121
+ public function add_option( $option ) {
122
+ $types = ['SWP_Addon_Registration', 'SWP_Option_Toggle', 'SWP_Option_Select', 'SWP_Option_Text', 'SWP_Option_Textarea'];
123
+
124
+ $type = get_class( $option );
125
+
126
+ if ( !( in_array( $type, $types ) || is_subclass_of( $option, 'SWP_Option' ) ) ) {
127
+ $this->_throw("Requres one of the SWP_Option child classes.");
128
+ }
129
+
130
+ $name = $option->key;
131
+ $this->options->$name = $option;
132
+
133
+ return $this;
134
+ }
135
+
136
+
137
+ /**
138
+ * Adds multiple options at once.
139
+ *
140
+ * Option objects can be created inside of an array and then added to this
141
+ * section via this method.
142
+ *
143
+ * @since 3.0.0 | 01 MAR 2018 | Created
144
+ * @param array $options An array of SWP_Option child objects.
145
+ * @return object $this The updated object. Allows for method chaining.
146
+ *
147
+ */
148
+ public function add_options( $options ) {
149
+ if ( !is_array( $options ) ) {
150
+ $this->_throw( "Requires an array of SWP_Option objects." );
151
+ }
152
+
153
+ foreach ( $options as $option ) {
154
+ $this->add_option( $option );
155
+ }
156
+
157
+ return $this;
158
+ }
159
+
160
+
161
+ /**
162
+ * A method to render the html for each tab.
163
+ *
164
+ * @since 3.0.0 | 03 MAR 2018 | Created
165
+ * @param void
166
+ * @return string Fully qualified HTML for this tab.
167
+ *
168
+ */
169
+ public function render_HTML() {
170
+ //* The opening tag, which may or may not have dependencies or be premium.
171
+ $html = '<div class="sw-section sw-grid sw-col-940 sw-fit sw-option-container ' . $this->key . '_title_wrapper" ';
172
+ $html .= $this->render_dependency();
173
+ $html .= $this->render_premium();
174
+ $html .= '>';
175
+
176
+ $html .= '<h2>';
177
+ $html .= '<a target="_blank" class="swp_support_link" href="'. $this->link .'" title="Click here to learn more about these options.">i</a>';
178
+ $html .= $this->name . '</h2>';
179
+
180
+ $html .= '</div>';
181
+
182
+ $html .= '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $this->key . '_description_wrapper">';
183
+ $html .= '<p class="sw-subtitle">' . $this->description . '</p>';
184
+ $html .= '</div>';
185
+
186
+ // $html .= '<div class="sw-options-wrap">';
187
+ $html .= $this->render_options();
188
+ // $html .= '</div>';
189
+
190
+ return $html;
191
+ }
192
+
193
+
194
+ /**
195
+ * Renders the section's options HTML.
196
+ *
197
+ * @since 3.0.0 | 01 MAR 2018 | Created
198
+ * @param void
199
+ * @return string $options The fully qualified HTML for the sections options.
200
+ *
201
+ */
202
+ private function render_options() {
203
+ $map = $this->sort_by_priority($this->options);
204
+ $options = '';
205
+
206
+ foreach( $map as $prioritized ) {
207
+ foreach( $this->options as $option) {
208
+ if ( $option->key === $prioritized['key'] ) :
209
+ $options .= $option->render_HTML();
210
+ endif;
211
+ }
212
+ }
213
+
214
+ return $options;
215
+ }
216
+ }
functions/options/SWP_Options_Page_Tab.php CHANGED
@@ -1,164 +1,164 @@
1
- <?php
2
-
3
- /**
4
- * SWP_Options_Page_Tab: The class used to create tabs on the options page.
5
- *
6
- * This class is used to create each individual tab on the options page. Each tab is an
7
- * object that contains a name, a priority, and a sections property. The sections property
8
- * is a collection of "section" objects each of which will contain a collection of related
9
- * options to display on the options page in a group.
10
- *
11
- * @package SocialWarfare\Functions\Social-Networks
12
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
13
- * @license GPL-3.0+
14
- * @since 3.0.0 | 02 MAR 2017 | Created
15
- * @since 3.1.0 | 14 JUN 2018 | Updated to use set_key() method.
16
- * @access public
17
- *
18
- */
19
- class SWP_Options_Page_Tab extends SWP_Abstract {
20
-
21
-
22
- /**
23
- * Sections
24
- *
25
- * This property will contain a bunch of "section" objects each pertaining to a
26
- * different section of related options. Sections, like tabs, are also sorted
27
- * by their priority property in ascending order.
28
- *
29
- * @var array A group of "option" objects.
30
- *
31
- */
32
- public $sections;
33
-
34
-
35
- /**
36
- * Links
37
- * This is the link used by Javscript to switch tabs.
38
- *
39
- * Note: This is not an href or external link. This is just a key used by jQuery
40
- * to select the proper tab.
41
- *
42
- * @var string $link
43
- *
44
- */
45
- public $link;
46
-
47
-
48
- /**
49
- * The magic method used to instantiate this class.
50
- *
51
- * This method instantiates this class by settings the "sections" property to
52
- * an object so the the "options" objects can easily be added to it later on.
53
- *
54
- * @since 3.0.0 | 3 MAR 2018 | Created
55
- * @since 3.1.0 | 14 JUN 2018 | Update to use set_key() method.
56
- * @param str $name The name of this tab.
57
- * @param str $key The unique key for this tab.
58
- *
59
- */
60
- public function __construct( $name, $key ) {
61
- $this->sections = new stdClass();
62
-
63
- $this->set_name( $name );
64
- $this->set_link( $key );
65
- $this->set_key( $key );
66
-
67
- }
68
-
69
-
70
- /**
71
- * Pushes one SWP_Options_Page_Section object into $this array of sections.
72
- *
73
- * @since 3.0.0 | 01 MAR 2018 | Created
74
- * @param object $section SWP_Options_Page_Section - The section to add to the array.
75
- * @return object $this Allows for method chaining.
76
- *
77
- */
78
- public function add_section( $section ) {
79
- if ( !( 'SWP_Options_Page_Section' === get_class( $section ) || is_subclass_of( $section, 'SWP_Options_Page_Section' ) ) ) :
80
- $this->_throw( 'Please provide an instance of SWP_Options_Page_Section as the parameter.' );
81
- endif;
82
-
83
- $key = $section->key;
84
- $this->sections->$key = $section;
85
-
86
- return $this;
87
- }
88
-
89
- /**
90
- * Adds multiple SWP_Options_Page_Section objects into $this array of sections.
91
- *
92
- * @since 3.0.0 | 01 MAR 2018 | Created
93
- * @param array $sections An array of SWP_Options_Page_Section objects.
94
- * @return object $this The calling option, for method chaining.
95
- *
96
- */
97
- public function add_sections( $sections ) {
98
- if ( !is_array( $sections ) ) :
99
- $this->_throw( 'This method requires an array. Please use add_section to add a single instance of SWP_Options_Page_Section.' );
100
- endif;
101
-
102
- foreach ( $sections as $section ) {
103
- if ( 'SWP_Options_Page_Section' !== get_class( $section ) ) :
104
- $this->_throw( 'This need an array of SWP_Options_Page_Section objects.' );
105
- endif;
106
-
107
- $this->add_section( $section );
108
- }
109
-
110
- return $this;
111
- }
112
-
113
-
114
- /**
115
- * Sets the Javascript for switching tabs on the Admin page.
116
- *
117
- * Note: This is not an href or external link. This is just a key used by jQuery
118
- * to select the proper tab.
119
- *
120
- * @since 3.0.0 | 01 MAR 2018 | Created
121
- * @param string $link The key correlatign to the tab. Must match the javascript target.
122
- * @return object $this The calling option, for method chaining.
123
- *
124
- */
125
- public function set_link( $link ) {
126
- if ( !is_string( $link ) ) {
127
- $this->_throw( 'Please provide a valid string prefixed with "swp_" for the tab link.' );
128
- }
129
-
130
- $this->link = $link;
131
-
132
- return $this;
133
- }
134
-
135
-
136
- /**
137
- * A method to render the html for each tab.
138
- *
139
- * @since 3.0.0 | 03 MAR 2018 | Created
140
- * @param null
141
- * @return string Fully qualified HTML for this tab.
142
- *
143
- */
144
- public function render_HTML() {
145
- $map = $this->sort_by_priority($this->sections);
146
-
147
- $sections = $this->sort_by_priority( $map );
148
-
149
- $tab = '<div id="swp_' . strtolower( $this->key ) . '" class="sw-admin-tab sw-grid sw-col-940">';
150
-
151
- foreach( $map as $prioritized_section) {
152
- foreach( $this->sections as $section) {
153
- if ( $section->key === $prioritized_section['key'] ) :
154
- $tab .= $section->render_HTML();
155
- endif;
156
- }
157
- }
158
-
159
- $tab .= '</div>';
160
-
161
- return $tab;
162
- }
163
-
164
- }
1
+ <?php
2
+
3
+ /**
4
+ * SWP_Options_Page_Tab: The class used to create tabs on the options page.
5
+ *
6
+ * This class is used to create each individual tab on the options page. Each tab is an
7
+ * object that contains a name, a priority, and a sections property. The sections property
8
+ * is a collection of "section" objects each of which will contain a collection of related
9
+ * options to display on the options page in a group.
10
+ *
11
+ * @package SocialWarfare\Functions\Social-Networks
12
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
13
+ * @license GPL-3.0+
14
+ * @since 3.0.0 | 02 MAR 2017 | Created
15
+ * @since 3.1.0 | 14 JUN 2018 | Updated to use set_key() method.
16
+ * @access public
17
+ *
18
+ */
19
+ class SWP_Options_Page_Tab extends SWP_Abstract {
20
+
21
+
22
+ /**
23
+ * Sections
24
+ *
25
+ * This property will contain a bunch of "section" objects each pertaining to a
26
+ * different section of related options. Sections, like tabs, are also sorted
27
+ * by their priority property in ascending order.
28
+ *
29
+ * @var array A group of "option" objects.
30
+ *
31
+ */
32
+ public $sections;
33
+
34
+
35
+ /**
36
+ * Links
37
+ * This is the link used by Javscript to switch tabs.
38
+ *
39
+ * Note: This is not an href or external link. This is just a key used by jQuery
40
+ * to select the proper tab.
41
+ *
42
+ * @var string $link
43
+ *
44
+ */
45
+ public $link;
46
+
47
+
48
+ /**
49
+ * The magic method used to instantiate this class.
50
+ *
51
+ * This method instantiates this class by settings the "sections" property to
52
+ * an object so the the "options" objects can easily be added to it later on.
53
+ *
54
+ * @since 3.0.0 | 3 MAR 2018 | Created
55
+ * @since 3.1.0 | 14 JUN 2018 | Update to use set_key() method.
56
+ * @param str $name The name of this tab.
57
+ * @param str $key The unique key for this tab.
58
+ *
59
+ */
60
+ public function __construct( $name, $key ) {
61
+ $this->sections = new stdClass();
62
+
63
+ $this->set_name( $name );
64
+ $this->set_link( $key );
65
+ $this->set_key( $key );
66
+
67
+ }
68
+
69
+
70
+ /**
71
+ * Pushes one SWP_Options_Page_Section object into $this array of sections.
72
+ *
73
+ * @since 3.0.0 | 01 MAR 2018 | Created
74
+ * @param object $section SWP_Options_Page_Section - The section to add to the array.
75
+ * @return object $this Allows for method chaining.
76
+ *
77
+ */
78
+ public function add_section( $section ) {
79
+ if ( !( 'SWP_Options_Page_Section' === get_class( $section ) || is_subclass_of( $section, 'SWP_Options_Page_Section' ) ) ) :
80
+ $this->_throw( 'Please provide an instance of SWP_Options_Page_Section as the parameter.' );
81
+ endif;
82
+
83
+ $key = $section->key;
84
+ $this->sections->$key = $section;
85
+
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * Adds multiple SWP_Options_Page_Section objects into $this array of sections.
91
+ *
92
+ * @since 3.0.0 | 01 MAR 2018 | Created
93
+ * @param array $sections An array of SWP_Options_Page_Section objects.
94
+ * @return object $this The calling option, for method chaining.
95
+ *
96
+ */
97
+ public function add_sections( $sections ) {
98
+ if ( !is_array( $sections ) ) :
99
+ $this->_throw( 'This method requires an array. Please use add_section to add a single instance of SWP_Options_Page_Section.' );
100
+ endif;
101
+
102
+ foreach ( $sections as $section ) {
103
+ if ( 'SWP_Options_Page_Section' !== get_class( $section ) ) :
104
+ $this->_throw( 'This need an array of SWP_Options_Page_Section objects.' );
105
+ endif;
106
+
107
+ $this->add_section( $section );
108
+ }
109
+
110
+ return $this;
111
+ }
112
+
113
+
114
+ /**
115
+ * Sets the Javascript for switching tabs on the Admin page.
116
+ *
117
+ * Note: This is not an href or external link. This is just a key used by jQuery
118
+ * to select the proper tab.
119
+ *
120
+ * @since 3.0.0 | 01 MAR 2018 | Created
121
+ * @param string $link The key correlatign to the tab. Must match the javascript target.
122
+ * @return object $this The calling option, for method chaining.
123
+ *
124
+ */
125
+ public function set_link( $link ) {
126
+ if ( !is_string( $link ) ) {
127
+ $this->_throw( 'Please provide a valid string prefixed with "swp_" for the tab link.' );
128
+ }
129
+
130
+ $this->link = $link;
131
+
132
+ return $this;
133
+ }
134
+
135
+
136
+ /**
137
+ * A method to render the html for each tab.
138
+ *
139
+ * @since 3.0.0 | 03 MAR 2018 | Created
140
+ * @param null
141
+ * @return string Fully qualified HTML for this tab.
142
+ *
143
+ */
144
+ public function render_HTML() {
145
+ $map = $this->sort_by_priority($this->sections);
146
+
147
+ $sections = $this->sort_by_priority( $map );
148
+
149
+ $tab = '<div id="swp_' . strtolower( $this->key ) . '" class="sw-admin-tab sw-grid sw-col-940">';
150
+
151
+ foreach( $map as $prioritized_section) {
152
+ foreach( $this->sections as $section) {
153
+ if ( $section->key === $prioritized_section['key'] ) :
154
+ $tab .= $section->render_HTML();
155
+ endif;
156
+ }
157
+ }
158
+
159
+ $tab .= '</div>';
160
+
161
+ return $tab;
162
+ }
163
+
164
+ }
functions/options/SWP_Section_HTML.php CHANGED
@@ -1,561 +1,561 @@
1
- <?php
2
-
3
- /**
4
- * For creating markup that does not fit into the existing options.
5
- *
6
- * This extends SWP_Option rather than SWP_Section because it uses many of the
7
- * same methods as an option and is a child of a section, even though this is
8
- * neither necessarily an option or a section.
9
- *
10
- * @package SocialWarfare\Functions\Social-Networks
11
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
12
- * @license GPL-3.0+
13
- * @since 3.0.0 | 01 MAR 2018 | Created
14
- *
15
- */
16
- class SWP_Section_HTML extends SWP_Option {
17
-
18
-
19
- /**
20
- * HTML
21
- *
22
- * The non-conformant markup this object represents. Most of the sections and
23
- * options can be created using one of the existing SWP_{Item} classes.
24
- * Sometimes we need something that does not fit those boxes. This class
25
- * provides native methods for a few of those cases, and an add_HTML() method
26
- * for everything else.
27
- *
28
- * @var string $html
29
- *
30
- */
31
- public $html = '';
32
-
33
-
34
- /**
35
- * The required constructor for PHP classes.
36
- *
37
- * @since 3.0.0 | 01 MAR 2018 | Created
38
- * @param string $name Required: An arbitrary name, except for do_bitly_authentication_button
39
- * @param string $key Optional: If the object requires access beyond itself,
40
- * pass it a key. Otherwise $name will be used.
41
- * @return void
42
- * @see $this->do_bitly_authentication_button()
43
- *
44
- */
45
- public function __construct( $name, $key = null ) {
46
- $key = $key === null ? $name : $key;
47
-
48
- parent::__construct( $name, $key );
49
-
50
- $this->html = '';
51
- }
52
-
53
-
54
- /**
55
- * Allows custom HTML to be added.
56
- *
57
- * @since 3.0.0 | 01 MAR 2018 | Created
58
- * @param string $html Required: The fully qualified, ready-to-print HTML to display.
59
- * @return object $this This object for method chaining.
60
- *
61
- */
62
- public function add_HTML( $html ) {
63
- if ( !is_string( $html) ) :
64
- $this->_throw( 'This requires a string of HTML!' );
65
- endif;
66
-
67
- $this->html .= $html;
68
-
69
- return $this;
70
- }
71
-
72
-
73
- /**
74
- * A method for creating the admin sidebar HTML.
75
- *
76
- * @since 3.0.0 | 01 MAR 2018 | Created
77
- * @param void
78
- * @return string The compiled HTML returned as a string.
79
- *
80
- */
81
- public function do_admin_sidebar() {
82
- $status_title = __( 'Press Ctrl+C to Copy this information.' , 'social-warfare' );
83
- $support_link = __( 'Need help? Check out our <a href="https://warfareplugins.com/support/" target="_blank">Knowledgebase.' , 'social-warfare' );
84
- $support_status = __( 'Opening a support ticket? Copy your System Status by clicking the button below.' , 'social-warfare' );
85
- $get_status = __( 'Get System Status' , 'social-warfare' );
86
- ob_start();
87
- ?>
88
-
89
- <div class="sw-admin-sidebar sw-grid sw-col-220 sw-fit">
90
- <a href="https://warfareplugins.com/affiliates/" target="_blank"><img src="<?= SWP_PLUGIN_URL ?>/images/admin-options-page/affiliate-300x150.jpg"></a>
91
- <a href="https://warfareplugins.com/support-categories/getting-started/" target="_blank"><img src="<?= SWP_PLUGIN_URL ?>/images/admin-options-page/starter-guide-300x150.jpg"></a>
92
- <a href="https://warfareplugins.com/how-to-measure-social-media-roi-using-google-analytics/" target="_blank"><img src="<?= SWP_PLUGIN_URL ?>/images/admin-options-page/measure-roi-300x150.jpg"></a>
93
- <p class="sw-support-notice sw-italic"><?= $support_link ?></a></p>
94
- <p class="sw-support-notice sw-italic"><?= $support_status ?></p>
95
- <a href="#" class="button sw-blue-button sw-system-status"><?= $get_status ?></a>
96
-
97
- <!-- Sytem Status Container -->
98
- <div class="sw-clearfix"></div>
99
- <div class="system-status-wrapper">
100
- <h4><?= $status_title ?></h4>
101
- <div class="system-status-container"><?= $this->system_status() ?></div>
102
- </div>
103
- </div>
104
-
105
- <?php
106
-
107
- $this->html = ob_get_contents();
108
- ob_end_clean();
109
-
110
- return $this->html;
111
- }
112
-
113
-
114
- /**
115
- * A method for compiling the system status html.
116
- *
117
- * @since 3.0.0 | 01 MAR 2018 | Created
118
- * @param void
119
- * @return string The compiled html returned as a string.
120
- *
121
- */
122
- private function system_status() {
123
- /**
124
- * System Status Generator
125
- */
126
- global $swp_user_options;
127
-
128
- if ( ! function_exists( 'get_plugins' ) ) {
129
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
130
- }
131
-
132
- $plugins = get_plugins();
133
- $pluginList = '';
134
-
135
- foreach ( $plugins as $plugin ) :
136
- $pluginList .= '<tr><td><b>' . $plugin['Name'] . '</b></td><td>' . $plugin['Version'] . '</td></tr>';
137
- endforeach;
138
-
139
- if ( function_exists( 'fsockopen' ) ) :
140
- $fsockopen = '<span style="color:green;">Enabled</span>';
141
- else :
142
- $fsockopen = '<span style="color:red;">Disabled</span>';
143
- endif;
144
-
145
- if ( function_exists( 'curl_version' ) ) :
146
- $curl_version = curl_version();
147
- $curl_status = '<span style="color:green;">Enabled: v' . $curl_version['version'] . '</span>';
148
- else :
149
- $curl_status = '<span style="color:red;">Disabled</span>';
150
- endif;
151
-
152
- $theme = wp_get_theme();
153
-
154
- $system_status = '
155
- <table style="width:100%;">
156
- <tr><td><h2>Environment Statuses</h2></td><td></td></tr>
157
- <tr><td><b>Home URL</b></td><td>' . get_home_url() . '</td></tr>
158
- <tr><td><b>Site URL</b></td><td>' . get_site_url() . '</td></tr>
159
- <tr><td><b>WordPress Version</b></td><td>' . get_bloginfo( 'version' ) . '</td></tr>
160
- <tr><td><b>PHP Version</b></td><td>' . phpversion() . '</td></tr>
161
- <tr><td><b>WP Memory Limit</b></td><td>' . WP_MEMORY_LIMIT . '</td></tr>
162
- <tr><td><b>Social Warfare Version</b></td><td>' . SWP_VERSION . '</td></tr>
163
- <tr><td><h2>Connection Statuses</h2></td><td></td></tr>
164
- <tr><td><b>fsockopen</b></td><td>' . $fsockopen . '</td></tr>
165
- <tr><td><b>cURL</b></td><td>' . $curl_status . '</td></tr>
166
- <tr><td><h2>Plugin Statuses</h2></td><td></td></tr>
167
- <tr><td><b>Theme Name</b></td><td>' . $theme['Name'] . '</td></tr>
168
- <tr><td><b>Theme Version</b></td><td>' . $theme['Version'] . '</td></tr>
169
- <tr><td><b>Caching Method</b></td><td>' . ucfirst($swp_user_options['cache_method']) . '</td></tr>
170
- <tr><td><b>Active Plugins</b></td><td></td></tr>
171
- <tr><td><b>Number of Active Plugins</b></td><td>' . count( $plugins ) . '</td></tr>
172
- ' . $pluginList . '
173
- </table>
174
- ';
175
-
176
- return $system_status;
177
- }
178
-
179
-
180
- /**
181
- * A method for compiling the tweet count registration html.
182
- *
183
- * @since 3.0.0 | 01 MAR 2018 | Created
184
- * @param void
185
- * @return string The compiled html returned as a string.
186
- *
187
- */
188
- public function do_tweet_count_registration() {
189
- global $swp_user_options;
190
-
191
- // Check for a default value
192
- if ( isset( $swp_user_options['twitter_shares'] ) && $swp_user_options['twitter_shares'] == true ) :
193
- $status = 'on';
194
- $selected = 'checked';
195
- elseif ( isset( $swp_user_options['twitter_shares'] ) && $swp_user_options['twitter_shares'] == false ) :
196
- $status = 'off';
197
- $selected = '';
198
- else :
199
- $status = 'off';
200
- $selected = '';
201
- endif;
202
-
203
-
204
- $html = '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $this->key . '_wrapper" ' . $this->render_dependency() . '>';
205
-
206
- // Begin Registration Wrapper
207
- $html .= '<div class="tweet-count-wrapper" registration="false">';
208
-
209
- // Open the IS NOT Activated container
210
- $html .= '<div class="sw-grid sw-col-940 swp_tweets_not_activated">';
211
-
212
- // The Warning Notice & Instructions
213
- $html .= '<p class="sw-subtitle sw-registration-text sw-italic">Step 1: <a style="float:none;" class="button sw-navy-button" href="https://opensharecount.com" target="_blank">' . __( 'Click here to visit OpenShareCount.com (Recommended)' , 'social-warfare' ) . '</a>&nbsp;<a style="float:none;" class="button sw-navy-button" href="http://newsharecounts.com" target="_blank">' . __( 'Click here to visit NewShareCounts.com' , 'social-warfare' ) . '</a><br />' . __( 'Step 2: Follow the prompts on their website to create an account and add your domain to be tracked for share counts.' , 'social-warfare' ) . '<br />' . __( 'Step 3: Flip the switch below to "ON", select which tracking service the plugin should use, then save your changes.' , 'social-warfare' ) . '</p>';
214
-
215
- // Close the IS NOT ACTIVATED container
216
- $html .= '</div>';
217
-
218
- // Checkbox Module
219
- $html .= '<div class="sw-grid sw-col-300"><p class="sw-checkbox-label">Tweet Counts</p></div>';
220
- $html .= '<div class="sw-grid sw-col-300">';
221
- $html .= '<div class="sw-checkbox-toggle" status="' . $status . '" field="#twitter_shares"><div class="sw-checkbox-on">' . __( 'ON' , 'social-warfare' ) . '</div><div class="sw-checkbox-off">' . __( 'OFF' , 'social-warfare' ) . '</div></div>';
222
- $html .= '<input type="checkbox" class="sw-hidden" name="twitter_shares" id="twitter_shares" ' . $selected . ' />';
223
- $html .= '</div>';
224
- $html .= '<div class="sw-grid sw-col-300 sw-fit"></div>';
225
-
226
- // Close the Registration Wrapper
227
- $html .= '</div>';
228
-
229
- $html .= '</div>';
230
-
231
- $this->html = $html;
232
-
233
- return $html;
234
- }
235
-
236
-
237
- /**
238
- * Render the Bitly connection button on the Advanced tab.
239
- *
240
- * @since 3.0.0 | 01 MAR 2018 | Created
241
- * @param void
242
- * @return object $this The calling instance, for method chaining.
243
- *
244
- */
245
- public function do_bitly_authentication_button() {
246
- $link = "https://bitly.com/oauth/authorize?client_id=96c9b292c5503211b68cf4ab53f6e2f4b6d0defb&state=" . admin_url( 'admin-ajax.php' ) . "&redirect_uri=https://warfareplugins.com/bitly_oauth.php";
247
-
248
- if ( swp_get_option('bitly_access_token') ):
249
- $text = __( 'Connected', 'social-warfare' );
250
- $color = 'sw-green-button';
251
- else:
252
- $text = __( 'Authenticate', 'social-warfare' );
253
- $color = 'sw-navy-button';
254
- endif;
255
-
256
- ob_start() ?>
257
-
258
- <div class="sw-grid sw-col-940 sw-fit sw-option-container <?= $this->key ?> '_wrapper" data-dep="bitly_authentication" data-dep_val="[true]">
259
- <div class="sw-grid sw-col-300">
260
- <p class="sw-authenticate-label"><?php __( 'Bitly Link Shortening', 'social-warfare' ) ?></p>
261
- </div>
262
- <div class="sw-grid sw-col-300">
263
- <a class="button <?= $color ?>" href="<?= $link ?>"><?= $text ?></a>
264
- </div>
265
- <div class="sw-grid sw-col-300 sw-fit"></div>
266
- </div>
267
-
268
- <?php
269
-
270
- $this->html = ob_get_contents();
271
- ob_end_clean();
272
-
273
- return $this;
274
- }
275
-
276
-
277
- /**
278
- * The buttons preview as shown on the Display tab.
279
- *
280
- * @since 3.0.0 | 01 MAR 2018 | Created
281
- * @param void
282
- * @return object $this The calling instance, for method chaining.
283
- *
284
- */
285
- public function do_buttons_preview() {
286
- ob_start() ?>
287
-
288
- <div class="swp_social_panel swp_flat_fresh swp_default_full_color swp_individual_full_color swp_other_medium_gray" data-position="both" data-count="6" data-floatcolor="#ffffff" data-scale="1" data-align="full_width">
289
- <div class="nc_tweetContainer swp_google_plus" data-id="2">
290
- <a target="_blank" href="https://plus.google.com/share?url=http%3A%2F%2Fwfa.re%2F1W28voz" data-link="https://plus.google.com/share?url=http%3A%2F%2Fwfa.re%2F1W28voz" class="nc_tweet">
291
- <span class="iconFiller">
292
- <span class="spaceManWilly">
293
- <i class="sw swp_google_plus_icon"></i>
294
- <span class="swp_share"><?php __( '+1','social-warfare' ) ?></span>
295
- </span>
296
- </span>
297
- <span class="swp_count">1.2K</span>
298
- </a>
299
- </div>
300
- <div class="nc_tweetContainer swp_twitter" data-id="3">
301
- <a href="https://twitter.com/share?original_referer=/&text=Ultimate+Social+Share+%23WordPress+plugin%21+Beautiful%2C+super+fast+%26+more+http%3A%2F%2Fwarfareplugins.com+pic.twitter.com%2FA2zcCJwZtO&url=/&via=WarfarePlugins" data-link="https://twitter.com/share?original_referer=/&text=Ultimate+Social+Share+%23WordPress+plugin%21+Beautiful%2C+super+fast+%26+more+http%3A%2F%2Fwarfareplugins.com+pic.twitter.com%2FA2zcCJwZtO&url=/&via=WarfarePlugins" class="nc_tweet">
302
- <span class="iconFiller">
303
- <span class="spaceManWilly">
304
- <i class="sw swp_twitter_icon"></i>
305
- <span class="swp_share"><?php __( 'Tweet','social-warfare' ) ?></span>
306
- </span>
307
- </span>
308
- <span class="swp_count">280</span>
309
- </a>
310
- </div>
311
- <div class="nc_tweetContainer swp_pinterest" data-id="6">
312
- <a data-link="https://pinterest.com/pin/create/button/?url=https://warfareplugins.com/&media=https%3A%2F%2Fwarfareplugins.com%2Fwp-content%2Fuploads%2Fget-content-shared-735x1102.jpg&description=Customize+your+Pinterest+sharing+options%2C+create+easy+%22click+to+tweet%22+buttons+within+your+blog+posts%2C+beautiful+sharing+buttons+and+more.+Social+Warfare+is+the+ultimate+social+sharing+arsenal+for+WordPress%21" class="nc_tweet" data-count="0">
313
- <span class="iconFiller">
314
- <span class="spaceManWilly">
315
- <i class="sw swp_pinterest_icon"></i>
316
- <span class="swp_share"><?php __( 'Pin','social-warfare' ) ?></span>
317
- </span>
318
- </span>
319
- <span class="swp_count">104</span>
320
- </a>
321
- </div>
322
- <div class="nc_tweetContainer swp_facebook" data-id="4">
323
- <a target="_blank" href="https://www.facebook.com/share.php?u=http%3A%2F%2Fwfa.re%2F1W28vov" data-link="https://www.facebook.com/share.php?u=http%3A%2F%2Fwfa.re%2F1W28vov" class="nc_tweet">
324
- <span class="iconFiller">
325
- <span class="spaceManWilly">
326
- <i class="sw swp_facebook_icon"></i>
327
- <span class="swp_share"><?php __( 'Share','social-warfare' ) ?></span>
328
- </span>
329
- </span>
330
- <span class="swp_count">157</span>
331
- </a>
332
- </div>
333
- <div class="nc_tweetContainer swp_linkedin" data-id="5">
334
- <a target="_blank" href="https://www.linkedin.com/cws/share?url=http%3A%2F%2Fwfa.re%2F1W28twH" data-link="https://www.linkedin.com/cws/share?url=http%3A%2F%2Fwfa.re%2F1W28twH" class="nc_tweet">
335
- <span class="iconFiller">
336
- <span class="spaceManWilly">
337
- <i class="sw swp_linkedin_icon"></i>
338
- <span class="swp_share"><?php __( 'Share','social-warfare' ) ?></span>
339
- </span>
340
- </span>
341
- <span class="swp_count">51</span>
342
- </a>
343
- </div>
344
- <div class="nc_tweetContainer total_shares total_sharesalt" data-id="6" >
345
- <span class="swp_count">
346
- <span class="swp_label">Shares</span> 1.8K
347
- </span>
348
- </div>
349
- </div>
350
-
351
- <?php
352
-
353
- $this->html = ob_get_contents();
354
- ob_end_clean();
355
-
356
- return $this;
357
- }
358
-
359
-
360
- /**
361
- * Renders the three column table on the Display tab.
362
- *
363
- * @since 3.0.0 | 01 MAR 2018 | Created
364
- * @since 3.0.4 | 09 MAY 2018 | Added check for is_numeric to avoid throwing errors.
365
- * @since 3.0.5 | 09 MAY 2018 | Switched to using an iterator. Many post types are
366
- * being returned with associative keys, not numeric ones.
367
- * @param void
368
- * @return object $this The calling instance, for method chaining.
369
- *
370
- */
371
- public function do_button_position_table() {
372
- $default_types = ['page', 'post', 'home', 'archive_categories'];
373
- $other_types = get_post_types( ['public' => true, '_builtin' => false ], 'names' );
374
-
375
- $post_types = array_merge( $default_types, $other_types );
376
-
377
- $panel_locations = [
378
- 'above' => __( 'Above the Content', 'social-warfare' ),
379
- 'below' => __( 'Below the Content', 'social-warfare' ),
380
- 'both' => __( 'Both Above and Below the Content', 'social-warfare' ),
381
- 'none' => __( 'None/Manual Placement', 'social-warfare' )
382
- ];
383
-
384
- $float_locations = [
385
- 'on' => __( 'On','social_warfare'),
386
- 'off' => __( 'Off', 'social_warfare')
387
- ];
388
-
389
- $html = '<div class="sw-grid sw-col-940 sw-fit sw-option-container" ';
390
- $html .= $this->render_dependency();
391
- $html .= $this->render_premium();
392
- $html .= '>';
393
-
394
- $html .= '<div class="sw-grid sw-col-300">';
395
- $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Post Type' ,'social-warfare' ) . '</p>';
396
- $html .= '</div>';
397
- $html .= '<div class="sw-grid sw-col-300">';
398
- $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Static Buttons' ,'social-warfare' ) . '</p>';
399
- $html .= '</div>';
400
- $html .= '<div class="sw-grid sw-col-300 sw-fit">';
401
- $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Floating Buttons (If Activated)' ,'social-warfare' ) . '</p>';
402
- $html .= '</div>';
403
-
404
- $i = 0;
405
- foreach( $post_types as $index => $post ) {
406
-
407
- $priority = ($i + 1) * 10; $i++;
408
-
409
- $html .= '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $post . '_wrapper">';
410
-
411
- $html .= '<div class="sw-grid sw-col-300">';
412
- $html .= '<p class="sw-input-label">' . str_replace('_', ' & ', ucfirst($post)) . '</p>';
413
- $html .= '</div>';
414
-
415
- $html .= '<div class="sw-grid sw-col-300">';
416
-
417
- $panel = new SWP_Option_Select( 'Panel '. ucfirst( $post ), 'location_' . $post );
418
- $panel->set_priority( $priority )
419
- ->set_size( 'sw-col-300' )
420
- ->set_choices( $panel_locations )
421
- ->set_default( 'both' );
422
-
423
- $html .= $panel->render_HTML_element();
424
-
425
- $html .= '</div>';
426
- $html .= '<div class="sw-grid sw-col-300 sw-fit">';
427
-
428
- if ( $post !== 'home' && $post !== 'archive_categories' ) :
429
-
430
- $float = new SWP_Option_Select( 'Float ' . ucfirst( $post ), 'float_location_' . $post );
431
- $float->set_priority( $priority + 5 )
432
- ->set_size( 'sw-col-300' )
433
- ->set_choices( $float_locations )
434
- ->set_default( 'on' );
435
-
436
- $html .= $float->render_HTML_element();
437
-
438
- endif;
439
-
440
- $html .= '</div>';
441
-
442
- $html .= '</div>';
443
-
444
- }
445
-
446
- $html .= '</div>';
447
-
448
- $this->html = $html;
449
-
450
- return $this;
451
- }
452
-
453
-
454
- /**
455
- * Creates the Click To Tweet preview for the Styles tab.
456
- *
457
- * @since 3.0.0 | 01 MAR 2018 | Created
458
- * @param void
459
- * @return object $this The calling instance, for method chaining.
460
- *
461
- */
462
- public function do_ctt_preview() {
463
- //* Pull these variables out just to make the $html string easier to read.
464
- $link = "https://twitter.com/share?text=We+couldn%27t+find+one+social+sharing+plugin+that+met+all+of+our+needs%2C+so+we+built+it+ourselves.&amp;url=https://warfareplugins.com&amp;via=warfareplugins";
465
- $data_link = "https://twitter.com/share?text=We+couldn%27t+find+one+social+sharing+plugin+that+met+all+of+our+needs%2C+so+we+built+it+ourselves.&amp;url=https://wfa.re/1PtqdNM&amp;via=WarfarePlugins";
466
- $text = "We couldn't find one social sharing plugin that met all of our needs, so we built it ourselves.";
467
-
468
- $html = '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $this->key . '_wrapper">';
469
- $html .= '<a class="swp_CTT style1" data-style="style1" href="' . $link . '" data-link="' . $data_link . '" target="_blank">';
470
- $html .= '<span class="sw-click-to-tweet">';
471
- $html .= '<span class="sw-ctt-text">' . $text . '</span>';
472
- $html .= '<span class="sw-ctt-btn">Click To Tweet';
473
- $html .= '<i class="sw swp_twitter_icon"></i>';
474
- $html .= '</span>';
475
- $html .= '</span>';
476
- $html .= '</a>';
477
- $html .= '</div>';
478
-
479
-
480
- $this->html = $html;
481
-
482
- return $this;
483
-
484
- }
485
-
486
-
487
- /**
488
- * Renders the three column table on the Display tab.
489
- *
490
- * @since 3.0.0 | 01 MAR 2018 | Created
491
- * @param void
492
- * @return object $this The calling instance, for method chaining.
493
- *
494
- */
495
- public function do_yummly_display() {
496
- $html = '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $this->key . '_wrapper" ';
497
- $html .= $this->render_dependency();
498
- $html .= $this->render_premium();
499
- $html .= '>';
500
-
501
-
502
- //* Table headers
503
- $html .= '<div class="sw-grid sw-col-300">';
504
- $html .= '<p class="sw-select-label sw-short sw-no-padding"></p>';
505
- $html .= '</div>';
506
-
507
- $html .= '<div class="sw-grid sw-col-300">';
508
- $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Choose Category', 'social-warfare' ) . '</p>';
509
- $html .= '</div>';
510
-
511
- $html .= '<div class="sw-grid sw-col-300 sw-fit">';
512
- $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Choose Tag', 'social-warfare' ) . '</p>';
513
- $html .= '</div>';
514
-
515
- $yummly_categories = new SWP_Option_Text( __( 'Yummly Categories', 'social-warfare' ), 'yummly_categories' );
516
- $categories_html = $yummly_categories->set_priority( 10 )
517
- ->set_default( '' )
518
- ->render_HTML_element();
519
-
520
- $yummly_tags = new SWP_Option_Text( __( 'Yummly Tags', 'social-warfare'), 'yummly_tags' );
521
- $tags_html = $yummly_tags->set_priority( 10 )
522
- ->set_default( '' )
523
- ->render_HTML_element();
524
-
525
- //* Table body
526
- $html .= '<div class="sw-grid sw-col-300">';
527
- $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Yummly Terms' ,'social-warfare' ) . '</p>';
528
- $html .= '</div>';
529
-
530
- $html .= '<div class="sw-grid sw-col-300">';
531
- $html .= '<p class="sw-select-label sw-short sw-no-padding">' . $categories_html . '</p>';
532
- $html .= '</div>';
533
-
534
- $html .= '<div class="sw-grid sw-col-300 sw-fit">';
535
- $html .= '<p class="sw-select-label sw-short sw-no-padding">' . $tags_html . '</p>';
536
- $html .= '</div>';
537
-
538
- $html .= '</div>';
539
-
540
- $this->html = $html;
541
-
542
- return $this;
543
- }
544
-
545
-
546
- /**
547
- * The rendering method common to all classes.
548
- *
549
- * Unlike the other option classes, this class creates its HTML and does not immediately
550
- * return it. Instead, it stores the HTML inside itself and waits for the render_html
551
- * method to be called.
552
- *
553
- * @since 3.0.0 | 01 MAR 2018 | Created
554
- * @param void
555
- * @return string The object's saved HTML.
556
- *
557
- */
558
- public function render_HTML() {
559
- return $this->html;
560
- }
561
- }
1
+ <?php
2
+
3
+ /**
4
+ * For creating markup that does not fit into the existing options.
5
+ *
6
+ * This extends SWP_Option rather than SWP_Section because it uses many of the
7
+ * same methods as an option and is a child of a section, even though this is
8
+ * neither necessarily an option or a section.
9
+ *
10
+ * @package SocialWarfare\Functions\Social-Networks
11
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
12
+ * @license GPL-3.0+
13
+ * @since 3.0.0 | 01 MAR 2018 | Created
14
+ *
15
+ */
16
+ class SWP_Section_HTML extends SWP_Option {
17
+
18
+
19
+ /**
20
+ * HTML
21
+ *
22
+ * The non-conformant markup this object represents. Most of the sections and
23
+ * options can be created using one of the existing SWP_{Item} classes.
24
+ * Sometimes we need something that does not fit those boxes. This class
25
+ * provides native methods for a few of those cases, and an add_HTML() method
26
+ * for everything else.
27
+ *
28
+ * @var string $html
29
+ *
30
+ */
31
+ public $html = '';
32
+
33
+
34
+ /**
35
+ * The required constructor for PHP classes.
36
+ *
37
+ * @since 3.0.0 | 01 MAR 2018 | Created
38
+ * @param string $name Required: An arbitrary name, except for do_bitly_authentication_button
39
+ * @param string $key Optional: If the object requires access beyond itself,
40
+ * pass it a key. Otherwise $name will be used.
41
+ * @return void
42
+ * @see $this->do_bitly_authentication_button()
43
+ *
44
+ */
45
+ public function __construct( $name, $key = null ) {
46
+ $key = $key === null ? $name : $key;
47
+
48
+ parent::__construct( $name, $key );
49
+
50
+ $this->html = '';
51
+ }
52
+
53
+
54
+ /**
55
+ * Allows custom HTML to be added.
56
+ *
57
+ * @since 3.0.0 | 01 MAR 2018 | Created
58
+ * @param string $html Required: The fully qualified, ready-to-print HTML to display.
59
+ * @return object $this This object for method chaining.
60
+ *
61
+ */
62
+ public function add_HTML( $html ) {
63
+ if ( !is_string( $html) ) :
64
+ $this->_throw( 'This requires a string of HTML!' );
65
+ endif;
66
+
67
+ $this->html .= $html;
68
+
69
+ return $this;
70
+ }
71
+
72
+
73
+ /**
74
+ * A method for creating the admin sidebar HTML.
75
+ *
76
+ * @since 3.0.0 | 01 MAR 2018 | Created
77
+ * @param void
78
+ * @return string The compiled HTML returned as a string.
79
+ *
80
+ */
81
+ public function do_admin_sidebar() {
82
+ $status_title = __( 'Press Ctrl+C to Copy this information.' , 'social-warfare' );
83
+ $support_link = __( 'Need help? Check out our <a href="https://warfareplugins.com/support/" target="_blank">Knowledgebase.' , 'social-warfare' );
84
+ $support_status = __( 'Opening a support ticket? Copy your System Status by clicking the button below.' , 'social-warfare' );
85
+ $get_status = __( 'Get System Status' , 'social-warfare' );
86
+ ob_start();
87
+ ?>
88
+
89
+ <div class="sw-admin-sidebar sw-grid sw-col-220 sw-fit">
90
+ <a href="https://warfareplugins.com/affiliates/" target="_blank"><img src="<?= SWP_PLUGIN_URL ?>/images/admin-options-page/affiliate-300x150.jpg"></a>
91
+ <a href="https://warfareplugins.com/support-categories/getting-started/" target="_blank"><img src="<?= SWP_PLUGIN_URL ?>/images/admin-options-page/starter-guide-300x150.jpg"></a>
92
+ <a href="https://warfareplugins.com/how-to-measure-social-media-roi-using-google-analytics/" target="_blank"><img src="<?= SWP_PLUGIN_URL ?>/images/admin-options-page/measure-roi-300x150.jpg"></a>
93
+ <p class="sw-support-notice sw-italic"><?= $support_link ?></a></p>
94
+ <p class="sw-support-notice sw-italic"><?= $support_status ?></p>
95
+ <a href="#" class="button sw-blue-button sw-system-status"><?= $get_status ?></a>
96
+
97
+ <!-- Sytem Status Container -->
98
+ <div class="sw-clearfix"></div>
99
+ <div class="system-status-wrapper">
100
+ <h4><?= $status_title ?></h4>
101
+ <div class="system-status-container"><?= $this->system_status() ?></div>
102
+ </div>
103
+ </div>
104
+
105
+ <?php
106
+
107
+ $this->html = ob_get_contents();
108
+ ob_end_clean();
109
+
110
+ return $this->html;
111
+ }
112
+
113
+
114
+ /**
115
+ * A method for compiling the system status html.
116
+ *
117
+ * @since 3.0.0 | 01 MAR 2018 | Created
118
+ * @param void
119
+ * @return string The compiled html returned as a string.
120
+ *
121
+ */
122
+ private function system_status() {
123
+ /**
124
+ * System Status Generator
125
+ */
126
+ global $swp_user_options;
127
+
128
+ if ( ! function_exists( 'get_plugins' ) ) {
129
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
130
+ }
131
+
132
+ $plugins = get_plugins();
133
+ $pluginList = '';
134
+
135
+ foreach ( $plugins as $plugin ) :
136
+ $pluginList .= '<tr><td><b>' . $plugin['Name'] . '</b></td><td>' . $plugin['Version'] . '</td></tr>';
137
+ endforeach;
138
+
139
+ if ( function_exists( 'fsockopen' ) ) :
140
+ $fsockopen = '<span style="color:green;">Enabled</span>';
141
+ else :
142
+ $fsockopen = '<span style="color:red;">Disabled</span>';
143
+ endif;
144
+
145
+ if ( function_exists( 'curl_version' ) ) :
146
+ $curl_version = curl_version();
147
+ $curl_status = '<span style="color:green;">Enabled: v' . $curl_version['version'] . '</span>';
148
+ else :
149
+ $curl_status = '<span style="color:red;">Disabled</span>';
150
+ endif;
151
+
152
+ $theme = wp_get_theme();
153
+
154
+ $system_status = '
155
+ <table style="width:100%;">
156
+ <tr><td><h2>Environment Statuses</h2></td><td></td></tr>
157
+ <tr><td><b>Home URL</b></td><td>' . get_home_url() . '</td></tr>
158
+ <tr><td><b>Site URL</b></td><td>' . get_site_url() . '</td></tr>
159
+ <tr><td><b>WordPress Version</b></td><td>' . get_bloginfo( 'version' ) . '</td></tr>
160
+ <tr><td><b>PHP Version</b></td><td>' . phpversion() . '</td></tr>
161
+ <tr><td><b>WP Memory Limit</b></td><td>' . WP_MEMORY_LIMIT . '</td></tr>
162
+ <tr><td><b>Social Warfare Version</b></td><td>' . SWP_VERSION . '</td></tr>
163
+ <tr><td><h2>Connection Statuses</h2></td><td></td></tr>
164
+ <tr><td><b>fsockopen</b></td><td>' . $fsockopen . '</td></tr>
165
+ <tr><td><b>cURL</b></td><td>' . $curl_status . '</td></tr>
166
+ <tr><td><h2>Plugin Statuses</h2></td><td></td></tr>
167
+ <tr><td><b>Theme Name</b></td><td>' . $theme['Name'] . '</td></tr>
168
+ <tr><td><b>Theme Version</b></td><td>' . $theme['Version'] . '</td></tr>
169
+ <tr><td><b>Caching Method</b></td><td>' . ucfirst($swp_user_options['cache_method']) . '</td></tr>
170
+ <tr><td><b>Active Plugins</b></td><td></td></tr>
171
+ <tr><td><b>Number of Active Plugins</b></td><td>' . count( $plugins ) . '</td></tr>
172
+ ' . $pluginList . '
173
+ </table>
174
+ ';
175
+
176
+ return $system_status;
177
+ }
178
+
179
+
180
+ /**
181
+ * A method for compiling the tweet count registration html.
182
+ *
183
+ * @since 3.0.0 | 01 MAR 2018 | Created
184
+ * @param void
185
+ * @return string The compiled html returned as a string.
186
+ *
187
+ */
188
+ public function do_tweet_count_registration() {
189
+ global $swp_user_options;
190
+
191
+ // Check for a default value
192
+ if ( isset( $swp_user_options['twitter_shares'] ) && $swp_user_options['twitter_shares'] == true ) :
193
+ $status = 'on';
194
+ $selected = 'checked';
195
+ elseif ( isset( $swp_user_options['twitter_shares'] ) && $swp_user_options['twitter_shares'] == false ) :
196
+ $status = 'off';
197
+ $selected = '';
198
+ else :
199
+ $status = 'off';
200
+ $selected = '';
201
+ endif;
202
+
203
+
204
+ $html = '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $this->key . '_wrapper" ' . $this->render_dependency() . '>';
205
+
206
+ // Begin Registration Wrapper
207
+ $html .= '<div class="tweet-count-wrapper" registration="false">';
208
+
209
+ // Open the IS NOT Activated container
210
+ $html .= '<div class="sw-grid sw-col-940 swp_tweets_not_activated">';
211
+
212
+ // The Warning Notice & Instructions
213
+ $html .= '<p class="sw-subtitle sw-registration-text sw-italic">Step 1: <a style="float:none;" class="button sw-navy-button" href="https://opensharecount.com" target="_blank">' . __( 'Click here to visit OpenShareCount.com (Recommended)' , 'social-warfare' ) . '</a>&nbsp;<a style="float:none;" class="button sw-navy-button" href="http://newsharecounts.com" target="_blank">' . __( 'Click here to visit NewShareCounts.com' , 'social-warfare' ) . '</a><br />' . __( 'Step 2: Follow the prompts on their website to create an account and add your domain to be tracked for share counts.' , 'social-warfare' ) . '<br />' . __( 'Step 3: Flip the switch below to "ON", select which tracking service the plugin should use, then save your changes.' , 'social-warfare' ) . '</p>';
214
+
215
+ // Close the IS NOT ACTIVATED container
216
+ $html .= '</div>';
217
+
218
+ // Checkbox Module
219
+ $html .= '<div class="sw-grid sw-col-300"><p class="sw-checkbox-label">Tweet Counts</p></div>';
220
+ $html .= '<div class="sw-grid sw-col-300">';
221
+ $html .= '<div class="sw-checkbox-toggle" status="' . $status . '" field="#twitter_shares"><div class="sw-checkbox-on">' . __( 'ON' , 'social-warfare' ) . '</div><div class="sw-checkbox-off">' . __( 'OFF' , 'social-warfare' ) . '</div></div>';
222
+ $html .= '<input type="checkbox" class="sw-hidden" name="twitter_shares" id="twitter_shares" ' . $selected . ' />';
223
+ $html .= '</div>';
224
+ $html .= '<div class="sw-grid sw-col-300 sw-fit"></div>';
225
+
226
+ // Close the Registration Wrapper
227
+ $html .= '</div>';
228
+
229
+ $html .= '</div>';
230
+
231
+ $this->html = $html;
232
+
233
+ return $html;
234
+ }
235
+
236
+
237
+ /**
238
+ * Render the Bitly connection button on the Advanced tab.
239
+ *
240
+ * @since 3.0.0 | 01 MAR 2018 | Created
241
+ * @param void
242
+ * @return object $this The calling instance, for method chaining.
243
+ *
244
+ */
245
+ public function do_bitly_authentication_button() {
246
+ $link = "https://bitly.com/oauth/authorize?client_id=96c9b292c5503211b68cf4ab53f6e2f4b6d0defb&state=" . admin_url( 'admin-ajax.php' ) . "&redirect_uri=https://warfareplugins.com/bitly_oauth.php";
247
+
248
+ if ( swp_get_option('bitly_access_token') ):
249
+ $text = __( 'Connected', 'social-warfare' );
250
+ $color = 'sw-green-button';
251
+ else:
252
+ $text = __( 'Authenticate', 'social-warfare' );
253
+ $color = 'sw-navy-button';
254
+ endif;
255
+
256
+ ob_start() ?>
257
+
258
+ <div class="sw-grid sw-col-940 sw-fit sw-option-container <?= $this->key ?> '_wrapper" data-dep="bitly_authentication" data-dep_val="[true]">
259
+ <div class="sw-grid sw-col-300">
260
+ <p class="sw-authenticate-label"><?php __( 'Bitly Link Shortening', 'social-warfare' ) ?></p>
261
+ </div>
262
+ <div class="sw-grid sw-col-300">
263
+ <a class="button <?= $color ?>" href="<?= $link ?>"><?= $text ?></a>
264
+ </div>
265
+ <div class="sw-grid sw-col-300 sw-fit"></div>
266
+ </div>
267
+
268
+ <?php
269
+
270
+ $this->html = ob_get_contents();
271
+ ob_end_clean();
272
+
273
+ return $this;
274
+ }
275
+
276
+
277
+ /**
278
+ * The buttons preview as shown on the Display tab.
279
+ *
280
+ * @since 3.0.0 | 01 MAR 2018 | Created
281
+ * @param void
282
+ * @return object $this The calling instance, for method chaining.
283
+ *
284
+ */
285
+ public function do_buttons_preview() {
286
+ ob_start() ?>
287
+
288
+ <div class="swp_social_panel swp_flat_fresh swp_default_full_color swp_individual_full_color swp_other_medium_gray" data-position="both" data-count="6" data-floatcolor="#ffffff" data-scale="1" data-align="full_width">
289
+ <div class="nc_tweetContainer swp_google_plus" data-id="2">
290
+ <a target="_blank" href="https://plus.google.com/share?url=http%3A%2F%2Fwfa.re%2F1W28voz" data-link="https://plus.google.com/share?url=http%3A%2F%2Fwfa.re%2F1W28voz" class="nc_tweet">
291
+ <span class="iconFiller">
292
+ <span class="spaceManWilly">
293
+ <i class="sw swp_google_plus_icon"></i>
294
+ <span class="swp_share"><?php __( '+1','social-warfare' ) ?></span>
295
+ </span>
296
+ </span>
297
+ <span class="swp_count">1.2K</span>
298
+ </a>
299
+ </div>
300
+ <div class="nc_tweetContainer swp_twitter" data-id="3">
301
+ <a href="https://twitter.com/share?original_referer=/&text=Ultimate+Social+Share+%23WordPress+plugin%21+Beautiful%2C+super+fast+%26+more+http%3A%2F%2Fwarfareplugins.com+pic.twitter.com%2FA2zcCJwZtO&url=/&via=WarfarePlugins" data-link="https://twitter.com/share?original_referer=/&text=Ultimate+Social+Share+%23WordPress+plugin%21+Beautiful%2C+super+fast+%26+more+http%3A%2F%2Fwarfareplugins.com+pic.twitter.com%2FA2zcCJwZtO&url=/&via=WarfarePlugins" class="nc_tweet">
302
+ <span class="iconFiller">
303
+ <span class="spaceManWilly">
304
+ <i class="sw swp_twitter_icon"></i>
305
+ <span class="swp_share"><?php __( 'Tweet','social-warfare' ) ?></span>
306
+ </span>
307
+ </span>
308
+ <span class="swp_count">280</span>
309
+ </a>
310
+ </div>
311
+ <div class="nc_tweetContainer swp_pinterest" data-id="6">
312
+ <a data-link="https://pinterest.com/pin/create/button/?url=https://warfareplugins.com/&media=https%3A%2F%2Fwarfareplugins.com%2Fwp-content%2Fuploads%2Fget-content-shared-735x1102.jpg&description=Customize+your+Pinterest+sharing+options%2C+create+easy+%22click+to+tweet%22+buttons+within+your+blog+posts%2C+beautiful+sharing+buttons+and+more.+Social+Warfare+is+the+ultimate+social+sharing+arsenal+for+WordPress%21" class="nc_tweet" data-count="0">
313
+ <span class="iconFiller">
314
+ <span class="spaceManWilly">
315
+ <i class="sw swp_pinterest_icon"></i>
316
+ <span class="swp_share"><?php __( 'Pin','social-warfare' ) ?></span>
317
+ </span>
318
+ </span>
319
+ <span class="swp_count">104</span>
320
+ </a>
321
+ </div>
322
+ <div class="nc_tweetContainer swp_facebook" data-id="4">
323
+ <a target="_blank" href="https://www.facebook.com/share.php?u=http%3A%2F%2Fwfa.re%2F1W28vov" data-link="https://www.facebook.com/share.php?u=http%3A%2F%2Fwfa.re%2F1W28vov" class="nc_tweet">
324
+ <span class="iconFiller">
325
+ <span class="spaceManWilly">
326
+ <i class="sw swp_facebook_icon"></i>
327
+ <span class="swp_share"><?php __( 'Share','social-warfare' ) ?></span>
328
+ </span>
329
+ </span>
330
+ <span class="swp_count">157</span>
331
+ </a>
332
+ </div>
333
+ <div class="nc_tweetContainer swp_linkedin" data-id="5">
334
+ <a target="_blank" href="https://www.linkedin.com/cws/share?url=http%3A%2F%2Fwfa.re%2F1W28twH" data-link="https://www.linkedin.com/cws/share?url=http%3A%2F%2Fwfa.re%2F1W28twH" class="nc_tweet">
335
+ <span class="iconFiller">
336
+ <span class="spaceManWilly">
337
+ <i class="sw swp_linkedin_icon"></i>
338
+ <span class="swp_share"><?php __( 'Share','social-warfare' ) ?></span>
339
+ </span>
340
+ </span>
341
+ <span class="swp_count">51</span>
342
+ </a>
343
+ </div>
344
+ <div class="nc_tweetContainer total_shares total_sharesalt" data-id="6" >
345
+ <span class="swp_count">
346
+ <span class="swp_label">Shares</span> 1.8K
347
+ </span>
348
+ </div>
349
+ </div>
350
+
351
+ <?php
352
+
353
+ $this->html = ob_get_contents();
354
+ ob_end_clean();
355
+
356
+ return $this;
357
+ }
358
+
359
+
360
+ /**
361
+ * Renders the three column table on the Display tab.
362
+ *
363
+ * @since 3.0.0 | 01 MAR 2018 | Created
364
+ * @since 3.0.4 | 09 MAY 2018 | Added check for is_numeric to avoid throwing errors.
365
+ * @since 3.0.5 | 09 MAY 2018 | Switched to using an iterator. Many post types are
366
+ * being returned with associative keys, not numeric ones.
367
+ * @param void
368
+ * @return object $this The calling instance, for method chaining.
369
+ *
370
+ */
371
+ public function do_button_position_table() {
372
+ $default_types = ['page', 'post', 'home', 'archive_categories'];
373
+ $other_types = get_post_types( ['public' => true, '_builtin' => false ], 'names' );
374
+
375
+ $post_types = array_merge( $default_types, $other_types );
376
+
377
+ $panel_locations = [
378
+ 'above' => __( 'Above the Content', 'social-warfare' ),
379
+ 'below' => __( 'Below the Content', 'social-warfare' ),
380
+ 'both' => __( 'Both Above and Below the Content', 'social-warfare' ),
381
+ 'none' => __( 'None/Manual Placement', 'social-warfare' )
382
+ ];
383
+
384
+ $float_locations = [
385
+ 'on' => __( 'On','social_warfare'),
386
+ 'off' => __( 'Off', 'social_warfare')
387
+ ];
388
+
389
+ $html = '<div class="sw-grid sw-col-940 sw-fit sw-option-container" ';
390
+ $html .= $this->render_dependency();
391
+ $html .= $this->render_premium();
392
+ $html .= '>';
393
+
394
+ $html .= '<div class="sw-grid sw-col-300">';
395
+ $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Post Type' ,'social-warfare' ) . '</p>';
396
+ $html .= '</div>';
397
+ $html .= '<div class="sw-grid sw-col-300">';
398
+ $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Static Buttons' ,'social-warfare' ) . '</p>';
399
+ $html .= '</div>';
400
+ $html .= '<div class="sw-grid sw-col-300 sw-fit">';
401
+ $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Floating Buttons (If Activated)' ,'social-warfare' ) . '</p>';
402
+ $html .= '</div>';
403
+
404
+ $i = 0;
405
+ foreach( $post_types as $index => $post ) {
406
+
407
+ $priority = ($i + 1) * 10; $i++;
408
+
409
+ $html .= '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $post . '_wrapper">';
410
+
411
+ $html .= '<div class="sw-grid sw-col-300">';
412
+ $html .= '<p class="sw-input-label">' . str_replace('_', ' & ', ucfirst($post)) . '</p>';
413
+ $html .= '</div>';
414
+
415
+ $html .= '<div class="sw-grid sw-col-300">';
416
+
417
+ $panel = new SWP_Option_Select( 'Panel '. ucfirst( $post ), 'location_' . $post );
418
+ $panel->set_priority( $priority )
419
+ ->set_size( 'sw-col-300' )
420
+ ->set_choices( $panel_locations )
421
+ ->set_default( 'both' );
422
+
423
+ $html .= $panel->render_HTML_element();
424
+
425
+ $html .= '</div>';
426
+ $html .= '<div class="sw-grid sw-col-300 sw-fit">';
427
+
428
+ if ( $post !== 'home' && $post !== 'archive_categories' ) :
429
+
430
+ $float = new SWP_Option_Select( 'Float ' . ucfirst( $post ), 'float_location_' . $post );
431
+ $float->set_priority( $priority + 5 )
432
+ ->set_size( 'sw-col-300' )
433
+ ->set_choices( $float_locations )
434
+ ->set_default( 'on' );
435
+
436
+ $html .= $float->render_HTML_element();
437
+
438
+ endif;
439
+
440
+ $html .= '</div>';
441
+
442
+ $html .= '</div>';
443
+
444
+ }
445
+
446
+ $html .= '</div>';
447
+
448
+ $this->html = $html;
449
+
450
+ return $this;
451
+ }
452
+
453
+
454
+ /**
455
+ * Creates the Click To Tweet preview for the Styles tab.
456
+ *
457
+ * @since 3.0.0 | 01 MAR 2018 | Created
458
+ * @param void
459
+ * @return object $this The calling instance, for method chaining.
460
+ *
461
+ */
462
+ public function do_ctt_preview() {
463
+ //* Pull these variables out just to make the $html string easier to read.
464
+ $link = "https://twitter.com/share?text=We+couldn%27t+find+one+social+sharing+plugin+that+met+all+of+our+needs%2C+so+we+built+it+ourselves.&amp;url=https://warfareplugins.com&amp;via=warfareplugins";
465
+ $data_link = "https://twitter.com/share?text=We+couldn%27t+find+one+social+sharing+plugin+that+met+all+of+our+needs%2C+so+we+built+it+ourselves.&amp;url=https://wfa.re/1PtqdNM&amp;via=WarfarePlugins";
466
+ $text = "We couldn't find one social sharing plugin that met all of our needs, so we built it ourselves.";
467
+
468
+ $html = '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $this->key . '_wrapper">';
469
+ $html .= '<a class="swp_CTT style1" data-style="style1" href="' . $link . '" data-link="' . $data_link . '" target="_blank">';
470
+ $html .= '<span class="sw-click-to-tweet">';
471
+ $html .= '<span class="sw-ctt-text">' . $text . '</span>';
472
+ $html .= '<span class="sw-ctt-btn">Click To Tweet';
473
+ $html .= '<i class="sw swp_twitter_icon"></i>';
474
+ $html .= '</span>';
475
+ $html .= '</span>';
476
+ $html .= '</a>';
477
+ $html .= '</div>';
478
+
479
+
480
+ $this->html = $html;
481
+
482
+ return $this;
483
+
484
+ }
485
+
486
+
487
+ /**
488
+ * Renders the three column table on the Display tab.
489
+ *
490
+ * @since 3.0.0 | 01 MAR 2018 | Created
491
+ * @param void
492
+ * @return object $this The calling instance, for method chaining.
493
+ *
494
+ */
495
+ public function do_yummly_display() {
496
+ $html = '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $this->key . '_wrapper" ';
497
+ $html .= $this->render_dependency();
498
+ $html .= $this->render_premium();
499
+ $html .= '>';
500
+
501
+
502
+ //* Table headers
503
+ $html .= '<div class="sw-grid sw-col-300">';
504
+ $html .= '<p class="sw-select-label sw-short sw-no-padding"></p>';
505
+ $html .= '</div>';
506
+
507
+ $html .= '<div class="sw-grid sw-col-300">';
508
+ $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Choose Category', 'social-warfare' ) . '</p>';
509
+ $html .= '</div>';
510
+
511
+ $html .= '<div class="sw-grid sw-col-300 sw-fit">';
512
+ $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Choose Tag', 'social-warfare' ) . '</p>';
513
+ $html .= '</div>';
514
+
515
+ $yummly_categories = new SWP_Option_Text( __( 'Yummly Categories', 'social-warfare' ), 'yummly_categories' );
516
+ $categories_html = $yummly_categories->set_priority( 10 )
517
+ ->set_default( '' )
518
+ ->render_HTML_element();
519
+
520
+ $yummly_tags = new SWP_Option_Text( __( 'Yummly Tags', 'social-warfare'), 'yummly_tags' );
521
+ $tags_html = $yummly_tags->set_priority( 10 )
522
+ ->set_default( '' )
523
+ ->render_HTML_element();
524
+
525
+ //* Table body
526
+ $html .= '<div class="sw-grid sw-col-300">';
527
+ $html .= '<p class="sw-select-label sw-short sw-no-padding">' . __( 'Yummly Terms' ,'social-warfare' ) . '</p>';
528
+ $html .= '</div>';
529
+
530
+ $html .= '<div class="sw-grid sw-col-300">';
531
+ $html .= '<p class="sw-select-label sw-short sw-no-padding">' . $categories_html . '</p>';
532
+ $html .= '</div>';
533
+
534
+ $html .= '<div class="sw-grid sw-col-300 sw-fit">';
535
+ $html .= '<p class="sw-select-label sw-short sw-no-padding">' . $tags_html . '</p>';
536
+ $html .= '</div>';
537
+
538
+ $html .= '</div>';
539
+
540
+ $this->html = $html;
541
+
542
+ return $this;
543
+ }
544
+
545
+
546
+ /**
547
+ * The rendering method common to all classes.
548
+ *
549
+ * Unlike the other option classes, this class creates its HTML and does not immediately
550
+ * return it. Instead, it stores the HTML inside itself and waits for the render_html
551
+ * method to be called.
552
+ *
553
+ * @since 3.0.0 | 01 MAR 2018 | Created
554
+ * @param void
555
+ * @return string The object's saved HTML.
556
+ *
557
+ */
558
+ public function render_HTML() {
559
+ return $this->html;
560
+ }
561
+ }
functions/options/SWP_User_Options.php CHANGED
@@ -1,34 +1,34 @@
1
- <?php
2
-
3
- class SWP_User_options {
4
-
5
-
6
- public function __construct() {
7
- get_option('Our_Options_In_The_Database');
8
- $this->remove_unavailable_options();
9
- $this->set_defaults();
10
- }
11
-
12
- /**
13
- * This will compare the User Options in the database against the SWP_Options_Page object. If it does
14
- * not exist in the SWP_Options_Page object, that means that the addon that offered this option is not
15
- * active or not registered so delete it from SWP_User_Options.
16
- *
17
- * But DO NOT remove registration keys or registration timestamps.
18
- *
19
- */
20
- public function remove_unavailable_options() {
21
-
22
- }
23
-
24
- /**
25
- * Instead of a giant array of defaults like we have now, have it sort the options against the SWP_Options_Page object.
26
- * Any User Option that isn't set, simply set it to it's default value.
27
- *
28
- */
29
- public function set_defaults() {
30
-
31
- }
32
-
33
-
34
- }
1
+ <?php
2
+
3
+ class SWP_User_options {
4
+
5
+
6
+ public function __construct() {
7
+ get_option('Our_Options_In_The_Database');
8
+ $this->remove_unavailable_options();
9
+ $this->set_defaults();
10
+ }
11
+
12
+ /**
13
+ * This will compare the User Options in the database against the SWP_Options_Page object. If it does
14
+ * not exist in the SWP_Options_Page object, that means that the addon that offered this option is not
15
+ * active or not registered so delete it from SWP_User_Options.
16
+ *
17
+ * But DO NOT remove registration keys or registration timestamps.
18
+ *
19
+ */
20
+ public function remove_unavailable_options() {
21
+
22
+ }
23
+
24
+ /**
25
+ * Instead of a giant array of defaults like we have now, have it sort the options against the SWP_Options_Page object.
26
+ * Any User Option that isn't set, simply set it to it's default value.
27
+ *
28
+ */
29
+ public function set_defaults() {
30
+
31
+ }
32
+
33
+
34
+ }
functions/social-networks/SWP_Facebook.php CHANGED
@@ -1,197 +1,197 @@
1
- <?php
2
-
3
- /**
4
- * Facebook
5
- *
6
- * Class to add a Facebook share button to the available buttons
7
- *
8
- * @package SocialWarfare\Functions\Social-Networks
9
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
10
- * @license GPL-3.0+
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_Facebook extends SWP_Social_Network {
17
-
18
-
19
- /**
20
- * The Magic __construct Method
21
- *
22
- * This method is used to instantiate the social network object. It does three things.
23
- * First it sets the object properties for each network. Then it adds this object to
24
- * the globally accessible swp_social_networks array. Finally, it fetches the active
25
- * state (does the user have this button turned on?) so that it can be accessed directly
26
- * within the object.
27
- *
28
- * @since 3.0.0 | 06 APR 2018 | Created
29
- * @param none
30
- * @return none
31
- * @access public
32
- *
33
- */
34
- public function __construct() {
35
-
36
- // Update the class properties for this network
37
- $this->name = __( 'Facebook','social-warfare' );
38
- $this->cta = __( 'Share','social-warfare' );
39
- $this->key = 'facebook';
40
- $this->default = 'true';
41
- $this->base_share_url = 'https://www.facebook.com/share.php?u=';
42
-
43
- $this->init_social_network();
44
-
45
- if( true === $this->is_active() ):
46
- $this->register_cache_processes();
47
- endif;
48
-
49
- }
50
-
51
-
52
- /**
53
- * Generate the API Share Count Request URL
54
- *
55
- * @since 1.0.0 | 06 APR 2018 | Created
56
- * @access public
57
- * @param string $url The permalink of the page or post for which to fetch share counts
58
- * @return string $request_url The complete URL to be used to access share counts via the API
59
- *
60
- */
61
- public function get_api_link( $url ) {
62
- return 'https://graph.facebook.com/?fields=og_object{likes.summary(true).limit(0)},share&id=' . $url;
63
- }
64
-
65
-
66
- /**
67
- * Parse the response to get the share count
68
- *
69
- * @since 1.0.0 | 06 APR 2018 | Created
70
- * @access public
71
- * @param string $response The raw response returned from the API request
72
- * @return int $total_activity The number of shares reported from the API
73
- *
74
- */
75
- public function parse_api_response( $response ) {
76
- $formatted_response = json_decode( $response , true);
77
-
78
- if( !empty( $formatted_response['og_object'] ) ) {
79
- $likes = $formatted_response['og_object']['likes']['summary']['total_count'];
80
- } else {
81
- $likes = 0;
82
- }
83
-
84
- if( !empty( $formatted_response['share'] ) ){
85
- $comments = $formatted_response['share']['comment_count'];
86
- $shares = $formatted_response['share']['share_count'];
87
- } else {
88
- $comments = 0;
89
- $shares = 0;
90
- }
91
-
92
- $total = $likes + $comments + $shares;
93
- return $total;
94
- }
95
-
96
-
97
- /**
98
- * Register Cache Processes
99
- *
100
- * This method registered the processes that will need to be run during the
101
- * cache rebuild process. The new caching class (codenames neo-advanced cache
102
- * method) allows us to hook in functions that will run during the cache
103
- * rebuild process by hooking into the swp_cache_rebuild hook.
104
- *
105
- * @since 3.1.0 | 26 JUN 2018 | Created
106
- * @param void
107
- * @return void
108
- *
109
- */
110
- private function register_cache_processes() {
111
-
112
- add_action( 'swp_cache_rebuild', array( $this, 'add_facebook_footer_hook' ), 10, 1 );
113
- add_action( 'wp_ajax_swp_facebook_shares_update', array( $this, 'facebook_shares_update' ) );
114
- add_action( 'wp_ajax_nopriv_swp_facebook_shares_update', array( $this, 'facebook_shares_update' ) );
115
- }
116
-
117
-
118
- /**
119
- * A function to add the Facebook updater to the footer hook.
120
- *
121
- * This is a standalone method because we only want to hook into the footer
122
- * and display the script during the cache rebuild process.
123
- *
124
- * @since 3.1.0 | 25 JUN 2018 | Created
125
- * @param void
126
- * @return void
127
- *
128
- */
129
- public function add_facebook_footer_hook( $post_id ) {
130
- $this->post_id = $post_id;
131
- add_action( 'wp_footer', array( $this, 'print_facebook_script' ) );
132
- }
133
-
134
-
135
- /**
136
- * Output the AJAX/JS for updating Facebook share counts.
137
- *
138
- * @since 3.1.0 | 25 JUN 2018 | Created
139
- * @param void
140
- * @return void Output is printed directly to the screen.
141
- *
142
- */
143
- public function print_facebook_script() {
144
- global $swp_user_options;
145
-
146
- if ( $swp_user_options['recover_shares'] == true ) {
147
- $alternateURL = SWP_Permalink::get_alt_permalink( $this->post_id );
148
- } else {
149
- $alternateURL = false;
150
- }
151
-
152
- echo '<script type="text/javascript">
153
- document.addEventListener("DOMContentLoaded", function() {
154
- var swpButtonsExist = document.getElementsByClassName( "swp_social_panel" ).length > 0;
155
- if (swpButtonsExist) {
156
- swp_admin_ajax = "' . admin_url( 'admin-ajax.php' ) . '";
157
- swp_post_id=' . (int) $this->post_id . ';
158
- swp_post_url= "' . get_permalink() . '";
159
- swp_post_recovery_url = "' . $alternateURL . '";
160
- socialWarfarePlugin.fetchFacebookShares();
161
- }
162
- });
163
- </script>
164
- ';
165
- }
166
-
167
-
168
- /**
169
- * Process the Facebook shares response via admin-ajax.php.
170
- *
171
- * The object will be instantiated by the Cache_Loader class and it will
172
- * then call this method from there.
173
- *
174
- * @since 3.1.0 | 25 JUN 2018 | Created
175
- * @param void
176
- * @return void
177
- *
178
- */
179
- public function facebook_shares_update() {
180
- global $swp_user_options;
181
-
182
- $activity = $_POST['share_counts'];
183
- $post_id = $_POST['post_id'];
184
-
185
- $previous_activity = get_post_meta( $post_id, '_facebook_shares', true );
186
-
187
- if ( $activity > $previous_activity || true === _swp_is_debug('force_new_shares') ) :
188
- delete_post_meta( $post_id, '_facebook_shares' );
189
- update_post_meta( $post_id, '_facebook_shares', $activity );
190
- endif;
191
-
192
- echo 'Logged ' . $activity . ' shares.';
193
-
194
- wp_die();
195
- }
196
-
197
- }
1
+ <?php
2
+
3
+ /**
4
+ * Facebook
5
+ *
6
+ * Class to add a Facebook share button to the available buttons
7
+ *
8
+ * @package SocialWarfare\Functions\Social-Networks
9
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
10
+ * @license GPL-3.0+
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_Facebook extends SWP_Social_Network {
17
+
18
+
19
+ /**
20
+ * The Magic __construct Method
21
+ *
22
+ * This method is used to instantiate the social network object. It does three things.
23
+ * First it sets the object properties for each network. Then it adds this object to
24
+ * the globally accessible swp_social_networks array. Finally, it fetches the active
25
+ * state (does the user have this button turned on?) so that it can be accessed directly
26
+ * within the object.
27
+ *
28
+ * @since 3.0.0 | 06 APR 2018 | Created
29
+ * @param none
30
+ * @return none
31
+ * @access public
32
+ *
33
+ */
34
+ public function __construct() {
35
+
36
+ // Update the class properties for this network
37
+ $this->name = __( 'Facebook','social-warfare' );
38
+ $this->cta = __( 'Share','social-warfare' );
39
+ $this->key = 'facebook';
40
+ $this->default = 'true';
41
+ $this->base_share_url = 'https://www.facebook.com/share.php?u=';
42
+
43
+ $this->init_social_network();
44
+
45
+ if( true === $this->is_active() ):
46
+ $this->register_cache_processes();
47
+ endif;
48
+
49
+ }
50
+
51
+
52
+ /**
53
+ * Generate the API Share Count Request URL
54
+ *
55
+ * @since 1.0.0 | 06 APR 2018 | Created
56
+ * @access public
57
+ * @param string $url The permalink of the page or post for which to fetch share counts
58
+ * @return string $request_url The complete URL to be used to access share counts via the API
59
+ *
60
+ */
61
+ public function get_api_link( $url ) {
62
+ return 'https://graph.facebook.com/?fields=og_object{likes.summary(true).limit(0)},share&id=' . $url;
63
+ }
64
+
65
+
66
+ /**
67
+ * Parse the response to get the share count
68
+ *
69
+ * @since 1.0.0 | 06 APR 2018 | Created
70
+ * @access public
71
+ * @param string $response The raw response returned from the API request
72
+ * @return int $total_activity The number of shares reported from the API
73
+ *
74
+ */
75
+ public function parse_api_response( $response ) {
76
+ $formatted_response = json_decode( $response , true);
77
+
78
+ if( !empty( $formatted_response['og_object'] ) ) {
79
+ $likes = $formatted_response['og_object']['likes']['summary']['total_count'];
80
+ } else {
81
+ $likes = 0;
82
+ }
83
+
84
+ if( !empty( $formatted_response['share'] ) ){
85
+ $comments = $formatted_response['share']['comment_count'];
86
+ $shares = $formatted_response['share']['share_count'];
87
+ } else {
88
+ $comments = 0;
89
+ $shares = 0;
90
+ }
91
+
92
+ $total = $likes + $comments + $shares;
93
+ return $total;
94
+ }
95
+
96
+
97
+ /**
98
+ * Register Cache Processes
99
+ *
100
+ * This method registered the processes that will need to be run during the
101
+ * cache rebuild process. The new caching class (codenames neo-advanced cache
102
+ * method) allows us to hook in functions that will run during the cache
103
+ * rebuild process by hooking into the swp_cache_rebuild hook.
104
+ *
105
+ * @since 3.1.0 | 26 JUN 2018 | Created
106
+ * @param void
107
+ * @return void
108
+ *
109
+ */
110
+ private function register_cache_processes() {
111
+
112
+ add_action( 'swp_cache_rebuild', array( $this, 'add_facebook_footer_hook' ), 10, 1 );
113
+ add_action( 'wp_ajax_swp_facebook_shares_update', array( $this, 'facebook_shares_update' ) );
114
+ add_action( 'wp_ajax_nopriv_swp_facebook_shares_update', array( $this, 'facebook_shares_update' ) );
115
+ }
116
+
117
+
118
+ /**
119
+ * A function to add the Facebook updater to the footer hook.
120
+ *
121
+ * This is a standalone method because we only want to hook into the footer
122
+ * and display the script during the cache rebuild process.
123
+ *
124
+ * @since 3.1.0 | 25 JUN 2018 | Created
125
+ * @param void
126
+ * @return void
127
+ *
128
+ */
129
+ public function add_facebook_footer_hook( $post_id ) {
130
+ $this->post_id = $post_id;
131
+ add_action( 'wp_footer', array( $this, 'print_facebook_script' ) );
132
+ }
133
+
134
+
135
+ /**
136
+ * Output the AJAX/JS for updating Facebook share counts.
137
+ *
138
+ * @since 3.1.0 | 25 JUN 2018 | Created
139
+ * @param void
140
+ * @return void Output is printed directly to the screen.
141
+ *
142
+ */
143
+ public function print_facebook_script() {
144
+ global $swp_user_options;
145
+
146
+ if ( $swp_user_options['recover_shares'] == true ) {
147
+ $alternateURL = SWP_Permalink::get_alt_permalink( $this->post_id );
148
+ } else {
149
+ $alternateURL = false;
150
+ }
151
+
152
+ echo '<script type="text/javascript">
153
+ document.addEventListener("DOMContentLoaded", function() {
154
+ var swpButtonsExist = document.getElementsByClassName( "swp_social_panel" ).length > 0;
155
+ if (swpButtonsExist) {
156
+ swp_admin_ajax = "' . admin_url( 'admin-ajax.php' ) . '";
157
+ swp_post_id=' . (int) $this->post_id . ';
158
+ swp_post_url= "' . get_permalink() . '";
159
+ swp_post_recovery_url = "' . $alternateURL . '";
160
+ socialWarfarePlugin.fetchFacebookShares();
161
+ }
162
+ });
163
+ </script>
164
+ ';
165
+ }
166
+
167
+
168
+ /**
169
+ * Process the Facebook shares response via admin-ajax.php.
170
+ *
171
+ * The object will be instantiated by the Cache_Loader class and it will
172
+ * then call this method from there.
173
+ *
174
+ * @since 3.1.0 | 25 JUN 2018 | Created
175
+ * @param void
176
+ * @return void
177
+ *
178
+ */
179
+ public function facebook_shares_update() {
180
+ global $swp_user_options;
181
+
182
+ $activity = $_POST['share_counts'];
183
+ $post_id = $_POST['post_id'];
184
+
185
+ $previous_activity = get_post_meta( $post_id, '_facebook_shares', true );
186
+
187
+ if ( $activity > $previous_activity || true === _swp_is_debug('force_new_shares') ) :
188
+ delete_post_meta( $post_id, '_facebook_shares' );
189
+ update_post_meta( $post_id, '_facebook_shares', $activity );
190
+ endif;
191
+
192
+ echo 'Logged ' . $activity . ' shares.';
193
+
194
+ wp_die();
195
+ }
196
+
197
+ }
functions/social-networks/SWP_Google_Plus.php CHANGED
@@ -1,46 +1,46 @@
1
- <?php
2
-
3
- /**
4
- * Google Plus
5
- *
6
- * Class to add a Google Plus share button to the available buttons
7
- *
8
- * @package SocialWarfare\Functions\Social-Networks
9
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
10
- * @license GPL-3.0+
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 {
18
-
19
-
20
- /**
21
- * The Magic __construct Method
22
- *
23
- * This method is used to instantiate the social network object. It does three things.
24
- * First it sets the object properties for each network. Then it adds this object to
25
- * the globally accessible swp_social_networks array. Finally, it fetches the active
26
- * state (does the user have this button turned on?) so that it can be accessed directly
27
- * within the object.
28
- *
29
- * @since 3.0.0 | 06 APR 2018 | Created
30
- * @param none
31
- * @return none
32
- * @access public
33
- *
34
- */
35
- public function __construct() {
36
-
37
- // Update the class properties for this network
38
- $this->name = __( 'Google Plus','social-warfare' );
39
- $this->cta = __( '+1','social-warfare' );
40
- $this->key = 'google_plus';
41
- $this->default = 'true';
42
- $this->base_share_url = 'https://plus.google.com/share?url=';
43
-
44
- $this->init_social_network();
45
- }
46
- }
1
+ <?php
2
+
3
+ /**
4
+ * Google Plus
5
+ *
6
+ * Class to add a Google Plus share button to the available buttons
7
+ *
8
+ * @package SocialWarfare\Functions\Social-Networks
9
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
10
+ * @license GPL-3.0+
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 {
18
+
19
+
20
+ /**
21
+ * The Magic __construct Method
22
+ *
23
+ * This method is used to instantiate the social network object. It does three things.
24
+ * First it sets the object properties for each network. Then it adds this object to
25
+ * the globally accessible swp_social_networks array. Finally, it fetches the active
26
+ * state (does the user have this button turned on?) so that it can be accessed directly
27
+ * within the object.
28
+ *
29
+ * @since 3.0.0 | 06 APR 2018 | Created
30
+ * @param none
31
+ * @return none
32
+ * @access public
33
+ *
34
+ */
35
+ public function __construct() {
36
+
37
+ // Update the class properties for this network
38
+ $this->name = __( 'Google Plus','social-warfare' );
39
+ $this->cta = __( '+1','social-warfare' );
40
+ $this->key = 'google_plus';
41
+ $this->default = 'true';
42
+ $this->base_share_url = 'https://plus.google.com/share?url=';
43
+
44
+ $this->init_social_network();
45
+ }
46
+ }
functions/social-networks/SWP_Linkedin.php CHANGED
@@ -1,31 +1,31 @@
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
- }
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
@@ -1,186 +1,186 @@
1
- <?php
2
- /**
3
- * Pinterest
4
- *
5
- * Class to add a Pinterst share button to the available buttons
6
- *
7
- * @package SocialWarfare\Functions\Social-Networks
8
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
9
- * @license GPL-3.0+
10
- * @since 1.0.0 | Unknown | CREATED
11
- * @since 2.2.4 | 02 MAY 2017 | Refactored functions & upinterest_descriptionated docblocking
12
- * @since 3.0.0 | 05 APR 2018 | Rebuilt into a class-based system.
13
- *
14
- */
15
- class SWP_Pinterest extends SWP_Social_Network {
16
-
17
- /**
18
- * The Magic __construct Method
19
- *
20
- * This method is used to instantiate the social network object. It does three things.
21
- * First it sets the object properties for each network. Then it adds this object to
22
- * the globally accessible swp_social_networks array. Finally, it fetches the active
23
- * state (does the user have this button turned on?) so that it can be accessed directly
24
- * within the object.
25
- *
26
- * @since 3.0.0 | 06 APR 2018 | Created
27
- * @param none
28
- * @return none
29
- * @access public
30
- *
31
- */
32
- public function __construct() {
33
- // Upinterest_descriptionate the class properties for this network
34
- $this->name = __( 'Pinterest','social-warfare' );
35
- $this->cta = __( 'Pin','social-warfare' );
36
- $this->key = 'pinterest';
37
- $this->default = 'true';
38
- $this->base_share_url = 'https://pinterest.com/pin/create/button/?url=';
39
- $this->init_social_network();
40
- }
41
-
42
- /**
43
- * Generate the API Share Count Request URL
44
- *
45
- * @since 1.0.0 | 06 APR 2018 | Created
46
- * @access public
47
- * @param string $url The permalink of the page or post for which to fetch share counts
48
- * @return string $request_url The complete URL to be used to access share counts via the API
49
- *
50
- */
51
- public function get_api_link( $url ) {
52
- return 'https://api.pinterest.com/v1/urls/count.json?url=' . $url;
53
- }
54
-
55
- /**
56
- * Parse the response to get the share count
57
- *
58
- * @since 1.0.0 | 06 APR 2018 | Created
59
- * @access public
60
- * @param string $response The raw response returned from the API request
61
- * @return int $total_activity The number of shares reported from the API
62
- *
63
- */
64
- public function parse_api_response( $response ) {
65
- $response = preg_replace( '/^receiveCount\((.*)\)$/', "\\1", $response );
66
- $response = json_decode( $response, true );
67
- return isset( $response['count'] ) ? intval( $response['count'] ) : 0;
68
- }
69
-
70
-
71
- /**
72
- * Create the HTML to display the share button
73
- *
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;
81
- * ['shares'] => share count data
82
- * ['options'] => swp_user_options
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'] );
107
- else :
108
- $pinterest_username = '';
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
-
120
- if ( empty( $pinterest_description ) ) :
121
- $pinterest_description = $title;
122
- endif;
123
-
124
- $pinterest_description .= $pinterest_username;
125
-
126
- if ( !empty( $pinterest_image ) ) :
127
- $anchor = '<a rel="nofollow noreferrer noopener" 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 noreferrer noopener" 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">';
153
- $icon.= '<i class="sw swp_'.$this->key.'_icon"></i>';
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;
167
- // Put the button inside.
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;
178
-
179
- return $html;
180
- }
181
-
182
-
183
- public function generate_share_link( $post_data ) {
184
- return 0;
185
- }
186
- }
1
+ <?php
2
+ /**
3
+ * Pinterest
4
+ *
5
+ * Class to add a Pinterst share button to the available buttons
6
+ *
7
+ * @package SocialWarfare\Functions\Social-Networks
8
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
9
+ * @license GPL-3.0+
10
+ * @since 1.0.0 | Unknown | CREATED
11
+ * @since 2.2.4 | 02 MAY 2017 | Refactored functions & upinterest_descriptionated docblocking
12
+ * @since 3.0.0 | 05 APR 2018 | Rebuilt into a class-based system.
13
+ *
14
+ */
15
+ class SWP_Pinterest extends SWP_Social_Network {
16
+
17
+ /**
18
+ * The Magic __construct Method
19
+ *
20
+ * This method is used to instantiate the social network object. It does three things.
21
+ * First it sets the object properties for each network. Then it adds this object to
22
+ * the globally accessible swp_social_networks array. Finally, it fetches the active
23
+ * state (does the user have this button turned on?) so that it can be accessed directly
24
+ * within the object.
25
+ *
26
+ * @since 3.0.0 | 06 APR 2018 | Created
27
+ * @param none
28
+ * @return none
29
+ * @access public
30
+ *
31
+ */
32
+ public function __construct() {
33
+ // Upinterest_descriptionate the class properties for this network
34
+ $this->name = __( 'Pinterest','social-warfare' );
35
+ $this->cta = __( 'Pin','social-warfare' );
36
+ $this->key = 'pinterest';
37
+ $this->default = 'true';
38
+ $this->base_share_url = 'https://pinterest.com/pin/create/button/?url=';
39
+ $this->init_social_network();
40
+ }
41
+
42
+ /**
43
+ * Generate the API Share Count Request URL
44
+ *
45
+ * @since 1.0.0 | 06 APR 2018 | Created
46
+ * @access public
47
+ * @param string $url The permalink of the page or post for which to fetch share counts
48
+ * @return string $request_url The complete URL to be used to access share counts via the API
49
+ *
50
+ */
51
+ public function get_api_link( $url ) {
52
+ return 'https://api.pinterest.com/v1/urls/count.json?url=' . $url;
53
+ }
54
+
55
+ /**
56
+ * Parse the response to get the share count
57
+ *
58
+ * @since 1.0.0 | 06 APR 2018 | Created
59
+ * @access public
60
+ * @param string $response The raw response returned from the API request
61
+ * @return int $total_activity The number of shares reported from the API
62
+ *
63
+ */
64
+ public function parse_api_response( $response ) {
65
+ $response = preg_replace( '/^receiveCount\((.*)\)$/', "\\1", $response );
66
+ $response = json_decode( $response, true );
67
+ return isset( $response['count'] ) ? intval( $response['count'] ) : 0;
68
+ }
69
+
70
+
71
+ /**
72
+ * Create the HTML to display the share button
73
+ *
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;
81
+ * ['shares'] => share count data
82
+ * ['options'] => swp_user_options
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'] );
107
+ else :
108
+ $pinterest_username = '';
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
+
120
+ if ( empty( $pinterest_description ) ) :
121
+ $pinterest_description = $title;
122
+ endif;
123
+
124
+ $pinterest_description .= $pinterest_username;
125
+
126
+ if ( !empty( $pinterest_image ) ) :
127
+ $anchor = '<a rel="nofollow noreferrer noopener" 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 noreferrer noopener" 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">';
153
+ $icon.= '<i class="sw swp_'.$this->key.'_icon"></i>';
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;
167
+ // Put the button inside.
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;
178
+
179
+ return $html;
180
+ }
181
+
182
+
183
+ public function generate_share_link( $post_data ) {
184
+ return 0;
185
+ }
186
+ }
functions/social-networks/SWP_Social_Network.php CHANGED
@@ -1,506 +1,506 @@
1
- <?php
2
-
3
- /**
4
- * SWP_Social_Network
5
- *
6
- * This is the class that is used for adding new social networks to the
7
- * buttons which can be selected on the options page and rendered in the
8
- * panel of buttons.
9
- *
10
- * @package SocialWarfare\Functions\Social-Networks
11
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
12
- * @license GPL-3.0+
13
- * @since 3.0.0 | 05 APR 2018 | Created
14
- *
15
- */
16
- class SWP_Social_Network {
17
-
18
-
19
- /**
20
- * SWP_Utility_Trait provides useful tool like error handling.
21
- *
22
- */
23
- use SWP_Utility_Trait;
24
-
25
-
26
- /**
27
- * The display name of the social network
28
- *
29
- * This is the 'pretty name' that users will see. It should generally
30
- * reflect the official name of the network according to the way that
31
- * network is publicly branded.
32
- *
33
- * @var string
34
- *
35
- */
36
- public $name = '';
37
-
38
-
39
- /**
40
- * The call to action text.
41
- *
42
- * This is the text that will appear on the button whenever it is
43
- * hovered over. For example, Facebook says "share" and Google Plus
44
- * says "+1".
45
- *
46
- * @var string
47
- *
48
- */
49
- public $cta = '';
50
-
51
-
52
- /**
53
- * The snake_case name of the social network
54
- *
55
- * This is 'ugly name' of the network. This a snake_case key used for
56
- * the purpose of eliminating spaces so that we can save things in the
57
- * database and other such cool things.
58
- *
59
- * @var string
60
- *
61
- */
62
- public $key = '';
63
-
64
-
65
- /**
66
- * The default state of this network
67
- *
68
- * This property will determine where the icon appears in the options page
69
- * prior to the user setting and saving it. If true, it will appear in the
70
- * active section. If false, it will appear in the inactive section. Once
71
- * the user has updated/saved their preferences, this property will no
72
- * longer do anything.
73
- *
74
- * @var bool If true, the button is turned on by default.
75
- *
76
- */
77
- public $default = true;
78
-
79
-
80
- /**
81
- * The premium status of this network
82
- *
83
- * Whether this button is a premium network. An empty string refers to a
84
- * non-premium network. A string containing the key of the premium addon
85
- * to which this is a member is used for premium networks. For example,
86
- * setting this to 'pro' means that it is a premium network dependant on
87
- * the Social Warfare - Pro addon being installed and registered.
88
- *
89
- * @var string
90
- *
91
- */
92
- public $premium = '';
93
-
94
-
95
- /**
96
- * The active status of this network
97
- *
98
- * If the user has this network activated on the options page, then this
99
- * property will be set to true. If not, it will be set to false.
100
- *
101
- * @var bool
102
- *
103
- */
104
- public $active = false;
105
-
106
-
107
- /**
108
- * The generated html for the button
109
- *
110
- * After the first time the HTML is generated, we will store it in this variable
111
- * so that when it is needed for the second or third panel on the page, the render
112
- * html method will not have to make all the computations again.
113
- *
114
- * The html will be stored in an array indexed by post ID's. For example $this->html[27]
115
- * will contain the HTML for this button that was generated for post with 27 as ID.
116
- *
117
- * @var array
118
- *
119
- */
120
- public $html_store = array();
121
-
122
- /**
123
- * The Base URL for the share link
124
- *
125
- * This will allow us to generate the share link for networks that only use just
126
- * one URL parameter, the URL to the post. This way we can use a boilerplate method
127
- * for generating the share links here in the parent class and will only have to
128
- * overwrite that method in child classes that absolutely need it.
129
- *
130
- * @var string
131
- *
132
- */
133
- public $base_share_url = '';
134
-
135
- /**
136
- * Whether or not to show the share count for this network.
137
- *
138
- * @var boolean $show_shares;
139
- */
140
- public $show_shares = false;
141
-
142
-
143
- /**
144
- * A method to add this network object to the globally accessible array.
145
- *
146
- * @since 3.0.0 | 06 APR 2018 | Created
147
- * @param none
148
- * @return none
149
- * @access public
150
- *
151
- */
152
- public function add_to_global() {
153
-
154
- global $swp_social_networks;
155
- $swp_social_networks[$this->key] = $this;
156
-
157
- }
158
-
159
-
160
- /**
161
- * A function to run when the object is instantiated.
162
- *
163
- * @since 3.0.0 | 06 APR 2018 | Created
164
- * @param none
165
- * @return none
166
- * @access public
167
- *
168
- */
169
- public function init_social_network() {
170
- $this->add_to_global();
171
- $this->set_active_state();
172
- }
173
-
174
-
175
- /**
176
- * A method for providing the object with a name.
177
- *
178
- * @since 3.0.0 | 05 APR 2018 | Created
179
- * @param string $value The name of the object.
180
- * @return object $this Allows chaining of methods.
181
- * @access public
182
- *
183
- */
184
- public function set_name( $value ) {
185
-
186
- if ( !is_string( $value ) || empty( $value ) ) {
187
- $this->_throw("Please provide a string for your object's name." );
188
- }
189
-
190
- $this->name = $value;
191
-
192
- return $this;
193
- }
194
-
195
-
196
- /**
197
- * A method for updating this network's default property.
198
- *
199
- * @since 3.0.0 | 05 APR 2018 | Created
200
- * @param bool $value The default status of the network.
201
- * @return object $this Allows chaining of methods.
202
- * @access public
203
- *
204
- */
205
- public function set_default( $value ) {
206
- if ( !is_bool( $value ) || empty( $value ) ) {
207
- $this->_throw("Please provide a boolean value for your object's default state." );
208
- }
209
-
210
- $this->default = $value;
211
-
212
- return $this;
213
- }
214
-
215
-
216
- /**
217
- * A method for updating this network's key property.
218
- *
219
- * @since 3.0.0 | 05 APR 2018 | Created
220
- * @param string $value The key for the network.
221
- * @return object $this Allows chaining of methods.
222
- * @access public
223
- *
224
- */
225
- public function set_key( $value ) {
226
-
227
- if ( !is_string( $value ) || empty( $value ) ) {
228
- $this->_throw( 'Please provide a snake_case string for the key value.' );
229
- }
230
-
231
- $this->key = $value;
232
- return $this;
233
- }
234
-
235
-
236
- /**
237
- * A method for updating this network's premium property.
238
- *
239
- * @since 3.0.0 | 05 APR 2018 | Created
240
- * @param string $value A string corresponding to the key of the dependant premium addon.
241
- * @return object $this Allows chaining of methods.
242
- * @access public
243
- *
244
- */
245
- public function set_premium( $value ) {
246
-
247
- if ( !is_string( $value ) || empty( $value ) ) {
248
- $this->_throw( 'Please provide a string corresponding to the premium addon to which this network depends.' );
249
- }
250
-
251
- $this->premium = $value;
252
- return $this;
253
- }
254
-
255
-
256
- /**
257
- * A method to return the 'active' status of this network.
258
- *
259
- * @since 3.0.0 | 06 APR 2018 | Created
260
- * @param none
261
- * @return bool
262
- * @access public
263
- *
264
- */
265
- public function is_active() {
266
- return $this->active;
267
- }
268
-
269
-
270
- /**
271
- * A method to set the 'active' status of this network.
272
- *
273
- * @since 3.0.0 | 06 APR 2018 | Created
274
- * @param none
275
- * @return none
276
- * @access public
277
- *
278
- */
279
- public function set_active_state() {
280
- global $swp_user_options;
281
- if ( isset( $swp_user_options['order_of_icons'][$this->key] ) ) {
282
- $this->active = true;
283
- }
284
- }
285
-
286
-
287
- /**
288
- * A method to save the generated HTML. This allows us to not have to
289
- * run all of the computations every time. Instead, just reuse the HTML
290
- * that was rendered by the method the first time it was created.
291
- *
292
- * @since 3.0.0 | 06 APR 2018 | Created
293
- * @param string $html The string of HTML to save in this property.
294
- * @param int $post_id The ID of the post that this belongs to.
295
- * @return none
296
- * @access public
297
- *
298
- */
299
- public function save_html( $html , $post_id ) {
300
- $this->html_store[$post_id] = $html;
301
- }
302
-
303
- /**
304
- * Show Share Counts?
305
- *
306
- * A method to determine whether or not share counts need to be shown
307
- * while rendering the HTML for this network's button.
308
- *
309
- * @since 3.0.0 | 06 APR 2018 | Created
310
- * @param array $array The array of data from the buttons panel.
311
- * @return bool
312
- * @access public
313
- * @TODO Make it accept two parameters, both arrays, $options and $share_counts.
314
- *
315
- */
316
- public function is_share_count_shown( $array ) {
317
-
318
- // If the shares value isn't set, don't show the share count.
319
- if( !isset( $array['shares'][$this->key] )):
320
- return false;
321
-
322
- // If the global button level shares are turned off, don't show the share count.
323
- elseif( !$array['options']['network_shares'] ):
324
- return false;
325
-
326
- // If the total shares haven't yet exceeded the minimum set in the options, don't show the share count.
327
- elseif( $array['shares']['total_shares'] < $array['options']['minimum_shares']):
328
- return false;
329
-
330
- // If the share count is literally 0, don't show the share count.
331
- elseif( $array['shares'][$this->key] <= 0 ):
332
- return false;
333
-
334
- // Show the share count.
335
- else:
336
- return true;
337
- endif;
338
- }
339
-
340
-
341
- /**
342
- * Create the HTML to display the share button
343
- *
344
- * @since 1.0.0
345
- * @access public
346
- * @param array $network_counts Associative array of 'network_key' => 'count_value'
347
- * @return array $array The modified array which will now contain the html for this button
348
- * @todo Eliminate the array
349
- *
350
- */
351
- public function render_HTML( $panel_context , $echo = false ) {
352
-
353
- $post_data = $panel_context['post_data'];
354
- $share_counts = $panel_context['shares'];
355
- $options = $panel_context['options'];
356
-
357
- $share_link = $this->generate_share_link( $post_data );
358
-
359
- // Build the button.
360
- $icon = '<span class="iconFiller">';
361
- $icon.= '<span class="spaceManWilly">';
362
- $icon.= '<i class="sw swp_'.$this->key.'_icon"></i>';
363
- $icon.= '<span class="swp_share">' . $this->cta . '</span>';
364
- $icon .= '</span>';
365
- $icon .= '</span>';
366
-
367
- if ( true === $this->are_shares_shown( $share_counts , $options ) ) :
368
- $icon .= '<span class="swp_count">' . swp_kilomega( $share_counts[$this->key] ) . '</span>';
369
- else :
370
- $icon = '<span class="swp_count swp_hide">' . $icon . '</span>';
371
- endif;
372
-
373
- // Build the wrapper.
374
- $html = '<div class="nc_tweetContainer swp_'.$this->key.'" data-network="'.$this->key.'">';
375
- $html .= '<a rel="nofollow noreferrer noopener" target="_blank" href="' . $share_link . '" data-link="' . $share_link . '" class="nc_tweet">';
376
- // Put the button inside.
377
- $html .= $icon;
378
- $html.= '</a>';
379
- $html.= '</div>';
380
-
381
- // Store these buttons so that we don't have to generate them for each set
382
- $this->html = $html;
383
-
384
- if ( $echo ) :
385
- echo $html;
386
- endif;
387
-
388
- return $html;
389
-
390
- }
391
-
392
-
393
- /**
394
- * Are Shares Shown?
395
- *
396
- * This function returns a boolean letting the render_html method know
397
- * if we are supposed to be showing the share count or not.
398
- *
399
- * @since 3.0.0 | 18 APR 2018 | Created
400
- * @param array $share_counts The array of share counts
401
- * @param array $options The array of options from the button panel object.
402
- * @return bool Do we show the share counts?
403
- *
404
- */
405
- public function are_shares_shown( $share_counts , $options ) {
406
-
407
- // False if the share count is empty
408
- if ( empty( $share_counts[$this->key] ) ) :
409
- return false;
410
-
411
- // False if the total share count is below the minimum
412
- elseif( $share_counts['total_shares'] < $options['minimum_shares'] ):
413
- return false;
414
-
415
- // False if the share count is zero.
416
- elseif( $share_counts[$this->key] = 0 ):
417
- return false;
418
-
419
- // False if network shares are turned off in the options.
420
- elseif( false == $options['network_shares'] ):
421
- return false;
422
-
423
- else :
424
- return true;
425
- endif;
426
-
427
- return $this;
428
- }
429
-
430
-
431
- /**
432
- * A method for processing URL's.
433
- *
434
- * This is designed to process the URL that is being shared onto the social
435
- * platorms. It takes care of encoding, UTM parameters, link shortening, etc.
436
- *
437
- * @since 3.0.0 | 06 APR 2018 | Created
438
- * @param array $array The array of data from the buttons panel.
439
- * @return string The processed URL.
440
- *
441
- */
442
- public function get_shareable_permalink( $post_data ) {
443
- return urlencode( urldecode( SWP_URL_Management::process_url( $post_data['permalink'] , $this->key , $post_data['ID'] ) ) );
444
- }
445
-
446
-
447
- /**
448
- * Generate the share link
449
- *
450
- * This is the link that is being clicked on which will open up the share
451
- * dialogue. Thie method is only used for networks that use this exact same pattern.
452
- * For anything that accepts more than just the post permalink as a URL parameter,
453
- * those networks will have to overwrite this method with their own custom method
454
- * in their respective child classes.
455
- *
456
- * @since 3.0.0 | 08 APR 2018 | Created
457
- * @param array $array The array of information passed in from the buttons panel.
458
- * @return string The generated link
459
- * @access public
460
- *
461
- */
462
- public function generate_share_link( $post_data ) {
463
- $share_link = $this->base_share_url . $this->get_shareable_permalink( $post_data );
464
- return $share_link;
465
- }
466
-
467
-
468
- /**
469
- * Generate the API Share Count Request URL
470
- *
471
- * For most social networks, the api link is unique and this method will need to be
472
- * overwritten in their respective child classes. However, for any networks that do
473
- * not support share counts, having the method here in the parent class will allow
474
- * us to simply use this one without have to write a new one in each child class.
475
- *
476
- * @since 3.0.0 | 08 APR 2018 | Created
477
- * @access public
478
- * @param string $url The permalink of the page or post for which to fetch share counts
479
- * @return string $request_url The complete URL to be used to access share counts via the API
480
- *
481
- */
482
- public function get_api_link( $url ) {
483
- return 0;
484
- }
485
-
486
-
487
- /**
488
- * Parse the response to get the share count
489
- *
490
- * For most social networks, parsing of the API response needs to be a unique method
491
- * that is declared in each network's child class. However, we are including it here
492
- * for all networks that do not support share counts at all. If a network does not
493
- * support share count fetching, then it can just use the method defined here in the
494
- * parent class.
495
- *
496
- * @since 3.0.0 | 08 APR 2018 | Created
497
- * @access public
498
- * @param string $response The raw response returned from the API request
499
- * @return int $total_activity The number of shares reported from the API
500
- *
501
- */
502
- public function parse_api_response( $response ) {
503
- return 0;
504
- }
505
-
506
- }
1
+ <?php
2
+
3
+ /**
4
+ * SWP_Social_Network
5
+ *
6
+ * This is the class that is used for adding new social networks to the
7
+ * buttons which can be selected on the options page and rendered in the
8
+ * panel of buttons.
9
+ *
10
+ * @package SocialWarfare\Functions\Social-Networks
11
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
12
+ * @license GPL-3.0+
13
+ * @since 3.0.0 | 05 APR 2018 | Created
14
+ *
15
+ */
16
+ class SWP_Social_Network {
17
+
18
+
19
+ /**
20
+ * SWP_Utility_Trait provides useful tool like error handling.
21
+ *
22
+ */
23
+ use SWP_Utility_Trait;
24
+
25
+
26
+ /**
27
+ * The display name of the social network
28
+ *
29
+ * This is the 'pretty name' that users will see. It should generally
30
+ * reflect the official name of the network according to the way that
31
+ * network is publicly branded.
32
+ *
33
+ * @var string
34
+ *
35
+ */
36
+ public $name = '';
37
+
38
+
39
+ /**
40
+ * The call to action text.
41
+ *
42
+ * This is the text that will appear on the button whenever it is
43
+ * hovered over. For example, Facebook says "share" and Google Plus
44
+ * says "+1".
45
+ *
46
+ * @var string
47
+ *
48
+ */
49
+ public $cta = '';
50
+
51
+
52
+ /**
53
+ * The snake_case name of the social network
54
+ *
55
+ * This is 'ugly name' of the network. This a snake_case key used for
56
+ * the purpose of eliminating spaces so that we can save things in the
57
+ * database and other such cool things.
58
+ *
59
+ * @var string
60
+ *
61
+ */
62
+ public $key = '';
63
+
64
+
65
+ /**
66
+ * The default state of this network
67
+ *
68
+ * This property will determine where the icon appears in the options page
69
+ * prior to the user setting and saving it. If true, it will appear in the
70
+ * active section. If false, it will appear in the inactive section. Once
71
+ * the user has updated/saved their preferences, this property will no
72
+ * longer do anything.
73
+ *
74
+ * @var bool If true, the button is turned on by default.
75
+ *
76
+ */
77
+ public $default = true;
78
+
79
+
80
+ /**
81
+ * The premium status of this network
82
+ *
83
+ * Whether this button is a premium network. An empty string refers to a
84
+ * non-premium network. A string containing the key of the premium addon
85
+ * to which this is a member is used for premium networks. For example,
86
+ * setting this to 'pro' means that it is a premium network dependant on
87
+ * the Social Warfare - Pro addon being installed and registered.
88
+ *
89
+ * @var string
90
+ *
91
+ */
92
+ public $premium = '';
93
+
94
+
95
+ /**
96
+ * The active status of this network
97
+ *
98
+ * If the user has this network activated on the options page, then this
99
+ * property will be set to true. If not, it will be set to false.
100
+ *
101
+ * @var bool
102
+ *
103
+ */
104
+ public $active = false;
105
+
106
+
107
+ /**
108
+ * The generated html for the button
109
+ *
110
+ * After the first time the HTML is generated, we will store it in this variable
111
+ * so that when it is needed for the second or third panel on the page, the render
112
+ * html method will not have to make all the computations again.
113
+ *
114
+ * The html will be stored in an array indexed by post ID's. For example $this->html[27]
115
+ * will contain the HTML for this button that was generated for post with 27 as ID.
116
+ *
117
+ * @var array
118
+ *
119
+ */
120
+ public $html_store = array();
121
+
122
+ /**
123
+ * The Base URL for the share link
124
+ *
125
+ * This will allow us to generate the share link for networks that only use just
126
+ * one URL parameter, the URL to the post. This way we can use a boilerplate method
127
+ * for generating the share links here in the parent class and will only have to
128
+ * overwrite that method in child classes that absolutely need it.
129
+ *
130
+ * @var string
131
+ *
132
+ */
133
+ public $base_share_url = '';
134
+
135
+ /**
136
+ * Whether or not to show the share count for this network.
137
+ *
138
+ * @var boolean $show_shares;
139
+ */
140
+ public $show_shares = false;
141
+
142
+
143
+ /**
144
+ * A method to add this network object to the globally accessible array.
145
+ *
146
+ * @since 3.0.0 | 06 APR 2018 | Created
147
+ * @param none
148
+ * @return none
149
+ * @access public
150
+ *
151
+ */
152
+ public function add_to_global() {
153
+
154
+ global $swp_social_networks;
155
+ $swp_social_networks[$this->key] = $this;
156
+
157
+ }
158
+
159
+
160
+ /**
161
+ * A function to run when the object is instantiated.
162
+ *
163
+ * @since 3.0.0 | 06 APR 2018 | Created
164
+ * @param none
165
+ * @return none
166
+ * @access public
167
+ *
168
+ */
169
+ public function init_social_network() {
170
+ $this->add_to_global();
171
+ $this->set_active_state();
172
+ }
173
+
174
+
175
+ /**
176
+ * A method for providing the object with a name.
177
+ *
178
+ * @since 3.0.0 | 05 APR 2018 | Created
179
+ * @param string $value The name of the object.
180
+ * @return object $this Allows chaining of methods.
181
+ * @access public
182
+ *
183
+ */
184
+ public function set_name( $value ) {
185
+
186
+ if ( !is_string( $value ) || empty( $value ) ) {
187
+ $this->_throw("Please provide a string for your object's name." );
188
+ }
189
+
190
+ $this->name = $value;
191
+
192
+ return $this;
193
+ }
194
+
195
+
196
+ /**
197
+ * A method for updating this network's default property.
198
+ *
199
+ * @since 3.0.0 | 05 APR 2018 | Created
200
+ * @param bool $value The default status of the network.
201
+ * @return object $this Allows chaining of methods.
202
+ * @access public
203
+ *
204
+ */
205
+ public function set_default( $value ) {
206
+ if ( !is_bool( $value ) || empty( $value ) ) {
207
+ $this->_throw("Please provide a boolean value for your object's default state." );
208
+ }
209
+
210
+ $this->default = $value;
211
+
212
+ return $this;
213
+ }
214
+
215
+
216
+ /**
217
+ * A method for updating this network's key property.
218
+ *
219
+ * @since 3.0.0 | 05 APR 2018 | Created
220
+ * @param string $value The key for the network.
221
+ * @return object $this Allows chaining of methods.
222
+ * @access public
223
+ *
224
+ */
225
+ public function set_key( $value ) {
226
+
227
+ if ( !is_string( $value ) || empty( $value ) ) {
228
+ $this->_throw( 'Please provide a snake_case string for the key value.' );
229
+ }
230
+
231
+ $this->key = $value;
232
+ return $this;
233
+ }
234
+
235
+
236
+ /**
237
+ * A method for updating this network's premium property.
238
+ *
239
+ * @since 3.0.0 | 05 APR 2018 | Created
240
+ * @param string $value A string corresponding to the key of the dependant premium addon.
241
+ * @return object $this Allows chaining of methods.
242
+ * @access public
243
+ *
244
+ */
245
+ public function set_premium( $value ) {
246
+
247
+ if ( !is_string( $value ) || empty( $value ) ) {
248
+ $this->_throw( 'Please provide a string corresponding to the premium addon to which this network depends.' );
249
+ }
250
+
251
+ $this->premium = $value;
252
+ return $this;
253
+ }
254
+
255
+
256
+ /**
257
+ * A method to return the 'active' status of this network.
258
+ *
259
+ * @since 3.0.0 | 06 APR 2018 | Created
260
+ * @param none
261
+ * @return bool
262
+ * @access public
263
+ *
264
+ */
265
+ public function is_active() {
266
+ return $this->active;
267
+ }
268
+
269
+
270
+ /**
271
+ * A method to set the 'active' status of this network.
272
+ *
273
+ * @since 3.0.0 | 06 APR 2018 | Created
274
+ * @param none
275
+ * @return none
276
+ * @access public
277
+ *
278
+ */
279
+ public function set_active_state() {
280
+ global $swp_user_options;
281
+ if ( isset( $swp_user_options['order_of_icons'][$this->key] ) ) {
282
+ $this->active = true;
283
+ }
284
+ }
285
+
286
+
287
+ /**
288
+ * A method to save the generated HTML. This allows us to not have to
289
+ * run all of the computations every time. Instead, just reuse the HTML
290
+ * that was rendered by the method the first time it was created.
291
+ *
292
+ * @since 3.0.0 | 06 APR 2018 | Created
293
+ * @param string $html The string of HTML to save in this property.
294
+ * @param int $post_id The ID of the post that this belongs to.
295
+ * @return none
296
+ * @access public
297
+ *
298
+ */
299
+ public function save_html( $html , $post_id ) {
300
+ $this->html_store[$post_id] = $html;
301
+ }
302
+
303
+ /**
304
+ * Show Share Counts?
305
+ *
306
+ * A method to determine whether or not share counts need to be shown
307
+ * while rendering the HTML for this network's button.
308
+ *
309
+ * @since 3.0.0 | 06 APR 2018 | Created
310
+ * @param array $array The array of data from the buttons panel.
311
+ * @return bool
312
+ * @access public
313
+ * @TODO Make it accept two parameters, both arrays, $options and $share_counts.
314
+ *
315
+ */
316
+ public function is_share_count_shown( $array ) {
317
+
318
+ // If the shares value isn't set, don't show the share count.
319
+ if( !isset( $array['shares'][$this->key] )):
320
+ return false;
321
+
322
+ // If the global button level shares are turned off, don't show the share count.
323
+ elseif( !$array['options']['network_shares'] ):
324
+ return false;
325
+
326
+ // If the total shares haven't yet exceeded the minimum set in the options, don't show the share count.
327
+ elseif( $array['shares']['total_shares'] < $array['options']['minimum_shares']):
328
+ return false;
329
+
330
+ // If the share count is literally 0, don't show the share count.
331
+ elseif( $array['shares'][$this->key] <= 0 ):
332
+ return false;
333
+
334
+ // Show the share count.
335
+ else:
336
+ return true;
337
+ endif;
338
+ }
339
+
340
+
341
+ /**
342
+ * Create the HTML to display the share button
343
+ *
344
+ * @since 1.0.0
345
+ * @access public
346
+ * @param array $network_counts Associative array of 'network_key' => 'count_value'
347
+ * @return array $array The modified array which will now contain the html for this button
348
+ * @todo Eliminate the array
349
+ *
350
+ */
351
+ public function render_HTML( $panel_context , $echo = false ) {
352
+
353
+ $post_data = $panel_context['post_data'];
354
+ $share_counts = $panel_context['shares'];
355
+ $options = $panel_context['options'];
356
+
357
+ $share_link = $this->generate_share_link( $post_data );
358
+
359
+ // Build the button.
360
+ $icon = '<span class="iconFiller">';
361
+ $icon.= '<span class="spaceManWilly">';
362
+ $icon.= '<i class="sw swp_'.$this->key.'_icon"></i>';
363
+ $icon.= '<span class="swp_share">' . $this->cta . '</span>';
364
+ $icon .= '</span>';
365
+ $icon .= '</span>';
366
+
367
+ if ( true === $this->are_shares_shown( $share_counts , $options ) ) :
368
+ $icon .= '<span class="swp_count">' . swp_kilomega( $share_counts[$this->key] ) . '</span>';
369
+ else :
370
+ $icon = '<span class="swp_count swp_hide">' . $icon . '</span>';
371
+ endif;
372
+
373
+ // Build the wrapper.
374
+ $html = '<div class="nc_tweetContainer swp_'.$this->key.'" data-network="'.$this->key.'">';
375
+ $html .= '<a rel="nofollow noreferrer noopener" target="_blank" href="' . $share_link . '" data-link="' . $share_link . '" class="nc_tweet">';
376
+ // Put the button inside.
377
+ $html .= $icon;
378
+ $html.= '</a>';
379
+ $html.= '</div>';
380
+
381
+ // Store these buttons so that we don't have to generate them for each set
382
+ $this->html = $html;
383
+
384
+ if ( $echo ) :
385
+ echo $html;
386
+ endif;
387
+
388
+ return $html;
389
+
390
+ }
391
+
392
+
393
+ /**
394
+ * Are Shares Shown?
395
+ *
396
+ * This function returns a boolean letting the render_html method know
397
+ * if we are supposed to be showing the share count or not.
398
+ *
399
+ * @since 3.0.0 | 18 APR 2018 | Created
400
+ * @param array $share_counts The array of share counts
401
+ * @param array $options The array of options from the button panel object.
402
+ * @return bool Do we show the share counts?
403
+ *
404
+ */
405
+ public function are_shares_shown( $share_counts , $options ) {
406
+
407
+ // False if the share count is empty
408
+ if ( empty( $share_counts[$this->key] ) ) :
409
+ return false;
410
+
411
+ // False if the total share count is below the minimum
412
+ elseif( $share_counts['total_shares'] < $options['minimum_shares'] ):
413
+ return false;
414
+
415
+ // False if the share count is zero.
416
+ elseif( $share_counts[$this->key] = 0 ):
417
+ return false;
418
+
419
+ // False if network shares are turned off in the options.
420
+ elseif( false == $options['network_shares'] ):
421
+ return false;
422
+
423
+ else :
424
+ return true;
425
+ endif;
426
+
427
+ return $this;
428
+ }
429
+
430
+
431
+ /**
432
+ * A method for processing URL's.
433
+ *
434
+ * This is designed to process the URL that is being shared onto the social
435
+ * platorms. It takes care of encoding, UTM parameters, link shortening, etc.
436
+ *
437
+ * @since 3.0.0 | 06 APR 2018 | Created
438
+ * @param array $array The array of data from the buttons panel.
439
+ * @return string The processed URL.
440
+ *
441
+ */
442
+ public function get_shareable_permalink( $post_data ) {
443
+ return urlencode( urldecode( SWP_URL_Management::process_url( $post_data['permalink'] , $this->key , $post_data['ID'] ) ) );
444
+ }
445
+
446
+
447
+ /**
448
+ * Generate the share link
449
+ *
450
+ * This is the link that is being clicked on which will open up the share
451
+ * dialogue. Thie method is only used for networks that use this exact same pattern.
452
+ * For anything that accepts more than just the post permalink as a URL parameter,
453
+ * those networks will have to overwrite this method with their own custom method
454
+ * in their respective child classes.
455
+ *
456
+ * @since 3.0.0 | 08 APR 2018 | Created
457
+ * @param array $array The array of information passed in from the buttons panel.
458
+ * @return string The generated link
459
+ * @access public
460
+ *
461
+ */
462
+ public function generate_share_link( $post_data ) {
463
+ $share_link = $this->base_share_url . $this->get_shareable_permalink( $post_data );
464
+ return $share_link;
465
+ }
466
+
467
+
468
+ /**
469
+ * Generate the API Share Count Request URL
470
+ *
471
+ * For most social networks, the api link is unique and this method will need to be
472
+ * overwritten in their respective child classes. However, for any networks that do
473
+ * not support share counts, having the method here in the parent class will allow
474
+ * us to simply use this one without have to write a new one in each child class.
475
+ *
476
+ * @since 3.0.0 | 08 APR 2018 | Created
477
+ * @access public
478
+ * @param string $url The permalink of the page or post for which to fetch share counts
479
+ * @return string $request_url The complete URL to be used to access share counts via the API
480
+ *
481
+ */
482
+ public function get_api_link( $url ) {
483
+ return 0;
484
+ }
485
+
486
+
487
+ /**
488
+ * Parse the response to get the share count
489
+ *
490
+ * For most social networks, parsing of the API response needs to be a unique method
491
+ * that is declared in each network's child class. However, we are including it here
492
+ * for all networks that do not support share counts at all. If a network does not
493
+ * support share count fetching, then it can just use the method defined here in the
494
+ * parent class.
495
+ *
496
+ * @since 3.0.0 | 08 APR 2018 | Created
497
+ * @access public
498
+ * @param string $response The raw response returned from the API request
499
+ * @return int $total_activity The number of shares reported from the API
500
+ *
501
+ */
502
+ public function parse_api_response( $response ) {
503
+ return 0;
504
+ }
505
+
506
+ }
functions/social-networks/SWP_Social_Networks_Loader.php CHANGED
@@ -1,60 +1,60 @@
1
- <?php
2
-
3
- /**
4
- * A class to load up all of this plugin's social networks.
5
- *
6
- * The purpose of this class is to create a global social networks array and
7
- * then to load up and instantiate each of the social networks as objects into
8
- * that array.
9
- *
10
- * @since 3.0.0 | Created | 05 APR 2018
11
- *
12
- */
13
- class SWP_Social_Networks_Loader {
14
-
15
-
16
- /**
17
- * The Magic __construct method.
18
- *
19
- * This method creates the global $swp_social_networks array and then queues
20
- * up the instantiation of all the networks to be run after all the plugin
21
- * including all addons have been loaded.
22
- *
23
- * @since 3.0.0 | Created | 06 APR 2018
24
- * @param none
25
- * @return none
26
- * @access public
27
- *
28
- */
29
- public function __construct() {
30
-
31
- // Create a global array to contain our social network objects.
32
- global $swp_social_networks;
33
- $swp_social_networks = array();
34
-
35
- add_filter( 'plugins_loaded' , array( $this , 'instantiate_networks' ) , 999 );
36
-
37
- }
38
-
39
-
40
- /**
41
- * Instantiate all the networks.
42
- *
43
- * This class loops through every single declared child class of the
44
- * primary SWP_Social_Network class and fires it up.
45
- *
46
- * @since 3.0.0 | Created | 06 APR 2018
47
- * @param none
48
- * @return none
49
- * @access public
50
- *
51
- */
52
- public function instantiate_networks() {
53
- foreach( get_declared_classes() as $class ){
54
- if( is_subclass_of( $class, 'SWP_Social_Network' ) ) {
55
- new $class;
56
- }
57
- }
58
- }
59
-
60
- }
1
+ <?php
2
+
3
+ /**
4
+ * A class to load up all of this plugin's social networks.
5
+ *
6
+ * The purpose of this class is to create a global social networks array and
7
+ * then to load up and instantiate each of the social networks as objects into
8
+ * that array.
9
+ *
10
+ * @since 3.0.0 | Created | 05 APR 2018
11
+ *
12
+ */
13
+ class SWP_Social_Networks_Loader {
14
+
15
+
16
+ /**
17
+ * The Magic __construct method.
18
+ *
19
+ * This method creates the global $swp_social_networks array and then queues
20
+ * up the instantiation of all the networks to be run after all the plugin
21
+ * including all addons have been loaded.
22
+ *
23
+ * @since 3.0.0 | Created | 06 APR 2018
24
+ * @param none
25
+ * @return none
26
+ * @access public
27
+ *
28
+ */
29
+ public function __construct() {
30
+
31
+ // Create a global array to contain our social network objects.
32
+ global $swp_social_networks;
33
+ $swp_social_networks = array();
34
+
35
+ add_filter( 'plugins_loaded' , array( $this , 'instantiate_networks' ) , 999 );
36
+
37
+ }
38
+
39
+
40
+ /**
41
+ * Instantiate all the networks.
42
+ *
43
+ * This class loops through every single declared child class of the
44
+ * primary SWP_Social_Network class and fires it up.
45
+ *
46
+ * @since 3.0.0 | Created | 06 APR 2018
47
+ * @param none
48
+ * @return none
49
+ * @access public
50
+ *
51
+ */
52
+ public function instantiate_networks() {
53
+ foreach( get_declared_classes() as $class ){
54
+ if( is_subclass_of( $class, 'SWP_Social_Network' ) ) {
55
+ new $class;
56
+ }
57
+ }
58
+ }
59
+
60
+ }
functions/social-networks/SWP_Stumble_Upon.php CHANGED
@@ -1,85 +1,85 @@
1
- <?php
2
-
3
- /**
4
- * Stumbleupon
5
- *
6
- * Class to add a StumbleUpon share button to the available buttons
7
- *
8
- * @package SocialWarfare\Functions\Social-Networks
9
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
10
- * @license GPL-3.0+
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_Stumble_Upon extends SWP_Social_Network {
17
-
18
-
19
- /**
20
- * The Magic __construct Method
21
- *
22
- * This method is used to instantiate the social network object. It does three things.
23
- * First it sets the object properties for each network. Then it adds this object to
24
- * the globally accessible swp_social_networks array. Finally, it fetches the active
25
- * state (does the user have this button turned on?) so that it can be accessed directly
26
- * within the object.
27
- *
28
- * @since 3.0.0 | 06 APR 2018 | Created
29
- * @param none
30
- * @return none
31
- * @access public
32
- *
33
- */
34
- public function __construct() {
35
-
36
- // Update the class properties for this network
37
- $this->name = __( 'StumbleUpon','social-warfare' );
38
- $this->cta = __( 'Stumble','social-warfare' );
39
- $this->key = 'stumbleupon';
40
- $this->default = 'false';
41
- $this->base_share_url = 'https://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
-
58
- /**
59
- * Generate the API Share Count Request URL
60
- *
61
- * @since 1.0.0 | 06 APR 2018 | Created
62
- * @access public
63
- * @param string $url The permalink of the page or post for which to fetch share counts
64
- * @return string $request_url The complete URL to be used to access share counts via the API
65
- *
66
- */
67
- public function get_api_link( $url ) {
68
- return 'https://www.stumbleupon.com/services/1.01/badge.getinfo?url=' . $url;
69
- }
70
-
71
-
72
- /**
73
- * Parse the response to get the share count
74
- *
75
- * @since 1.0.0 | 06 APR 2018 | Created
76
- * @access public
77
- * @param string $response The raw response returned from the API request
78
- * @return int $total_activity The number of shares reported from the API
79
- *
80
- */
81
- public function parse_api_response( $response ) {
82
- $response = json_decode( $response, true );
83
- return isset( $response['result']['views'] ) ? intval( $response['result']['views'] ) : 0;
84
- }
85
- }
1
+ <?php
2
+
3
+ /**
4
+ * Stumbleupon
5
+ *
6
+ * Class to add a StumbleUpon share button to the available buttons
7
+ *
8
+ * @package SocialWarfare\Functions\Social-Networks
9
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
10
+ * @license GPL-3.0+
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_Stumble_Upon extends SWP_Social_Network {
17
+
18
+
19
+ /**
20
+ * The Magic __construct Method
21
+ *
22
+ * This method is used to instantiate the social network object. It does three things.
23
+ * First it sets the object properties for each network. Then it adds this object to
24
+ * the globally accessible swp_social_networks array. Finally, it fetches the active
25
+ * state (does the user have this button turned on?) so that it can be accessed directly
26
+ * within the object.
27
+ *
28
+ * @since 3.0.0 | 06 APR 2018 | Created
29
+ * @param none
30
+ * @return none
31
+ * @access public
32
+ *
33
+ */
34
+ public function __construct() {
35
+
36
+ // Update the class properties for this network
37
+ $this->name = __( 'StumbleUpon','social-warfare' );
38
+ $this->cta = __( 'Stumble','social-warfare' );
39
+ $this->key = 'stumbleupon';
40
+ $this->default = 'false';
41
+ $this->base_share_url = 'https://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
+
58
+ /**
59
+ * Generate the API Share Count Request URL
60
+ *
61
+ * @since 1.0.0 | 06 APR 2018 | Created
62
+ * @access public
63
+ * @param string $url The permalink of the page or post for which to fetch share counts
64
+ * @return string $request_url The complete URL to be used to access share counts via the API
65
+ *
66
+ */
67
+ public function get_api_link( $url ) {
68
+ return 'https://www.stumbleupon.com/services/1.01/badge.getinfo?url=' . $url;
69
+ }
70
+
71
+
72
+ /**
73
+ * Parse the response to get the share count
74
+ *
75
+ * @since 1.0.0 | 06 APR 2018 | Created
76
+ * @access public
77
+ * @param string $response The raw response returned from the API request
78
+ * @return int $total_activity The number of shares reported from the API
79
+ *
80
+ */
81
+ public function parse_api_response( $response ) {
82
+ $response = json_decode( $response, true );
83
+ return isset( $response['result']['views'] ) ? intval( $response['result']['views'] ) : 0;
84
+ }
85
+ }
functions/social-networks/SWP_Twitter.php CHANGED
@@ -1,181 +1,181 @@
1
- <?php
2
-
3
- /**
4
- * Twitter
5
- *
6
- * Class to add a Twitter share button to the available buttons
7
- *
8
- * @package SocialWarfare\Functions\Social-Networks
9
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
10
- * @license GPL-3.0+
11
- * @since 1.0.0 | Unknown | Created
12
- * @since 2.2.4 | 02 MAY 2017 | Refactored functions & updated docblocking
13
- * @since 3.0.0 | 07 APR 2018 | Rebuilt into a class-based system.
14
- *
15
- */
16
- class SWP_Twitter extends SWP_Social_Network {
17
-
18
-
19
- /**
20
- * The Magic __construct Method
21
- *
22
- * This method is used to instantiate the social network object. It does three things.
23
- * First it sets the object properties for each network. Then it adds this object to
24
- * the globally accessible swp_social_networks array. Finally, it fetches the active
25
- * state (does the user have this button turned on?) so that it can be accessed directly
26
- * within the object.
27
- *
28
- * @since 3.0.0 | 07 APR 2018 | Created
29
- * @param none
30
- * @return none
31
- * @access public
32
- *
33
- */
34
- public function __construct() {
35
-
36
- // Update the class properties for this network
37
- $this->name = __( 'Twitter','social-warfare' );
38
- $this->cta = __( 'Tweet','social-warfare' );
39
- $this->key = 'twitter';
40
- $this->default = 'true';
41
-
42
- $this->init_social_network();
43
- }
44
-
45
- /**
46
- * Generate the API Share Count Request URL
47
- *
48
- * @since 3.0.0 | 07 APR 2018 | Created
49
- * @access public
50
- * @param string $url The permalink of the page or post for which to fetch share counts
51
- * @return string $request_url The complete URL to be used to access share counts via the API
52
- *
53
- */
54
- public function get_api_link( $url ) {
55
- // Fetch the user's options
56
- global $swp_user_options;
57
-
58
- // If the user has enabled Twitter shares....
59
- if ( swp_get_option('twitter_shares') && isset( $swp_user_options['tweet_count_source'] ) ) :
60
-
61
- // Return the correct Twitter JSON endpoint URL
62
- if ('opensharecount' == $swp_user_options['tweet_count_source']) {
63
- $request_url = 'https://opensharecount.com/count.json?url='. $url;
64
- } else {
65
- $request_url = 'http://public.newsharecounts.com/count.json?url=' . $url;
66
- }
67
-
68
- // Debugging
69
- if ( _swp_is_debug( 'twitter' ) ) {
70
- echo '<b>Request URL:</b> ' . $request_url . '<br />';
71
- }
72
-
73
- return $request_url;
74
-
75
- // If the user has not enabled Twitter shares....
76
- else :
77
-
78
- // Return nothing so we don't run an API call
79
- return 0;
80
-
81
- endif;
82
- }
83
-
84
-
85
- /**
86
- * Parse the response to get the share count
87
- *
88
- * @since 3.0.0 | 07 APR 2018 | Created
89
- * @access public
90
- * @param string $response The raw response returned from the API request
91
- * @return int $total_activity The number of shares reported from the API
92
- *
93
- */
94
- public function parse_api_response( $response ) {
95
-
96
- // Fetch the user's options
97
- global $swp_user_options;
98
-
99
- // If the user has enabled Twitter shares....
100
- if ( swp_get_option('twitter_shares') ) :
101
-
102
- // Debugging
103
- if ( _swp_is_debug( 'twitter' ) ) :
104
- echo '<b>Response:</b> ' . $response . '<br />';
105
- endif;
106
-
107
- // Parse the response to get the actual number
108
- $response = json_decode( $response, true );
109
-
110
- return isset( $response['count'] )?intval( $response['count'] ):0;
111
-
112
- // If the user has not enabled Twitter shares....
113
- else :
114
-
115
- // Return the number 0
116
- return 0;
117
-
118
- endif;
119
- }
120
-
121
-
122
- /**
123
- * Generate the share link
124
- *
125
- * This is the link that is being clicked on which will open up the share
126
- * dialogue.
127
- *
128
- * @since 3.0.0 | 07 APR 2018 | Created
129
- * @param array $post_data The array of information passed in from the buttons panel.
130
- * @return string The generated link
131
- * @access public
132
- *
133
- */
134
- public function generate_share_link( $post_data ) {
135
-
136
- // Generate a title for the share.
137
- $title = str_replace( '|', '', strip_tags( $post_data['post_title'] ) );
138
-
139
- // Check for a custom tweet from the post options.
140
- $custom_tweet = get_post_meta( $post_data['ID'] , 'swp_custom_tweet' , true );
141
-
142
- if ( gettype( $custom_tweet) === 'string' && !empty( $custom_tweet ) ) :
143
- $custom_tweet = urlencode( html_entity_decode( $custom_tweet, ENT_COMPAT, 'UTF-8' ) );
144
- else :
145
- $custom_tweet = urlencode( html_entity_decode( $title, ENT_COMPAT, 'UTF-8' ) );
146
- endif;
147
-
148
- $twitter_link = $this->get_shareable_permalink( $post_data );
149
-
150
- // If the custom tweet contains a link, block Twitter for auto adding another one.
151
- if ( false !== strpos( $custom_tweet , 'http' ) ) :
152
- $url_parameter = '&url=/';
153
- else :
154
- $url_parameter = '&url=' . $twitter_link;
155
- endif;
156
-
157
- $twitter_mention = get_post_meta( $post_data['ID'] , 'swp_twitter_mention' , true );
158
-
159
- if (false != $twitter_mention):
160
- $custom_tweet .= ' @'.str_replace('@','',$twitter_mention);
161
- endif;
162
-
163
- $user_twitter_handle = get_the_author_meta( 'swp_twitter' , SWP_User_Profile::get_author( $post_data['ID'] ) );
164
-
165
- if ( $user_twitter_handle ) :
166
- $via_parameter = '&via=' . str_replace( '@','',$user_twitter_handle );
167
- elseif ( $post_data['options']['twitter_id'] ) :
168
- $via_parameter = '&via=' . str_replace( '@','',$post_data['options']['twitter_id'] );
169
- else :
170
- $via_parameter = '';
171
- endif;
172
-
173
- $parameters = $custom_tweet . $url_parameter . $via_parameter;
174
-
175
- $intent_link = "https://twitter.com/intent/tweet?text=$parameters";
176
-
177
- return $intent_link;
178
-
179
- }
180
-
181
- }
1
+ <?php
2
+
3
+ /**
4
+ * Twitter
5
+ *
6
+ * Class to add a Twitter share button to the available buttons
7
+ *
8
+ * @package SocialWarfare\Functions\Social-Networks
9
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
10
+ * @license GPL-3.0+
11
+ * @since 1.0.0 | Unknown | Created
12
+ * @since 2.2.4 | 02 MAY 2017 | Refactored functions & updated docblocking
13
+ * @since 3.0.0 | 07 APR 2018 | Rebuilt into a class-based system.
14
+ *
15
+ */
16
+ class SWP_Twitter extends SWP_Social_Network {
17
+
18
+
19
+ /**
20
+ * The Magic __construct Method
21
+ *
22
+ * This method is used to instantiate the social network object. It does three things.
23
+ * First it sets the object properties for each network. Then it adds this object to
24
+ * the globally accessible swp_social_networks array. Finally, it fetches the active
25
+ * state (does the user have this button turned on?) so that it can be accessed directly
26
+ * within the object.
27
+ *
28
+ * @since 3.0.0 | 07 APR 2018 | Created
29
+ * @param none
30
+ * @return none
31
+ * @access public
32
+ *
33
+ */
34
+ public function __construct() {
35
+
36
+ // Update the class properties for this network
37
+ $this->name = __( 'Twitter','social-warfare' );
38
+ $this->cta = __( 'Tweet','social-warfare' );
39
+ $this->key = 'twitter';
40
+ $this->default = 'true';
41
+
42
+ $this->init_social_network();
43
+ }
44
+
45
+ /**
46
+ * Generate the API Share Count Request URL
47
+ *
48
+ * @since 3.0.0 | 07 APR 2018 | Created
49
+ * @access public
50
+ * @param string $url The permalink of the page or post for which to fetch share counts
51
+ * @return string $request_url The complete URL to be used to access share counts via the API
52
+ *
53
+ */
54
+ public function get_api_link( $url ) {
55
+ // Fetch the user's options
56
+ global $swp_user_options;
57
+
58
+ // If the user has enabled Twitter shares....
59
+ if ( swp_get_option('twitter_shares') && isset( $swp_user_options['tweet_count_source'] ) ) :
60
+
61
+ // Return the correct Twitter JSON endpoint URL
62
+ if ('opensharecount' == $swp_user_options['tweet_count_source']) {
63
+ $request_url = 'https://opensharecount.com/count.json?url='. $url;
64
+ } else {
65
+ $request_url = 'http://public.newsharecounts.com/count.json?url=' . $url;
66
+ }
67
+
68
+ // Debugging
69
+ if ( _swp_is_debug( 'twitter' ) ) {
70
+ echo '<b>Request URL:</b> ' . $request_url . '<br />';
71
+ }
72
+
73
+ return $request_url;
74
+
75
+ // If the user has not enabled Twitter shares....
76
+ else :
77
+
78
+ // Return nothing so we don't run an API call
79
+ return 0;
80
+
81
+ endif;
82
+ }
83
+
84
+
85
+ /**
86
+ * Parse the response to get the share count
87
+ *
88
+ * @since 3.0.0 | 07 APR 2018 | Created
89
+ * @access public
90
+ * @param string $response The raw response returned from the API request
91
+ * @return int $total_activity The number of shares reported from the API
92
+ *
93
+ */
94
+ public function parse_api_response( $response ) {
95
+
96
+ // Fetch the user's options
97
+ global $swp_user_options;
98
+
99
+ // If the user has enabled Twitter shares....
100
+ if ( swp_get_option('twitter_shares') ) :
101
+
102
+ // Debugging
103
+ if ( _swp_is_debug( 'twitter' ) ) :
104
+ echo '<b>Response:</b> ' . $response . '<br />';
105
+ endif;
106
+
107
+ // Parse the response to get the actual number
108
+ $response = json_decode( $response, true );
109
+
110
+ return isset( $response['count'] )?intval( $response['count'] ):0;
111
+
112
+ // If the user has not enabled Twitter shares....
113
+ else :
114
+
115
+ // Return the number 0
116
+ return 0;
117
+
118
+ endif;
119
+ }
120
+
121
+
122
+ /**
123
+ * Generate the share link
124
+ *
125
+ * This is the link that is being clicked on which will open up the share
126
+ * dialogue.
127
+ *
128
+ * @since 3.0.0 | 07 APR 2018 | Created
129
+ * @param array $post_data The array of information passed in from the buttons panel.
130
+ * @return string The generated link
131
+ * @access public
132
+ *
133
+ */
134
+ public function generate_share_link( $post_data ) {
135
+
136
+ // Generate a title for the share.
137
+ $title = str_replace( '|', '', strip_tags( $post_data['post_title'] ) );
138
+
139
+ // Check for a custom tweet from the post options.
140
+ $custom_tweet = get_post_meta( $post_data['ID'] , 'swp_custom_tweet' , true );
141
+
142
+ if ( gettype( $custom_tweet) === 'string' && !empty( $custom_tweet ) ) :
143
+ $custom_tweet = urlencode( html_entity_decode( $custom_tweet, ENT_COMPAT, 'UTF-8' ) );
144
+ else :
145
+ $custom_tweet = urlencode( html_entity_decode( $title, ENT_COMPAT, 'UTF-8' ) );
146
+ endif;
147
+
148
+ $twitter_link = $this->get_shareable_permalink( $post_data );
149
+
150
+ // If the custom tweet contains a link, block Twitter for auto adding another one.
151
+ if ( false !== strpos( $custom_tweet , 'http' ) ) :
152
+ $url_parameter = '&url=/';
153
+ else :
154
+ $url_parameter = '&url=' . $twitter_link;
155
+ endif;
156
+
157
+ $twitter_mention = get_post_meta( $post_data['ID'] , 'swp_twitter_mention' , true );
158
+
159
+ if (false != $twitter_mention):
160
+ $custom_tweet .= ' @'.str_replace('@','',$twitter_mention);
161
+ endif;
162
+
163
+ $user_twitter_handle = get_the_author_meta( 'swp_twitter' , SWP_User_Profile::get_author( $post_data['ID'] ) );
164
+
165
+ if ( $user_twitter_handle ) :
166
+ $via_parameter = '&via=' . str_replace( '@','',$user_twitter_handle );
167
+ elseif ( $post_data['options']['twitter_id'] ) :
168
+ $via_parameter = '&via=' . str_replace( '@','',$post_data['options']['twitter_id'] );
169
+ else :
170
+ $via_parameter = '';
171
+ endif;
172
+
173
+ $parameters = $custom_tweet . $url_parameter . $via_parameter;
174
+
175
+ $intent_link = "https://twitter.com/intent/tweet?text=$parameters";
176
+
177
+ return $intent_link;
178
+
179
+ }
180
+
181
+ }
functions/utilities/SWP_Abstract.php CHANGED
@@ -1,385 +1,385 @@
1
- <?php
2
-
3
- /**
4
- * SWP_Abstract: The abstract class used for all other options classes.
5
- *
6
- * @package SocialWarfare\Functions\Utilities
7
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
- * @license GPL-3.0+
9
- * @since 3.0.0 | 02 MAR 2018 | Created
10
- * @since 3.1.0 | 14 JUN 2018 | Added the set_key() method.
11
- * @access public
12
- *
13
- */
14
- class SWP_Abstract {
15
-
16
-
17
- /**
18
- * SWP_Utility_Trait provides useful tool like error handling.
19
- *
20
- */
21
- use SWP_Utility_Trait;
22
-
23
-
24
- /**
25
- * Name
26
- *
27
- * The name of this option. This is a "pretty" name that the plugin user will see.
28
- *
29
- * @var string
30
- *
31
- */
32
- public $name;
33
-
34
-
35
- /**
36
- * Type
37
- *
38
- * The type property refers to the type of option this represents (e.g. input,
39
- * textarea, checkbox, etc.)
40
- *
41
- * @var string
42
- *
43
- */
44
- public $type;
45
-
46
-
47
- /**
48
- * Default
49
- *
50
- * The default property refers to the default value for this option. This is
51
- * what the option will be set to until the user changes it.
52
- *
53
- * @var mixed This var is dependant on what type of option is being generated.
54
- *
55
- */
56
- public $default;
57
-
58
-
59
- /**
60
- * Premium
61
- *
62
- * This property determines whether or not this option is a premium option. By
63
- * default this property is set to false. The set_premium() method can be called
64
- * to change this property. When called, the set_premium() method will accept a
65
- * string corresponding to the registration key of the premium plugin on which
66
- * this option relies. It will set the $premium_addon property to that string and
67
- * switch this property to true.
68
- *
69
- * @var bool
70
- *
71
- */
72
- public $premium = false;
73
-
74
- /**
75
- * Addon
76
- *
77
- * This propety is set iff $premium === true. The value of $addon is the
78
- * code for the corresponding addon. Permissable values are:
79
- *
80
- * pro
81
- *
82
- * @var string
83
- *
84
- */
85
- public $addon = '';
86
-
87
-
88
- /**
89
- * Priority
90
- *
91
- * The priority property is used to determine the order in which the options are
92
- * presented to the user. These options will be sorted prior to the rendering of
93
- * the HTML in ascending order. That is to say, an option with a priority of 10
94
- * will appear before an option with a priority of 20.
95
- *
96
- * @var integer
97
- *
98
- */
99
- public $priority;
100
-
101
-
102
- /**
103
- * The Construct Method
104
- *
105
- * Pull in the users options from the database and pull in the global network objects.
106
- *
107
- * @since 3.0.0 | 24 APR 2018 | Created
108
- * @param string $name The name of the option
109
- * @return none
110
- *
111
- */
112
- public function __construct( $name ) {
113
- $this->set_name( $name );
114
- $this->user_options = get_option( 'social_warfare_settings' );
115
-
116
- add_action('plugins_loaded', array( $this , 'load_social_networks' ) , 1000 );
117
-
118
- }
119
-
120
-
121
- /**
122
- * A function to pull the global social networks into a local property.
123
- *
124
- * @since 3.0.0 | 24 APR 2018 | Created
125
- * @param none
126
- * @return none
127
- *
128
- */
129
- public function load_social_networks() {
130
- global $swp_social_networks;
131
- $this->networks = $swp_social_networks;
132
- }
133
-
134
- public function get_property( $property ) {
135
- if ( property_exists( __CLASS__, $property ) ) {
136
- return $this->$property;
137
- }
138
-
139
- $this->_throw("Property $property does not exist in " . __CLASS__ . "." );
140
- }
141
-
142
-
143
- public function get_all_icons() {
144
- return $this->networks;
145
- }
146
-
147
- public function get_user_icons() {
148
- if ( isset( $this->user_options['order_of_icons'] ) ) :
149
- $user_icons = $this->user_options['order_of_icons'];
150
- else:
151
- $user_icons = [
152
- 'google_plus' => 'google_plus',
153
- 'twitter' => 'twitter',
154
- 'facebook' => 'facebook',
155
- 'linkedin' => 'linkedin',
156
- 'pinterest' => 'pinterest'
157
- ];
158
- endif;
159
-
160
- if ( empty( $user_icons ) ):
161
- $all_icons = $this->get_all_icons();
162
- $defaults = array();
163
-
164
- foreach( $all_icons as $network_key => $network_obj ) {
165
- $defaults[$network_key] = $network_obj;
166
- }
167
-
168
- return $defaults;
169
-
170
- endif;
171
-
172
- if ( is_array( $user_icons ) && array_key_exists( 'active', $user_icons) ) :
173
- return $user_icons['active'];
174
- endif;
175
-
176
- return $user_icons;
177
- }
178
-
179
-
180
- /**
181
- * Set the Name
182
- *
183
- * @since 3.0.0 | 25 APR 2018 | Created
184
- * @param string $name The name of this option.
185
- * @return object $this Allows method chaining.
186
- *
187
- */
188
- public function set_name( $name ) {
189
- if ( !is_string($name) ) {
190
- $this->_throw("Please provide a string for your object's name." );
191
- }
192
-
193
- $this->name = $name;
194
-
195
- return $this;
196
- }
197
-
198
- public function set_priority( $priority ) {
199
- if ( ! intval( $priority ) || $priority < 1) {
200
- $this->_throw("Requires an integer greater than 0.");
201
- }
202
-
203
- $this->priority = $priority;
204
-
205
- return $this;
206
- }
207
-
208
- /**
209
- * Creates a Javscript selector keyname based on the object's name.
210
- *
211
- * @param string $name The name to be converted to a key. Usually the objects name.
212
- * @return string $key A valid PHP and jQuery target keyname.
213
- */
214
- public function name_to_key( $name ) {
215
- if ( !is_string( $name ) ) :
216
- $this->_throw( 'Please provide a string to get a key.' );
217
- endif;
218
-
219
- //* Remove all non-word character symbols.
220
- $key = preg_replace( '#[^\w\s]#i', '', $name );
221
-
222
- //* Replace spaces with underscores.
223
- $key = preg_replace( '/\s+/', '_', $name );
224
-
225
-
226
- return strtolower( $key );
227
- }
228
-
229
- /**
230
- * Set the premium status of the object.
231
- *
232
- * Since there are going to be multiple addons, it's not sufficient to set premium to simply true or
233
- * false. Instead, it will be false by default. Unless this method is called and a string corresponding
234
- * the registration key of the corresponding premium addon is passed. Example: $SWP_Option->set_premium('pro');
235
- *
236
- * This will then set the premium property to true and place the registration key into the premium_addon property.
237
- *
238
- * This method does not need to be called unless it is a premium option.
239
- *
240
- * @since 3.0.0 | 02 MAR 2018 | Created
241
- * @param string String corresponding to the registration key of premium plugin if true.
242
- * @return $this Return the object to allow method chaining.
243
- *
244
- */
245
- public function set_premium( $premium_addon ) {
246
- if ( !is_string( $premium_addon ) ) {
247
- $addons = [ 'pro' ];
248
- $addon_string = PHP_EOL;
249
-
250
- foreach( $addons as $addon ) {
251
- $addon_string . $addon . PHP_EOL;
252
- }
253
- $this->_throw( "Please provide a string that is one of the following: " . var_export($addons ) );
254
- }
255
-
256
- $this->premium = $premium_addon;
257
-
258
- return $this;
259
- }
260
-
261
- public function get_priority_map( $object) {
262
-
263
- return array_values( $this->object_to_array( $object ) );
264
- }
265
-
266
- public function object_to_array ( $object ) {
267
- if(!is_object($object) && !is_array($object)):
268
- return $object;
269
- endif;
270
-
271
- return array_map( [$this, 'object_to_array'], (array) $object);
272
- }
273
-
274
- /**
275
- * Sorts all core, premium, and third-party items by their designated priority.
276
- *
277
- * This is pretty hacky.
278
- * Ideally, the code would be pure as demonstrated in the andrewbaxter link below.
279
- * However, because we use objects with named keys to store our data, we can iterate
280
- * the objects as a numeric index. (E.g., $array[0] throws an error).
281
- * To resolve this, we have to
282
- */
283
- //* Logic: http://interactivepython.org/runestone/static/pythonds/SortSearch/TheQuickSort.html
284
- //* Code: http://andrewbaxter.net/quicksort.php
285
- public function sort_by_priority( $object ) {
286
-
287
- if (is_object($object)) {
288
- $array = $this->get_priority_map( $object) ; //get_object_vars($object);
289
- } else {
290
- $array = $object;
291
- }
292
-
293
- $length = count( $array );
294
-
295
- if ( $length < 2 ) {
296
- return $array;
297
- }
298
-
299
- if ( $length === 2 ) :
300
- $first;
301
- $second;
302
- $index = 0;
303
-
304
- foreach( $array as $name => $object) {
305
- if ( $index === 2) break;
306
-
307
- if ( $index === 0) {
308
- $first = $object;
309
- } else {
310
- $second = $object;
311
- }
312
-
313
- $index++;
314
- }
315
-
316
- if ($first['priority'] > $second['priority']) {
317
- return [$second, $first];
318
- }
319
-
320
- return [$first, $second];
321
- endif;
322
-
323
- $left = $right = array();
324
-
325
- $pivot = $array[0];
326
-
327
- for ($i = 1; $i < $length; $i++) {
328
- $item = $array[$i];
329
-
330
- $item['priority'] < $pivot['priority'] ? $left[] = $item : $right[] = $item;
331
- }
332
-
333
- return array_merge( $this->sort_by_priority($left), [$pivot], $this->sort_by_priority($right) );
334
- }
335
-
336
-
337
-
338
- /**
339
- * Adds the SWP dependency attributes, if this object has a dependency set.
340
- *
341
- * @return string The HTML attributes if the object has dependency, or an empty string.
342
- */
343
- protected function render_dependency() {
344
- if ( !empty( $this->dependency) ) :
345
- return ' data-dep="' . $this->dependency->parent . '" data-dep_val=\'' . json_encode($this->dependency->values) . '\'';
346
- endif;
347
-
348
- return ' ';
349
- }
350
-
351
-
352
- /**
353
- * Adds the SWP premium attributes, if this object is premium.
354
- *
355
- * @return string The HTML attribute if the object has dependency, or an empty string.
356
- */
357
- protected function render_premium() {
358
- return;
359
- if ( isset( $this->premium ) ) :
360
- return ' premium="true" ';
361
- endif;
362
-
363
- return ' ';
364
- }
365
-
366
-
367
- /**
368
- * Sets the key used by dependent sections and options.
369
- *
370
- * @since 3.0.0 | 01 MAR 2018 | Created
371
- * @since 3.1.0 | 14 JUN 2018 | Migrated from child class to here.
372
- * @param string $key The unique key being assigned to this section.
373
- * @return SWP_Options_Page_Section $this The updated object.
374
- *
375
- */
376
- public function set_key( $key ) {
377
- if ( !is_string($key) ) {
378
- $this->_throw("Please provide a string for your object's key." );
379
- }
380
-
381
- $this->key = $key;
382
-
383
- return $this;
384
- }
385
- }
1
+ <?php
2
+
3
+ /**
4
+ * SWP_Abstract: The abstract class used for all other options classes.
5
+ *
6
+ * @package SocialWarfare\Functions\Utilities
7
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
+ * @license GPL-3.0+
9
+ * @since 3.0.0 | 02 MAR 2018 | Created
10
+ * @since 3.1.0 | 14 JUN 2018 | Added the set_key() method.
11
+ * @access public
12
+ *
13
+ */
14
+ class SWP_Abstract {
15
+
16
+
17
+ /**
18
+ * SWP_Utility_Trait provides useful tool like error handling.
19
+ *
20
+ */
21
+ use SWP_Utility_Trait;
22
+
23
+
24
+ /**
25
+ * Name
26
+ *
27
+ * The name of this option. This is a "pretty" name that the plugin user will see.
28
+ *
29
+ * @var string
30
+ *
31
+ */
32
+ public $name;
33
+
34
+
35
+ /**
36
+ * Type
37
+ *
38
+ * The type property refers to the type of option this represents (e.g. input,
39
+ * textarea, checkbox, etc.)
40
+ *
41
+ * @var string
42
+ *
43
+ */
44
+ public $type;
45
+
46
+
47
+ /**
48
+ * Default
49
+ *
50
+ * The default property refers to the default value for this option. This is
51
+ * what the option will be set to until the user changes it.
52
+ *
53
+ * @var mixed This var is dependant on what type of option is being generated.
54
+ *
55
+ */
56
+ public $default;
57
+
58
+
59
+ /**
60
+ * Premium
61
+ *
62
+ * This property determines whether or not this option is a premium option. By
63
+ * default this property is set to false. The set_premium() method can be called
64
+ * to change this property. When called, the set_premium() method will accept a
65
+ * string corresponding to the registration key of the premium plugin on which
66
+ * this option relies. It will set the $premium_addon property to that string and
67
+ * switch this property to true.
68
+ *
69
+ * @var bool
70
+ *
71
+ */
72
+ public $premium = false;
73
+
74
+ /**
75
+ * Addon
76
+ *
77
+ * This propety is set iff $premium === true. The value of $addon is the
78
+ * code for the corresponding addon. Permissable values are:
79
+ *
80
+ * pro
81
+ *
82
+ * @var string
83
+ *
84
+ */
85
+ public $addon = '';
86
+
87
+
88
+ /**
89
+ * Priority
90
+ *
91
+ * The priority property is used to determine the order in which the options are
92
+ * presented to the user. These options will be sorted prior to the rendering of
93
+ * the HTML in ascending order. That is to say, an option with a priority of 10
94
+ * will appear before an option with a priority of 20.
95
+ *
96
+ * @var integer
97
+ *
98
+ */
99
+ public $priority;
100
+
101
+
102
+ /**
103
+ * The Construct Method
104
+ *
105
+ * Pull in the users options from the database and pull in the global network objects.
106
+ *
107
+ * @since 3.0.0 | 24 APR 2018 | Created
108
+ * @param string $name The name of the option
109
+ * @return none
110
+ *
111
+ */
112
+ public function __construct( $name ) {
113
+ $this->set_name( $name );
114
+ $this->user_options = get_option( 'social_warfare_settings' );
115
+
116
+ add_action('plugins_loaded', array( $this , 'load_social_networks' ) , 1000 );
117
+
118
+ }
119
+
120
+
121
+ /**
122
+ * A function to pull the global social networks into a local property.
123
+ *
124
+ * @since 3.0.0 | 24 APR 2018 | Created
125
+ * @param none
126
+ * @return none
127
+ *
128
+ */
129
+ public function load_social_networks() {
130
+ global $swp_social_networks;
131
+ $this->networks = $swp_social_networks;
132
+ }
133
+
134
+ public function get_property( $property ) {
135
+ if ( property_exists( __CLASS__, $property ) ) {
136
+ return $this->$property;
137
+ }
138
+
139
+ $this->_throw("Property $property does not exist in " . __CLASS__ . "." );
140
+ }
141
+
142
+
143
+ public function get_all_icons() {
144
+ return $this->networks;
145
+ }
146
+
147
+ public function get_user_icons() {
148
+ if ( isset( $this->user_options['order_of_icons'] ) ) :
149
+ $user_icons = $this->user_options['order_of_icons'];
150
+ else:
151
+ $user_icons = [
152
+ 'google_plus' => 'google_plus',
153
+ 'twitter' => 'twitter',
154
+ 'facebook' => 'facebook',
155
+ 'linkedin' => 'linkedin',
156
+ 'pinterest' => 'pinterest'
157
+ ];
158
+ endif;
159
+
160
+ if ( empty( $user_icons ) ):
161
+ $all_icons = $this->get_all_icons();
162
+ $defaults = array();
163
+
164
+ foreach( $all_icons as $network_key => $network_obj ) {
165
+ $defaults[$network_key] = $network_obj;
166
+ }
167
+
168
+ return $defaults;
169
+
170
+ endif;
171
+
172
+ if ( is_array( $user_icons ) && array_key_exists( 'active', $user_icons) ) :
173
+ return $user_icons['active'];
174
+ endif;
175
+
176
+ return $user_icons;
177
+ }
178
+
179
+
180
+ /**
181
+ * Set the Name
182
+ *
183
+ * @since 3.0.0 | 25 APR 2018 | Created
184
+ * @param string $name The name of this option.
185
+ * @return object $this Allows method chaining.
186
+ *
187
+ */
188
+ public function set_name( $name ) {
189
+ if ( !is_string($name) ) {
190
+ $this->_throw("Please provide a string for your object's name." );
191
+ }
192
+
193
+ $this->name = $name;
194
+
195
+ return $this;
196
+ }
197
+
198
+ public function set_priority( $priority ) {
199
+ if ( ! intval( $priority ) || $priority < 1) {
200
+ $this->_throw("Requires an integer greater than 0.");
201
+ }
202
+
203
+ $this->priority = $priority;
204
+
205
+ return $this;
206
+ }
207
+
208
+ /**
209
+ * Creates a Javscript selector keyname based on the object's name.
210
+ *
211
+ * @param string $name The name to be converted to a key. Usually the objects name.
212
+ * @return string $key A valid PHP and jQuery target keyname.
213
+ */
214
+ public function name_to_key( $name ) {
215
+ if ( !is_string( $name ) ) :
216
+ $this->_throw( 'Please provide a string to get a key.' );
217
+ endif;
218
+
219
+ //* Remove all non-word character symbols.
220
+ $key = preg_replace( '#[^\w\s]#i', '', $name );
221
+
222
+ //* Replace spaces with underscores.
223
+ $key = preg_replace( '/\s+/', '_', $name );
224
+
225
+
226
+ return strtolower( $key );
227
+ }
228
+
229
+ /**
230
+ * Set the premium status of the object.
231
+ *
232
+ * Since there are going to be multiple addons, it's not sufficient to set premium to simply true or
233
+ * false. Instead, it will be false by default. Unless this method is called and a string corresponding
234
+ * the registration key of the corresponding premium addon is passed. Example: $SWP_Option->set_premium('pro');
235
+ *
236
+ * This will then set the premium property to true and place the registration key into the premium_addon property.
237
+ *
238
+ * This method does not need to be called unless it is a premium option.
239
+ *
240
+ * @since 3.0.0 | 02 MAR 2018 | Created
241
+ * @param string String corresponding to the registration key of premium plugin if true.
242
+ * @return $this Return the object to allow method chaining.
243
+ *
244
+ */
245
+ public function set_premium( $premium_addon ) {
246
+ if ( !is_string( $premium_addon ) ) {
247
+ $addons = [ 'pro' ];
248
+ $addon_string = PHP_EOL;
249
+
250
+ foreach( $addons as $addon ) {
251
+ $addon_string . $addon . PHP_EOL;
252
+ }
253
+ $this->_throw( "Please provide a string that is one of the following: " . var_export($addons ) );
254
+ }
255
+
256
+ $this->premium = $premium_addon;
257
+
258
+ return $this;
259
+ }
260
+
261
+ public function get_priority_map( $object) {
262
+
263
+ return array_values( $this->object_to_array( $object ) );
264
+ }
265
+
266
+ public function object_to_array ( $object ) {
267
+ if(!is_object($object) && !is_array($object)):
268
+ return $object;
269
+ endif;
270
+
271
+ return array_map( [$this, 'object_to_array'], (array) $object);
272
+ }
273
+
274
+ /**
275
+ * Sorts all core, premium, and third-party items by their designated priority.
276
+ *
277
+ * This is pretty hacky.
278
+ * Ideally, the code would be pure as demonstrated in the andrewbaxter link below.
279
+ * However, because we use objects with named keys to store our data, we can iterate
280
+ * the objects as a numeric index. (E.g., $array[0] throws an error).
281
+ * To resolve this, we have to
282
+ */
283
+ //* Logic: http://interactivepython.org/runestone/static/pythonds/SortSearch/TheQuickSort.html
284
+ //* Code: http://andrewbaxter.net/quicksort.php
285
+ public function sort_by_priority( $object ) {
286
+
287
+ if (is_object($object)) {
288
+ $array = $this->get_priority_map( $object) ; //get_object_vars($object);
289
+ } else {
290
+ $array = $object;
291
+ }
292
+
293
+ $length = count( $array );
294
+
295
+ if ( $length < 2 ) {
296
+ return $array;
297
+ }
298
+
299
+ if ( $length === 2 ) :
300
+ $first;
301
+ $second;
302
+ $index = 0;
303
+
304
+ foreach( $array as $name => $object) {
305
+ if ( $index === 2) break;
306
+
307
+ if ( $index === 0) {
308
+ $first = $object;
309
+ } else {
310
+ $second = $object;
311
+ }
312
+
313
+ $index++;
314
+ }
315
+
316
+ if ($first['priority'] > $second['priority']) {
317
+ return [$second, $first];
318
+ }
319
+
320
+ return [$first, $second];
321
+ endif;
322
+
323
+ $left = $right = array();
324
+
325
+ $pivot = $array[0];
326
+
327
+ for ($i = 1; $i < $length; $i++) {
328
+ $item = $array[$i];
329
+
330
+ $item['priority'] < $pivot['priority'] ? $left[] = $item : $right[] = $item;
331
+ }
332
+
333
+ return array_merge( $this->sort_by_priority($left), [$pivot], $this->sort_by_priority($right) );
334
+ }
335
+
336
+
337
+
338
+ /**
339
+ * Adds the SWP dependency attributes, if this object has a dependency set.
340
+ *
341
+ * @return string The HTML attributes if the object has dependency, or an empty string.
342
+ */
343
+ protected function render_dependency() {
344
+ if ( !empty( $this->dependency) ) :
345
+ return ' data-dep="' . $this->dependency->parent . '" data-dep_val=\'' . json_encode($this->dependency->values) . '\'';
346
+ endif;
347
+
348
+ return ' ';
349
+ }
350
+
351
+
352
+ /**
353
+ * Adds the SWP premium attributes, if this object is premium.
354
+ *
355
+ * @return string The HTML attribute if the object has dependency, or an empty string.
356
+ */
357
+ protected function render_premium() {
358
+ return;
359
+ if ( isset( $this->premium ) ) :
360
+ return ' premium="true" ';
361
+ endif;
362
+
363
+ return ' ';
364
+ }
365
+
366
+
367
+ /**
368
+ * Sets the key used by dependent sections and options.
369
+ *
370
+ * @since 3.0.0 | 01 MAR 2018 | Created
371
+ * @since 3.1.0 | 14 JUN 2018 | Migrated from child class to here.
372
+ * @param string $key The unique key being assigned to this section.
373
+ * @return SWP_Options_Page_Section $this The updated object.
374
+ *
375
+ */
376
+ public function set_key( $key ) {
377
+ if ( !is_string($key) ) {
378
+ $this->_throw("Please provide a string for your object's key." );
379
+ }
380
+
381
+ $this->key = $key;
382
+
383
+ return $this;
384
+ }
385
+ }
functions/utilities/SWP_CURL.php CHANGED
@@ -1,109 +1,109 @@
1
- <?php
2
-
3
- /**
4
- * SWP_CURL: A class process API share count requests via cURL
5
- *
6
- * @package SocialWarfare\Functions
7
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
- * @license GPL-3.0+
9
- * @since 1.0.0
10
- * @since 3.0.0 | 22 FEB 2018 | Refactored into a class-based system.
11
- *
12
- */
13
- class SWP_CURL {
14
-
15
- public static function fetch_shares_via_curl_multi( $links ) {
16
-
17
- if ( _swp_is_debug( 'is_cache_fresh' ) ) :
18
- $started = time();
19
- echo "Starting multi curl request at : " . $started;
20
- endif;
21
-
22
- $curly = array();
23
- $result = array();
24
-
25
- // multi handle
26
- $mh = curl_multi_init();
27
-
28
- // loop through $links and create curl handles
29
- // then add them to the multi-handle
30
- if( is_array( $links ) ):
31
- foreach ( $links as $network => $link_data ) :
32
- if ( $link_data !== 0 || ($link_data !== 0 && $network == 'google_plus') ) :
33
- $curly[ $network ] = curl_init();
34
-
35
- if ( $network == 'google_plus' ) :
36
-
37
- curl_setopt( $curly[ $network ], CURLOPT_URL, 'https://clients6.google.com/rpc' );
38
- curl_setopt( $curly[ $network ], CURLOPT_POST, true );
39
- curl_setopt( $curly[ $network ], CURLOPT_SSL_VERIFYPEER, false );
40
- curl_setopt( $curly[ $network ], CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . rawurldecode( $link_data ) . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]' );
41
- curl_setopt( $curly[ $network ], CURLOPT_RETURNTRANSFER, true );
42
- curl_setopt( $curly[ $network ], CURLOPT_HTTPHEADER, array( 'Content-type: application/json' ) );
43
-
44
- else :
45
-
46
- $url = (is_array( $link_data ) && ! empty( $link_data['url'] )) ? $link_data['url'] : $link_data;
47
- curl_setopt( $curly[ $network ], CURLOPT_URL, $url );
48
- curl_setopt( $curly[ $network ], CURLOPT_HEADER, 0 );
49
- curl_setopt( $curly[ $network ], CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
50
- curl_setopt( $curly[ $network ], CURLOPT_FAILONERROR, 0 );
51
- curl_setopt( $curly[ $network ], CURLOPT_FOLLOWLOCATION, 0 );
52
- curl_setopt( $curly[ $network ], CURLOPT_RETURNTRANSFER,1 );
53
- curl_setopt( $curly[ $network ], CURLOPT_SSL_VERIFYPEER, false );
54
- curl_setopt( $curly[ $network ], CURLOPT_SSL_VERIFYHOST, false );
55
- curl_setopt( $curly[ $network ], CURLOPT_TIMEOUT, 5 );
56
- curl_setopt( $curly[ $network ], CURLOPT_CONNECTTIMEOUT, 5 );
57
- curl_setopt( $curly[ $network ], CURLOPT_NOSIGNAL, 1 );
58
- curl_setopt( $curly[ $network ], CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
59
- // curl_setopt($curly[$network], CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);
60
- endif;
61
-
62
- curl_multi_add_handle( $mh, $curly[ $network ] );
63
-
64
- endif;
65
- endforeach;
66
- endif;
67
-
68
- // execute the handles
69
- $running = null;
70
- do {
71
- curl_multi_exec( $mh, $running );
72
- } while ($running > 0);
73
-
74
- // get content and remove handles
75
- foreach ( $curly as $network => $content ) {
76
- $result[ $network ] = curl_multi_getcontent( $content );
77
- curl_multi_remove_handle( $mh, $content );
78
- }
79
-
80
- curl_multi_close( $mh );
81
-
82
- return $result;
83
- }
84
-
85
- public static function file_get_contents_curl( $url ) {
86
- $ch = curl_init();
87
- curl_setopt( $ch, CURLOPT_URL, $url );
88
- curl_setopt( $ch, CURLOPT_HEADER, 0 );
89
- curl_setopt( $ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
90
- curl_setopt( $ch, CURLOPT_FAILONERROR, 0 );
91
- curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 0 );
92
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER,1 );
93
- curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
94
- curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
95
- curl_setopt( $ch, CURLOPT_TIMEOUT, 5 );
96
- curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 5 );
97
- curl_setopt( $ch, CURLOPT_NOSIGNAL, 1 );
98
- curl_setopt( $ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
99
- $cont = @curl_exec( $ch );
100
- $curl_errno = curl_errno( $ch );
101
- curl_close( $ch );
102
-
103
- if ( $curl_errno > 0 ) {
104
- return false;
105
- }
106
-
107
- return $cont;
108
- }
109
- }
1
+ <?php
2
+
3
+ /**
4
+ * SWP_CURL: A class process API share count requests via cURL
5
+ *
6
+ * @package SocialWarfare\Functions
7
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
+ * @license GPL-3.0+
9
+ * @since 1.0.0
10
+ * @since 3.0.0 | 22 FEB 2018 | Refactored into a class-based system.
11
+ *
12
+ */
13
+ class SWP_CURL {
14
+
15
+ public static function fetch_shares_via_curl_multi( $links ) {
16
+
17
+ if ( _swp_is_debug( 'is_cache_fresh' ) ) :
18
+ $started = time();
19
+ echo "Starting multi curl request at : " . $started;
20
+ endif;
21
+
22
+ $curly = array();
23
+ $result = array();
24
+
25
+ // multi handle
26
+ $mh = curl_multi_init();
27
+
28
+ // loop through $links and create curl handles
29
+ // then add them to the multi-handle
30
+ if( is_array( $links ) ):
31
+ foreach ( $links as $network => $link_data ) :
32
+ if ( $link_data !== 0 || ($link_data !== 0 && $network == 'google_plus') ) :
33
+ $curly[ $network ] = curl_init();
34
+
35
+ if ( $network == 'google_plus' ) :
36
+
37
+ curl_setopt( $curly[ $network ], CURLOPT_URL, 'https://clients6.google.com/rpc' );
38
+ curl_setopt( $curly[ $network ], CURLOPT_POST, true );
39
+ curl_setopt( $curly[ $network ], CURLOPT_SSL_VERIFYPEER, false );
40
+ curl_setopt( $curly[ $network ], CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . rawurldecode( $link_data ) . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]' );
41
+ curl_setopt( $curly[ $network ], CURLOPT_RETURNTRANSFER, true );
42
+ curl_setopt( $curly[ $network ], CURLOPT_HTTPHEADER, array( 'Content-type: application/json' ) );
43
+
44
+ else :
45
+
46
+ $url = (is_array( $link_data ) && ! empty( $link_data['url'] )) ? $link_data['url'] : $link_data;
47
+ curl_setopt( $curly[ $network ], CURLOPT_URL, $url );
48
+ curl_setopt( $curly[ $network ], CURLOPT_HEADER, 0 );
49
+ curl_setopt( $curly[ $network ], CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
50
+ curl_setopt( $curly[ $network ], CURLOPT_FAILONERROR, 0 );
51
+ curl_setopt( $curly[ $network ], CURLOPT_FOLLOWLOCATION, 0 );
52
+ curl_setopt( $curly[ $network ], CURLOPT_RETURNTRANSFER,1 );
53
+ curl_setopt( $curly[ $network ], CURLOPT_SSL_VERIFYPEER, false );
54
+ curl_setopt( $curly[ $network ], CURLOPT_SSL_VERIFYHOST, false );
55
+ curl_setopt( $curly[ $network ], CURLOPT_TIMEOUT, 5 );
56
+ curl_setopt( $curly[ $network ], CURLOPT_CONNECTTIMEOUT, 5 );
57
+ curl_setopt( $curly[ $network ], CURLOPT_NOSIGNAL, 1 );
58
+ curl_setopt( $curly[ $network ], CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
59
+ // curl_setopt($curly[$network], CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);
60
+ endif;
61
+
62
+ curl_multi_add_handle( $mh, $curly[ $network ] );
63
+
64
+ endif;
65
+ endforeach;
66
+ endif;
67
+
68
+ // execute the handles
69
+ $running = null;
70
+ do {
71
+ curl_multi_exec( $mh, $running );
72
+ } while ($running > 0);
73
+
74
+ // get content and remove handles
75
+ foreach ( $curly as $network => $content ) {
76
+ $result[ $network ] = curl_multi_getcontent( $content );
77
+ curl_multi_remove_handle( $mh, $content );
78
+ }
79
+
80
+ curl_multi_close( $mh );
81
+
82
+ return $result;
83
+ }
84
+
85
+ public static function file_get_contents_curl( $url ) {
86
+ $ch = curl_init();
87
+ curl_setopt( $ch, CURLOPT_URL, $url );
88
+ curl_setopt( $ch, CURLOPT_HEADER, 0 );
89
+ curl_setopt( $ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
90
+ curl_setopt( $ch, CURLOPT_FAILONERROR, 0 );
91
+ curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 0 );
92
+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER,1 );
93
+ curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
94
+ curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
95
+ curl_setopt( $ch, CURLOPT_TIMEOUT, 5 );
96
+ curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 5 );
97
+ curl_setopt( $ch, CURLOPT_NOSIGNAL, 1 );
98
+ curl_setopt( $ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
99
+ $cont = @curl_exec( $ch );
100
+ $curl_errno = curl_errno( $ch );
101
+ curl_close( $ch );
102
+
103
+ if ( $curl_errno > 0 ) {
104
+ return false;
105
+ }
106
+
107
+ return $cont;
108
+ }
109
+ }
functions/utilities/SWP_Compatibility.php CHANGED
@@ -1,150 +1,150 @@
1
- <?php
2
-
3
- /**
4
- * SWP_Compatibility: A class to enhance compatibility with other plugins
5
- *
6
- * @package SocialWarfare\Functions
7
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
- * @license GPL-3.0+
9
- * @since 1.0.0
10
- * @since 3.0.0 | 22 FEB 2018 | Refactored into a class-based system.
11
- *
12
- */
13
- class SWP_Compatibility {
14
-
15
-
16
- /**
17
- * The magic method used to insantiate this class.
18
- *
19
- * This adds compatibility with Simple Podcast Press, the Duplicate Posts
20
- * plugin, and Really Simple SSL.
21
- *
22
- * @since 2.1.4
23
- * @access public
24
- * @param integer $id The post ID
25
- * @return none
26
- *
27
- */
28
- public function __construct() {
29
- // Disabe Open Graph tags on Simple Podcast Press Pages
30
- if ( is_plugin_active( 'simple-podcast-press/simple-podcast-press.php' ) ) {
31
- global $ob_wp_simplepodcastpress;
32
- remove_action( 'wp_head' , array( $ob_wp_simplepodcastpress, 'spp_open_graph' ) , 1 );
33
- }
34
-
35
- // Remove our custom fields when a post is duplicated via the Duplicate Post plugin.
36
- add_action( 'dp_duplicate_post', array( $this , 'remove_fields' ) );
37
-
38
- // Fix the links that are modified by the Really Simple SSL plugin.
39
- add_filter("rsssl_fixer_output", [$this, 'rsssl_fix_compatibility'] );
40
-
41
- }
42
-
43
-
44
- /**
45
- * A function to remove all Social Warfare fields when a post
46
- * is duplicated using the duplicate post plugin.
47
- *
48
- * @since 2.1.4
49
- * @access public
50
- * @param integer $id The post ID
51
- * @return none
52
- *
53
- */
54
- function remove_fields($id) {
55
-
56
- // Delete any share count fields
57
- delete_post_meta( $id , '_buffer_shares' );
58
- delete_post_meta( $id , '_facebook_shares' );
59
- delete_post_meta( $id , '_flipboard_shares' );
60
- delete_post_meta( $id , '_google_plus_shares' );
61
- delete_post_meta( $id , '_hacker_news_shares' );
62
- delete_post_meta( $id , '_linkedin_shares' );
63
- delete_post_meta( $id , '_pinterest_shares' );
64
- delete_post_meta( $id , '_pocket_shares' );
65
- delete_post_meta( $id , '_reddit_shares' );
66
- delete_post_meta( $id , '_stumbleupon_shares' );
67
- delete_post_meta( $id , '_tumblr_shares' );
68
- delete_post_meta( $id , '_twitter_shares' );
69
- delete_post_meta( $id , '_whatsapp_shares' );
70
- delete_post_meta( $id , '_yummly_shares' );
71
- delete_post_meta( $id , '_total_shares' );
72
-
73
- // Delete any bitly links
74
- delete_post_meta( $id , 'bitly_link_buffer' );
75
- delete_post_meta( $id , 'bitly_link_facebook' );
76
- delete_post_meta( $id , 'bitly_link_flipboard' );
77
- delete_post_meta( $id , 'bitly_link_google_plus' );
78
- delete_post_meta( $id , 'bitly_link_hacker_news' );
79
- delete_post_meta( $id , 'bitly_link_linkedin' );
80
- delete_post_meta( $id , 'bitly_link_pinterest' );
81
- delete_post_meta( $id , 'bitly_link_pocket' );
82
- delete_post_meta( $id , 'bitly_link_reddit' );
83
- delete_post_meta( $id , 'bitly_link_stumbleupon' );
84
- delete_post_meta( $id , 'bitly_link_tumblr' );
85
- delete_post_meta( $id , 'bitly_link_twitter' );
86
- delete_post_meta( $id , 'bitly_link_whatsapp' );
87
- delete_post_meta( $id , 'bitly_link_yummly' );
88
- delete_post_meta( $id , 'bitly_link' );
89
-
90
- // Delete any custom options fields
91
- delete_post_meta( $id , 'nc_customTweet' );
92
- delete_post_meta( $id , 'nc_float_location' );
93
- delete_post_meta( $id , 'nc_ogDescription' );
94
- delete_post_meta( $id , 'swp_og_image' );
95
- delete_post_meta( $id , 'nc_ogTitle' );
96
- delete_post_meta( $id , 'nc_pinterest_description' );
97
- delete_post_meta( $id , 'swp_pinterest_image' );
98
- delete_post_meta( $id , 'swp_post_location' );
99
- delete_post_meta( $id , 'sw_fb_author' );
100
- delete_post_meta( $id , 'sw_open_graph_image_data' );
101
- delete_post_meta( $id , 'sw_open_graph_image_url' );
102
- delete_post_meta( $id , 'sw_open_thumbnail_url' );
103
- delete_post_meta( $id , 'sw_pinterest_image_url' );
104
- delete_post_meta( $id , 'sw_twitter_username' );
105
- delete_post_meta( $id , 'swp_cache_timestamp' );
106
- delete_post_meta( $id , 'swp_open_graph_image_data' );
107
- delete_post_meta( $id , 'swp_open_graph_image_url' );
108
- delete_post_meta( $id , 'swp_open_thumbnail_url' );
109
- delete_post_meta( $id , 'swp_pinterest_image_url' );
110
- delete_post_meta( $id , 'swp_recovery_url' );
111
-
112
- $new_meta_fields = [
113
- 'swp_og_image',
114
- 'swp_og_title',
115
- 'swp_pinterest_image',
116
- 'swp_custom_tweet',
117
- 'swp_post_location',
118
- 'swp_float_location',
119
- 'swp_pinterest_description',
120
- 'swp_twitter_id',
121
- 'swp_og_description',
122
- 'swp_pinterest_description',
123
- 'swp_cache_timestamp',
124
- 'swp_pin_browser_extension',
125
- 'swp_pin_browser_extension_location',
126
- 'swp_pin_browser_extension_url'
127
- ];
128
-
129
- foreach($new_meta_fields as $field) {
130
- delete_post_meta( $id, $field );
131
- }
132
-
133
- }
134
-
135
-
136
- /**
137
- * A function to fix the share recovery conflict with Really Simple SSL plugin
138
- * @param string $html A string of html to be filtered
139
- * @return string $html The filtered string of html
140
- * @access public
141
- * @since 2.2.2
142
- *
143
- */
144
- function rsssl_fix_compatibility($html) {
145
- //replace the https back to http
146
- $html = str_replace( "swp_post_recovery_url = 'https://" , "swp_post_recovery_url = 'http://" , $html);
147
- return $html;
148
- }
149
-
150
- }
1
+ <?php
2
+
3
+ /**
4
+ * SWP_Compatibility: A class to enhance compatibility with other plugins
5
+ *
6
+ * @package SocialWarfare\Functions
7
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
8
+ * @license GPL-3.0+
9
+ * @since 1.0.0
10
+ * @since 3.0.0 | 22 FEB 2018 | Refactored into a class-based system.
11
+ *
12
+ */
13
+ class SWP_Compatibility {
14
+
15
+
16
+ /**
17
+ * The magic method used to insantiate this class.
18
+ *
19
+ * This adds compatibility with Simple Podcast Press, the Duplicate Posts
20
+ * plugin, and Really Simple SSL.
21
+ *
22
+ * @since 2.1.4
23
+ * @access public
24
+ * @param integer $id The post ID
25
+ * @return none
26
+ *
27
+ */
28
+ public function __construct() {
29
+ // Disabe Open Graph tags on Simple Podcast Press Pages
30
+ if ( is_plugin_active( 'simple-podcast-press/simple-podcast-press.php' ) ) {
31
+ global $ob_wp_simplepodcastpress;
32
+ remove_action( 'wp_head' , array( $ob_wp_simplepodcastpress, 'spp_open_graph' ) , 1 );
33
+ }
34
+
35
+ // Remove our custom fields when a post is duplicated via the Duplicate Post plugin.
36
+ add_action( 'dp_duplicate_post', array( $this , 'remove_fields' ) );
37
+
38
+ // Fix the links that are modified by the Really Simple SSL plugin.
39
+ add_filter("rsssl_fixer_output", [$this, 'rsssl_fix_compatibility'] );
40
+
41
+ }
42
+
43
+
44
+ /**
45
+ * A function to remove all Social Warfare fields when a post
46
+ * is duplicated using the duplicate post plugin.
47
+ *
48
+ * @since 2.1.4
49
+ * @access public
50
+ * @param integer $id The post ID
51
+ * @return none
52
+ *
53
+ */
54
+ function remove_fields($id) {
55
+
56
+ // Delete any share count fields
57
+ delete_post_meta( $id , '_buffer_shares' );
58
+ delete_post_meta( $id , '_facebook_shares' );
59
+ delete_post_meta( $id , '_flipboard_shares' );
60
+ delete_post_meta( $id , '_google_plus_shares' );
61
+ delete_post_meta( $id , '_hacker_news_shares' );
62
+ delete_post_meta( $id , '_linkedin_shares' );
63
+ delete_post_meta( $id , '_pinterest_shares' );
64
+ delete_post_meta( $id , '_pocket_shares' );
65
+ delete_post_meta( $id , '_reddit_shares' );
66
+ delete_post_meta( $id , '_stumbleupon_shares' );
67
+ delete_post_meta( $id , '_tumblr_shares' );
68
+ delete_post_meta( $id , '_twitter_shares' );
69
+ delete_post_meta( $id , '_whatsapp_shares' );
70
+ delete_post_meta( $id , '_yummly_shares' );
71
+ delete_post_meta( $id , '_total_shares' );
72
+
73
+ // Delete any bitly links
74
+ delete_post_meta( $id , 'bitly_link_buffer' );
75
+ delete_post_meta( $id , 'bitly_link_facebook' );
76
+ delete_post_meta( $id , 'bitly_link_flipboard' );
77
+ delete_post_meta( $id , 'bitly_link_google_plus' );
78
+ delete_post_meta( $id , 'bitly_link_hacker_news' );
79
+ delete_post_meta( $id , 'bitly_link_linkedin' );
80
+ delete_post_meta( $id , 'bitly_link_pinterest' );
81
+ delete_post_meta( $id , 'bitly_link_pocket' );
82
+ delete_post_meta( $id , 'bitly_link_reddit' );
83
+ delete_post_meta( $id , 'bitly_link_stumbleupon' );
84
+ delete_post_meta( $id , 'bitly_link_tumblr' );
85
+ delete_post_meta( $id , 'bitly_link_twitter' );
86
+ delete_post_meta( $id , 'bitly_link_whatsapp' );
87
+ delete_post_meta( $id , 'bitly_link_yummly' );
88
+ delete_post_meta( $id , 'bitly_link' );
89
+
90
+ // Delete any custom options fields
91
+ delete_post_meta( $id , 'nc_customTweet' );
92
+ delete_post_meta( $id , 'nc_float_location' );
93
+ delete_post_meta( $id , 'nc_ogDescription' );
94
+ delete_post_meta( $id , 'swp_og_image' );
95
+ delete_post_meta( $id , 'nc_ogTitle' );
96
+ delete_post_meta( $id , 'nc_pinterest_description' );
97
+ delete_post_meta( $id , 'swp_pinterest_image' );
98
+ delete_post_meta( $id , 'swp_post_location' );
99
+ delete_post_meta( $id , 'sw_fb_author' );
100
+ delete_post_meta( $id , 'sw_open_graph_image_data' );
101
+ delete_post_meta( $id , 'sw_open_graph_image_url' );
102
+ delete_post_meta( $id , 'sw_open_thumbnail_url' );
103
+ delete_post_meta( $id , 'sw_pinterest_image_url' );
104
+ delete_post_meta( $id , 'sw_twitter_username' );
105
+ delete_post_meta( $id , 'swp_cache_timestamp' );
106
+ delete_post_meta( $id , 'swp_open_graph_image_data' );
107
+ delete_post_meta( $id , 'swp_open_graph_image_url' );
108
+ delete_post_meta( $id , 'swp_open_thumbnail_url' );
109
+ delete_post_meta( $id , 'swp_pinterest_image_url' );
110
+ delete_post_meta( $id , 'swp_recovery_url' );
111
+
112
+ $new_meta_fields = [
113
+ 'swp_og_image',
114
+ 'swp_og_title',
115
+ 'swp_pinterest_image',
116
+ 'swp_custom_tweet',
117
+ 'swp_post_location',
118
+ 'swp_float_location',
119
+ 'swp_pinterest_description',
120
+ 'swp_twitter_id',
121
+ 'swp_og_description',
122
+ 'swp_pinterest_description',
123
+ 'swp_cache_timestamp',
124
+ 'swp_pin_browser_extension',
125
+ 'swp_pin_browser_extension_location',
126
+ 'swp_pin_browser_extension_url'
127
+ ];
128
+
129
+ foreach($new_meta_fields as $field) {
130
+ delete_post_meta( $id, $field );
131
+ }
132
+
133
+ }
134
+
135
+
136
+ /**
137
+ * A function to fix the share recovery conflict with Really Simple SSL plugin
138
+ * @param string $html A string of html to be filtered
139
+ * @return string $html The filtered string of html
140
+ * @access public
141
+ * @since 2.2.2
142
+ *
143
+ */
144
+ function rsssl_fix_compatibility($html) {
145
+ //replace the https back to http
146
+ $html = str_replace( "swp_post_recovery_url = 'https://" , "swp_post_recovery_url = 'http://" , $html);
147
+ return $html;
148
+ }
149
+
150
+ }
functions/utilities/SWP_Database_Migration.php CHANGED
@@ -1,649 +1,649 @@
1
- <?php
2
- /**
3
- * The Database updater for Social Warfare 3.0.0.
4
- *
5
- * This willl either migrate previous options to social_warfare_settings,
6
- * or create the new default settings.
7
- *
8
- * @since 3.0.0 | 08 MAY 2018 | Created
9
- * @since 3.0.6 | 14 MAY 2018 | Added local $last_migrated property.
10
- * @since 3.1.0 | 13 JUN 2018 | Replaced array bracket notation.
11
- *
12
- */
13
- class SWP_Database_Migration {
14
-
15
-
16
- /**
17
- * This property represents the version during which we last made changes
18
- * and therefore want the database migrator to have run up to this version.
19
- *
20
- * @var string
21
- *
22
- */
23
- public $last_migrated = '3.0.5';
24
-
25
-
26
- /**
27
- * Checks to see if we are on the most up-to-date database schema.
28
- *
29
- * If not, runs the migration and updators.
30
- *
31
- * @since 3.0.0 | 01 MAY 2018 | Created the function
32
- * @param void
33
- * @return void
34
- *
35
- */
36
- public function __construct() {
37
-
38
- // Set up the defaults before directing into the template functions.
39
- add_action( 'template_redirect' , array( $this , 'scan_for_new_defaults' ) );
40
-
41
- // Queue up the migrate features to run after plugins are loaded.
42
- add_action( 'plugins_loaded', array( $this, 'init' ) );
43
- }
44
-
45
-
46
- /**
47
- * This function initializes and calls up all the migration methods.
48
- *
49
- * @since 3.0.0 | 08 MAY 2018 | Created
50
- * @param void
51
- * @return void
52
- *
53
- */
54
- public function init() {
55
-
56
- // Check for and migrate the settings page data.
57
- if ( !$this->database_is_migrated() ) {
58
- $this->migrate();
59
- }
60
-
61
- // Initialize the database for new installs.
62
- if ( !$this->has_3_0_0_settings() ) {
63
- $this->initialize_database();
64
- }
65
-
66
- // Check for and migrate the post meta fields.
67
- if ( !$this->post_meta_is_migrated() ) {
68
- $this->update_post_meta();
69
- $this->update_hidden_post_meta();
70
- $this->update_last_migrated();
71
- }
72
-
73
- $this->debug_parameters();
74
-
75
-
76
- }
77
-
78
-
79
- /**
80
- * A method to allow for easier debugging of database migration functions.
81
- *
82
- * The following URL parameters may be used for debugging purposes:
83
- * ?swp_debug=get_user_options | Outputs an array of user settings.
84
- * ?swp_debug=migrate_db | Runs settings page db migrator.
85
- * ?swp_debug=initialize_db | Runs the database initializer.
86
- * ?swp_debug=migrate_post_meta | Migrates the post meta fields.
87
- * ?swp_debug=get_last_migrated | Outputs the last_updated version number.
88
- * ?swp_debug=update_last_migrated | Updates the last_updated version number.
89
- *
90
- * @since 3.1.0 | 13 JUN 2018 | Created
91
- * @param void
92
- * @return void
93
- */
94
- public function debug_parameters() {
95
-
96
- // Output an array of user options if called via a debugging parameter.
97
- if ( true === _swp_is_debug('get_user_options') ) :
98
- echo "<pre>";
99
- var_export( get_option( 'social_warfare_settings', array() ) );
100
- echo "</pre>";
101
- wp_die();
102
- endif;
103
-
104
- // Migrate settings page if explicitly being called via a debugging parameter.
105
- if ( true === _swp_is_debug('migrate_db') ) {
106
- $this->migrate();
107
- }
108
-
109
- // Initialize database if explicitly being called via a debugging parameter.
110
- if ( true === _swp_is_debug('initialize_db') ) {
111
- $this->initialize_db();
112
- }
113
-
114
- // Update post meta if explicitly being called via a debugging parameter.
115
- if ( true === _swp_is_debug('migrate_post_meta') ) {
116
- $this->update_post_meta();
117
- $this->update_hidden_post_meta();
118
- }
119
-
120
- // Output the last_migrated status if called via a debugging parameter.
121
- if ( true === _swp_is_Debug('get_last_migrated') ) {
122
- $this->get_last_migrated( true );
123
- }
124
-
125
- // Update the last migrated status if called via a debugging parameter.
126
- if ( true === _swp_is_Debug('update_last_migrated') ) {
127
- $this->update_last_migrated();
128
- }
129
- }
130
-
131
- /**
132
- * Checks to see if Social Warfare < 3.0.0 options exist.
133
- *
134
- * If these options exist in the databse, we need to move them
135
- * from "socialWarfareOptions" to "social_warfare_settings",
136
- * then
137
- *
138
- * @since 3.0.0 | 01 MAY 2018 | Created the function
139
- * @param void
140
- * @return bool True if migrated, else false.
141
- *
142
- */
143
- public function database_is_migrated() {
144
- $option = get_option( 'social_warfare_settings' , false);
145
- return false !== $option;
146
- }
147
-
148
-
149
- /**
150
- * Checks to see if we have 3.0.0 settings installed or not.
151
- *
152
- * @since 3.0.0 | 01 MAY 2018 | Created the function
153
- * @param void
154
- * @return bool True if the 3.0.0 array exists, otherwise false.
155
- *
156
- */
157
- protected function has_3_0_0_settings() {
158
-
159
- //* Check to see if the 3.0.0 settings exist.
160
- $settings = get_option( 'social_warfare_settings', false );
161
- return is_array( $settings );
162
- }
163
-
164
-
165
- /**
166
- * Tries to get an option that uses the old post_meta keynames.
167
- *
168
- * @since 3.0.0 | 01 MAY 2018 | Created the function
169
- * @param void
170
- * @return bool True if the old option still exists; false otherwise.
171
- *
172
- */
173
- public function post_meta_is_migrated() {
174
- if( $this->last_migrated !== $this->get_last_migrated() ) {
175
- return false;
176
- }
177
-
178
- //* Fetch posts with 2.3.5 metadata.
179
- $old_metadata = get_posts( array( 'meta_key' => 'nc_postLocation', 'numberposts' => 1 ) );
180
-
181
- return count( $old_metadata ) === 0;
182
- }
183
-
184
- /**
185
- * Creates the default value for any new keys.
186
- *
187
- * @since 3.0.8 | 16 MAY 2018 | Created the method.
188
- * @since 3.0.8 | 24 MAY 2018 | Added check for order_of_icons
189
- * @since 3.1.0 | 13 JUN 2018 | Replaced array bracket notation.
190
- * @param void
191
- * @return void
192
- *
193
- */
194
- public function scan_for_new_defaults() {
195
- global $swp_user_options;
196
-
197
- $updated = false;
198
- $defaults = apply_filters( 'swp_options_page_defaults', array() );
199
-
200
- // Manually set the order_of_icons default.
201
- $defaults['order_of_icons'] = array(
202
- 'google_plus' => 'google_plus',
203
- 'twitter' => 'twitter',
204
- 'facebook' => 'facebook',
205
- 'linkedin' => 'linkedin',
206
- 'pinterest' => 'pinterest'
207
- );
208
-
209
- foreach ($defaults as $key => $value ) {
210
- if ( !array_key_exists( $key, $swp_user_options) ) :
211
- $swp_user_options[$key] = $value;
212
- $updated = true;
213
- endif;
214
- }
215
-
216
- if ( $updated ) {
217
- update_option( 'social_warfare_settings', $swp_user_options );
218
- }
219
-
220
- }
221
-
222
-
223
- /**
224
- * A method for updating the post meta fields.
225
- *
226
- * @since 3.0.0 | 08 MAY 2018 | Created
227
- * @since 3.1.0 | 13 JUN 2018 | Replaced array bracket notations.
228
- * @param void
229
- * @return void
230
- *
231
- */
232
- public function update_hidden_post_meta() {
233
- global $wpdb;
234
-
235
- try {
236
- set_time_limit(300);
237
- } catch (Exception $e) {
238
- if ( function_exists( 'error_log' ) ) :
239
- error_log($e->getMessage());
240
- endif;
241
- }
242
-
243
- $hidden_map = array(
244
- '_googlePlus_shares' => '_google_plus_shares',
245
- '_linkedIn_shares' => '_linkedin_shares',
246
- 'bitly_link_googlePlus' => '_bitly_link_google_plus',
247
- 'bitly_link_linkedIn' => '_bitly_link_linked_in'
248
- );
249
-
250
- $query = "
251
- UPDATE " . $wpdb->prefix . "postmeta
252
- SET meta_key = %s
253
- WHERE meta_key = %s
254
- ";
255
-
256
- foreach ( $hidden_map as $old_key => $new_key ) {
257
- //* Make replacements for the first kind of prefix.
258
- $q = $wpdb->prepare( $query, $new_key, $old_key );
259
- $wpdb->query( $q );
260
- }
261
- }
262
-
263
-
264
- /**
265
- * Replaces 2.3.5 camelCased keys with 3.0.0 standardized snake_cased keys.
266
- *
267
- * @since 3.0.0 | 01 MAY 2018 | Created the function
268
- * @since 3.0.6 | 14 MAY 2018 | Added time limit to prevent very large datasets from timing out.
269
- * @param void
270
- * @return void
271
- *
272
- */
273
- public function update_post_meta() {
274
- global $wpdb;
275
-
276
- set_time_limit(300);
277
-
278
- //* Notice there is no prefix on any of the indices.
279
- //* Old code has prefixed these with either "nc_" or "swp_".
280
- //* For simplicity's sake, we'll just check each for both.
281
- $metadata_map = array(
282
- 'ogImage' => 'swp_og_image',
283
- 'ogTitle' => 'swp_og_title',
284
- 'pinterestImage' => 'swp_pinterest_image',
285
- 'customTweet' => 'swp_custom_tweet',
286
- 'postLocation' => 'swp_post_location',
287
- 'floatLocation' => 'swp_float_location',
288
- 'pinterestDescription' => 'swp_pinterest_description',
289
- 'twitterID' => 'swp_twitter_id',
290
- 'ogDescription' => 'swp_og_description',
291
- 'cache_timestamp' => 'swp_cache_timestamp',
292
- 'pin_browser_extension' => 'swp_pin_browser_extension',
293
- 'pin_browser_extension_location' => 'swp_pin_browser_extension_location',
294
- 'pin_browser_extension_url' => 'swp_pin_browser_extension_url',
295
- 'totes' => 'total_shares'
296
- );
297
-
298
- $prefix1 = "nc_";
299
- $prefix2 = "swp_";
300
-
301
- $query = "
302
- UPDATE " . $wpdb->prefix . "postmeta
303
- SET meta_key = %s
304
- WHERE meta_key = %s
305
- ";
306
-
307
- foreach ( $metadata_map as $old_key => $new_key ) {
308
- //* Make replacements for the first kind of prefix.
309
- $q1 = $wpdb->prepare( $query, $new_key, $prefix1 . $old_key );
310
- $results = $wpdb->query( $q1 );
311
-
312
- //* And make replacements for the second kind of prefix.
313
- $q2 = $wpdb->prepare( $query, $new_key, $prefix2 . $old_key );
314
- $results = $wpdb->query( $q2 );
315
- }
316
-
317
- }
318
-
319
-
320
- /**
321
- * Seeds the database with Social Warfare 3.0.0 default values.
322
- *
323
- * @since 3.0.0 | 01 MAY 2018 | Created the function
324
- * @param void
325
- * @return void
326
- *
327
- */
328
- public function initialize_database() {
329
- $defaults = array(
330
- 'location_archive_categories' => 'below',
331
- 'location_home' => 'none',
332
- 'location_post' => 'below',
333
- 'location_page' => 'below',
334
- 'float_location_post' => 'on',
335
- 'float_location_page' => 'off',
336
- 'total_shares' => true,
337
- 'network_shares' => true,
338
- 'twitter_id' => false,
339
- 'swp_twitter_card' => true,
340
- 'button_shape' => 'flatFresh',
341
- 'default_colors' => 'full_color',
342
- 'single_colors' => 'full_color',
343
- 'hover_colors' => 'full_color',
344
- 'float_default_colors' => 'full_color',
345
- 'float_single_colors' => 'full_color',
346
- 'float_hover_colors' => 'fullColor',
347
- 'float_style_source' => true,
348
- 'float_size' => 1,
349
- 'float_alignment' => 'center',
350
- 'button_size' => 1,
351
- 'button_alignment' => 'fullWidth',
352
- 'transition' => 'slide',
353
- 'float_screen_width' => 1100,
354
- 'ctt_theme' => 'style1',
355
- 'ctt_css' => "",
356
- 'twitter_shares' => false,
357
- 'floating_panel' => true,
358
- 'float_location' => 'bottom',
359
- 'float_background_color' => '#ffffff',
360
- 'float_button_shape' => 'default',
361
- 'float_vertical' => 'center',
362
- 'float_button_count' => 5,
363
- 'custom_color' => '#000000',
364
- 'custom_color_outlines' => '#000000',
365
- 'float_custom_color' => '#000000',
366
- 'float_custom_color_outlines' => '#000000',
367
- 'recover_shares' => false,
368
- 'recovery_format' => 'unchanged',
369
- 'recovery_protocol' => 'unchanged',
370
- 'recovery_prefix' => 'unchanged',
371
- 'decimals' => 0,
372
- 'decimal_separator' => 'period',
373
- 'totals_alignment' => 'total_sharesalt',
374
- 'google_analytics' => false,
375
- 'bitly_authentication' => false,
376
- 'minimum_shares' => 0,
377
- 'full_content' => false,
378
- 'frame_buster' => false,
379
- 'analytics_medium' => 'social',
380
- 'analytics_campaign' => 'SocialWarfare',
381
- 'swp_click_tracking' => false,
382
- 'order_of_icons_method' => 'manual',
383
- 'og_post' => 'article',
384
- 'og_page' => 'article',
385
- 'pinterest_image_location' => 'hidden',
386
- 'pin_browser_extension' => false,
387
- 'pinterest_fallback' => 'all',
388
- 'pinit_toggle' => false,
389
- 'pinit_location_horizontal' => 'center',
390
- 'pinit_location_vertical' => 'top',
391
- 'pinit_min_width' => '200',
392
- 'pinit_min_height' => '200',
393
- 'pinit_image_source' => 'image',
394
- 'pinit_image_description' => 'alt_text',
395
- 'utm_on_pins' => false,
396
- 'pin_browser_extension' => false,
397
- 'pin_browser_extension_location' => 'hidden',
398
- 'pinterest_fallback' => 'all',
399
- 'float_mobile' => 'bottom',
400
- 'force_new_shares' => false,
401
- 'cache_method' => 'advanced',
402
- 'order_of_icons' => array(
403
- 'twitter' => 'Twitter',
404
- 'linkedIn' => 'LinkedIn',
405
- 'pinterest' => 'Pinterest',
406
- 'facebook' => 'Facebook',
407
- 'google_plus' => 'Google Plus',
408
- ),
409
- );
410
-
411
- update_option( 'social_warfare_settings', $defaults );
412
- }
413
-
414
-
415
- /**
416
- * Map prevous key/value pairs to new keys.
417
- *
418
- * This also deletes the previous keys once the migration is done.
419
- * @since 3.0.0 | 01 MAY 2018 | Created the function
420
- * @since 3.1.0 | 13 JUN 2018 | Replaced array bracket notation.
421
- * @param void
422
- * @return void
423
- *
424
- */
425
- private function migrate() {
426
- $options = get_option( 'socialWarfareOptions', array() );
427
-
428
- if ( $options === array() ) :
429
- //* The old options do not exist.
430
- return;
431
- endif;
432
-
433
- $map = array(
434
- //* Options names
435
- 'locationSite' => 'location_archive_categories',
436
- 'locationHome' => 'location_home',
437
- 'totesEach' => 'network_shares',
438
- 'totes' => 'total_shares',
439
- 'minTotes' => 'minimum_shares',
440
- 'visualTheme' => 'button_shape',
441
- 'buttonSize' => 'button_size',
442
- 'dColorSet' => 'default_colors',
443
- 'oColorSet' => 'hover_colors',
444
- 'iColorSet' => 'single_colors',
445
- 'swDecimals' => 'decimals',
446
- 'swp_decimal_separator' => 'decimal_separator',
447
- 'swTotesFormat' => 'totals_alignment',
448
- 'float' => 'floating_panel',
449
- 'floatOption' => 'float_location',
450
- 'swp_float_scr_sz' => 'float_screen_width',
451
- 'sideReveal' => 'transition',
452
- 'floatStyle' => 'float_button_shape',
453
- 'floatStyleSource' => 'float_style_source',
454
- 'sideDColorSet' => 'float_default_colors',
455
- 'sideOColorSet' => 'float_hover_colors',
456
- 'sideIColorSet' => 'float_single_colors',
457
- 'swp_twitter_card' => 'twitter_cards',
458
- 'twitterID' => 'twitter_id',
459
- 'pinterestID' => 'pinterest_id',
460
- 'facebookPublisherUrl' => 'facebook_publisher_url',
461
- 'facebookAppID' => 'facebook_app_id',
462
- 'sniplyBuster' => 'frame_buster',
463
- 'linkShortening' => 'bitly_authentication',
464
- 'cacheMethod' => 'cache_method',
465
- 'googleAnalytics' => 'google_analytics',
466
- 'analyticsMedium' => 'analytics_medium',
467
- 'analyticsCampaign' => 'analytics_campaign',
468
- 'advanced_pinterest_image' => 'pin_browser_extension',
469
- 'advanced_pinterest_image_location' => 'pinterest_image_location',
470
- 'pin_browser_extension_location' => 'pin_browser_extension_location',
471
- 'advanced_pinterest_fallback' => 'pinterest_fallback',
472
- 'recovery_custom_format' => 'recovery_permalink',
473
- 'cttTheme' => 'ctt_theme',
474
- 'cttCSS' => 'ctt_css',
475
- 'sideCustomColor' => 'single_custom_color',
476
- 'floatBgColor' => 'float_background_color',
477
- 'orderOfIconsSelect' => 'order_of_icons_method',
478
- 'newOrderOfIcons' => 'order_of_icons',
479
- );
480
-
481
- $value_map = array(
482
- 'flatFresh' => 'flat_fresh',
483
- 'threeDee' => 'three_dee',
484
- 'fullColor' => 'full_color',
485
- 'lightGray' => 'light_gray',
486
- 'mediumGray' => 'medium_gray',
487
- 'darkGray' => 'dark_gray',
488
- 'lgOutlines' => 'light_gray_outlines',
489
- 'mdOutlines' => 'medium_gray_outlines',
490
- 'dgOutlines' => 'dark_gray_outlines',
491
- 'colorOutlines' => 'color_outlines',
492
- 'customColor' => 'custom_color',
493
- 'ccOutlines' => 'custom_color_outlines',
494
- 'totesAlt' => 'totals_right',
495
- 'totesAltLeft' => 'totals_left',
496
- 'buttonFloat' => 'button_alignment',
497
- 'post' => 'location_post',
498
- 'page' => 'location_page',
499
- 'float_vertical'=> 'float_alignment',
500
- 'fullWidth' => 'full_width',
501
- 'floatLeftMobile' => 'float_mobile',
502
- );
503
-
504
- $migrations = array();
505
-
506
- foreach( $options as $old => $value ) {
507
- //* The order of icons used to be stored in an array at 'active'.
508
- if ( is_array( $value) && array_key_exists( 'active', $value) ) :
509
- $new_value = $value;
510
- //* Filter out the booleans and integers.
511
- elseif ( is_string( $value ) ):
512
- $new_value = array_key_exists($value, $value_map) ? $value_map[$value] : $value;
513
- else :
514
- $new_value = $value;
515
- endif;
516
-
517
- //* Specific case: newOrderOfIcons mapping.
518
- if ( 'newOrderOfIcons' === $old ) :
519
- if ( array_key_exists( 'googlePlus', $new_value ) ) :
520
- unset( $new_value['googlePlus'] );
521
- $new_value[] = 'google_plus';
522
- endif;
523
-
524
- if (array_key_exists( 'linkedIn', $new_value) ) :
525
- unset( $new_value['linkedIn'] );
526
- $new_value[] = 'linkedin';
527
- endif;
528
- endif;
529
-
530
- //* Specific case: customColor mapping.
531
- if ( $old === 'customColor' ) :
532
- $migrations['custom_color'] = $new_value;
533
- $migrations['custom_color_outlines'] = $new_value;
534
-
535
- // If the float style source is set to inherit the style from the static buttons.
536
- if ( $options['floatStyleSource'] == true ) :
537
- $migrations['float_custom_color'] = $new_value;
538
- $migrations['float_custom_color_outlines'] = $new_value;
539
- endif;
540
- endif;
541
-
542
- // Only if the source is set to not inherit them from the static buttons.
543
- if ( $old === 'sideCustomColor' ) :
544
- $migrations['float_custom_color'] = $new_value;
545
- $migrations['float_custom_color_outlines'] = $new_value;
546
- endif;
547
-
548
- if ( array_key_exists( $old, $map) ) :
549
- //* We specified an update to the key.
550
- $new = $map[$old];
551
- $migrations[$new] = $new_value;
552
- else :
553
- //* The previous key was fine, keep it.
554
- $migrations[$old] = $new_value;
555
- endif;
556
-
557
- }
558
-
559
- //* Manually adding these in as short term solution.
560
- if ( !isset( $migrations['float_size'] ) ) :
561
- $migrations['float_size'] = '1';
562
- endif;
563
-
564
- if ( !isset( $migrations['float_location'] ) ) :
565
- $migrations['float_location'] = 'bottom';
566
- endif;
567
-
568
- if ( !isset( $migrations['float_alignment'] ) ) :
569
- $migrations['float_alignment'] = 'center';
570
- endif;
571
-
572
- $custom_colors = array( 'custom_color', 'custom_color_outlines', 'float_custom_color', 'float_custom_color_outlines' );
573
-
574
- foreach( $custom_colors as $color ) {
575
- if ( !isset($migrations[$color] ) ) :
576
- $migrations[$color] = "#333333";
577
- endif;
578
- }
579
-
580
- $removals = array(
581
- 'dashboardShares',
582
- 'rawNumbers',
583
- 'notShowing',
584
- 'visualEditorBug',
585
- 'loopFix',
586
- 'locationrevision',
587
- 'locationattachment',
588
- );
589
-
590
- foreach ( $removals as $trash ) :
591
- if ( ( $migrations[$trash] ) ) :
592
- unset($migrations[$trash]);
593
- endif;
594
- endforeach;
595
-
596
- update_option( 'social_warfare_settings', $migrations );
597
- //* Play it safe for now.
598
- //* Leave socialWarfareOptions in the database.
599
- // delete_option( 'socialWarfareOptions' );
600
- }
601
-
602
-
603
- /**
604
- * Get Last Migrated
605
- *
606
- * This method gets the version number during which the last migration was
607
- * run. This allows us to increment a version if we need a part of this class
608
- * to run again.
609
- *
610
- * @since 3.0.0 | Created | 08 MAY 2018
611
- * @param boolean $echo True echoes the data; False returns it.
612
- * @return mixed (str) Version number if found, (bool) false if not found.
613
- *
614
- */
615
- public function get_last_migrated( $echo = false ) {
616
- $options = get_option( 'social_warfare_settings' );
617
-
618
- if ( array_key_exists( 'last_migrated', $options ) ) :
619
- if ( true === $echo ) :
620
- var_dump( $options['last_migrated'] );
621
- endif;
622
-
623
- return $options['last_migrated'];
624
- endif;
625
-
626
- if ( true === $echo ) :
627
- echo "No previous migration version has been set.";
628
- endif;
629
-
630
- return false;
631
-
632
- }
633
-
634
-
635
- /**
636
- * A method to update the last migrated version number.
637
- *
638
- * @since 3.0.0 | Created | 08 MAY 2018
639
- * @param null
640
- * @return void
641
- *
642
- */
643
- public function update_last_migrated() {
644
- $options = get_option( 'social_warfare_settings' );
645
- $options['last_migrated'] = $this->last_migrated;
646
-
647
- update_option( 'social_warfare_settings', $options );
648
- }
649
- }
1
+ <?php
2
+ /**
3
+ * The Database updater for Social Warfare 3.0.0.
4
+ *
5
+ * This willl either migrate previous options to social_warfare_settings,
6
+ * or create the new default settings.
7
+ *
8
+ * @since 3.0.0 | 08 MAY 2018 | Created
9
+ * @since 3.0.6 | 14 MAY 2018 | Added local $last_migrated property.
10
+ * @since 3.1.0 | 13 JUN 2018 | Replaced array bracket notation.
11
+ *
12
+ */
13
+ class SWP_Database_Migration {
14
+
15
+
16
+ /**
17
+ * This property represents the version during which we last made changes
18
+ * and therefore want the database migrator to have run up to this version.
19
+ *
20
+ * @var string
21
+ *
22
+ */
23
+ public $last_migrated = '3.0.5';
24
+
25
+
26
+ /**
27
+ * Checks to see if we are on the most up-to-date database schema.
28
+ *
29
+ * If not, runs the migration and updators.
30
+ *
31
+ * @since 3.0.0 | 01 MAY 2018 | Created the function
32
+ * @param void
33
+ * @return void
34
+ *
35
+ */
36
+ public function __construct() {
37
+
38
+ // Set up the defaults before directing into the template functions.
39
+ add_action( 'template_redirect' , array( $this , 'scan_for_new_defaults' ) );
40
+
41
+ // Queue up the migrate features to run after plugins are loaded.
42
+ add_action( 'plugins_loaded', array( $this, 'init' ) );
43
+ }
44
+
45
+
46
+ /**
47
+ * This function initializes and calls up all the migration methods.
48
+ *
49
+ * @since 3.0.0 | 08 MAY 2018 | Created
50
+ * @param void
51
+ * @return void
52
+ *
53
+ */
54
+ public function init() {
55
+
56
+ // Check for and migrate the settings page data.
57
+ if ( !$this->database_is_migrated() ) {
58
+ $this->migrate();
59
+ }
60
+
61
+ // Initialize the database for new installs.
62
+ if ( !$this->has_3_0_0_settings() ) {
63
+ $this->initialize_database();
64
+ }
65
+
66
+ // Check for and migrate the post meta fields.
67
+ if ( !$this->post_meta_is_migrated() ) {
68
+ $this->update_post_meta();
69
+ $this->update_hidden_post_meta();
70
+ $this->update_last_migrated();
71
+ }
72
+
73
+ $this->debug_parameters();
74
+
75
+
76
+ }
77
+
78
+
79
+ /**
80
+ * A method to allow for easier debugging of database migration functions.
81
+ *
82
+ * The following URL parameters may be used for debugging purposes:
83
+ * ?swp_debug=get_user_options | Outputs an array of user settings.
84
+ * ?swp_debug=migrate_db | Runs settings page db migrator.
85
+ * ?swp_debug=initialize_db | Runs the database initializer.
86
+ * ?swp_debug=migrate_post_meta | Migrates the post meta fields.
87
+ * ?swp_debug=get_last_migrated | Outputs the last_updated version number.
88
+ * ?swp_debug=update_last_migrated | Updates the last_updated version number.
89
+ *
90
+ * @since 3.1.0 | 13 JUN 2018 | Created
91
+ * @param void
92
+ * @return void
93
+ */
94
+ public function debug_parameters() {
95
+
96
+ // Output an array of user options if called via a debugging parameter.
97
+ if ( true === _swp_is_debug('get_user_options') ) :
98
+ echo "<pre>";
99
+ var_export( get_option( 'social_warfare_settings', array() ) );
100
+ echo "</pre>";
101
+ wp_die();
102
+ endif;
103
+
104
+ // Migrate settings page if explicitly being called via a debugging parameter.
105
+ if ( true === _swp_is_debug('migrate_db') ) {
106
+ $this->migrate();
107
+ }
108
+
109
+ // Initialize database if explicitly being called via a debugging parameter.
110
+ if ( true === _swp_is_debug('initialize_db') ) {
111
+ $this->initialize_db();
112
+ }
113
+
114
+ // Update post meta if explicitly being called via a debugging parameter.
115
+ if ( true === _swp_is_debug('migrate_post_meta') ) {
116
+ $this->update_post_meta();
117
+ $this->update_hidden_post_meta();
118
+ }
119
+
120
+ // Output the last_migrated status if called via a debugging parameter.
121
+ if ( true === _swp_is_Debug('get_last_migrated') ) {
122
+ $this->get_last_migrated( true );
123
+ }
124
+
125
+ // Update the last migrated status if called via a debugging parameter.
126
+ if ( true === _swp_is_Debug('update_last_migrated') ) {
127
+ $this->update_last_migrated();
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Checks to see if Social Warfare < 3.0.0 options exist.
133
+ *
134
+ * If these options exist in the databse, we need to move them
135
+ * from "socialWarfareOptions" to "social_warfare_settings",
136
+ * then
137
+ *
138
+ * @since 3.0.0 | 01 MAY 2018 | Created the function
139
+ * @param void
140
+ * @return bool True if migrated, else false.
141
+ *
142
+ */
143
+ public function database_is_migrated() {
144
+ $option = get_option( 'social_warfare_settings' , false);
145
+ return false !== $option;
146
+ }
147
+
148
+
149
+ /**
150
+ * Checks to see if we have 3.0.0 settings installed or not.
151
+ *
152
+ * @since 3.0.0 | 01 MAY 2018 | Created the function
153
+ * @param void
154
+ * @return bool True if the 3.0.0 array exists, otherwise false.
155
+ *
156
+ */
157
+ protected function has_3_0_0_settings() {
158
+
159
+ //* Check to see if the 3.0.0 settings exist.
160
+ $settings = get_option( 'social_warfare_settings', false );
161
+ return is_array( $settings );
162
+ }
163
+
164
+
165
+ /**
166
+ * Tries to get an option that uses the old post_meta keynames.
167
+ *
168
+ * @since 3.0.0 | 01 MAY 2018 | Created the function
169
+ * @param void
170
+ * @return bool True if the old option still exists; false otherwise.
171
+ *
172
+ */
173
+ public function post_meta_is_migrated() {
174
+ if( $this->last_migrated !== $this->get_last_migrated() ) {
175
+ return false;
176
+ }
177
+
178
+ //* Fetch posts with 2.3.5 metadata.
179
+ $old_metadata = get_posts( array( 'meta_key' => 'nc_postLocation', 'numberposts' => 1 ) );
180
+
181
+ return count( $old_metadata ) === 0;
182
+ }
183
+
184
+ /**
185
+ * Creates the default value for any new keys.
186
+ *
187
+ * @since 3.0.8 | 16 MAY 2018 | Created the method.
188
+ * @since 3.0.8 | 24 MAY 2018 | Added check for order_of_icons
189
+ * @since 3.1.0 | 13 JUN 2018 | Replaced array bracket notation.
190
+ * @param void
191
+ * @return void
192
+ *
193
+ */
194
+ public function scan_for_new_defaults() {
195
+ global $swp_user_options;
196
+
197
+ $updated = false;
198
+ $defaults = apply_filters( 'swp_options_page_defaults', array() );
199
+
200
+ // Manually set the order_of_icons default.
201
+ $defaults['order_of_icons'] = array(
202
+ 'google_plus' => 'google_plus',
203
+ 'twitter' => 'twitter',
204
+ 'facebook' => 'facebook',
205
+ 'linkedin' => 'linkedin',
206
+ 'pinterest' => 'pinterest'
207
+ );
208
+
209
+ foreach ($defaults as $key => $value ) {
210
+ if ( !array_key_exists( $key, $swp_user_options) ) :
211
+ $swp_user_options[$key] = $value;
212
+ $updated = true;
213
+ endif;
214
+ }
215
+
216
+ if ( $updated ) {
217
+ update_option( 'social_warfare_settings', $swp_user_options );
218
+ }
219
+
220
+ }
221
+
222
+
223
+ /**
224
+ * A method for updating the post meta fields.
225
+ *
226
+ * @since 3.0.0 | 08 MAY 2018 | Created
227
+ * @since 3.1.0 | 13 JUN 2018 | Replaced array bracket notations.
228
+ * @param void
229
+ * @return void
230
+ *
231
+ */
232
+ public function update_hidden_post_meta() {
233
+ global $wpdb;
234
+
235
+ try {
236
+ set_time_limit(300);
237
+ } catch (Exception $e) {
238
+ if ( function_exists( 'error_log' ) ) :
239
+ error_log($e->getMessage());
240
+ endif;
241
+ }
242
+
243
+ $hidden_map = array(
244
+ '_googlePlus_shares' => '_google_plus_shares',
245
+ '_linkedIn_shares' => '_linkedin_shares',
246
+ 'bitly_link_googlePlus' => '_bitly_link_google_plus',
247
+ 'bitly_link_linkedIn' => '_bitly_link_linked_in'
248
+ );
249
+
250
+ $query = "
251
+ UPDATE " . $wpdb->prefix . "postmeta
252
+ SET meta_key = %s
253
+ WHERE meta_key = %s
254
+ ";
255
+
256
+ foreach ( $hidden_map as $old_key => $new_key ) {
257
+ //* Make replacements for the first kind of prefix.
258
+ $q = $wpdb->prepare( $query, $new_key, $old_key );
259
+ $wpdb->query( $q );
260
+ }
261
+ }
262
+
263
+
264
+ /**
265
+ * Replaces 2.3.5 camelCased keys with 3.0.0 standardized snake_cased keys.
266
+ *
267
+ * @since 3.0.0 | 01 MAY 2018 | Created the function
268
+ * @since 3.0.6 | 14 MAY 2018 | Added time limit to prevent very large datasets from timing out.
269
+ * @param void
270
+ * @return void
271
+ *
272
+ */
273
+ public function update_post_meta() {
274
+ global $wpdb;
275
+
276
+ set_time_limit(300);
277
+
278
+ //* Notice there is no prefix on any of the indices.
279
+ //* Old code has prefixed these with either "nc_" or "swp_".
280
+ //* For simplicity's sake, we'll just check each for both.
281
+ $metadata_map = array(
282
+ 'ogImage' => 'swp_og_image',
283
+ 'ogTitle' => 'swp_og_title',
284
+ 'pinterestImage' => 'swp_pinterest_image',
285
+ 'customTweet' => 'swp_custom_tweet',
286
+ 'postLocation' => 'swp_post_location',
287
+ 'floatLocation' => 'swp_float_location',
288
+ 'pinterestDescription' => 'swp_pinterest_description',
289
+ 'twitterID' => 'swp_twitter_id',
290
+ 'ogDescription' => 'swp_og_description',
291
+ 'cache_timestamp' => 'swp_cache_timestamp',
292
+ 'pin_browser_extension' => 'swp_pin_browser_extension',
293
+ 'pin_browser_extension_location' => 'swp_pin_browser_extension_location',
294
+ 'pin_browser_extension_url' => 'swp_pin_browser_extension_url',
295
+ 'totes' => 'total_shares'
296
+ );
297
+
298
+ $prefix1 = "nc_";
299
+ $prefix2 = "swp_";
300
+
301
+ $query = "
302
+ UPDATE " . $wpdb->prefix . "postmeta
303
+ SET meta_key = %s
304
+ WHERE meta_key = %s
305
+ ";
306
+
307
+ foreach ( $metadata_map as $old_key => $new_key ) {
308
+ //* Make replacements for the first kind of prefix.
309
+ $q1 = $wpdb->prepare( $query, $new_key, $prefix1 . $old_key );
310
+ $results = $wpdb->query( $q1 );
311
+
312
+ //* And make replacements for the second kind of prefix.
313
+ $q2 = $wpdb->prepare( $query, $new_key, $prefix2 . $old_key );
314
+ $results = $wpdb->query( $q2 );
315
+ }
316
+
317
+ }
318
+
319
+
320
+ /**
321
+ * Seeds the database with Social Warfare 3.0.0 default values.
322
+ *
323
+ * @since 3.0.0 | 01 MAY 2018 | Created the function
324
+ * @param void
325
+ * @return void
326
+ *
327
+ */
328
+ public function initialize_database() {
329
+ $defaults = array(
330
+ 'location_archive_categories' => 'below',
331
+ 'location_home' => 'none',
332
+ 'location_post' => 'below',
333
+ 'location_page' => 'below',
334
+ 'float_location_post' => 'on',
335
+ 'float_location_page' => 'off',
336
+ 'total_shares' => true,
337
+ 'network_shares' => true,
338
+ 'twitter_id' => false,
339
+ 'swp_twitter_card' => true,
340
+ 'button_shape' => 'flatFresh',
341
+ 'default_colors' => 'full_color',
342
+ 'single_colors' => 'full_color',
343
+ 'hover_colors' => 'full_color',
344
+ 'float_default_colors' => 'full_color',
345
+ 'float_single_colors' => 'full_color',
346
+ 'float_hover_colors' => 'fullColor',
347
+ 'float_style_source' => true,
348
+ 'float_size' => 1,
349
+ 'float_alignment' => 'center',
350
+ 'button_size' => 1,
351
+ 'button_alignment' => 'fullWidth',
352
+ 'transition' => 'slide',
353
+ 'float_screen_width' => 1100,
354
+ 'ctt_theme' => 'style1',
355
+ 'ctt_css' => "",
356
+ 'twitter_shares' => false,
357
+ 'floating_panel' => true,
358
+ 'float_location' => 'bottom',
359
+ 'float_background_color' => '#ffffff',
360
+ 'float_button_shape' => 'default',
361
+ 'float_vertical' => 'center',
362
+ 'float_button_count' => 5,
363
+ 'custom_color' => '#000000',
364
+ 'custom_color_outlines' => '#000000',
365
+ 'float_custom_color' => '#000000',
366
+ 'float_custom_color_outlines' => '#000000',
367
+ 'recover_shares' => false,
368
+ 'recovery_format' => 'unchanged',
369
+ 'recovery_protocol' => 'unchanged',
370
+ 'recovery_prefix' => 'unchanged',
371
+ 'decimals' => 0,
372
+ 'decimal_separator' => 'period',
373
+ 'totals_alignment' => 'total_sharesalt',
374
+ 'google_analytics' => false,
375
+ 'bitly_authentication' => false,
376
+ 'minimum_shares' => 0,
377
+ 'full_content' => false,
378
+ 'frame_buster' => false,
379
+ 'analytics_medium' => 'social',
380
+ 'analytics_campaign' => 'SocialWarfare',
381
+ 'swp_click_tracking' => false,
382
+ 'order_of_icons_method' => 'manual',
383
+ 'og_post' => 'article',
384
+ 'og_page' => 'article',
385
+ 'pinterest_image_location' => 'hidden',
386
+ 'pin_browser_extension' => false,
387
+ 'pinterest_fallback' => 'all',
388
+ 'pinit_toggle' => false,
389
+ 'pinit_location_horizontal' => 'center',
390
+ 'pinit_location_vertical' => 'top',
391
+ 'pinit_min_width' => '200',
392
+ 'pinit_min_height' => '200',
393
+ 'pinit_image_source' => 'image',
394
+ 'pinit_image_description' => 'alt_text',
395
+ 'utm_on_pins' => false,
396
+ 'pin_browser_extension' => false,
397
+ 'pin_browser_extension_location' => 'hidden',
398
+ 'pinterest_fallback' => 'all',
399
+ 'float_mobile' => 'bottom',
400
+ 'force_new_shares' => false,
401
+ 'cache_method' => 'advanced',
402
+ 'order_of_icons' => array(
403
+ 'twitter' => 'Twitter',
404
+ 'linkedIn' => 'LinkedIn',
405
+ 'pinterest' => 'Pinterest',
406
+ 'facebook' => 'Facebook',
407
+ 'google_plus' => 'Google Plus',
408
+ ),
409
+ );
410
+
411
+ update_option( 'social_warfare_settings', $defaults );
412
+ }
413
+
414
+
415
+ /**
416
+ * Map prevous key/value pairs to new keys.
417
+ *
418
+ * This also deletes the previous keys once the migration is done.
419
+ * @since 3.0.0 | 01 MAY 2018 | Created the function
420
+ * @since 3.1.0 | 13 JUN 2018 | Replaced array bracket notation.
421
+ * @param void
422
+ * @return void
423
+ *
424
+ */
425
+ private function migrate() {
426
+ $options = get_option( 'socialWarfareOptions', array() );
427
+
428
+ if ( $options === array() ) :
429
+ //* The old options do not exist.
430
+ return;
431
+ endif;
432
+
433
+ $map = array(
434
+ //* Options names
435
+ 'locationSite' => 'location_archive_categories',
436
+ 'locationHome' => 'location_home',
437
+ 'totesEach' => 'network_shares',
438
+ 'totes' => 'total_shares',
439
+ 'minTotes' => 'minimum_shares',
440
+ 'visualTheme' => 'button_shape',
441
+ 'buttonSize' => 'button_size',
442
+ 'dColorSet' => 'default_colors',
443
+ 'oColorSet' => 'hover_colors',
444
+ 'iColorSet' => 'single_colors',
445
+ 'swDecimals' => 'decimals',
446
+ 'swp_decimal_separator' => 'decimal_separator',
447
+ 'swTotesFormat' => 'totals_alignment',
448
+ 'float' => 'floating_panel',
449
+ 'floatOption' => 'float_location',
450
+ 'swp_float_scr_sz' => 'float_screen_width',
451
+ 'sideReveal' => 'transition',
452
+ 'floatStyle' => 'float_button_shape',
453
+ 'floatStyleSource' => 'float_style_source',
454
+ 'sideDColorSet' => 'float_default_colors',
455
+ 'sideOColorSet' => 'float_hover_colors',
456
+ 'sideIColorSet' => 'float_single_colors',
457
+ 'swp_twitter_card' => 'twitter_cards',
458
+ 'twitterID' => 'twitter_id',
459
+ 'pinterestID' => 'pinterest_id',
460
+ 'facebookPublisherUrl' => 'facebook_publisher_url',
461
+ 'facebookAppID' => 'facebook_app_id',
462
+ 'sniplyBuster' => 'frame_buster',
463
+ 'linkShortening' => 'bitly_authentication',
464
+ 'cacheMethod' => 'cache_method',
465
+ 'googleAnalytics' => 'google_analytics',
466
+ 'analyticsMedium' => 'analytics_medium',
467
+ 'analyticsCampaign' => 'analytics_campaign',
468
+ 'advanced_pinterest_image' => 'pin_browser_extension',
469
+ 'advanced_pinterest_image_location' => 'pinterest_image_location',
470
+ 'pin_browser_extension_location' => 'pin_browser_extension_location',
471
+ 'advanced_pinterest_fallback' => 'pinterest_fallback',
472
+ 'recovery_custom_format' => 'recovery_permalink',
473
+ 'cttTheme' => 'ctt_theme',
474
+ 'cttCSS' => 'ctt_css',
475
+ 'sideCustomColor' => 'single_custom_color',
476
+ 'floatBgColor' => 'float_background_color',
477
+ 'orderOfIconsSelect' => 'order_of_icons_method',
478
+ 'newOrderOfIcons' => 'order_of_icons',
479
+ );
480
+
481
+ $value_map = array(
482
+ 'flatFresh' => 'flat_fresh',
483
+ 'threeDee' => 'three_dee',
484
+ 'fullColor' => 'full_color',
485
+ 'lightGray' => 'light_gray',
486
+ 'mediumGray' => 'medium_gray',
487
+ 'darkGray' => 'dark_gray',
488
+ 'lgOutlines' => 'light_gray_outlines',
489
+ 'mdOutlines' => 'medium_gray_outlines',
490
+ 'dgOutlines' => 'dark_gray_outlines',
491
+ 'colorOutlines' => 'color_outlines',
492
+ 'customColor' => 'custom_color',
493
+ 'ccOutlines' => 'custom_color_outlines',
494
+ 'totesAlt' => 'totals_right',
495
+ 'totesAltLeft' => 'totals_left',
496
+ 'buttonFloat' => 'button_alignment',
497
+ 'post' => 'location_post',
498
+ 'page' => 'location_page',
499
+ 'float_vertical'=> 'float_alignment',
500
+ 'fullWidth' => 'full_width',
501
+ 'floatLeftMobile' => 'float_mobile',
502
+ );
503
+
504
+ $migrations = array();
505
+
506
+ foreach( $options as $old => $value ) {
507
+ //* The order of icons used to be stored in an array at 'active'.
508
+ if ( is_array( $value) && array_key_exists( 'active', $value) ) :
509
+ $new_value = $value;
510
+ //* Filter out the booleans and integers.
511
+ elseif ( is_string( $value ) ):
512
+ $new_value = array_key_exists($value, $value_map) ? $value_map[$value] : $value;
513
+ else :
514
+ $new_value = $value;
515
+ endif;
516
+
517
+ //* Specific case: newOrderOfIcons mapping.
518
+ if ( 'newOrderOfIcons' === $old ) :
519
+ if ( array_key_exists( 'googlePlus', $new_value ) ) :
520
+ unset( $new_value['googlePlus'] );
521
+ $new_value[] = 'google_plus';
522
+ endif;
523
+
524
+ if (array_key_exists( 'linkedIn', $new_value) ) :
525
+ unset( $new_value['linkedIn'] );
526
+ $new_value[] = 'linkedin';
527
+ endif;
528
+ endif;
529
+
530
+ //* Specific case: customColor mapping.
531
+ if ( $old === 'customColor' ) :
532
+ $migrations['custom_color'] = $new_value;
533
+ $migrations['custom_color_outlines'] = $new_value;
534
+
535
+ // If the float style source is set to inherit the style from the static buttons.
536
+ if ( $options['floatStyleSource'] == true ) :
537
+ $migrations['float_custom_color'] = $new_value;
538
+ $migrations['float_custom_color_outlines'] = $new_value;
539
+ endif;
540
+ endif;
541
+
542
+ // Only if the source is set to not inherit them from the static buttons.
543
+ if ( $old === 'sideCustomColor' ) :
544
+ $migrations['float_custom_color'] = $new_value;
545
+ $migrations['float_custom_color_outlines'] = $new_value;
546
+ endif;
547
+
548
+ if ( array_key_exists( $old, $map) ) :
549
+ //* We specified an update to the key.
550
+ $new = $map[$old];
551
+ $migrations[$new] = $new_value;
552
+ else :
553
+ //* The previous key was fine, keep it.
554
+ $migrations[$old] = $new_value;
555
+ endif;
556
+
557
+ }
558
+
559
+ //* Manually adding these in as short term solution.
560
+ if ( !isset( $migrations['float_size'] ) ) :
561
+ $migrations['float_size'] = '1';
562
+ endif;
563
+
564
+ if ( !isset( $migrations['float_location'] ) ) :
565
+ $migrations['float_location'] = 'bottom';
566
+ endif;
567
+
568
+ if ( !isset( $migrations['float_alignment'] ) ) :
569
+ $migrations['float_alignment'] = 'center';
570
+ endif;
571
+
572
+ $custom_colors = array( 'custom_color', 'custom_color_outlines', 'float_custom_color', 'float_custom_color_outlines' );
573
+
574
+ foreach( $custom_colors as $color ) {
575
+ if ( !isset($migrations[$color] ) ) :
576
+ $migrations[$color] = "#333333";
577
+ endif;
578
+ }
579
+
580
+ $removals = array(
581
+ 'dashboardShares',
582
+ 'rawNumbers',
583
+ 'notShowing',
584
+ 'visualEditorBug',
585
+ 'loopFix',
586
+ 'locationrevision',
587
+ 'locationattachment',
588
+ );
589
+
590
+ foreach ( $removals as $trash ) :
591
+ if ( ( $migrations[$trash] ) ) :
592
+ unset($migrations[$trash]);
593
+ endif;
594
+ endforeach;
595
+
596
+ update_option( 'social_warfare_settings', $migrations );
597
+ //* Play it safe for now.
598
+ //* Leave socialWarfareOptions in the database.
599
+ // delete_option( 'socialWarfareOptions' );
600
+ }
601
+
602
+
603
+ /**
604
+ * Get Last Migrated
605
+ *
606
+ * This method gets the version number during which the last migration was
607
+ * run. This allows us to increment a version if we need a part of this class
608
+ * to run again.
609
+ *
610
+ * @since 3.0.0 | Created | 08 MAY 2018
611
+ * @param boolean $echo True echoes the data; False returns it.
612
+ * @return mixed (str) Version number if found, (bool) false if not found.
613
+ *
614
+ */
615
+ public function get_last_migrated( $echo = false ) {
616
+ $options = get_option( 'social_warfare_settings' );
617
+
618
+ if ( array_key_exists( 'last_migrated', $options ) ) :
619
+ if ( true === $echo ) :
620
+ var_dump( $options['last_migrated'] );
621
+ endif;
622
+
623
+ return $options['last_migrated'];
624
+ endif;
625
+
626
+ if ( true === $echo ) :
627
+ echo "No previous migration version has been set.";
628
+ endif;
629
+
630
+ return false;
631
+
632
+ }
633
+
634
+
635
+ /**
636
+ * A method to update the last migrated version number.
637
+ *
638
+ * @since 3.0.0 | Created | 08 MAY 2018
639
+ * @param null
640
+ * @return void
641
+ *
642
+ */
643
+ public function update_last_migrated() {
644
+ $options = get_option( 'social_warfare_settings' );
645
+ $options['last_migrated'] = $this->last_migrated;
646
+
647
+ update_option( 'social_warfare_settings', $options );
648
+ }
649
+ }
functions/utilities/SWP_JSON_Cache_Handler.php CHANGED
@@ -1,147 +1,147 @@
1
- <?php
2
-
3
- /**
4
- * A Class for Fetching Remote JSON data and caching it in a manner that will
5
- * easily allow other classes to access the data for the purpose of generating
6
- * notices, updating the sidebar, etc.
7
- *
8
- * Everything is stored in local properties to allow the debug method to simply
9
- * dump the $this item allowing us to see the results of everything that has
10
- * been processed by this class.
11
- *
12
- * @package SocialWarfare\Functions
13
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
14
- * @license GPL-3.0+
15
- * @since 3.1.0 | 27 JUN 2018 | Created
16
- *
17
- */
18
- class SWP_JSON_Cache_Handler {
19
-
20
-
21
- /**
22
- * The fetched from the remote JSON file.
23
- *
24
- * @var string
25
- *
26
- */
27
- private $response = '';
28
-
29
-
30
- /**
31
- * The responsed parsed into an associative array.
32
- *
33
- * @var array
34
- *
35
- */
36
- private $parsed_response = array();
37
-
38
-
39
- /**
40
- * The cached JSON data fetched from the database.
41
- *
42
- * @var array
43
- *
44
- */
45
- private $cached_data = array();
46
-
47
-
48
- /**
49
- * Instantiate the class object.
50
- *
51
- * Check if the cache is fresh, if not, ping the JSON file on our server,
52
- * parse the results, and store them in an options field in the database.
53
- *
54
- * @since 3.1.0 | 28 JUN 2018 | Created
55
- * @param void
56
- * @return void
57
- *
58
- */
59
- public function __construct() {
60
- if( false === $this->is_cache_fresh() ):
61
- $this->fetch_new_json_data();
62
- $this->debug();
63
- endif;
64
- }
65
-
66
-
67
- /**
68
- * Fetch new JSON data.
69
- *
70
- * @since 3.1.0 | 28 JUN 2018 | Created
71
- * @param void
72
- * @return void
73
- *
74
- */
75
- private function fetch_new_json_data() {
76
-
77
- // Fetch the response.
78
- $response = wp_remote_get( 'https://warfareplugins.com/json_updates.php' );
79
- $this->response = wp_remote_retrieve_body( $response );
80
-
81
- // Create the cache data array.
82
- $this->parsed_response = array();
83
-
84
- if( !empty($this->response) ):
85
- $this->parsed_response = json_decode( $this->response , true );
86
- endif;
87
-
88
- $this->parsed_response['timestamp'] = time();
89
-
90
- // Store the data in the database.
91
- update_option('swp_json_cache' , $this->parsed_response , true );
92
-
93
- }
94
-
95
-
96
- /**
97
- * A method to determin if the cached data is still fresh.
98
- *
99
- * @since 3.1.0 | 28 JUN 2018 | Created
100
- * @param void
101
- * @return boolean true if fresh, false if expired.
102
- *
103
- */
104
- private function is_cache_fresh() {
105
-
106
- // If we're debugging, the cache is expired and needs to fetch.
107
- if( true == _swp_is_debug( 'json_fetch' ) ):
108
- return false;
109
- endif;
110
-
111
- $this->cache_data = get_option('swp_json_cache');
112
-
113
- // If no cached data, the cache is not fresh.
114
- if( false === $this->cache_data):
115
- return false;
116
- endif;
117
-
118
- // Forumlate the timestamps.
119
- $timestamp = $this->cache_data['timestamp'];
120
- $current_time = time();
121
- $time_between_checks = ( 6 * 60 * 60 );
122
-
123
- // Compare the timestamps.
124
- if ($current_time > $timestamp + $time_between_checks ) :
125
- return false;
126
- endif;
127
-
128
- return true;
129
-
130
- }
131
-
132
-
133
- /**
134
- * A method for debugging this class.
135
- *
136
- * @since 3.1.0 | 28 JUN 2018 | Created
137
- * @param void
138
- * @return void
139
- *
140
- */
141
- private function debug() {
142
- if( true === _swp_is_debug( 'json_fetch') ):
143
- var_dump($this);
144
- endif;
145
- }
146
-
147
- }
1
+ <?php
2
+
3
+ /**
4
+ * A Class for Fetching Remote JSON data and caching it in a manner that will
5
+ * easily allow other classes to access the data for the purpose of generating
6
+ * notices, updating the sidebar, etc.
7
+ *
8
+ * Everything is stored in local properties to allow the debug method to simply
9
+ * dump the $this item allowing us to see the results of everything that has
10
+ * been processed by this class.
11
+ *
12
+ * @package SocialWarfare\Functions
13
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
14
+ * @license GPL-3.0+
15
+ * @since 3.1.0 | 27 JUN 2018 | Created
16
+ *
17
+ */
18
+ class SWP_JSON_Cache_Handler {
19
+
20
+
21
+ /**
22
+ * The fetched from the remote JSON file.
23
+ *
24
+ * @var string
25
+ *
26
+ */
27
+ private $response = '';
28
+
29
+
30
+ /**
31
+ * The responsed parsed into an associative array.
32
+ *
33
+ * @var array
34
+ *
35
+ */
36
+ private $parsed_response = array();
37
+
38
+
39
+ /**
40
+ * The cached JSON data fetched from the database.
41
+ *
42
+ * @var array
43
+ *
44
+ */
45
+ private $cached_data = array();
46
+
47
+
48
+ /**
49
+ * Instantiate the class object.
50
+ *
51
+ * Check if the cache is fresh, if not, ping the JSON file on our server,
52
+ * parse the results, and store them in an options field in the database.
53
+ *
54
+ * @since 3.1.0 | 28 JUN 2018 | Created
55
+ * @param void
56
+ * @return void
57
+ *
58
+ */
59
+ public function __construct() {
60
+ if( false === $this->is_cache_fresh() ):
61
+ $this->fetch_new_json_data();
62
+ $this->debug();
63
+ endif;
64
+ }
65
+
66
+
67
+ /**
68
+ * Fetch new JSON data.
69
+ *
70
+ * @since 3.1.0 | 28 JUN 2018 | Created
71
+ * @param void
72
+ * @return void
73
+ *
74
+ */
75
+ private function fetch_new_json_data() {
76
+
77
+ // Fetch the response.
78
+ $response = wp_remote_get( 'https://warfareplugins.com/json_updates.php' );
79
+ $this->response = wp_remote_retrieve_body( $response );
80
+
81
+ // Create the cache data array.
82
+ $this->parsed_response = array();
83
+
84
+ if( !empty($this->response) ):
85
+ $this->parsed_response = json_decode( $this->response , true );
86
+ endif;
87
+
88
+ $this->parsed_response['timestamp'] = time();
89
+
90
+ // Store the data in the database.
91
+ update_option('swp_json_cache' , $this->parsed_response , true );
92
+
93
+ }
94
+
95
+
96
+ /**
97
+ * A method to determin if the cached data is still fresh.
98
+ *
99
+ * @since 3.1.0 | 28 JUN 2018 | Created
100
+ * @param void
101
+ * @return boolean true if fresh, false if expired.
102
+ *
103
+ */
104
+ private function is_cache_fresh() {
105
+
106
+ // If we're debugging, the cache is expired and needs to fetch.
107
+ if( true == _swp_is_debug( 'json_fetch' ) ):
108
+ return false;
109
+ endif;
110
+
111
+ $this->cache_data = get_option('swp_json_cache');
112
+
113
+ // If no cached data, the cache is not fresh.
114
+ if( false === $this->cache_data):
115
+ return false;
116
+ endif;
117
+
118
+ // Forumlate the timestamps.
119
+ $timestamp = $this->cache_data['timestamp'];
120
+ $current_time = time();
121
+ $time_between_checks = ( 6 * 60 * 60 );
122
+
123
+ // Compare the timestamps.
124
+ if ($current_time > $timestamp + $time_between_checks ) :
125
+ return false;
126
+ endif;
127
+
128
+ return true;
129
+
130
+ }
131
+
132
+
133
+ /**
134
+ * A method for debugging this class.
135
+ *
136
+ * @since 3.1.0 | 28 JUN 2018 | Created
137
+ * @param void
138
+ * @return void
139
+ *
140
+ */
141
+ private function debug() {
142
+ if( true === _swp_is_debug( 'json_fetch') ):
143
+ var_dump($this);
144
+ endif;
145
+ }
146
+
147
+ }
functions/utilities/SWP_Localization.php CHANGED
@@ -1,53 +1,53 @@
1
- <?php
2
- /**
3
- * Functions to load translations for the plugin.
4
- *
5
- * @package SocialWarfare\Functions
6
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
- * @license GPL-3.0+
8
- * @since 1.0.0
9
- */
10
-
11
- class SWP_Localization {
12
-
13
-
14
- /**
15
- * Load up the text domain for translations
16
- *
17
- * @since 1.0.0
18
- * @return void
19
- */
20
- public function init() {
21
- $loaded = load_plugin_textdomain(
22
- 'social-warfare',
23
- false,
24
- dirname( plugin_basename( SWP_PLUGIN_FILE ) ) . '/languages'
25
- );
26
- }
27
-
28
-
29
- /**
30
- * Remove translations from memory.
31
- *
32
- * @since 1.0.0
33
- * @access public
34
- * @return bool true if the text domain was loaded, false if it was not.
35
- *
36
- */
37
- public function swp_unload_textdomain() {
38
- return unload_textdomain( 'social-warfare' );
39
- }
40
-
41
- /**
42
- * Whether or not the language has been loaded already.
43
- *
44
- * @since 1.0.0
45
- * @access public
46
- * @return bool
47
- *
48
- */
49
- public function swp_is_textdomain_loaded() {
50
- return is_textdomain_loaded( 'social-warfare' );
51
- }
52
-
53
- }
1
+ <?php
2
+ /**
3
+ * Functions to load translations for the plugin.
4
+ *
5
+ * @package SocialWarfare\Functions
6
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
7
+ * @license GPL-3.0+
8
+ * @since 1.0.0
9
+ */
10
+
11
+ class SWP_Localization {
12
+
13
+
14
+ /**
15
+ * Load up the text domain for translations
16
+ *
17
+ * @since 1.0.0
18
+ * @return void
19
+ */
20
+ public function init() {
21
+ $loaded = load_plugin_textdomain(
22
+ 'social-warfare',
23
+ false,
24
+ dirname( plugin_basename( SWP_PLUGIN_FILE ) ) . '/languages'
25
+ );
26
+ }
27
+
28
+
29
+ /**
30
+ * Remove translations from memory.
31
+ *
32
+ * @since 1.0.0
33
+ * @access public
34
+ * @return bool true if the text domain was loaded, false if it was not.
35
+ *
36
+ */
37
+ public function swp_unload_textdomain() {
38
+ return unload_textdomain( 'social-warfare' );
39
+ }
40
+
41
+ /**
42
+ * Whether or not the language has been loaded already.
43
+ *
44
+ * @since 1.0.0
45
+ * @access public
46
+ * @return bool
47
+ *
48
+ */
49
+ public function swp_is_textdomain_loaded() {
50
+ return is_textdomain_loaded( 'social-warfare' );
51
+ }
52
+
53
+ }
functions/utilities/SWP_Notice.php CHANGED
@@ -1,405 +1,405 @@
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
- $this->no_cta = false;
39
-
40
- // Add hooks to display our admin notices in the dashbaord and on our settings page.
41
- add_action( 'admin_notices', array( $this, 'print_HTML' ) );
42
- add_action( 'swp_admin_notices', array( $this, 'get_HTML' ) );
43
-
44
- // Add a hook for permanently dismissing a notice via admin-ajax.php
45
- add_action( 'wp_ajax_dismiss', array( $this, 'dismiss' ) );
46
- add_action( 'wp_ajax_nopriv_dismiss', array( $this, 'dismiss' ) );
47
-
48
- }
49
-
50
-
51
- /**
52
- * Initialize the basics of this property.
53
- *
54
- * This method checks for the dismissed_notices options array in the database.
55
- * If it doesn't exist, it creates it as an empty array. It then stores that
56
- * array in a local property to control the display or non-display of this
57
- * notice. It then finds the attributes for this specific notice and stores it
58
- * in the local $data property.
59
- *
60
- * @since 3.0.9 | 07 JUN 2018 | Created
61
- * @access public
62
- * @param null
63
- * @return null
64
- *
65
- */
66
- public function init() {
67
- $notices = get_option( 'social_warfare_dismissed_notices', false );
68
-
69
- if ( false === $notices ) {
70
- update_option( 'social_warfare_dismissed_notices', array() );
71
- $notices = array();
72
- }
73
-
74
- $this->notices = $notices;
75
-
76
- if ( isset( $notices[$this->key] ) ) :
77
- $this->data = $notices[$this->key];
78
- endif;
79
- }
80
-
81
-
82
- /**
83
- * A method to determine if this notice should be displayed.
84
- *
85
- * This method lets the class now if this notice should be displayed or not. It checks
86
- * thing like the start date, the end date, the dimissal status if it was temporarily
87
- * dismissed versus permanently dismissed and so on.
88
- *
89
- * @since 3.0.9 | 07 JUN 2018 | Created
90
- * @access public
91
- * @param null
92
- * @return bool Default true.
93
- *
94
- */
95
- public function should_display_notice() {
96
- $now = new DateTime();
97
- $now = $now->format('Y-m-d H:i:s');
98
-
99
- // If the start date has not been reached.
100
- if ( isset( $this->start_date ) && $now < $this->start_date ) {
101
- return false;
102
- }
103
-
104
- // If the end date has been reached.
105
- if( isset( $this->end_date ) && $now > $this->end_date ) {
106
- return false;
107
- }
108
-
109
- //* No dismissal has happened yet.
110
- if ( empty( $this->data['timestamp']) ) :
111
- return true;
112
- endif;
113
-
114
- //* They have dismissed a permadismiss.
115
- if ( isset( $this->data['timestamp'] ) && $this->data['timeframe'] == 0) {
116
- return false;
117
- }
118
-
119
- //* They have dismissed with a temp CTA.
120
- if ( isset( $this->data['timeframe'] ) && $this->data['timeframe'] > 0 ) {
121
-
122
- $expiry = $this->data['timestamp'];
123
-
124
- return $now > $expiry;
125
- }
126
-
127
- return true;
128
- }
129
-
130
-
131
- /**
132
- * Processes notice dismissals via ajax.
133
- *
134
- * This is the method that is added to the Wordpress admin-ajax hooks.
135
- *
136
- * @since 3.0.9 | 07 JUN 2018 | Created
137
- * @access public
138
- * @param null
139
- * @return null The response from update_option is echoed.
140
- *
141
- */
142
- public function dismiss() {
143
- $key = $_POST['key'];
144
- $timeframe = $_POST['timeframe'];
145
- $now = new DateTime();
146
-
147
- if ( 0 < $timeframe ) {
148
- $timestamp = $now->modify("+$timeframe days")->format('Y-m-d H:i:s');
149
- } else {
150
- $timestamp = $now->format('Y-m-d H:i:s');
151
- }
152
-
153
- $this->notices[$key]['timestamp'] = $timestamp;
154
- $this->notices[$key]['timeframe'] = $timeframe;
155
-
156
- echo json_encode( update_option( 'social_warfare_dismissed_notices', $this->notices ) );
157
- wp_die();
158
- }
159
-
160
-
161
- /**
162
- * A method to allow you to set the message text for this notice.
163
- *
164
- * @since 3.0.9 | 07 JUN 2018 | Created
165
- * @access public
166
- * @param string $message A string of text for the notices message.
167
- * @return object $this Allows for method chaining.
168
- *
169
- */
170
- public function set_message( $message ) {
171
- if ( !is_string( $message ) ) :
172
- throw("Please provide a string for your database key.");
173
- endif;
174
-
175
- $this->message = $message;
176
-
177
- return $this;
178
- }
179
-
180
-
181
- /**
182
- * A method to allow you to set the unique key for this notice.
183
- *
184
- * @since 3.0.9 | 07 JUN 2018 | Created
185
- * @access protected
186
- * @param string $key A string representing this notices unique key.
187
- * @return object $this Allows for method chaining.
188
- *
189
- */
190
- protected function set_key( $key ) {
191
- if ( !is_string ( $key ) ) :
192
- throw("Please provide a string for your database key.");
193
- endif;
194
-
195
- $this->key = $key;
196
-
197
- return $this;
198
- }
199
-
200
-
201
- /**
202
- * Set a start date.
203
- *
204
- * This will allow us to schedule messages to be displayed at a specific date in the
205
- * future. For example, before the StumbleUpon service goes away, we may want to post
206
- * a notice letting folks know that it WILL BE going away. The day that they actually
207
- * go away could be the start date for a notice that says that they HAVE gone away.
208
- *
209
- * @since 3.0.9 | 07 JUN 2018 | Created
210
- * @access public
211
- * @param string $start_date A str date formatted to 'Y-m-d H:i:s'
212
- * @return $this Allows for method chaining
213
- * @TODO Add a type check, if possible, for a properly formatted date string.
214
- *
215
- */
216
- public function set_start_date( $start_date ) {
217
- if ( $this->is_date( $start_date ) ) :
218
- $this->start_date = $start_date;
219
- endif;
220
-
221
- return $this;
222
- }
223
-
224
-
225
- /**
226
- * Set an end date.
227
- *
228
- * This will allow us to schedule messages to stop being displayed at a specific date
229
- * in the future. For example, before the StumbleUpon service goes away, we may want
230
- * to post a notice letting folks know that it WILL BE going away. The day that they
231
- * actually go away could be the end date for that notice and the start date for a
232
- * notice that says that they HAVE gone away. Additionally, we may only want to notify
233
- * people about StumbleUpon having gone away for 60 days after it happens. After that,
234
- * we can just assume that they've probably heard from somewhere else and not worry
235
- * about showing a notice message.
236
- *
237
- * @since 3.0.9 | 07 JUN 2018 | Created
238
- * @access public
239
- * @param string $end_date A str date formatted to 'Y-m-d H:i:s'
240
- * @return $this Allows for method chaining
241
- * @TODO Add a type check, if possible, for a properly formatted date string.
242
- *
243
- */
244
- public function set_end_date( $end_date ) {
245
- if ( $this->is_date( $end_date ) ) :
246
- $this->end_date = $end_date;
247
- endif;
248
-
249
- return $this;
250
- }
251
-
252
-
253
- /**
254
- * Creates the interactive CTA for the notice.
255
- *
256
- * @since 3.0.9 | 07 JUN 2018 | Created
257
- * @access public
258
- * @param string $action Optional. The message to be displayed. Default "Thanks, I understand."
259
- * @param string $href Optional. The outbound href.
260
- * @param string $class Optional. The CSS classname to assign to the CTA.
261
- * @param string $timeframe
262
- * @return $this Allows for method chaining.
263
- *
264
- */
265
- public function add_cta( $action = '', $href = '', $class = '' , $timeframe = 0 ) {
266
- if ( '' === $action ) :
267
- $action = "Thanks, I understand.";
268
- endif;
269
-
270
- if ( !empty( $href ) && '' !== $href ) :
271
- $href = ' href="' . $href . '" target="_blank"';
272
- endif;
273
-
274
- $cta = array();
275
- $cta['action'] = $action;
276
- $cta['href'] = $href;
277
- $cta['class'] = $class;
278
- $cta['timeframe'] = $timeframe;
279
-
280
- $this->actions[] = $cta;
281
-
282
- return $this;
283
- }
284
-
285
-
286
- /**
287
- * Render out the HTML.
288
- *
289
- * Ideally, everything before this method will create a beautiful data-oriented
290
- * object. The only HTML that should be compiled should be inside this method.
291
- *
292
- * @since 3.0.9 | 07 JUN 2018 | Created
293
- * @access public
294
- * @param null
295
- * @return string The compiled HTML of the dashboard notice.
296
- *
297
- */
298
- public function render_HTML() {
299
- if ( empty( $this->actions) && false === $this->no_cta) :
300
- $this->add_cta();
301
- endif;
302
-
303
- $html = '<div class="swp-dismiss-notice notice notice-info " data-key="' . $this->key . '">';
304
- $html .= '<p>' . $this->message . ' - Warfare Plugins Team</p>';
305
- $html .= '<div class="swp-actions">';
306
-
307
- foreach( $this->actions as $cta) {
308
- $html .= '<a class="swp-notice-cta ' . $cta['class'] . '" ' . $cta['href'] . ' data-timeframe="'.$cta['timeframe'].'">';
309
- $html .= $cta['action'];
310
- $html .= "</a>";
311
- }
312
-
313
- $html .= '</div>';
314
- $html .= '</div>';
315
-
316
- $this->html = $html;
317
-
318
- return $this;
319
- }
320
-
321
-
322
- /**
323
- * Gets (returns) the HTML for this notice.
324
- *
325
- * We have two separate methods for this. One for returning the HTML, and
326
- * one for echoing the html. This one returns it.
327
- *
328
- * @since 3.0.9 | 07 JUN 2018 | Created
329
- * @access public
330
- * @param string $notices The string of notices to be modified.
331
- * @return string The modified string of notices' html.
332
- *
333
- */
334
- public function get_HTML( $notices = '' ) {
335
-
336
- if ( !$this->should_display_notice() ) :
337
- return $notices;
338
- endif;
339
-
340
- if ( empty( $this->html ) ) :
341
- $this->render_HTML();
342
- endif;
343
-
344
- return $notices .= $this->html;
345
- }
346
-
347
-
348
- /**
349
- * Echos the HTML for this notice.
350
- *
351
- * We have two separate methods for this. One for returning the HTML, and
352
- * one for echoing the html. This one echos it.
353
- *
354
- * @since 3.0.9 | 07 JUN 2018 | Created
355
- * @access public
356
- * @param string $notices The string of notices to be modified.
357
- * @return string The modified string of notices' html.
358
- *
359
- */
360
- public function print_HTML() {
361
- if ( !$this->should_display_notice() ) :
362
- return;
363
- endif;
364
-
365
- if ( empty( $this->html ) ) :
366
- $this->render_HTML();
367
- endif;
368
-
369
- echo $this->html;
370
-
371
- return $this;
372
- }
373
-
374
- /**
375
- * Checks whether a string is formatted as our default Date format.
376
- *
377
- * @since 3.0.9 | 08 JUN 2018 | Created
378
- * @param string $string The datetime string in question.
379
- * @return bool True iff the string is of the format 'Y-m-d h:i:s'.
380
- *
381
- */
382
- private function is_date( $string ) {
383
- return DateTime::createFromFormat( 'Y-m-d h:i:s', $string ) !== false;
384
- }
385
-
386
-
387
- /**
388
- * Prevents a CTA from being displayed on the notice.
389
- *
390
- * In cases where we require the user to take action, we need them
391
- * to follow the directions in the message before removing the notice.
392
- *
393
- * @since 3.1.0 | 05 JUL 2018 | Created the method.
394
- * @return SWP_Notice $this, for method chaining.
395
- *
396
- */
397
- public function remove_cta() {
398
- //* Force the ctas to an empty array so render can still loop over it.
399
- $this->actions = array();
400
-
401
- $this->no_cta = true;
402
-
403
- return $this;
404
- }
405
- }
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
+ $this->no_cta = false;
39
+
40
+ // Add hooks to display our admin notices in the dashbaord and on our settings page.
41
+ add_action( 'admin_notices', array( $this, 'print_HTML' ) );
42
+ add_action( 'swp_admin_notices', array( $this, 'get_HTML' ) );
43
+
44
+ // Add a hook for permanently dismissing a notice via admin-ajax.php
45
+ add_action( 'wp_ajax_dismiss', array( $this, 'dismiss' ) );
46
+ add_action( 'wp_ajax_nopriv_dismiss', array( $this, 'dismiss' ) );
47
+
48
+ }
49
+
50
+
51
+ /**
52
+ * Initialize the basics of this property.
53
+ *
54
+ * This method checks for the dismissed_notices options array in the database.
55
+ * If it doesn't exist, it creates it as an empty array. It then stores that
56
+ * array in a local property to control the display or non-display of this
57
+ * notice. It then finds the attributes for this specific notice and stores it
58
+ * in the local $data property.
59
+ *
60
+ * @since 3.0.9 | 07 JUN 2018 | Created
61
+ * @access public
62
+ * @param null
63
+ * @return null
64
+ *
65
+ */
66
+ public function init() {
67
+ $notices = get_option( 'social_warfare_dismissed_notices', false );
68
+
69
+ if ( false === $notices ) {
70
+ update_option( 'social_warfare_dismissed_notices', array() );
71
+ $notices = array();
72
+ }
73
+
74
+ $this->notices = $notices;
75
+
76
+ if ( isset( $notices[$this->key] ) ) :
77
+ $this->data = $notices[$this->key];
78
+ endif;
79
+ }
80
+
81
+
82
+ /**
83
+ * A method to determine if this notice should be displayed.
84
+ *
85
+ * This method lets the class now if this notice should be displayed or not. It checks
86
+ * thing like the start date, the end date, the dimissal status if it was temporarily
87
+ * dismissed versus permanently dismissed and so on.
88
+ *
89
+ * @since 3.0.9 | 07 JUN 2018 | Created
90
+ * @access public
91
+ * @param null
92
+ * @return bool Default true.
93
+ *
94
+ */
95
+ public function should_display_notice() {
96
+ $now = new DateTime();
97
+ $now = $now->format('Y-m-d H:i:s');
98
+
99
+ // If the start date has not been reached.
100
+ if ( isset( $this->start_date ) && $now < $this->start_date ) {
101
+ return false;
102
+ }
103
+
104
+ // If the end date has been reached.
105
+ if( isset( $this->end_date ) && $now > $this->end_date ) {
106
+ return false;
107
+ }
108
+
109
+ //* No dismissal has happened yet.
110
+ if ( empty( $this->data['timestamp']) ) :
111
+ return true;
112
+ endif;
113
+
114
+ //* They have dismissed a permadismiss.
115
+ if ( isset( $this->data['timestamp'] ) && $this->data['timeframe'] == 0) {
116
+ return false;
117
+ }
118
+
119
+ //* They have dismissed with a temp CTA.
120
+ if ( isset( $this->data['timeframe'] ) && $this->data['timeframe'] > 0 ) {
121
+
122
+ $expiry = $this->data['timestamp'];
123
+
124
+ return $now > $expiry;
125
+ }
126
+
127
+ return true;
128
+ }
129
+
130
+
131
+ /**
132
+ * Processes notice dismissals via ajax.
133
+ *
134
+ * This is the method that is added to the Wordpress admin-ajax hooks.
135
+ *
136
+ * @since 3.0.9 | 07 JUN 2018 | Created
137
+ * @access public
138
+ * @param null
139
+ * @return null The response from update_option is echoed.
140
+ *
141
+ */
142
+ public function dismiss() {
143
+ $key = $_POST['key'];
144
+ $timeframe = $_POST['timeframe'];
145
+ $now = new DateTime();
146
+
147
+ if ( 0 < $timeframe ) {
148
+ $timestamp = $now->modify("+$timeframe days")->format('Y-m-d H:i:s');
149
+ } else {
150
+ $timestamp = $now->format('Y-m-d H:i:s');
151
+ }
152
+
153
+ $this->notices[$key]['timestamp'] = $timestamp;
154
+ $this->notices[$key]['timeframe'] = $timeframe;
155
+
156
+ echo json_encode( update_option( 'social_warfare_dismissed_notices', $this->notices ) );
157
+ wp_die();
158
+ }
159
+
160
+
161
+ /**
162
+ * A method to allow you to set the message text for this notice.
163
+ *
164
+ * @since 3.0.9 | 07 JUN 2018 | Created
165
+ * @access public
166
+ * @param string $message A string of text for the notices message.
167
+ * @return object $this Allows for method chaining.
168
+ *
169
+ */
170
+ public function set_message( $message ) {
171
+ if ( !is_string( $message ) ) :
172
+ throw("Please provide a string for your database key.");
173
+ endif;
174
+
175
+ $this->message = $message;
176
+
177
+ return $this;
178
+ }
179
+
180
+
181
+ /**
182
+ * A method to allow you to set the unique key for this notice.
183
+ *
184
+ * @since 3.0.9 | 07 JUN 2018 | Created
185
+ * @access protected
186
+ * @param string $key A string representing this notices unique key.
187
+ * @return object $this Allows for method chaining.
188
+ *
189
+ */
190
+ protected function set_key( $key ) {
191
+ if ( !is_string ( $key ) ) :
192
+ throw("Please provide a string for your database key.");
193
+ endif;
194
+
195
+ $this->key = $key;
196
+
197
+ return $this;
198
+ }
199
+
200
+
201
+ /**
202
+ * Set a start date.
203
+ *
204
+ * This will allow us to schedule messages to be displayed at a specific date in the
205
+ * future. For example, before the StumbleUpon service goes away, we may want to post
206
+ * a notice letting folks know that it WILL BE going away. The day that they actually
207
+ * go away could be the start date for a notice that says that they HAVE gone away.
208
+ *
209
+ * @since 3.0.9 | 07 JUN 2018 | Created
210
+ * @access public
211
+ * @param string $start_date A str date formatted to 'Y-m-d H:i:s'
212
+ * @return $this Allows for method chaining
213
+ * @TODO Add a type check, if possible, for a properly formatted date string.
214
+ *
215
+ */
216
+ public function set_start_date( $start_date ) {
217
+ if ( $this->is_date( $start_date ) ) :
218
+ $this->start_date = $start_date;
219
+ endif;
220
+
221
+ return $this;
222
+ }
223
+
224
+
225
+ /**
226
+ * Set an end date.
227
+ *
228
+ * This will allow us to schedule messages to stop being displayed at a specific date
229
+ * in the future. For example, before the StumbleUpon service goes away, we may want
230
+ * to post a notice letting folks know that it WILL BE going away. The day that they
231
+ * actually go away could be the end date for that notice and the start date for a
232
+ * notice that says that they HAVE gone away. Additionally, we may only want to notify
233
+ * people about StumbleUpon having gone away for 60 days after it happens. After that,
234
+ * we can just assume that they've probably heard from somewhere else and not worry
235
+ * about showing a notice message.
236
+ *
237
+ * @since 3.0.9 | 07 JUN 2018 | Created
238
+ * @access public
239
+ * @param string $end_date A str date formatted to 'Y-m-d H:i:s'
240
+ * @return $this Allows for method chaining
241
+ * @TODO Add a type check, if possible, for a properly formatted date string.
242
+ *
243
+ */
244
+ public function set_end_date( $end_date ) {
245
+ if ( $this->is_date( $end_date ) ) :
246
+ $this->end_date = $end_date;
247
+ endif;
248
+
249
+ return $this;
250
+ }
251
+
252
+
253
+ /**
254
+ * Creates the interactive CTA for the notice.
255
+ *
256
+ * @since 3.0.9 | 07 JUN 2018 | Created
257
+ * @access public
258
+ * @param string $action Optional. The message to be displayed. Default "Thanks, I understand."
259
+ * @param string $href Optional. The outbound href.
260
+ * @param string $class Optional. The CSS classname to assign to the CTA.
261
+ * @param string $timeframe
262
+ * @return $this Allows for method chaining.
263
+ *
264
+ */
265
+ public function add_cta( $action = '', $href = '', $class = '' , $timeframe = 0 ) {
266
+ if ( '' === $action ) :
267
+ $action = "Thanks, I understand.";
268
+ endif;
269
+
270
+ if ( !empty( $href ) && '' !== $href ) :
271
+ $href = ' href="' . $href . '" target="_blank"';
272
+ endif;
273
+
274
+ $cta = array();
275
+ $cta['action'] = $action;
276
+ $cta['href'] = $href;
277
+ $cta['class'] = $class;
278
+ $cta['timeframe'] = $timeframe;
279
+
280
+ $this->actions[] = $cta;
281
+
282
+ return $this;
283
+ }
284
+
285
+
286
+ /**
287
+ * Render out the HTML.
288
+ *
289
+ * Ideally, everything before this method will create a beautiful data-oriented
290
+ * object. The only HTML that should be compiled should be inside this method.
291
+ *
292
+ * @since 3.0.9 | 07 JUN 2018 | Created
293
+ * @access public
294
+ * @param null
295
+ * @return string The compiled HTML of the dashboard notice.
296
+ *
297
+ */
298
+ public function render_HTML() {
299
+ if ( empty( $this->actions) && false === $this->no_cta) :
300
+ $this->add_cta();
301
+ endif;
302
+
303
+ $html = '<div class="swp-dismiss-notice notice notice-info " data-key="' . $this->key . '">';
304
+ $html .= '<p>' . $this->message . ' - Warfare Plugins Team</p>';
305
+ $html .= '<div class="swp-actions">';
306
+
307
+ foreach( $this->actions as $cta) {
308
+ $html .= '<a class="swp-notice-cta ' . $cta['class'] . '" ' . $cta['href'] . ' data-timeframe="'.$cta['timeframe'].'">';
309
+ $html .= $cta['action'];
310
+ $html .= "</a>";
311
+ }
312
+
313
+ $html .= '</div>';
314
+ $html .= '</div>';
315
+
316
+ $this->html = $html;
317
+
318
+ return $this;
319
+ }
320
+
321
+
322
+ /**
323
+ * Gets (returns) the HTML for this notice.
324
+ *
325
+ * We have two separate methods for this. One for returning the HTML, and
326
+ * one for echoing the html. This one returns it.
327
+ *
328
+ * @since 3.0.9 | 07 JUN 2018 | Created
329
+ * @access public
330
+ * @param string $notices The string of notices to be modified.
331
+ * @return string The modified string of notices' html.
332
+ *
333
+ */
334
+ public function get_HTML( $notices = '' ) {
335
+
336
+ if ( !$this->should_display_notice() ) :
337
+ return $notices;
338
+ endif;
339
+
340
+ if ( empty( $this->html ) ) :
341
+ $this->render_HTML();
342
+ endif;
343
+
344
+ return $notices .= $this->html;
345
+ }
346
+
347
+
348
+ /**
349
+ * Echos the HTML for this notice.
350
+ *
351
+ * We have two separate methods for this. One for returning the HTML, and
352
+ * one for echoing the html. This one echos it.
353
+ *
354
+ * @since 3.0.9 | 07 JUN 2018 | Created
355
+ * @access public
356
+ * @param string $notices The string of notices to be modified.
357
+ * @return string The modified string of notices' html.
358
+ *
359
+ */
360
+ public function print_HTML() {
361
+ if ( !$this->should_display_notice() ) :
362
+ return;
363
+ endif;
364
+
365
+ if ( empty( $this->html ) ) :
366
+ $this->render_HTML();
367
+ endif;
368
+
369
+ echo $this->html;
370
+
371
+ return $this;
372
+ }
373
+
374
+ /**
375
+ * Checks whether a string is formatted as our default Date format.
376
+ *
377
+ * @since 3.0.9 | 08 JUN 2018 | Created
378
+ * @param string $string The datetime string in question.
379
+ * @return bool True iff the string is of the format 'Y-m-d h:i:s'.
380
+ *
381
+ */
382
+ private function is_date( $string ) {
383
+ return DateTime::createFromFormat( 'Y-m-d h:i:s', $string ) !== false;
384
+ }
385
+
386
+
387
+ /**
388
+ * Prevents a CTA from being displayed on the notice.
389
+ *
390
+ * In cases where we require the user to take action, we need them
391
+ * to follow the directions in the message before removing the notice.
392
+ *
393
+ * @since 3.1.0 | 05 JUL 2018 | Created the method.
394
+ * @return SWP_Notice $this, for method chaining.
395
+ *
396
+ */
397
+ public function remove_cta() {
398
+ //* Force the ctas to an empty array so render can still loop over it.
399
+ $this->actions = array();
400
+
401
+ $this->no_cta = true;
402
+
403
+ return $this;
404
+ }
405
+ }
functions/utilities/SWP_Notice_Loader.php CHANGED
@@ -1,127 +1,127 @@
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
- * @package SocialWarfare\Functions\Social-Networks
10
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
11
- * @license GPL-3.0+
12
- * @since 3.0.9 | 09 JUN 2018 | Created the class.
13
- * @since 3.1.0 | 27 JUN 2018 | Break each notice into it's own method.
14
- *
15
- */
16
- class SWP_Notice_Loader {
17
-
18
-
19
- /**
20
- * Instantiate the class.
21
- *
22
- * The constructor will call up the methods that create each of the various
23
- * notices throughout the plugin.
24
- *
25
- * @since 3.0.9 | 09 JUN 2018 | Created.
26
- * @since 3.1.0 | 27 JUN 2018 | Updated to use separate methods per notice.
27
- * @see SWP_Notice.php
28
- * @param void
29
- * @return void
30
- *
31
- */
32
- public function __construct() {
33
- $this->activate_json_notices();
34
- $this->debug();
35
- }
36
-
37
-
38
- /**
39
- * Activate notices created via our remote JSON file.
40
- *
41
- * @since 3.1.0 | 27 JUN 2018 | Created
42
- * @param void
43
- * @return void
44
- *
45
- */
46
- private function activate_json_notices() {
47
- $cache_data = get_option('swp_json_cache');
48
-
49
- if( false === $cache_data ):
50
- return;
51
- endif;
52
-
53
- if( !is_array( $cache_data ) || empty($cache_data['notices']) ):
54
- return;
55
- endif;
56
-
57
- foreach( $cache_data['notices'] as $notice ) :
58
- if ( empty( $notice['key'] ) || empty( $notice['message'] ) ) {
59
- continue;
60
- }
61
-
62
- $key = $notice['key'];
63
- $message = $notice['message'];
64
-
65
- $n = new SWP_Notice( $key, $message );
66
-
67
- if ( !empty( $notice['ctas'] ) ) {
68
-
69
- foreach( $notice['ctas'] as $cta) {
70
- $fields = [
71
- 'action' => '',
72
- 'link' => '',
73
- 'class' => '',
74
- 'timeframe' => 0
75
- ];
76
-
77
- $_cta = [];
78
-
79
- foreach( $fields as $field => $default ) {
80
- if ( isset( $cta[$field] ) ) {
81
- $_cta[$field] = $cta[$field];
82
- } else {
83
- $_cta[$field] = $default;
84
- }
85
- }
86
-
87
- $n->add_cta( $_cta['action'], $_cta['link'], $_cta['class'], $_cta['timeframe'] );
88
- }
89
- }
90
-
91
- if ( isset( $notice['start_date'] ) ) {
92
- $n->set_start_date( $notice['start_date'] );
93
- }
94
-
95
- if ( isset( $notice['end_date'] ) ) {
96
- $n->set_end_date( $notice['end_date'] );
97
- }
98
-
99
- if ( isset( $notice['no_cta'] ) ) {
100
- $n->remove_cta();
101
- }
102
-
103
- $this->notices[] = $n;
104
-
105
- endforeach;
106
- }
107
-
108
-
109
- /**
110
- * A function for debugging this class.
111
- *
112
- * All notices are stored in the $this->notices as an array of notice
113
- * objects. Since this is the last method called, all notices should be
114
- * present in the $this object for review.
115
- *
116
- * @since 3.1.0 | 28 JUN 2018 | Created
117
- * @param void
118
- * @return void
119
- *
120
- */
121
- private function debug() {
122
- if( true === _swp_is_debug( 'notices' ) ):
123
- var_dump($this);
124
- endif;
125
- }
126
-
127
- }
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
+ * @package SocialWarfare\Functions\Social-Networks
10
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
11
+ * @license GPL-3.0+
12
+ * @since 3.0.9 | 09 JUN 2018 | Created the class.
13
+ * @since 3.1.0 | 27 JUN 2018 | Break each notice into it's own method.
14
+ *
15
+ */
16
+ class SWP_Notice_Loader {
17
+
18
+
19
+ /**
20
+ * Instantiate the class.
21
+ *
22
+ * The constructor will call up the methods that create each of the various
23
+ * notices throughout the plugin.
24
+ *
25
+ * @since 3.0.9 | 09 JUN 2018 | Created.
26
+ * @since 3.1.0 | 27 JUN 2018 | Updated to use separate methods per notice.
27
+ * @see SWP_Notice.php
28
+ * @param void
29
+ * @return void
30
+ *
31
+ */
32
+ public function __construct() {
33
+ $this->activate_json_notices();
34
+ $this->debug();
35
+ }
36
+
37
+
38
+ /**
39
+ * Activate notices created via our remote JSON file.
40
+ *
41
+ * @since 3.1.0 | 27 JUN 2018 | Created
42
+ * @param void
43
+ * @return void
44
+ *
45
+ */
46
+ private function activate_json_notices() {
47
+ $cache_data = get_option('swp_json_cache');
48
+
49
+ if( false === $cache_data ):
50
+ return;
51
+ endif;
52
+
53
+ if( !is_array( $cache_data ) || empty($cache_data['notices']) ):
54
+ return;
55
+ endif;
56
+
57
+ foreach( $cache_data['notices'] as $notice ) :
58
+ if ( empty( $notice['key'] ) || empty( $notice['message'] ) ) {
59
+ continue;
60
+ }
61
+
62
+ $key = $notice['key'];
63
+ $message = $notice['message'];
64
+
65
+ $n = new SWP_Notice( $key, $message );
66
+
67
+ if ( !empty( $notice['ctas'] ) ) {
68
+
69
+ foreach( $notice['ctas'] as $cta) {
70
+ $fields = [
71
+ 'action' => '',
72
+ 'link' => '',
73
+ 'class' => '',
74
+ 'timeframe' => 0
75
+ ];
76
+
77
+ $_cta = [];
78
+
79
+ foreach( $fields as $field => $default ) {
80
+ if ( isset( $cta[$field] ) ) {
81
+ $_cta[$field] = $cta[$field];
82
+ } else {
83
+ $_cta[$field] = $default;
84
+ }
85
+ }
86
+
87
+ $n->add_cta( $_cta['action'], $_cta['link'], $_cta['class'], $_cta['timeframe'] );
88
+ }
89
+ }
90
+
91
+ if ( isset( $notice['start_date'] ) ) {
92
+ $n->set_start_date( $notice['start_date'] );
93
+ }
94
+
95
+ if ( isset( $notice['end_date'] ) ) {
96
+ $n->set_end_date( $notice['end_date'] );
97
+ }
98
+
99
+ if ( isset( $notice['no_cta'] ) ) {
100
+ $n->remove_cta();
101
+ }
102
+
103
+ $this->notices[] = $n;
104
+
105
+ endforeach;
106
+ }
107
+
108
+
109
+ /**
110
+ * A function for debugging this class.
111
+ *
112
+ * All notices are stored in the $this->notices as an array of notice
113
+ * objects. Since this is the last method called, all notices should be
114
+ * present in the $this object for review.
115
+ *
116
+ * @since 3.1.0 | 28 JUN 2018 | Created
117
+ * @param void
118
+ * @return void
119
+ *
120
+ */
121
+ private function debug() {
122
+ if( true === _swp_is_debug( 'notices' ) ):
123
+ var_dump($this);
124
+ endif;
125
+ }
126
+
127
+ }
functions/utilities/SWP_Permalink.php CHANGED
@@ -1,214 +1,214 @@
1
- <?php
2
-
3
- /**
4
- * A class of functions used to fetch alternate permalinks.
5
- *
6
- * This class allows the share count API to check for share counts using multiple
7
- * forms of a post's permalink. This is used for the share recovery features.
8
- *
9
- * This class has no __construct method as it won't ever really need to be instantiated.
10
- *
11
- * @package SocialWarfare\Utilities
12
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
13
- * @license GPL-3.0+
14
- * @since 3.0.0 | 22 FEB 2018 | Refactored into a class-based system.
15
- *
16
- */
17
- class SWP_Permalink {
18
-
19
-
20
- /**
21
- * A method to parse and produce the alternate permalink.
22
- *
23
- * @since 1.0.0
24
- * @param int The post ID.
25
- * @param bool Whether to keep the post name.
26
- * @return string The modified URL of the post.
27
- *
28
- */
29
- public static function get_alt_permalink( $post = 0, $leavename = false ) {
30
- global $swp_user_options;
31
-
32
- $rewritecode = array(
33
- '%year%',
34
- '%monthnum%',
35
- '%day%',
36
- '%hour%',
37
- '%minute%',
38
- '%second%',
39
- $leavename? '' : '%postname%',
40
- '%post_id%',
41
- '%category%',
42
- '%author%',
43
- $leavename? '' : '%pagename%',
44
- );
45
-
46
- if ( is_object( $post ) && isset( $post->filter ) && 'sample' == $post->filter ) {
47
- $sample = true;
48
- } else {
49
- $post = get_post( $post );
50
- $sample = false;
51
- }
52
-
53
- if ( empty( $post->ID ) ) {
54
- return false;
55
- }
56
-
57
- // Build the structure
58
- $structure = $swp_user_options['recovery_format'];
59
-
60
- if ( $structure == 'custom' ) :
61
- $permalink = $swp_user_options['recovery_permalink'];
62
- elseif ( $structure == 'unchanged' ) :
63
- $permalink = get_option( 'permalink_structure' );
64
- elseif ( $structure == 'default' ) :
65
- $permalink = '';
66
- elseif ( $structure == 'day_and_name' ) :
67
- $permalink = '/%year%/%monthnum%/%day%/%postname%/';
68
- elseif ( $structure == 'month_and_name' ) :
69
- $permalink = '/%year%/%monthnum%/%postname%/';
70
- elseif ( $structure == 'numeric' ) :
71
- $permalink = '/archives/%post_id%';
72
- elseif ( $structure == 'post_name' ) :
73
- $permalink = '/%postname%/';
74
- else :
75
- $permalink = get_option( 'permalink_structure' );
76
- endif;
77
-
78
- /**
79
- * Filter the permalink structure for a post before token replacement occurs.
80
- *
81
- * Only applies to posts with post_type of 'post'.
82
- *
83
- * @since 3.0.0
84
- *
85
- * @param string $permalink The site's permalink structure.
86
- * @param WP_Post $post The post in question.
87
- * @param bool $leavename Whether to keep the post name.
88
- */
89
- $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
90
-
91
- // Check if the user has defined a specific custom URL
92
- $custom_url = get_post_meta( get_the_ID() , 'swp_recovery_url' , true );
93
- if ( $custom_url ) :
94
- return $custom_url;
95
- else :
96
-
97
- if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) {
98
- $unixtime = strtotime( $post->post_date );
99
-
100
- $category = '';
101
- if ( strpos( $permalink, '%category%' ) !== false ) {
102
- $cats = get_the_category( $post->ID );
103
- if ( $cats ) {
104
- usort( $cats, '_usort_terms_by_ID' ); // order by ID
105
-
106
- /**
107
- * Filter the category that gets used in the %category% permalink token.
108
- *
109
- * @since 3.5.0
110
- *
111
- * @param stdClass $cat The category to use in the permalink.
112
- * @param array $cats Array of all categories associated with the post.
113
- * @param WP_Post $post The post in question.
114
- */
115
- $category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post );
116
-
117
- $category_object = get_term( $category_object, 'category' );
118
- $category = $category_object->slug;
119
- if ( $parent = $category_object->parent ) {
120
- $category = get_category_parents( $parent, false, '/', true ) . $category;
121
- }
122
- }
123
- // show default category in permalinks, without
124
- // having to assign it explicitly
125
- if ( empty( $category ) ) {
126
- $default_category = get_term( get_option( 'default_category' ), 'category' );
127
- $category = is_wp_error( $default_category ) ? '' : $default_category->slug;
128
- }
129
- }
130
-
131
- $author = '';
132
- if ( strpos( $permalink, '%author%' ) !== false ) {
133
- $authordata = get_userdata( $post->post_author );
134
- $author = $authordata->user_nicename;
135
- }
136
-
137
- $date = explode( ' ',date( 'Y m d H i s', $unixtime ) );
138
- $rewritereplace =
139
- array(
140
- $date[0],
141
- $date[1],
142
- $date[2],
143
- $date[3],
144
- $date[4],
145
- $date[5],
146
- $post->post_name,
147
- $post->ID,
148
- $category,
149
- $author,
150
- $post->post_name,
151
- );
152
- $permalink = home_url( str_replace( $rewritecode, $rewritereplace, $permalink ) );
153
-
154
- if ( $structure != 'custom' ) :
155
- $permalink = user_trailingslashit( $permalink, 'single' );
156
- endif;
157
-
158
- } else { // if they're not using the fancy permalink option
159
- $permalink = home_url( '?p=' . $post->ID );
160
- }// End if().
161
-
162
- /**
163
- * Filter the permalink for a post.
164
- *
165
- * Only applies to posts with post_type of 'post'.
166
- *
167
- * @since 1.5.0
168
- *
169
- * @param string $permalink The post's permalink.
170
- * @param WP_Post $post The post in question.
171
- * @param bool $leavename Whether to keep the post name.
172
- */
173
- $url = apply_filters( 'post_link', $permalink, $post, $leavename );
174
-
175
- // Ignore all filters and just start with the site url on the home page
176
- if( is_front_page() ):
177
- $url = get_site_url();
178
- endif;
179
-
180
- // Check if they're using cross domain recovery
181
- if ( isset( $swp_user_options['current_domain'] ) && $swp_user_options['current_domain']
182
- && isset( $swp_user_options['former_domain'] ) && $swp_user_options['former_domain'] ) :
183
- $url = str_replace( $swp_user_options['current_domain'],$swp_user_options['former_domain'],$url );
184
- endif;
185
-
186
- // Filter the Protocol
187
- if ( $swp_user_options['recovery_protocol'] == 'https' && strpos( $url,'https' ) === false ) :
188
- $url = str_replace( 'http','https',$url );
189
- elseif ( $swp_user_options['recovery_protocol'] == 'http' && strpos( $url,'https' ) !== false ) :
190
- $url = str_replace( 'https','http',$url );
191
- endif;
192
-
193
- // Filter the prefix
194
- if ( $swp_user_options['recovery_prefix'] == 'unchanged' ) :
195
- elseif ( $swp_user_options['recovery_prefix'] == 'www' && strpos( $url,'www' ) === false ) :
196
- $url = str_replace( 'http://','http://www.',$url );
197
- $url = str_replace( 'https://','https://www.',$url );
198
- elseif ( $swp_user_options['recovery_prefix'] == 'nonwww' && strpos( $url,'www' ) !== false ) :
199
- $url = str_replace( 'http://www.','http://',$url );
200
- $url = str_replace( 'https://www.','https://',$url );
201
- endif;
202
-
203
- // Filter out the subdomain
204
- if ( isset( $swp_user_options['recovery_subdomain'] ) && $swp_user_options['recovery_subdomain'] != '' ) :
205
- $url = str_replace( $swp_user_options['recovery_subdomain'] . '.' , '' , $url );
206
- endif;
207
-
208
- return $url;
209
-
210
- endif;
211
-
212
- }
213
-
214
- }
1
+ <?php
2
+
3
+ /**
4
+ * A class of functions used to fetch alternate permalinks.
5
+ *
6
+ * This class allows the share count API to check for share counts using multiple
7
+ * forms of a post's permalink. This is used for the share recovery features.
8
+ *
9
+ * This class has no __construct method as it won't ever really need to be instantiated.
10
+ *
11
+ * @package SocialWarfare\Utilities
12
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
13
+ * @license GPL-3.0+
14
+ * @since 3.0.0 | 22 FEB 2018 | Refactored into a class-based system.
15
+ *
16
+ */
17
+ class SWP_Permalink {
18
+
19
+
20
+ /**
21
+ * A method to parse and produce the alternate permalink.
22
+ *
23
+ * @since 1.0.0
24
+ * @param int The post ID.
25
+ * @param bool Whether to keep the post name.
26
+ * @return string The modified URL of the post.
27
+ *
28
+ */
29
+ public static function get_alt_permalink( $post = 0, $leavename = false ) {
30
+ global $swp_user_options;
31
+
32
+ $rewritecode = array(
33
+ '%year%',
34
+ '%monthnum%',
35
+ '%day%',
36
+ '%hour%',
37
+ '%minute%',
38
+ '%second%',
39
+ $leavename? '' : '%postname%',
40
+ '%post_id%',
41
+ '%category%',
42
+ '%author%',
43
+ $leavename? '' : '%pagename%',
44
+ );
45
+
46
+ if ( is_object( $post ) && isset( $post->filter ) && 'sample' == $post->filter ) {
47
+ $sample = true;
48
+ } else {
49
+ $post = get_post( $post );
50
+ $sample = false;
51
+ }
52
+
53
+ if ( empty( $post->ID ) ) {
54
+ return false;
55
+ }
56
+
57
+ // Build the structure
58
+ $structure = $swp_user_options['recovery_format'];
59
+
60
+ if ( $structure == 'custom' ) :
61
+ $permalink = $swp_user_options['recovery_permalink'];
62
+ elseif ( $structure == 'unchanged' ) :
63
+ $permalink = get_option( 'permalink_structure' );
64
+ elseif ( $structure == 'default' ) :
65
+ $permalink = '';
66
+ elseif ( $structure == 'day_and_name' ) :
67
+ $permalink = '/%year%/%monthnum%/%day%/%postname%/';
68
+ elseif ( $structure == 'month_and_name' ) :
69
+ $permalink = '/%year%/%monthnum%/%postname%/';
70
+ elseif ( $structure == 'numeric' ) :
71
+ $permalink = '/archives/%post_id%';
72
+ elseif ( $structure == 'post_name' ) :
73
+ $permalink = '/%postname%/';
74
+ else :
75
+ $permalink = get_option( 'permalink_structure' );
76
+ endif;
77
+
78
+ /**
79
+ * Filter the permalink structure for a post before token replacement occurs.
80
+ *
81
+ * Only applies to posts with post_type of 'post'.
82
+ *
83
+ * @since 3.0.0
84
+ *
85
+ * @param string $permalink The site's permalink structure.
86
+ * @param WP_Post $post The post in question.
87
+ * @param bool $leavename Whether to keep the post name.
88
+ */
89
+ $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
90
+
91
+ // Check if the user has defined a specific custom URL
92
+ $custom_url = get_post_meta( get_the_ID() , 'swp_recovery_url' , true );
93
+ if ( $custom_url ) :
94
+ return $custom_url;
95
+ else :
96
+
97
+ if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) {
98
+ $unixtime = strtotime( $post->post_date );
99
+
100
+ $category = '';
101
+ if ( strpos( $permalink, '%category%' ) !== false ) {
102
+ $cats = get_the_category( $post->ID );
103
+ if ( $cats ) {
104
+ usort( $cats, '_usort_terms_by_ID' ); // order by ID
105
+
106
+ /**
107
+ * Filter the category that gets used in the %category% permalink token.
108
+ *
109
+ * @since 3.5.0
110
+ *
111
+ * @param stdClass $cat The category to use in the permalink.
112
+ * @param array $cats Array of all categories associated with the post.
113
+ * @param WP_Post $post The post in question.
114
+ */
115
+ $category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post );
116
+
117
+ $category_object = get_term( $category_object, 'category' );
118
+ $category = $category_object->slug;
119
+ if ( $parent = $category_object->parent ) {
120
+ $category = get_category_parents( $parent, false, '/', true ) . $category;
121
+ }
122
+ }
123
+ // show default category in permalinks, without
124
+ // having to assign it explicitly
125
+ if ( empty( $category ) ) {
126
+ $default_category = get_term( get_option( 'default_category' ), 'category' );
127
+ $category = is_wp_error( $default_category ) ? '' : $default_category->slug;
128
+ }
129
+ }
130
+
131
+ $author = '';
132
+ if ( strpos( $permalink, '%author%' ) !== false ) {
133
+ $authordata = get_userdata( $post->post_author );
134
+ $author = $authordata->user_nicename;
135
+ }
136
+
137
+ $date = explode( ' ',date( 'Y m d H i s', $unixtime ) );
138
+ $rewritereplace =
139
+ array(
140
+ $date[0],
141
+ $date[1],
142
+ $date[2],
143
+ $date[3],
144
+ $date[4],
145
+ $date[5],
146
+ $post->post_name,
147
+ $post->ID,
148
+ $category,
149
+ $author,
150
+ $post->post_name,
151
+ );
152
+ $permalink = home_url( str_replace( $rewritecode, $rewritereplace, $permalink ) );
153
+
154
+ if ( $structure != 'custom' ) :
155
+ $permalink = user_trailingslashit( $permalink, 'single' );
156
+ endif;
157
+
158
+ } else { // if they're not using the fancy permalink option
159
+ $permalink = home_url( '?p=' . $post->ID );
160
+ }// End if().
161
+
162
+ /**
163
+ * Filter the permalink for a post.
164
+ *
165
+ * Only applies to posts with post_type of 'post'.
166
+ *
167
+ * @since 1.5.0
168
+ *
169
+ * @param string $permalink The post's permalink.
170
+ * @param WP_Post $post The post in question.
171
+ * @param bool $leavename Whether to keep the post name.
172
+ */
173
+ $url = apply_filters( 'post_link', $permalink, $post, $leavename );
174
+
175
+ // Ignore all filters and just start with the site url on the home page
176
+ if( is_front_page() ):
177
+ $url = get_site_url();
178
+ endif;
179
+
180
+ // Check if they're using cross domain recovery
181
+ if ( isset( $swp_user_options['current_domain'] ) && $swp_user_options['current_domain']
182
+ && isset( $swp_user_options['former_domain'] ) && $swp_user_options['former_domain'] ) :
183
+ $url = str_replace( $swp_user_options['current_domain'],$swp_user_options['former_domain'],$url );
184
+ endif;
185
+
186
+ // Filter the Protocol
187
+ if ( $swp_user_options['recovery_protocol'] == 'https' && strpos( $url,'https' ) === false ) :
188
+ $url = str_replace( 'http','https',$url );
189
+ elseif ( $swp_user_options['recovery_protocol'] == 'http' && strpos( $url,'https' ) !== false ) :
190
+ $url = str_replace( 'https','http',$url );
191
+ endif;
192
+
193
+ // Filter the prefix
194
+ if ( $swp_user_options['recovery_prefix'] == 'unchanged' ) :
195
+ elseif ( $swp_user_options['recovery_prefix'] == 'www' && strpos( $url,'www' ) === false ) :
196
+ $url = str_replace( 'http://','http://www.',$url );
197
+ $url = str_replace( 'https://','https://www.',$url );
198
+ elseif ( $swp_user_options['recovery_prefix'] == 'nonwww' && strpos( $url,'www' ) !== false ) :
199
+ $url = str_replace( 'http://www.','http://',$url );
200
+ $url = str_replace( 'https://www.','https://',$url );
201
+ endif;
202
+
203
+ // Filter out the subdomain
204
+ if ( isset( $swp_user_options['recovery_subdomain'] ) && $swp_user_options['recovery_subdomain'] != '' ) :
205
+ $url = str_replace( $swp_user_options['recovery_subdomain'] . '.' , '' , $url );
206
+ endif;
207
+
208
+ return $url;
209
+
210
+ endif;
211
+
212
+ }
213
+
214
+ }
functions/utilities/SWP_Plugin_Updater.php CHANGED
@@ -1,495 +1,495 @@
1
- <?php
2
-
3
- /**
4
- * Allows plugins to use their own update API.
5
- *
6
- * This class is built and created by the Author of the Easy Digital
7
- * Downloads eCommerce suite. It is used to ping EDD on our storefront
8
- * at periodic intervals in order to check for available updates. We
9
- * host this class here in core so that it can be accessed via each
10
- * installed premium addon to the plugin.
11
- *
12
- * @author Easy Digital Downloads
13
- * @version 1.6.14
14
- *
15
- */
16
- class SWP_Plugin_Updater {
17
-
18
- private $api_url = '';
19
- private $api_data = array();
20
- private $name = '';
21
- private $slug = '';
22
- private $version = '';
23
- private $wp_override = false;
24
- private $cache_key = '';
25
-
26
- /**
27
- * Class constructor.
28
- *
29
- * @uses plugin_basename()
30
- * @uses hook()
31
- *
32
- * @param string $_api_url The URL pointing to the custom API endpoint.
33
- * @param string $_plugin_file Path to the plugin file.
34
- * @param array $_api_data Optional data to send with API calls.
35
- */
36
- public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
37
-
38
- global $edd_plugin_data;
39
-
40
- $this->api_url = trailingslashit( $_api_url );
41
- $this->api_data = $_api_data;
42
- $this->name = plugin_basename( $_plugin_file );
43
- $this->slug = basename( $_plugin_file, '.php' );
44
- $this->version = $_api_data['version'];
45
- $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
46
- $this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
47
- $this->cache_key = md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
48
-
49
- $edd_plugin_data[ $this->slug ] = $this->api_data;
50
-
51
- // Set up hooks.
52
- $this->init();
53
-
54
- }
55
-
56
- /**
57
- * Set up WordPress filters to hook into WP's update process.
58
- *
59
- * @uses add_filter()
60
- *
61
- * @return void
62
- */
63
- public function init() {
64
-
65
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
66
- add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
67
- remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
68
- add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
69
- add_action( 'admin_init', array( $this, 'show_changelog' ) );
70
-
71
- }
72
-
73
- /**
74
- * Check for Updates at the defined API endpoint and modify the update array.
75
- *
76
- * This function dives into the update API just when WordPress creates its update array,
77
- * then adds a custom API call and injects the custom plugin data retrieved from the API.
78
- * It is reassembled from parts of the native WordPress plugin update code.
79
- * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
80
- *
81
- * @uses api_request()
82
- *
83
- * @param array $_transient_data Update array build by WordPress.
84
- * @return array Modified update array with custom plugin data.
85
- */
86
- public function check_update( $_transient_data ) {
87
-
88
- global $pagenow;
89
-
90
- if ( ! is_object( $_transient_data ) ) {
91
- $_transient_data = new stdClass;
92
- }
93
-
94
- if ( 'plugins.php' == $pagenow && is_multisite() ) {
95
- return $_transient_data;
96
- }
97
-
98
- if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
99
- return $_transient_data;
100
- }
101
-
102
- $version_info = $this->get_cached_version_info();
103
-
104
- if ( false === $version_info ) {
105
- $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
106
-
107
- $this->set_version_info_cache( $version_info );
108
-
109
- }
110
-
111
- if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
112
-
113
- if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
114
-
115
- $_transient_data->response[ $this->name ] = $version_info;
116
-
117
- }
118
-
119
- $_transient_data->last_checked = current_time( 'timestamp' );
120
- $_transient_data->checked[ $this->name ] = $this->version;
121
-
122
- }
123
-
124
- return $_transient_data;
125
- }
126
-
127
- /**
128
- * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
129
- *
130
- * @param string $file
131
- * @param array $plugin
132
- */
133
- public function show_update_notification( $file, $plugin ) {
134
-
135
- if ( is_network_admin() ) {
136
- return;
137
- }
138
-
139
- if( ! current_user_can( 'update_plugins' ) ) {
140
- return;
141
- }
142
-
143
- if( ! is_multisite() ) {
144
- return;
145
- }
146
-
147
- if ( $this->name != $file ) {
148
- return;
149
- }
150
-
151
- // Remove our filter on the site transient
152
- remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
153
-
154
- $update_cache = get_site_transient( 'update_plugins' );
155
-
156
- $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
157
-
158
- if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
159
-
160
- $version_info = $this->get_cached_version_info();
161
-
162
- if ( false === $version_info ) {
163
- $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
164
-
165
- $this->set_version_info_cache( $version_info );
166
- }
167
-
168
- if ( ! is_object( $version_info ) ) {
169
- return;
170
- }
171
-
172
- if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
173
-
174
- $update_cache->response[ $this->name ] = $version_info;
175
-
176
- }
177
-
178
- $update_cache->last_checked = current_time( 'timestamp' );
179
- $update_cache->checked[ $this->name ] = $this->version;
180
-
181
- set_site_transient( 'update_plugins', $update_cache );
182
-
183
- } else {
184
-
185
- $version_info = $update_cache->response[ $this->name ];
186
-
187
- }
188
-
189
- // Restore our filter
190
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
191
-
192
- if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
193
-
194
- // build a plugin list row, with update notification
195
- $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
196
- # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
197
- echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
198
- echo '<td colspan="3" class="plugin-update colspanchange">';
199
- echo '<div class="update-message notice inline notice-warning notice-alt">';
200
-
201
- $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
202
-
203
- if ( empty( $version_info->download_link ) ) {
204
- printf(
205
- __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
206
- esc_html( $version_info->name ),
207
- '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
208
- esc_html( $version_info->new_version ),
209
- '</a>'
210
- );
211
- } else {
212
- printf(
213
- __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
214
- esc_html( $version_info->name ),
215
- '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
216
- esc_html( $version_info->new_version ),
217
- '</a>',
218
- '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
219
- '</a>'
220
- );
221
- }
222
-
223
- do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
224
-
225
- echo '</div></td></tr>';
226
- }
227
- }
228
-
229
- /**
230
- * Updates information on the "View version x.x details" page with custom data.
231
- *
232
- * @uses api_request()
233
- *
234
- * @param mixed $_data
235
- * @param string $_action
236
- * @param object $_args
237
- * @return object $_data
238
- */
239
- public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
240
-
241
- if ( $_action != 'plugin_information' ) {
242
-
243
- return $_data;
244
-
245
- }
246
-
247
- if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
248
-
249
- return $_data;
250
-
251
- }
252
-
253
- $to_send = array(
254
- 'slug' => $this->slug,
255
- 'is_ssl' => is_ssl(),
256
- 'fields' => array(
257
- 'banners' => array(),
258
- 'reviews' => false
259
- )
260
- );
261
-
262
- $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
263
-
264
- // Get the transient where we store the api request for this plugin for 24 hours
265
- $edd_api_request_transient = $this->get_cached_version_info( $cache_key );
266
-
267
- //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
268
- if ( empty( $edd_api_request_transient ) ) {
269
-
270
- $api_response = $this->api_request( 'plugin_information', $to_send );
271
-
272
- // Expires in 3 hours
273
- $this->set_version_info_cache( $api_response, $cache_key );
274
-
275
- if ( false !== $api_response ) {
276
- $_data = $api_response;
277
- }
278
-
279
- } else {
280
- $_data = $edd_api_request_transient;
281
- }
282
-
283
- // Convert sections into an associative array, since we're getting an object, but Core expects an array.
284
- if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
285
- $new_sections = array();
286
- foreach ( $_data->sections as $key => $value ) {
287
- $new_sections[ $key ] = $value;
288
- }
289
-
290
- $_data->sections = $new_sections;
291
- }
292
-
293
- // Convert banners into an associative array, since we're getting an object, but Core expects an array.
294
- if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
295
- $new_banners = array();
296
- foreach ( $_data->banners as $key => $value ) {
297
- $new_banners[ $key ] = $value;
298
- }
299
-
300
- $_data->banners = $new_banners;
301
- }
302
-
303
- return $_data;
304
- }
305
-
306
- /**
307
- * Disable SSL verification in order to prevent download update failures
308
- *
309
- * @param array $args
310
- * @param string $url
311
- * @return object $array
312
- */
313
- public function http_request_args( $args, $url ) {
314
-
315
- $verify_ssl = $this->verify_ssl();
316
- if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
317
- $args['sslverify'] = $verify_ssl;
318
- }
319
- return $args;
320
-
321
- }
322
-
323
- /**
324
- * Calls the API and, if successfull, returns the object delivered by the API.
325
- *
326
- * @uses get_bloginfo()
327
- * @uses wp_remote_post()
328
- * @uses is_wp_error()
329
- *
330
- * @param string $_action The requested action.
331
- * @param array $_data Parameters for the API action.
332
- * @return false|object
333
- */
334
- private function api_request( $_action, $_data ) {
335
-
336
- global $wp_version;
337
-
338
- $data = array_merge( $this->api_data, $_data );
339
-
340
- if ( $data['slug'] != $this->slug ) {
341
- return;
342
- }
343
-
344
- if( $this->api_url == trailingslashit (home_url() ) ) {
345
- return false; // Don't allow a plugin to ping itself
346
- }
347
-
348
- $api_params = array(
349
- 'edd_action' => 'get_version',
350
- 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
351
- 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
352
- 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
353
- 'version' => isset( $data['version'] ) ? $data['version'] : false,
354
- 'slug' => $data['slug'],
355
- 'author' => $data['author'],
356
- 'url' => home_url(),
357
- 'beta' => ! empty( $data['beta'] ),
358
- );
359
-
360
- $verify_ssl = $this->verify_ssl();
361
- $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
362
-
363
- if ( ! is_wp_error( $request ) ) {
364
- $request = json_decode( wp_remote_retrieve_body( $request ) );
365
- }
366
-
367
- if ( $request && isset( $request->sections ) ) {
368
- $request->sections = maybe_unserialize( $request->sections );
369
- } else {
370
- $request = false;
371
- }
372
-
373
- if ( $request && isset( $request->banners ) ) {
374
- $request->banners = maybe_unserialize( $request->banners );
375
- }
376
-
377
- if( ! empty( $request->sections ) ) {
378
- foreach( $request->sections as $key => $section ) {
379
- $request->$key = (array) $section;
380
- }
381
- }
382
-
383
- return $request;
384
- }
385
-
386
- public function show_changelog() {
387
-
388
- global $edd_plugin_data;
389
-
390
- if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
391
- return;
392
- }
393
-
394
- if( empty( $_REQUEST['plugin'] ) ) {
395
- return;
396
- }
397
-
398
- if( empty( $_REQUEST['slug'] ) ) {
399
- return;
400
- }
401
-
402
- if( ! current_user_can( 'update_plugins' ) ) {
403
- wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
404
- }
405
-
406
- $data = $edd_plugin_data[ $_REQUEST['slug'] ];
407
- $beta = ! empty( $data['beta'] ) ? true : false;
408
- $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
409
- $version_info = $this->get_cached_version_info( $cache_key );
410
-
411
- if( false === $version_info ) {
412
-
413
- $api_params = array(
414
- 'edd_action' => 'get_version',
415
- 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
416
- 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
417
- 'slug' => $_REQUEST['slug'],
418
- 'author' => $data['author'],
419
- 'url' => home_url(),
420
- 'beta' => ! empty( $data['beta'] )
421
- );
422
-
423
- $verify_ssl = $this->verify_ssl();
424
- $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
425
-
426
- if ( ! is_wp_error( $request ) ) {
427
- $version_info = json_decode( wp_remote_retrieve_body( $request ) );
428
- }
429
-
430
-
431
- if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
432
- $version_info->sections = maybe_unserialize( $version_info->sections );
433
- } else {
434
- $version_info = false;
435
- }
436
-
437
- if( ! empty( $version_info ) ) {
438
- foreach( $version_info->sections as $key => $section ) {
439
- $version_info->$key = (array) $section;
440
- }
441
- }
442
-
443
- $this->set_version_info_cache( $version_info, $cache_key );
444
-
445
- }
446
-
447
- if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
448
- echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
449
- }
450
-
451
- exit;
452
- }
453
-
454
- public function get_cached_version_info( $cache_key = '' ) {
455
-
456
- if( empty( $cache_key ) ) {
457
- $cache_key = $this->cache_key;
458
- }
459
-
460
- $cache = get_option( $cache_key );
461
-
462
- if( empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) {
463
- return false; // Cache is expired
464
- }
465
-
466
- return json_decode( $cache['value'] );
467
-
468
- }
469
-
470
- public function set_version_info_cache( $value = '', $cache_key = '' ) {
471
-
472
- if( empty( $cache_key ) ) {
473
- $cache_key = $this->cache_key;
474
- }
475
-
476
- $data = array(
477
- 'timeout' => strtotime( '+3 hours', current_time( 'timestamp' ) ),
478
- 'value' => json_encode( $value )
479
- );
480
-
481
- update_option( $cache_key, $data, 'no' );
482
-
483
- }
484
-
485
- /**
486
- * Returns if the SSL of the store should be verified.
487
- *
488
- * @since 1.6.13
489
- * @return bool
490
- */
491
- private function verify_ssl() {
492
- return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
493
- }
494
-
495
- }
1
+ <?php
2
+
3
+ /**
4
+ * Allows plugins to use their own update API.
5
+ *
6
+ * This class is built and created by the Author of the Easy Digital
7
+ * Downloads eCommerce suite. It is used to ping EDD on our storefront
8
+ * at periodic intervals in order to check for available updates. We
9
+ * host this class here in core so that it can be accessed via each
10
+ * installed premium addon to the plugin.
11
+ *
12
+ * @author Easy Digital Downloads
13
+ * @version 1.6.14
14
+ *
15
+ */
16
+ class SWP_Plugin_Updater {
17
+
18
+ private $api_url = '';
19
+ private $api_data = array();
20
+ private $name = '';
21
+ private $slug = '';
22
+ private $version = '';
23
+ private $wp_override = false;
24
+ private $cache_key = '';
25
+
26
+ /**
27
+ * Class constructor.
28
+ *
29
+ * @uses plugin_basename()
30
+ * @uses hook()
31
+ *
32
+ * @param string $_api_url The URL pointing to the custom API endpoint.
33
+ * @param string $_plugin_file Path to the plugin file.
34
+ * @param array $_api_data Optional data to send with API calls.
35
+ */
36
+ public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
37
+
38
+ global $edd_plugin_data;
39
+
40
+ $this->api_url = trailingslashit( $_api_url );
41
+ $this->api_data = $_api_data;
42
+ $this->name = plugin_basename( $_plugin_file );
43
+ $this->slug = basename( $_plugin_file, '.php' );
44
+ $this->version = $_api_data['version'];
45
+ $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
46
+ $this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
47
+ $this->cache_key = md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
48
+
49
+ $edd_plugin_data[ $this->slug ] = $this->api_data;
50
+
51
+ // Set up hooks.
52
+ $this->init();
53
+
54
+ }
55
+
56
+ /**
57
+ * Set up WordPress filters to hook into WP's update process.
58
+ *
59
+ * @uses add_filter()
60
+ *
61
+ * @return void
62
+ */
63
+ public function init() {
64
+
65
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
66
+ add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
67
+ remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
68
+ add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
69
+ add_action( 'admin_init', array( $this, 'show_changelog' ) );
70
+
71
+ }
72
+
73
+ /**
74
+ * Check for Updates at the defined API endpoint and modify the update array.
75
+ *
76
+ * This function dives into the update API just when WordPress creates its update array,
77
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
78
+ * It is reassembled from parts of the native WordPress plugin update code.
79
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
80
+ *
81
+ * @uses api_request()
82
+ *
83
+ * @param array $_transient_data Update array build by WordPress.
84
+ * @return array Modified update array with custom plugin data.
85
+ */
86
+ public function check_update( $_transient_data ) {
87
+
88
+ global $pagenow;
89
+
90
+ if ( ! is_object( $_transient_data ) ) {
91
+ $_transient_data = new stdClass;
92
+ }
93
+
94
+ if ( 'plugins.php' == $pagenow && is_multisite() ) {
95
+ return $_transient_data;
96
+ }
97
+
98
+ if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
99
+ return $_transient_data;
100
+ }
101
+
102
+ $version_info = $this->get_cached_version_info();
103
+
104
+ if ( false === $version_info ) {
105
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
106
+
107
+ $this->set_version_info_cache( $version_info );
108
+
109
+ }
110
+
111
+ if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
112
+
113
+ if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
114
+
115
+ $_transient_data->response[ $this->name ] = $version_info;
116
+
117
+ }
118
+
119
+ $_transient_data->last_checked = current_time( 'timestamp' );
120
+ $_transient_data->checked[ $this->name ] = $this->version;
121
+
122
+ }
123
+
124
+ return $_transient_data;
125
+ }
126
+
127
+ /**
128
+ * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
129
+ *
130
+ * @param string $file
131
+ * @param array $plugin
132
+ */
133
+ public function show_update_notification( $file, $plugin ) {
134
+
135
+ if ( is_network_admin() ) {
136
+ return;
137
+ }
138
+
139
+ if( ! current_user_can( 'update_plugins' ) ) {
140
+ return;
141
+ }
142
+
143
+ if( ! is_multisite() ) {
144
+ return;
145
+ }
146
+
147
+ if ( $this->name != $file ) {
148
+ return;
149
+ }
150
+
151
+ // Remove our filter on the site transient
152
+ remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
153
+
154
+ $update_cache = get_site_transient( 'update_plugins' );
155
+
156
+ $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
157
+
158
+ if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
159
+
160
+ $version_info = $this->get_cached_version_info();
161
+
162
+ if ( false === $version_info ) {
163
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
164
+
165
+ $this->set_version_info_cache( $version_info );
166
+ }
167
+
168
+ if ( ! is_object( $version_info ) ) {
169
+ return;
170
+ }
171
+
172
+ if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
173
+
174
+ $update_cache->response[ $this->name ] = $version_info;
175
+
176
+ }
177
+
178
+ $update_cache->last_checked = current_time( 'timestamp' );
179
+ $update_cache->checked[ $this->name ] = $this->version;
180
+
181
+ set_site_transient( 'update_plugins', $update_cache );
182
+
183
+ } else {
184
+
185
+ $version_info = $update_cache->response[ $this->name ];
186
+
187
+ }
188
+
189
+ // Restore our filter
190
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
191
+
192
+ if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
193
+
194
+ // build a plugin list row, with update notification
195
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
196
+ # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
197
+ echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
198
+ echo '<td colspan="3" class="plugin-update colspanchange">';
199
+ echo '<div class="update-message notice inline notice-warning notice-alt">';
200
+
201
+ $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
202
+
203
+ if ( empty( $version_info->download_link ) ) {
204
+ printf(
205
+ __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
206
+ esc_html( $version_info->name ),
207
+ '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
208
+ esc_html( $version_info->new_version ),
209
+ '</a>'
210
+ );
211
+ } else {
212
+ printf(
213
+ __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
214
+ esc_html( $version_info->name ),
215
+ '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
216
+ esc_html( $version_info->new_version ),
217
+ '</a>',
218
+ '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
219
+ '</a>'
220
+ );
221
+ }
222
+
223
+ do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
224
+
225
+ echo '</div></td></tr>';
226
+ }
227
+ }
228
+
229
+ /**
230
+ * Updates information on the "View version x.x details" page with custom data.
231
+ *
232
+ * @uses api_request()
233
+ *
234
+ * @param mixed $_data
235
+ * @param string $_action
236
+ * @param object $_args
237
+ * @return object $_data
238
+ */
239
+ public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
240
+
241
+ if ( $_action != 'plugin_information' ) {
242
+
243
+ return $_data;
244
+
245
+ }
246
+
247
+ if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
248
+
249
+ return $_data;
250
+
251
+ }
252
+
253
+ $to_send = array(
254
+ 'slug' => $this->slug,
255
+ 'is_ssl' => is_ssl(),
256
+ 'fields' => array(
257
+ 'banners' => array(),
258
+ 'reviews' => false
259
+ )
260
+ );
261
+
262
+ $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
263
+
264
+ // Get the transient where we store the api request for this plugin for 24 hours
265
+ $edd_api_request_transient = $this->get_cached_version_info( $cache_key );
266
+
267
+ //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
268
+ if ( empty( $edd_api_request_transient ) ) {
269
+
270
+ $api_response = $this->api_request( 'plugin_information', $to_send );
271
+
272
+ // Expires in 3 hours
273
+ $this->set_version_info_cache( $api_response, $cache_key );
274
+
275
+ if ( false !== $api_response ) {
276
+ $_data = $api_response;
277
+ }
278
+
279
+ } else {
280
+ $_data = $edd_api_request_transient;
281
+ }
282
+
283
+ // Convert sections into an associative array, since we're getting an object, but Core expects an array.
284
+ if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
285
+ $new_sections = array();
286
+ foreach ( $_data->sections as $key => $value ) {
287
+ $new_sections[ $key ] = $value;
288
+ }
289
+
290
+ $_data->sections = $new_sections;
291
+ }
292
+
293
+ // Convert banners into an associative array, since we're getting an object, but Core expects an array.
294
+ if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
295
+ $new_banners = array();
296
+ foreach ( $_data->banners as $key => $value ) {
297
+ $new_banners[ $key ] = $value;
298
+ }
299
+
300
+ $_data->banners = $new_banners;
301
+ }
302
+
303
+ return $_data;
304
+ }
305
+
306
+ /**
307
+ * Disable SSL verification in order to prevent download update failures
308
+ *
309
+ * @param array $args
310
+ * @param string $url
311
+ * @return object $array
312
+ */
313
+ public function http_request_args( $args, $url ) {
314
+
315
+ $verify_ssl = $this->verify_ssl();
316
+ if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
317
+ $args['sslverify'] = $verify_ssl;
318
+ }
319
+ return $args;
320
+
321
+ }
322
+
323
+ /**
324
+ * Calls the API and, if successfull, returns the object delivered by the API.
325
+ *
326
+ * @uses get_bloginfo()
327
+ * @uses wp_remote_post()
328
+ * @uses is_wp_error()
329
+ *
330
+ * @param string $_action The requested action.
331
+ * @param array $_data Parameters for the API action.
332
+ * @return false|object
333
+ */
334
+ private function api_request( $_action, $_data ) {
335
+
336
+ global $wp_version;
337
+
338
+ $data = array_merge( $this->api_data, $_data );
339
+
340
+ if ( $data['slug'] != $this->slug ) {
341
+ return;
342
+ }
343
+
344
+ if( $this->api_url == trailingslashit (home_url() ) ) {
345
+ return false; // Don't allow a plugin to ping itself
346
+ }
347
+
348
+ $api_params = array(
349
+ 'edd_action' => 'get_version',
350
+ 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
351
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
352
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
353
+ 'version' => isset( $data['version'] ) ? $data['version'] : false,
354
+ 'slug' => $data['slug'],
355
+ 'author' => $data['author'],
356
+ 'url' => home_url(),
357
+ 'beta' => ! empty( $data['beta'] ),
358
+ );
359
+
360
+ $verify_ssl = $this->verify_ssl();
361
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
362
+
363
+ if ( ! is_wp_error( $request ) ) {
364
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
365
+ }
366
+
367
+ if ( $request && isset( $request->sections ) ) {
368
+ $request->sections = maybe_unserialize( $request->sections );
369
+ } else {
370
+ $request = false;
371
+ }
372
+
373
+ if ( $request && isset( $request->banners ) ) {
374
+ $request->banners = maybe_unserialize( $request->banners );
375
+ }
376
+
377
+ if( ! empty( $request->sections ) ) {
378
+ foreach( $request->sections as $key => $section ) {
379
+ $request->$key = (array) $section;
380
+ }
381
+ }
382
+
383
+ return $request;
384
+ }
385
+
386
+ public function show_changelog() {
387
+
388
+ global $edd_plugin_data;
389
+
390
+ if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
391
+ return;
392
+ }
393
+
394
+ if( empty( $_REQUEST['plugin'] ) ) {
395
+ return;
396
+ }
397
+
398
+ if( empty( $_REQUEST['slug'] ) ) {
399
+ return;
400
+ }
401
+
402
+ if( ! current_user_can( 'update_plugins' ) ) {
403
+ wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
404
+ }
405
+
406
+ $data = $edd_plugin_data[ $_REQUEST['slug'] ];
407
+ $beta = ! empty( $data['beta'] ) ? true : false;
408
+ $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
409
+ $version_info = $this->get_cached_version_info( $cache_key );
410
+
411
+ if( false === $version_info ) {
412
+
413
+ $api_params = array(
414
+ 'edd_action' => 'get_version',
415
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
416
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
417
+ 'slug' => $_REQUEST['slug'],
418
+ 'author' => $data['author'],
419
+ 'url' => home_url(),
420
+ 'beta' => ! empty( $data['beta'] )
421
+ );
422
+
423
+ $verify_ssl = $this->verify_ssl();
424
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
425
+
426
+ if ( ! is_wp_error( $request ) ) {
427
+ $version_info = json_decode( wp_remote_retrieve_body( $request ) );
428
+ }
429
+
430
+
431
+ if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
432
+ $version_info->sections = maybe_unserialize( $version_info->sections );
433
+ } else {
434
+ $version_info = false;
435
+ }
436
+
437
+ if( ! empty( $version_info ) ) {
438
+ foreach( $version_info->sections as $key => $section ) {
439
+ $version_info->$key = (array) $section;
440
+ }
441
+ }
442
+
443
+ $this->set_version_info_cache( $version_info, $cache_key );
444
+
445
+ }
446
+
447
+ if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
448
+ echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
449
+ }
450
+
451
+ exit;
452
+ }
453
+
454
+ public function get_cached_version_info( $cache_key = '' ) {
455
+
456
+ if( empty( $cache_key ) ) {
457
+ $cache_key = $this->cache_key;
458
+ }
459
+
460
+ $cache = get_option( $cache_key );
461
+
462
+ if( empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) {
463
+ return false; // Cache is expired
464
+ }
465
+
466
+ return json_decode( $cache['value'] );
467
+
468
+ }
469
+
470
+ public function set_version_info_cache( $value = '', $cache_key = '' ) {
471
+
472
+ if( empty( $cache_key ) ) {
473
+ $cache_key = $this->cache_key;
474
+ }
475
+
476
+ $data = array(
477
+ 'timeout' => strtotime( '+3 hours', current_time( 'timestamp' ) ),
478
+ 'value' => json_encode( $value )
479
+ );
480
+
481
+ update_option( $cache_key, $data, 'no' );
482
+
483
+ }
484
+
485
+ /**
486
+ * Returns if the SSL of the store should be verified.
487
+ *
488
+ * @since 1.6.13
489
+ * @return bool
490
+ */
491
+ private function verify_ssl() {
492
+ return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
493
+ }
494
+
495
+ }
functions/utilities/SWP_Post_Cache.php CHANGED
@@ -1,677 +1,677 @@
1
- <?php
2
-
3
- /**
4
- * The Post_Cache Object
5
- *
6
- * This class will control the cached data for each individual post across a
7
- * WordPress website. Direct calls for data such as share counts, will pull and
8
- * return cached data.
9
- *
10
- * Since all Post_Cache objects should be loaded via the Post_Cache_Loader class,
11
- * we will use the instantiation method (__construct) to queue up asyncronous
12
- * methods for rebuilding cached data. This should allow us to run that subset
13
- * of functions only once per page load, and then the cache will once again be
14
- * fresh for a few hours before we need to do it again.
15
- *
16
- * This class contains four major sections of methods:
17
- * 1. Set up the cache object and necessary properties.
18
- * 2. Check if the cache is fresh or not.
19
- * 3. Update the cached data when the cache is expired.
20
- * 4. Allow a publicly accessable method for fetching cached counts.
21
- *
22
- * @package SocialWarfare\Functions\Utilities
23
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
24
- * @license GPL-3.0+
25
- * @since 3.1.0 | 20 JUN 2018 | Created
26
- * @access public
27
- *
28
- */
29
- class SWP_Post_Cache {
30
-
31
-
32
- /**
33
- * SECTION #1: SETTING UP THE CACHE OBJECT
34
- *
35
- * The methods in this section are used to set up the cache object by
36
- * initializing the object, setting up local properties, and pulling in the
37
- * global $post object that will be used throughout the class.
38
- *
39
- */
40
-
41
- /**
42
- * The WordPress Post Object
43
- *
44
- * @see $this->establish_post_data() method.
45
- * @var object
46
- *
47
- */
48
- public $post;
49
-
50
-
51
- /**
52
- * The ID of the Current Post Being Processed
53
- *
54
- * @see $this->establish_post_data() method.
55
- * @var integer
56
- *
57
- */
58
- public $id;
59
-
60
-
61
- /**
62
- * The Magic Construct Method
63
- *
64
- * This method 1.) instantiates the object
65
- * making the public methods available for use by the plugin, and
66
- * 2.) Determine if the cache is fresh, and if not, trigger an
67
- * asyncronous request to rebuild the cached data.
68
- *
69
- * @todo Can we eliminate all post data except for the post_id?
70
- * @since 3.1.0 | 20 JUN 2018 | Created
71
- * @param integer $post_id The ID of the post
72
- * @return void
73
- *
74
- */
75
- public function __construct( $post_id ) {
76
- global $swp_user_options;
77
-
78
- // Set up the post data into local properties.
79
- $this->id = $post_id;
80
- $this->establish_share_counts();
81
-
82
- // If the cache is expired, trigger the rebuild processes.
83
- if ( false === $this->is_cache_fresh() ):
84
- $this->rebuild_cached_data();
85
- endif;
86
-
87
- // Debugging
88
- $this->debug();
89
- }
90
-
91
-
92
- /**
93
- * A method for debugging and outputting the class object.
94
- *
95
- * @since 3.1.0 | 25 JUN 2018 | Created
96
- * @param void
97
- * @return void
98
- *
99
- */
100
- private function debug() {
101
- if( true === _swp_is_debug('swp_share_cache') ):
102
- echo "<pre>", var_dump( $this ), "</pre>";
103
- endif;
104
- }
105
-
106
-
107
- /**
108
- * SECTION #2: CHECKING IF THE CACHE IS FRESH
109
- *
110
- * The methods in this section are used to determine whether or not the
111
- * cached data needs to be rebuilt or not.
112
- *
113
- */
114
-
115
-
116
- /**
117
- * Determines if the data has recently been updated.
118
- *
119
- * This is the determining method to decide if a cache is fresh or if it
120
- * needs to be rebuilt.
121
- *
122
- * @since 3.1.0 | 19 JUN 2018 | Ported from function to class method.
123
- * @access public
124
- * @param void
125
- * @return boolean True if fresh, false if expired and needs rebuilt.
126
- *
127
- */
128
- public function is_cache_fresh() {
129
- // Bail early if it's a crawl bot. If so, ONLY SERVE CACHED RESULTS FOR MAXIMUM SPEED.
130
- if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/bot|crawl|slurp|spider/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) :
131
- return true;
132
- endif;
133
-
134
- // Always be true if we're not a single post.
135
- if ( !is_singular() ) :
136
- return true;
137
- endif;
138
-
139
- // If a URL parameter is specifically telling it to rebuild.
140
- if ( isset( $_GET['swp_cache'] ) && 'rebuild' === $_GET['swp_cache'] ) {
141
- return false;
142
- }
143
-
144
- // If a POST request (AJAX) is specifically telling it to rebuild.
145
- if( isset( $_POST['swp_cache'] ) && 'rebuild' === $_POST['swp_cache'] ) {
146
- return false;
147
- }
148
-
149
- // Check if the cache is older than is allowable for this post.
150
- if( $this->get_cache_age() >= $this->get_allowable_age() ):
151
- return false;
152
- endif;
153
-
154
- return true;
155
-
156
- }
157
-
158
-
159
- /**
160
- * Determines how recently, in hours, the cache has been updated.
161
- *
162
- * @since 3.1.0 | 19 JUN 2018 | Created the method.
163
- * @todo Review
164
- * @param void
165
- * @return int The current age of the cache in hours.
166
- *
167
- */
168
- protected function get_cache_age() {
169
-
170
- // An integer in hours. Example: 424814 == Number of hourse since Unix epoch.
171
- $current_time = floor( ( ( date( 'U' ) / 60 ) / 60 ) );
172
-
173
- // The integer in hours at time of storage since the Unix epoch.
174
- $last_checked_time = get_post_meta( $this->id, 'swp_cache_timestamp', true );
175
-
176
- if ( !is_numeric( $last_checked_time ) ) :
177
- $last_checked_time = 0;
178
- endif;
179
-
180
-
181
- // How many hours has it been since the cache was rebuilt?
182
- $age = $current_time - $last_checked_time;
183
-
184
- return $age;
185
- }
186
-
187
-
188
- /**
189
- * Get the duration during which this cache can be considered fresh.
190
- *
191
- * A cache is fresh for the following durations:
192
- * 1 Hour - New Posts less than 21 days old.
193
- * 4 Hours - Medium Posts less than 60 days old.
194
- * 12 Hours - Old Posts Older than 60 days old.
195
- *
196
- * @since 3.1.0 | 20 JUN 2018 | Created
197
- * @todo Review
198
- * @param void
199
- * @return integer The duration in hours that applies to this cache.
200
- *
201
- */
202
- public function get_allowable_age() {
203
-
204
- // Integer in hours of the current age of the post.
205
- $post_age = floor( date( 'U' ) - get_post_time( 'U' , false , $this->id ) );
206
-
207
- // If it's less than 21 days old.
208
- if ( $post_age < ( 21 * 86400 ) ) {
209
- return 1;
210
-
211
- // If it's less than 60 days old.
212
- } elseif ( $post_age < ( 60 * 86400 ) ) {
213
- return 4;
214
- }
215
-
216
- // If it's really old.
217
- return 12;
218
- }
219
-
220
-
221
- /**
222
- * SECTION #3: REBUILDING THE CACHED DATA
223
- *
224
- * The methods in this section are used to rebuild all of the cached data.
225
- *
226
- */
227
-
228
-
229
-
230
- /**
231
- * Trigger the Cache Rebuild
232
- *
233
- * This method will trigger a non-blocking request to admin-ajax. This
234
- * request will be intercepted/recieved by the Post_Cache_Loader class
235
- * during which it will load this post_cache object and call the
236
- * rebuild_cached_data() method below. This way the rebuilding of the cache
237
- * is conducted in an asyncronous, non-blocking fashion.
238
- *
239
- * @TODO Add the wp_remote_post to ping admin-ajax.php.
240
- * @since 3.1.0 | 25 JUN 2018 | Created
241
- * @param void
242
- * @return void
243
- *
244
- */
245
- protected function trigger_cache_rebuild() {
246
- //* Ping ajax to Post_Cache_Loader->
247
- $data = array(
248
- 'method' => 'POST',
249
- 'action' => 'swp_rebuild_cache',
250
- 'post_id' => $this->id
251
- );
252
-
253
- $args = array(
254
- // 'timeout' => 0.01,
255
- 'blocking' => false,
256
- 'body' => $data,
257
- 'cookies' => $_COOKIE,
258
- 'sslverify' => false,
259
- );
260
-
261
- $var = wp_remote_post( admin_url( 'admin-ajax.php', $args ) );
262
- var_dump($var);
263
- }
264
-
265
-
266
- /**
267
- * A method to rebuild all cached data
268
- *
269
- * This is the method that will be called during the rebuild. This is also
270
- * the method that we want to run asyncronously. This method will call all
271
- * other methods and run the action filter to allow third-party functions
272
- * to run during the cache rebuild process.
273
- *
274
- * @since 3.1.0 | 20 JUN 2018 | Created
275
- * @todo Move all calls to cache rebuild methods into this method. This
276
- * will become the one and only method that is used to rebuild this
277
- * particular cache of data.
278
- * @param void
279
- * @return void
280
- *
281
- */
282
- public function rebuild_cached_data() {
283
- $this->rebuild_share_counts();
284
- $this->rebuild_pinterest_image();
285
- $this->rebuild_open_graph_image();
286
- $this->process_urls();
287
- $this->reset_timestamp();
288
-
289
- // A hook to run allowing third-party functions to run.
290
- do_action( 'swp_cache_rebuild', $this->id );
291
- }
292
-
293
-
294
- public function process_urls() {
295
- global $swp_social_networks;
296
- $permalink = get_permalink( $this->id );
297
- foreach($swp_social_networks as $network):
298
- if($network->is_active()):
299
- SWP_URL_Management::process_url( $permalink , $network->key , $this->id , false );
300
- endif;
301
- endforeach;
302
- }
303
-
304
-
305
- /**
306
- * Pinterest Image
307
- *
308
- * Convert the pinterest image ID to a URL and store it in a meta field
309
- * because then the URL will be autoloaded with the post preventing the
310
- * need for an additional database query during page loads.
311
- *
312
- * @since 3.1.0 | 19 JUN 2018 | Ported from function to class method.
313
- * @access protected
314
- * @param void
315
- * @return void
316
- *
317
- */
318
- public function rebuild_pinterest_image() {
319
-
320
- // Check if a custom pinterest image has been declared
321
- $pin_image_id = get_post_meta( $this->id , 'swp_pinterest_image' , true );
322
-
323
- if ( false !== $pin_image_id ) :
324
- $pin_image_url = wp_get_attachment_url( $pin_image_id );
325
- $cur_image_url = get_post_meta( $this->id , 'swp_pinterest_image_url' , true );
326
-
327
- // No need to update the database if the image URL has not changed
328
- if($pin_image_url !== $cur_image_url):
329
- delete_post_meta( $this->id,'swp_pinterest_image_url' );
330
- update_post_meta( $this->id,'swp_pinterest_image_url' , $pin_image_url );
331
- endif;
332
-
333
- else:
334
- delete_post_meta( $this->id , 'swp_pinterest_image_url' );
335
- endif;
336
- }
337
-
338
-
339
- /**
340
-
341
- * Open Graph Image
342
- *
343
- * Convert the open graph image ID to a URL and store it in a meta field
344
- * because then the URL will be autoloaded with the post preventing the
345
- * need for an additional database query during page loads.
346
- *
347
- * @since 3.1.0 | 19 JUN 2018 | Ported from function to class method.
348
- * @access protected
349
- * @param void
350
- * @return void
351
- *
352
- */
353
- public function rebuild_open_graph_image() {
354
- $image_id = get_post_meta( $this->id , 'swp_og_image' , true );
355
-
356
- if ( $image_id ):
357
-
358
- $cur_image_url = get_post_meta( $this->id , 'swp_open_graph_image_url' , true );
359
- $new_image_url = wp_get_attachment_url( $image_id );
360
-
361
- // No need to update the DB if the url hasn't changed
362
- if( $cur_image_url !== $new_image_url ):
363
-
364
- $image_data = wp_get_attachment_image_src( $image_id , 'full' );
365
- delete_post_meta( $this->id , 'swp_open_graph_image_data' );
366
- update_post_meta( $this->id , 'swp_open_graph_image_data' , json_encode( $image_data ) );
367
-
368
- delete_post_meta( $this->id,'swp_open_graph_image_url' );
369
- update_post_meta( $this->id,'swp_open_graph_image_url' , $new_image_url );
370
-
371
- endif;
372
- else:
373
- delete_post_meta( $this->id,'swp_open_graph_image_url' );
374
- endif;
375
- }
376
-
377
-
378
- /**
379
- * Resets the cache timestamp to the current time in hours since Unix epoch.
380
- *
381
- * @since 3.1.0 | 19 JUN 2018 | Ported from function to class method.
382
- * @access protected
383
- * @param void
384
- * @return void
385
- *
386
- */
387
- public function reset_timestamp() {
388
- delete_post_meta( $this->id, 'swp_cache_timestamp' );
389
- update_post_meta( $this->id, 'swp_cache_timestamp', floor( ( ( date( 'U' ) / 60 ) / 60 ) ) );
390
- }
391
-
392
-
393
- /**
394
- * Removes the timestamp on certain hooks like when a post is updated.
395
- *
396
- * @since 3.1.0 | 19 JUN 2018 | Ported from function to class method.
397
- * @param void
398
- * @return void
399
- *
400
- */
401
- public function delete_timestamp() {
402
- delete_post_meta( $this->id, 'swp_cache_timestamp' );
403
- }
404
-
405
-
406
- /**
407
- * Finishes processing the share data after the network links have been set up.
408
- *
409
- * The flow of logic should look something like this:
410
- * establish_permalinks(); $this->permalinks;
411
- * establish_api_request_urls(); $this->api_urls;
412
- * fetch_api_responses(); $this->raw_api_responses;
413
- * parse_api_responses(); $this->parsed_api_responses;
414
- * calculate_network_shares(); $this->share_counts;
415
- * calculate_total_shares(); $this->share_counts['total_shares'];
416
- * cache_share_counts(); Stored in DB post meta.
417
- *
418
- * @since 3.1.0 | 21 JUN 2018 | Created
419
- * @access protected
420
- * @param void
421
- * @return void
422
- *
423
- */
424
- protected function rebuild_share_counts() {
425
- global $swp_social_networks, $swp_user_options;
426
-
427
- $this->establish_permalinks();
428
- $this->establish_api_request_urls();
429
- $this->fetch_api_responses();
430
- $this->parse_api_responses();
431
- $this->calculate_network_shares();
432
- $this->calculate_network_shares();
433
- $this->cache_share_counts();
434
- }
435
-
436
-
437
- /**
438
- * Establish the Permalinks to be checked for shares.
439
- *
440
- * The word Permalink here specifically refers to URL's of blog posts which
441
- * we want to fetch share counts for. We want a system that allows us to
442
- * create permalinks for the primary permalink, the share recovery permalink,
443
- * allow a filter for programatic adding of others, and so on.
444
- *
445
- * The processed results will be stored in $this->permalinks.
446
- * @var permalinks Links to be checked for share counts during the
447
- * share count update process.
448
- *
449
- * @since 3.1.0 | 21 JUN 2018 | Created
450
- * @access private
451
- * @param void
452
- * @return void
453
- *
454
- */
455
- private function establish_permalinks() {
456
- global $swp_social_networks, $swp_user_options;
457
- $this->permalinks = array();
458
-
459
- foreach( $swp_social_networks as $key => $object):
460
- if ( !$object->active ) :
461
- continue;
462
- endif;
463
-
464
- $this->permalinks[$key][] = get_permalink( $this->id );
465
-
466
- if( true === $swp_user_options['recover_shares'] ) :
467
- $this->permalinks[$key][] = SWP_Permalink::get_alt_permalink( $this->id );
468
- endif;
469
-
470
- $this->permalinks = apply_filters( 'swp_recovery_filter', $this->permalinks );
471
- endforeach;
472
-
473
- }
474
-
475
-
476
- /**
477
- * Prepares outbound API links per network.
478
- *
479
- * @since 3.1.0 | 25 JUN 2018 | Created the method.
480
- * @var api_urls The array of outbound API request destinations.
481
- * @param void
482
- * @return void
483
- *
484
- */
485
- private function establish_api_request_urls() {
486
- global $swp_social_networks;
487
-
488
- $this->api_urls = array();
489
-
490
- foreach ( $this->permalinks as $network => $links ) {
491
- $current_request = 0;
492
- foreach( $links as $url ) {
493
- $this->api_urls[$current_request][$network] = $swp_social_networks[$network]->get_api_link( $url );
494
- ++$current_request;
495
- }
496
- }
497
- }
498
-
499
-
500
- /**
501
- * Fetch responses from the network API's.
502
- *
503
- * This method will use the $this->api_urls array, loop through them, and
504
- * using curl_multi will fetch raw responses from the network API's. The
505
- * results will be stored in $this->raw_api_responses array.
506
- *
507
- * @since 3.1.0 | 25 JUN 2018 | Created
508
- * @var raw_api_responses An array of responses from the API's.
509
- * @param void
510
- * @return void All data is stored in local properties.
511
- *
512
- */
513
- private function fetch_api_responses() {
514
- $current_request = 0;
515
- foreach ( $this->api_urls as $request => $networks ) {
516
- $this->raw_api_responses[$current_request] = SWP_CURL::fetch_shares_via_curl_multi( $networks );
517
- $current_request++;
518
- }
519
- }
520
-
521
-
522
- /**
523
- * Parse the API responses
524
- *
525
- * This method will take the array of raw responses stored inside the
526
- * $this->raw_api_responses property and use each network's parse method
527
- * to convert them into integers that we can use to tally up our share counts.
528
- *
529
- * @since 3.1.0 | 25 JUN 2018 | Created
530
- * @var parsed_api_responses An array of integers from parsing the responses.
531
- * @param void
532
- * @return void Processed data is stored in local properties.
533
- *
534
- */
535
- private function parse_api_responses() {
536
- global $swp_social_networks;
537
- $this->parsed_api_responses = array();
538
-
539
- foreach( $this->raw_api_responses as $request => $responses ) {
540
- $current_request = 0;
541
-
542
- foreach ( $responses as $key => $response ) {
543
- $this->parsed_api_responses[$current_request][$key][] = $swp_social_networks[$key]->parse_api_response( $response );
544
- $current_request++;
545
- }
546
- }
547
- }
548
-
549
-
550
- /**
551
- * Calculate the network shares.
552
- *
553
- * This method is used to calculate the shares for each network based on
554
- * what we have just retrieved from the API responses. Another method,
555
- * establish_share_counts will be used to create this data from the cached
556
- * database data. This one is ONLY used when the cache is not fresh and the
557
- * data is being rebuilt.
558
- *
559
- * @since 3.1.0 | 25 JUN 2018 | Created
560
- * @var share_counts An array of share count numbers.
561
- * @param void
562
- * @return void All data stored in local properties.
563
- *
564
- */
565
- private function calculate_network_shares() {
566
- global $swp_social_networks;
567
-
568
- $share_counts = array();
569
-
570
- foreach ( $this->parsed_api_responses as $request => $networks ) {
571
- foreach ( $networks as $key => $count_array ) {
572
- foreach ( $count_array as $count ) {
573
- if ( !isset( $share_counts[$key] ) ) {
574
- $share_counts[$key] = 0;
575
- }
576
-
577
- $share_counts[$key] += $count;
578
- }
579
-
580
- }
581
- }
582
-
583
- $this->share_counts = $share_counts;
584
- }
585
-
586
-
587
- /**
588
- * Update the meta fields with the new share counts.
589
- *
590
- * As per the inline docblock below, we only update if larger numbers are
591
- * recieved than the previous checks. This is because some networks, like
592
- * Pinterest are notorious for randomly resetting some counts all the way
593
- * back to zero. This will prevent a post with 10K shares from keeping the
594
- * zero response.
595
- *
596
- * @since 3.1.0 | 25 JUN 2018 | Created
597
- * @param void
598
- * @return void
599
- *
600
- */
601
- private function cache_share_counts() {
602
- $this->share_counts['total_shares'] = 0;
603
-
604
- foreach( $this->share_counts as $key => $count ) {
605
- if ( 'total_shares' === $key ) {
606
- continue;
607
- }
608
-
609
- $previous_count = get_post_meta( $this->id, "_${key}_shares", true);
610
-
611
- if ( empty( $previous_count ) ) {
612
- $previous_count = 0;
613
- }
614
-
615
- // We only update to newly fetched numbers if they're bigger than
616
- // the old ones unless the url parameter is forcing it to take.
617
- if ( $count <= $previous_count && false === _swp_is_debug( 'force_new_shares' ) ) {
618
- $this->share_counts[$key] = $previous_count;
619
- }
620
-
621
- $this->share_counts['total_shares'] += $this->share_counts[$key];
622
-
623
- delete_post_meta( $this->id, "_${key}_shares");
624
- update_post_meta( $this->id, "_${key}_shares", $this->share_counts[$key] );
625
- }
626
-
627
- delete_post_meta( $this->id, '_total_shares');
628
- update_post_meta( $this->id, '_total_shares', $this->share_counts['total_shares'] );
629
- }
630
-
631
-
632
- /**
633
- * Gets the computed share data.
634
- *
635
- * @since 3.1.0 | 20 JUN 2018 | Created the method.
636
- * @param void
637
- * @return array $this->share_counts if it exists, or an empty array.
638
- *
639
- */
640
- public function get_shares() {
641
- if ( !empty( $this->share_counts ) ) :
642
- return $this->share_counts;
643
- endif;
644
-
645
- return array();
646
- }
647
-
648
-
649
- /**
650
- * Process the existing share data, or update it.
651
- *
652
- * @todo Remove all fresh_cache() checks. This method needs to assume the
653
- * cache is always fresh and always return cached data.
654
- *
655
- * @since 3.1.0 | 21 JUN 2018 | Created the method.
656
- * @access protected
657
- * @param void
658
- * @return void
659
- *
660
- */
661
- protected function establish_share_counts() {
662
- global $swp_social_networks;
663
-
664
- foreach( $swp_social_networks as $network => $network_object ) {
665
- if ( !isset( $swp_social_networks[$network] ) ) :
666
- continue;
667
- endif;
668
-
669
- $count = get_post_meta( $this->id, '_' . $network . '_shares', true );
670
- $this->share_counts[$network] = $count ? $count : 0;
671
- }
672
-
673
- $total = get_post_meta( $this->id, '_total_shares', true );
674
- $this->share_counts['total_shares'] = $total ? $total : 0;
675
- }
676
-
677
- }
1
+ <?php
2
+
3
+ /**
4
+ * The Post_Cache Object
5
+ *
6
+ * This class will control the cached data for each individual post across a
7
+ * WordPress website. Direct calls for data such as share counts, will pull and
8
+ * return cached data.
9
+ *
10
+ * Since all Post_Cache objects should be loaded via the Post_Cache_Loader class,
11
+ * we will use the instantiation method (__construct) to queue up asyncronous
12
+ * methods for rebuilding cached data. This should allow us to run that subset
13
+ * of functions only once per page load, and then the cache will once again be
14
+ * fresh for a few hours before we need to do it again.
15
+ *
16
+ * This class contains four major sections of methods:
17
+ * 1. Set up the cache object and necessary properties.
18
+ * 2. Check if the cache is fresh or not.
19
+ * 3. Update the cached data when the cache is expired.
20
+ * 4. Allow a publicly accessable method for fetching cached counts.
21
+ *
22
+ * @package SocialWarfare\Functions\Utilities
23
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
24
+ * @license GPL-3.0+
25
+ * @since 3.1.0 | 20 JUN 2018 | Created
26
+ * @access public
27
+ *
28
+ */
29
+ class SWP_Post_Cache {
30
+
31
+
32
+ /**
33
+ * SECTION #1: SETTING UP THE CACHE OBJECT
34
+ *
35
+ * The methods in this section are used to set up the cache object by
36
+ * initializing the object, setting up local properties, and pulling in the
37
+ * global $post object that will be used throughout the class.
38
+ *
39
+ */
40
+
41
+ /**
42
+ * The WordPress Post Object
43
+ *
44
+ * @see $this->establish_post_data() method.
45
+ * @var object
46
+ *
47
+ */
48
+ public $post;
49
+
50
+
51
+ /**
52
+ * The ID of the Current Post Being Processed
53
+ *
54
+ * @see $this->establish_post_data() method.
55
+ * @var integer
56
+ *
57
+ */
58
+ public $id;
59
+
60
+
61
+ /**
62
+ * The Magic Construct Method
63
+ *
64
+ * This method 1.) instantiates the object
65
+ * making the public methods available for use by the plugin, and
66
+ * 2.) Determine if the cache is fresh, and if not, trigger an
67
+ * asyncronous request to rebuild the cached data.
68
+ *
69
+ * @todo Can we eliminate all post data except for the post_id?
70
+ * @since 3.1.0 | 20 JUN 2018 | Created
71
+ * @param integer $post_id The ID of the post
72
+ * @return void
73
+ *
74
+ */
75
+ public function __construct( $post_id ) {
76
+ global $swp_user_options;
77
+
78
+ // Set up the post data into local properties.
79
+ $this->id = $post_id;
80
+ $this->establish_share_counts();
81
+
82
+ // If the cache is expired, trigger the rebuild processes.
83
+ if ( false === $this->is_cache_fresh() ):
84
+ $this->rebuild_cached_data();
85
+ endif;
86
+
87
+ // Debugging
88
+ $this->debug();
89
+ }
90
+
91
+
92
+ /**
93
+ * A method for debugging and outputting the class object.
94
+ *
95
+ * @since 3.1.0 | 25 JUN 2018 | Created
96
+ * @param void
97
+ * @return void
98
+ *
99
+ */
100
+ private function debug() {
101
+ if( true === _swp_is_debug('swp_share_cache') ):
102
+ echo "<pre>", var_dump( $this ), "</pre>";
103
+ endif;
104
+ }
105
+
106
+
107
+ /**
108
+ * SECTION #2: CHECKING IF THE CACHE IS FRESH
109
+ *
110
+ * The methods in this section are used to determine whether or not the
111
+ * cached data needs to be rebuilt or not.
112
+ *
113
+ */
114
+
115
+
116
+ /**
117
+ * Determines if the data has recently been updated.
118
+ *
119
+ * This is the determining method to decide if a cache is fresh or if it
120
+ * needs to be rebuilt.
121
+ *
122
+ * @since 3.1.0 | 19 JUN 2018 | Ported from function to class method.
123
+ * @access public
124
+ * @param void
125
+ * @return boolean True if fresh, false if expired and needs rebuilt.
126
+ *
127
+ */
128
+ public function is_cache_fresh() {
129
+ // Bail early if it's a crawl bot. If so, ONLY SERVE CACHED RESULTS FOR MAXIMUM SPEED.
130
+ if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/bot|crawl|slurp|spider/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) :
131
+ return true;
132
+ endif;
133
+
134
+ // Always be true if we're not a single post.
135
+ if ( !is_singular() ) :
136
+ return true;
137
+ endif;
138
+
139
+ // If a URL parameter is specifically telling it to rebuild.
140
+ if ( isset( $_GET['swp_cache'] ) && 'rebuild' === $_GET['swp_cache'] ) {
141
+ return false;
142
+ }
143
+
144
+ // If a POST request (AJAX) is specifically telling it to rebuild.
145
+ if( isset( $_POST['swp_cache'] ) && 'rebuild' === $_POST['swp_cache'] ) {
146
+ return false;
147
+ }
148
+
149
+ // Check if the cache is older than is allowable for this post.
150
+ if( $this->get_cache_age() >= $this->get_allowable_age() ):
151
+ return false;
152
+ endif;
153
+
154
+ return true;
155
+
156
+ }
157
+
158
+
159
+ /**
160
+ * Determines how recently, in hours, the cache has been updated.
161
+ *
162
+ * @since 3.1.0 | 19 JUN 2018 | Created the method.
163
+ * @todo Review
164
+ * @param void
165
+ * @return int The current age of the cache in hours.
166
+ *
167
+ */
168
+ protected function get_cache_age() {
169
+
170
+ // An integer in hours. Example: 424814 == Number of hourse since Unix epoch.
171
+ $current_time = floor( ( ( date( 'U' ) / 60 ) / 60 ) );
172
+
173
+ // The integer in hours at time of storage since the Unix epoch.
174
+ $last_checked_time = get_post_meta( $this->id, 'swp_cache_timestamp', true );
175
+
176
+ if ( !is_numeric( $last_checked_time ) ) :
177
+ $last_checked_time = 0;
178
+ endif;
179
+
180
+
181
+ // How many hours has it been since the cache was rebuilt?
182
+ $age = $current_time - $last_checked_time;
183
+
184
+ return $age;
185
+ }
186
+
187
+
188
+ /**
189
+ * Get the duration during which this cache can be considered fresh.
190
+ *
191
+ * A cache is fresh for the following durations:
192
+ * 1 Hour - New Posts less than 21 days old.
193
+ * 4 Hours - Medium Posts less than 60 days old.
194
+ * 12 Hours - Old Posts Older than 60 days old.
195
+ *
196
+ * @since 3.1.0 | 20 JUN 2018 | Created
197
+ * @todo Review
198
+ * @param void
199
+ * @return integer The duration in hours that applies to this cache.
200
+ *
201
+ */
202
+ public function get_allowable_age() {
203
+
204
+ // Integer in hours of the current age of the post.
205
+ $post_age = floor( date( 'U' ) - get_post_time( 'U' , false , $this->id ) );
206
+
207
+ // If it's less than 21 days old.
208
+ if ( $post_age < ( 21 * 86400 ) ) {
209
+ return 1;
210
+
211
+ // If it's less than 60 days old.
212
+ } elseif ( $post_age < ( 60 * 86400 ) ) {
213
+ return 4;
214
+ }
215
+
216
+ // If it's really old.
217
+ return 12;
218
+ }
219
+
220
+
221
+ /**
222
+ * SECTION #3: REBUILDING THE CACHED DATA
223
+ *
224
+ * The methods in this section are used to rebuild all of the cached data.
225
+ *
226
+ */
227
+
228
+
229
+
230
+ /**
231
+ * Trigger the Cache Rebuild
232
+ *
233
+ * This method will trigger a non-blocking request to admin-ajax. This
234
+ * request will be intercepted/recieved by the Post_Cache_Loader class
235
+ * during which it will load this post_cache object and call the
236
+ * rebuild_cached_data() method below. This way the rebuilding of the cache
237
+ * is conducted in an asyncronous, non-blocking fashion.
238
+ *
239
+ * @TODO Add the wp_remote_post to ping admin-ajax.php.
240
+ * @since 3.1.0 | 25 JUN 2018 | Created
241
+ * @param void
242
+ * @return void
243
+ *
244
+ */
245
+ protected function trigger_cache_rebuild() {
246
+ //* Ping ajax to Post_Cache_Loader->
247
+ $data = array(
248
+ 'method' => 'POST',
249
+ 'action' => 'swp_rebuild_cache',
250
+ 'post_id' => $this->id
251
+ );
252
+
253
+ $args = array(
254
+ // 'timeout' => 0.01,
255
+ 'blocking' => false,
256
+ 'body' => $data,
257
+ 'cookies' => $_COOKIE,
258
+ 'sslverify' => false,
259
+ );
260
+
261
+ $var = wp_remote_post( admin_url( 'admin-ajax.php', $args ) );
262
+ var_dump($var);
263
+ }
264
+
265
+
266
+ /**
267
+ * A method to rebuild all cached data
268
+ *
269
+ * This is the method that will be called during the rebuild. This is also
270
+ * the method that we want to run asyncronously. This method will call all
271
+ * other methods and run the action filter to allow third-party functions
272
+ * to run during the cache rebuild process.
273
+ *
274
+ * @since 3.1.0 | 20 JUN 2018 | Created
275
+ * @todo Move all calls to cache rebuild methods into this method. This
276
+ * will become the one and only method that is used to rebuild this
277
+ * particular cache of data.
278
+ * @param void
279
+ * @return void
280
+ *
281
+ */
282
+ public function rebuild_cached_data() {
283
+ $this->rebuild_share_counts();
284
+ $this->rebuild_pinterest_image();
285
+ $this->rebuild_open_graph_image();
286
+ $this->process_urls();
287
+ $this->reset_timestamp();
288
+
289
+ // A hook to run allowing third-party functions to run.
290
+ do_action( 'swp_cache_rebuild', $this->id );
291
+ }
292
+
293
+
294
+ public function process_urls() {
295
+ global $swp_social_networks;
296
+ $permalink = get_permalink( $this->id );
297
+ foreach($swp_social_networks as $network):
298
+ if($network->is_active()):
299
+ SWP_URL_Management::process_url( $permalink , $network->key , $this->id , false );
300
+ endif;
301
+ endforeach;
302
+ }
303
+
304
+
305
+ /**
306
+ * Pinterest Image
307
+ *
308
+ * Convert the pinterest image ID to a URL and store it in a meta field
309
+ * because then the URL will be autoloaded with the post preventing the
310
+ * need for an additional database query during page loads.
311
+ *
312
+ * @since 3.1.0 | 19 JUN 2018 | Ported from function to class method.
313
+ * @access protected
314
+ * @param void
315
+ * @return void
316
+ *
317
+ */
318
+ public function rebuild_pinterest_image() {
319
+
320
+ // Check if a custom pinterest image has been declared
321
+ $pin_image_id = get_post_meta( $this->id , 'swp_pinterest_image' , true );
322
+
323
+ if ( false !== $pin_image_id ) :
324
+ $pin_image_url = wp_get_attachment_url( $pin_image_id );
325
+ $cur_image_url = get_post_meta( $this->id , 'swp_pinterest_image_url' , true );
326
+
327
+ // No need to update the database if the image URL has not changed
328
+ if($pin_image_url !== $cur_image_url):
329
+ delete_post_meta( $this->id,'swp_pinterest_image_url' );
330
+ update_post_meta( $this->id,'swp_pinterest_image_url' , $pin_image_url );
331
+ endif;
332
+
333
+ else:
334
+ delete_post_meta( $this->id , 'swp_pinterest_image_url' );
335
+ endif;
336
+ }
337
+
338
+
339
+ /**
340
+
341
+ * Open Graph Image
342
+ *
343
+ * Convert the open graph image ID to a URL and store it in a meta field
344
+ * because then the URL will be autoloaded with the post preventing the
345
+ * need for an additional database query during page loads.
346
+ *
347
+ * @since 3.1.0 | 19 JUN 2018 | Ported from function to class method.
348
+ * @access protected
349
+ * @param void
350
+ * @return void
351
+ *
352
+ */
353
+ public function rebuild_open_graph_image() {
354
+ $image_id = get_post_meta( $this->id , 'swp_og_image' , true );
355
+
356
+ if ( $image_id ):
357
+
358
+ $cur_image_url = get_post_meta( $this->id , 'swp_open_graph_image_url' , true );
359
+ $new_image_url = wp_get_attachment_url( $image_id );
360
+
361
+ // No need to update the DB if the url hasn't changed
362
+ if( $cur_image_url !== $new_image_url ):
363
+
364
+ $image_data = wp_get_attachment_image_src( $image_id , 'full' );
365
+ delete_post_meta( $this->id , 'swp_open_graph_image_data' );
366
+ update_post_meta( $this->id , 'swp_open_graph_image_data' , json_encode( $image_data ) );
367
+
368
+ delete_post_meta( $this->id,'swp_open_graph_image_url' );
369
+ update_post_meta( $this->id,'swp_open_graph_image_url' , $new_image_url );
370
+
371
+ endif;
372
+ else:
373
+ delete_post_meta( $this->id,'swp_open_graph_image_url' );
374
+ endif;
375
+ }
376
+
377
+
378
+ /**
379
+ * Resets the cache timestamp to the current time in hours since Unix epoch.
380
+ *
381
+ * @since 3.1.0 | 19 JUN 2018 | Ported from function to class method.
382
+ * @access protected
383
+ * @param void
384
+ * @return void
385
+ *
386
+ */
387
+ public function reset_timestamp() {
388
+ delete_post_meta( $this->id, 'swp_cache_timestamp' );
389
+ update_post_meta( $this->id, 'swp_cache_timestamp', floor( ( ( date( 'U' ) / 60 ) / 60 ) ) );
390
+ }
391
+
392
+
393
+ /**
394
+ * Removes the timestamp on certain hooks like when a post is updated.
395
+ *
396
+ * @since 3.1.0 | 19 JUN 2018 | Ported from function to class method.
397
+ * @param void
398
+ * @return void
399
+ *
400
+ */
401
+ public function delete_timestamp() {
402
+ delete_post_meta( $this->id, 'swp_cache_timestamp' );
403
+ }
404
+
405
+
406
+ /**
407
+ * Finishes processing the share data after the network links have been set up.
408
+ *
409
+ * The flow of logic should look something like this:
410
+ * establish_permalinks(); $this->permalinks;
411
+ * establish_api_request_urls(); $this->api_urls;
412
+ * fetch_api_responses(); $this->raw_api_responses;
413
+ * parse_api_responses(); $this->parsed_api_responses;
414
+ * calculate_network_shares(); $this->share_counts;
415
+ * calculate_total_shares(); $this->share_counts['total_shares'];
416
+ * cache_share_counts(); Stored in DB post meta.
417
+ *
418
+ * @since 3.1.0 | 21 JUN 2018 | Created
419
+ * @access protected
420
+ * @param void
421
+ * @return void
422
+ *
423
+ */
424
+ protected function rebuild_share_counts() {
425
+ global $swp_social_networks, $swp_user_options;
426
+
427
+ $this->establish_permalinks();
428
+ $this->establish_api_request_urls();
429
+ $this->fetch_api_responses();
430
+ $this->parse_api_responses();
431
+ $this->calculate_network_shares();
432
+ $this->calculate_network_shares();
433
+ $this->cache_share_counts();
434
+ }
435
+
436
+
437
+ /**
438
+ * Establish the Permalinks to be checked for shares.
439
+ *
440
+ * The word Permalink here specifically refers to URL's of blog posts which
441
+ * we want to fetch share counts for. We want a system that allows us to
442
+ * create permalinks for the primary permalink, the share recovery permalink,
443
+ * allow a filter for programatic adding of others, and so on.
444
+ *
445
+ * The processed results will be stored in $this->permalinks.
446
+ * @var permalinks Links to be checked for share counts during the
447
+ * share count update process.
448
+ *
449
+ * @since 3.1.0 | 21 JUN 2018 | Created
450
+ * @access private
451
+ * @param void
452
+ * @return void
453
+ *
454
+ */
455
+ private function establish_permalinks() {
456
+ global $swp_social_networks, $swp_user_options;
457
+ $this->permalinks = array();
458
+
459
+ foreach( $swp_social_networks as $key => $object):
460
+ if ( !$object->active ) :
461
+ continue;
462
+ endif;
463
+
464
+ $this->permalinks[$key][] = get_permalink( $this->id );
465
+
466
+ if( true === $swp_user_options['recover_shares'] ) :
467
+ $this->permalinks[$key][] = SWP_Permalink::get_alt_permalink( $this->id );
468
+ endif;
469
+
470
+ $this->permalinks = apply_filters( 'swp_recovery_filter', $this->permalinks );
471
+ endforeach;
472
+
473
+ }
474
+
475
+
476
+ /**
477
+ * Prepares outbound API links per network.
478
+ *
479
+ * @since 3.1.0 | 25 JUN 2018 | Created the method.
480
+ * @var api_urls The array of outbound API request destinations.
481
+ * @param void
482
+ * @return void
483
+ *
484
+ */
485
+ private function establish_api_request_urls() {
486
+ global $swp_social_networks;
487
+
488
+ $this->api_urls = array();
489
+
490
+ foreach ( $this->permalinks as $network => $links ) {
491
+ $current_request = 0;
492
+ foreach( $links as $url ) {
493
+ $this->api_urls[$current_request][$network] = $swp_social_networks[$network]->get_api_link( $url );
494
+ ++$current_request;
495
+ }
496
+ }
497
+ }
498
+
499
+
500
+ /**
501
+ * Fetch responses from the network API's.
502
+ *
503
+ * This method will use the $this->api_urls array, loop through them, and
504
+ * using curl_multi will fetch raw responses from the network API's. The
505
+ * results will be stored in $this->raw_api_responses array.
506
+ *
507
+ * @since 3.1.0 | 25 JUN 2018 | Created
508
+ * @var raw_api_responses An array of responses from the API's.
509
+ * @param void
510
+ * @return void All data is stored in local properties.
511
+ *
512
+ */
513
+ private function fetch_api_responses() {
514
+ $current_request = 0;
515
+ foreach ( $this->api_urls as $request => $networks ) {
516
+ $this->raw_api_responses[$current_request] = SWP_CURL::fetch_shares_via_curl_multi( $networks );
517
+ $current_request++;
518
+ }
519
+ }
520
+
521
+
522
+ /**
523
+ * Parse the API responses
524
+ *
525
+ * This method will take the array of raw responses stored inside the
526
+ * $this->raw_api_responses property and use each network's parse method
527
+ * to convert them into integers that we can use to tally up our share counts.
528
+ *
529
+ * @since 3.1.0 | 25 JUN 2018 | Created
530
+ * @var parsed_api_responses An array of integers from parsing the responses.
531
+ * @param void
532
+ * @return void Processed data is stored in local properties.
533
+ *
534
+ */
535
+ private function parse_api_responses() {
536
+ global $swp_social_networks;
537
+ $this->parsed_api_responses = array();
538
+
539
+ foreach( $this->raw_api_responses as $request => $responses ) {
540
+ $current_request = 0;
541
+
542
+ foreach ( $responses as $key => $response ) {
543
+ $this->parsed_api_responses[$current_request][$key][] = $swp_social_networks[$key]->parse_api_response( $response );
544
+ $current_request++;
545
+ }
546
+ }
547
+ }
548
+
549
+
550
+ /**
551
+ * Calculate the network shares.
552
+ *
553
+ * This method is used to calculate the shares for each network based on
554
+ * what we have just retrieved from the API responses. Another method,
555
+ * establish_share_counts will be used to create this data from the cached
556
+ * database data. This one is ONLY used when the cache is not fresh and the
557
+ * data is being rebuilt.
558
+ *
559
+ * @since 3.1.0 | 25 JUN 2018 | Created
560
+ * @var share_counts An array of share count numbers.
561
+ * @param void
562
+ * @return void All data stored in local properties.
563
+ *
564
+ */
565
+ private function calculate_network_shares() {
566
+ global $swp_social_networks;
567
+
568
+ $share_counts = array();
569
+
570
+ foreach ( $this->parsed_api_responses as $request => $networks ) {
571
+ foreach ( $networks as $key => $count_array ) {
572
+ foreach ( $count_array as $count ) {
573
+ if ( !isset( $share_counts[$key] ) ) {
574
+ $share_counts[$key] = 0;
575
+ }
576
+
577
+ $share_counts[$key] += $count;
578
+ }
579
+
580
+ }
581
+ }
582
+
583
+ $this->share_counts = $share_counts;
584
+ }
585
+
586
+
587
+ /**
588
+ * Update the meta fields with the new share counts.
589
+ *
590
+ * As per the inline docblock below, we only update if larger numbers are
591
+ * recieved than the previous checks. This is because some networks, like
592
+ * Pinterest are notorious for randomly resetting some counts all the way
593
+ * back to zero. This will prevent a post with 10K shares from keeping the
594
+ * zero response.
595
+ *
596
+ * @since 3.1.0 | 25 JUN 2018 | Created
597
+ * @param void
598
+ * @return void
599
+ *
600
+ */
601
+ private function cache_share_counts() {
602
+ $this->share_counts['total_shares'] = 0;
603
+
604
+ foreach( $this->share_counts as $key => $count ) {
605
+ if ( 'total_shares' === $key ) {
606
+ continue;
607
+ }
608
+
609
+ $previous_count = get_post_meta( $this->id, "_${key}_shares", true);
610
+
611
+ if ( empty( $previous_count ) ) {
612
+ $previous_count = 0;
613
+ }
614
+
615
+ // We only update to newly fetched numbers if they're bigger than
616
+ // the old ones unless the url parameter is forcing it to take.
617
+ if ( $count <= $previous_count && false === _swp_is_debug( 'force_new_shares' ) ) {
618
+ $this->share_counts[$key] = $previous_count;
619
+ }
620
+
621
+ $this->share_counts['total_shares'] += $this->share_counts[$key];
622
+
623
+ delete_post_meta( $this->id, "_${key}_shares");
624
+ update_post_meta( $this->id, "_${key}_shares", $this->share_counts[$key] );
625
+ }
626
+
627
+ delete_post_meta( $this->id, '_total_shares');
628
+ update_post_meta( $this->id, '_total_shares', $this->share_counts['total_shares'] );
629
+ }
630
+
631
+
632
+ /**
633
+ * Gets the computed share data.
634
+ *
635
+ * @since 3.1.0 | 20 JUN 2018 | Created the method.
636
+ * @param void
637
+ * @return array $this->share_counts if it exists, or an empty array.
638
+ *
639
+ */
640
+ public function get_shares() {
641
+ if ( !empty( $this->share_counts ) ) :
642
+ return $this->share_counts;
643
+ endif;
644
+
645
+ return array();
646
+ }
647
+
648
+
649
+ /**
650
+ * Process the existing share data, or update it.
651
+ *
652
+ * @todo Remove all fresh_cache() checks. This method needs to assume the
653
+ * cache is always fresh and always return cached data.
654
+ *
655
+ * @since 3.1.0 | 21 JUN 2018 | Created the method.
656
+ * @access protected
657
+ * @param void
658
+ * @return void
659
+ *
660
+ */
661
+ protected function establish_share_counts() {
662
+ global $swp_social_networks;
663
+
664
+ foreach( $swp_social_networks as $network => $network_object ) {
665
+ if ( !isset( $swp_social_networks[$network] ) ) :
666
+ continue;
667
+ endif;
668
+
669
+ $count = get_post_meta( $this->id, '_' . $network . '_shares', true );
670
+ $this->share_counts[$network] = $count ? $count : 0;
671
+ }
672
+
673
+ $total = get_post_meta( $this->id, '_total_shares', true );
674
+ $this->share_counts['total_shares'] = $total ? $total : 0;
675
+ }
676
+
677
+ }
functions/utilities/SWP_Post_Cache_Loader.php CHANGED
@@ -1,117 +1,117 @@
1
- <?php
2
-
3
- /**
4
- * The Global SWP_Post_Caches Object
5
- *
6
- * This class allows for the creation of a global $SWP_Post_Caches object. This
7
- * will be called and instantiated from the main loader class. It will then be
8
- * made available to classes like the buttons_panel class which can then use it
9
- * to fetch share counts for specific posts via their post_cache objects.
10
- *
11
- * This class is essentially a loader class for the post_cache objects.
12
- *
13
- * @package SocialWarfare\Functions\Utilities
14
- * @copyright Copyright (c) 2018, Warfare Plugins, LLC
15
- * @license GPL-3.0+
16
- * @since 3.1.0 | 20 JUN 2018 | Created
17
- * @access public
18
- *
19
- */
20
- class SWP_Post_Cache_Loader {
21
-
22
-
23
- /**
24
- * Array of the currently loaded SWP_Post_Cache objects, indexed by post_id.
25
- * These are meant to be accessed by the Buttons Panel, for example.
26
- *
27
- * @var array
28
- *
29
- */
30
- public $post_caches = array();
31
-
32
-
33
- /**
34
- * Load the class and queue up the admin hooks.
35
- *
36
- * @since 3.1.0 | 25 JUN 2018 | Created
37
- * @param void
38
- * @return void
39
- *
40
- */
41
- public function __construct() {
42
- add_action( 'wp_ajax_swp_rebuild_cache', array( $this, 'rebuild_post_cache_data' ) );
43
- add_action( 'wp_ajax_nopriv_swp_rebuild_cache', array( $this, 'rebuild_post_cache_data' ) );
44
-
45
- /**
46
- * Reset the cache timestamp when a post is updated. This will cause the
47
- * cache to rebuild on the next page load.
48
- *
49
- */
50
- add_action( 'save_post', array( $this, 'update_post' ) );
51
- add_action( 'publish_post', array( $this, 'update_post' ) );
52
- }
53
-
54
-
55
- /**
56
- * Gets the post_cache object for a specific post.
57
- *
58
- * Since all requests for post_cache objects should be called via this
59
- * method, we shouldn't have to worry about a post_cache object being
60
- * instantiated more than once for any given post. As such, we can use the
61
- * instantiation of that object to call functions that we want to make sure
62
- * only ever get run once, like updating the cached data.
63
- *
64
- * @since 3.1.0 | 20 JUNE 2018 | Created
65
- * @param integer $post_id The ID of the post being requested.
66
- * @return object The post_cache object for the post.
67
- *
68
- */
69
- public function get_post_cache( $post_id ) {
70
-
71
- if ( !array_key_exists( $post_id, $this->post_caches ) ) :
72
- $this->post_caches[$post_id] = new SWP_Post_Cache( $post_id );
73
- endif;
74
-
75
- return $this->post_caches[$post_id];
76
- }
77
-
78
-
79
- /**
80
- * Rebuild the cached data for a post cache.
81
- *
82
- * Since this class is loaded glboally, it can be made available for use by
83
- * admin ajax calls. This method will intercept/recieve the admin-ajax
84
- * request, instantiate a post cache object, and then instruct that object
85
- * to rebuild the post cache data.
86
- *
87
- * @todo Add the wp-die() or whatever command is needed to close a wp-ajax
88
- * handler method.
89
- * @since 3.1.0 | 25 JUN 2018 | Created
90
- * @param void
91
- * @return void
92
- *
93
- */
94
- public function rebuild_post_cache_data() {
95
- echo 'test';
96
- if( isset( $_POST['post_id'] ) ):
97
- $Post_Cache = new SWP_Post_Cache( $_POST['post_id'] );
98
- $Post_Cache->rebuild_cached_data();
99
- endif;
100
- wp_die();
101
- }
102
-
103
-
104
- /**
105
- * Resets the cache timestamp so that it will rebuild during the next page load.
106
- *
107
- * @since 3.1.0 | 26 JUN 2018 | Created the method.
108
- * @param void
109
- * @return void
110
- *
111
- */
112
- public function update_post( $post_id ) {
113
- $Post_Cache = new SWP_Post_Cache( $_POST['post_id'] );
114
- $Post_Cache->delete_timestamp();
115
- }
116
-
117
- }
1
+ <?php
2
+
3
+ /**
4
+ * The Global SWP_Post_Caches Object
5
+ *
6
+ * This class allows for the creation of a global $SWP_Post_Caches object. This
7
+ * will be called and instantiated from the main loader class. It will then be
8
+ * made available to classes like the buttons_panel class which can then use it
9
+ * to fetch share counts for specific posts via their post_cache objects.
10
+ *
11
+ * This class is essentially a loader class for the post_cache objects.
12
+ *
13
+ * @package SocialWarfare\Functions\Utilities
14
+ * @copyright Copyright (c) 2018, Warfare Plugins, LLC
15
+ * @license GPL-3.0+
16
+ * @since 3.1.0 | 20 JUN 2018 | Created
17
+ * @access public
18
+ *
19
+ */
20
+ class SWP_Post_Cache_Loader {
21
+
22
+
23
+ /**
24
+ * Array of the currently loaded SWP_Post_Cache objects, indexed by post_id.
25
+ * These are meant to be accessed by the Buttons Panel, for example.
26
+ *
27
+ * @var array
28
+ *
29
+ */
30
+ public $post_caches = array();
31
+
32
+
33
+ /**
34
+ * Load the class and queue up the admin hooks.
35
+ *
36
+ * @since 3.1.0 | 25 JUN 2018 | Created
37
+ * @param void
38
+ * @return void
39
+ *
40
+ */
41
+ public function __construct() {
42
+ add_action( 'wp_ajax_swp_rebuild_cache', array( $this, 'rebuild_post_cache_data' ) );
43
+ add_action( 'wp_ajax_nopriv_swp_rebuild_cache', array( $this, 'rebuild_post_cache_data' ) );
44
+
45
+ /**
46
+ * Reset the cache timestamp when a post is updated. This will cause the
47
+ * cache to rebuild on the next page load.
48
+ *
49
+ */
50
+ add_action( 'save_post', array( $this, 'update_post' ) );
51
+ add_action( 'publish_post', array( $this, 'update_post' ) );
52
+ }
53
+
54
+
55
+ /**
56
+ * Gets the post_cache object for a specific post.
57
+ *
58
+ * Since all requests for post_cache objects should be called via this
59
+ * method, we shouldn't have to worry about a post_cache object being
60
+ * instantiated more than once for any given post. As such, we can use the
61
+ * instantiation of that object to call functions that we want to make sure
62
+ * only ever get run once, like updating the cached data.
63
+ *
64
+ * @since 3.1.0 | 20 JUNE 2018 | Created
65
+ * @param integer $post_id The ID of the post being requested.
66
+ * @return object The post_cache object for the post.
67
+ *
68
+ */
69
+ public function get_post_cache( $post_id ) {
70
+
71
+ if ( !array_key_exists( $post_id, $this->post_caches ) ) :
72
+ $this->post_caches[$post_id] = new SWP_Post_Cache( $post_id );
73
+ endif;
74
+
75
+ return $this->post_caches[$post_id];
76
+ }
77
+
78
+
79
+ /**
80
+ * Rebuild the cached data for a post cache.
81
+ *
82
+ * Since this class is loaded glboally, it can be made available for use by
83
+ * admin ajax calls. This method will intercept/recieve the admin-ajax
84
+ * request, instantiate a post cache object, and then instruct that object
85
+ * to rebuild the post cache data.
86
+ *
87
+ * @todo Add the wp-die() or whatever command is needed to close a wp-ajax
88
+ * handler method.
89
+ * @since 3.1.0 | 25 JUN 2018 | Created
90
+ * @param void
91
+ * @return void
92
+ *
93
+ */
94
+ public function rebuild_post_cache_data() {
95
+ echo 'test';
96
+ if( isset( $_POST['post_id'] ) ):
97
+ $Post_Cache = new SWP_Post_Cache( $_POST['post_id'] );
98
+ $Post_Cache->rebuild_cached_data();
99
+ endif;
100
+ wp_die();
101
+ }
102
+
103
+
104
+ /**
105
+ * Resets the cache timestamp so that it will rebuild during the next page load.
106
+ *
107
+ * @since 3.1.0 | 26 JUN 2018 | Created the method.
108
+ * @param void
109
+ * @return void
110
+ *
111
+ */
112
+ public function update_post( $post_id ) {
113
+ $Post_Cache = new SWP_Post_Cache( $post_id );
114
+ $Post_Cache->delete_timestamp();
115
+ }
116
+
117
+ }
functions/utilities/SWP_URL_Management.php CHANGED
@@ -1,403 +1,403 @@
1
- <?php
2
-
3
- /**
4
- * SWP_URL_Management
5
- *
6
- * A class engineered to manage the links that are shared out to the various social
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
- */
14
- class SWP_URL_Management {
15
-
16
-
17
- /**
18
- * The magic __construct method.
19
- *
20
- * This method instantiates the SWP_URL_Management object. It's primary function
21
- * is to add the various methods to their approprate hooks for use later on in
22
- * modifying the links.
23
- *
24
- * @since 3.0.0 | 04 APR 2018 | Created
25
- * @param none
26
- * @return none
27
- * @access public
28
- *
29
- */
30
- public function __construct() {
31
-
32
- add_filter( 'swp_link_shortening' , array( $this , 'link_shortener' ) );
33
- add_filter( 'swp_analytics' , array( $this , 'google_analytics' ) );
34
- add_action( 'wp_ajax_nopriv_swp_bitly_oauth', array( $this , 'bitly_oauth_callback' ) );
35
-
36
- }
37
-
38
-
39
- /**
40
- * Google Analytics UTM Tracking Parameters
41
- *
42
- * This is the method used to add Google analytics UTM parameters to the links
43
- * that are being shared on social media.
44
- *
45
- * @since 3.0.0 | 04 APR 2018 | Created
46
- * @param array $array An array of arguments and data used in processing the URL.
47
- * @return array $array The modified array.
48
- * @access public
49
- *
50
- */
51
- public function google_analytics( $array ) {
52
- global $swp_user_options;
53
-
54
- // Fetch the user options
55
- $options = $swp_user_options;
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 ) :
70
- $array['url'] = $url . urlencode( '&' . $url_string );
71
- else :
72
- $array['url'] = $url . urlencode( '?' . $url_string );
73
- endif;
74
- endif;
75
-
76
- return $array;
77
- endif;
78
-
79
- return $array;
80
- }
81
-
82
-
83
- /**
84
- * The Bitly Link Shortener Method
85
- *
86
- * This is the function used to manage shortened links via the Bitly link
87
- * shortening service.
88
- *
89
- * @since 3.0.0 | 04 APR 2018 | Created
90
- * @param array $array An array of arguments and information.
91
- * @return array $array The modified array.
92
- * @access public
93
- *
94
- */
95
- public function link_shortener( $array ) {
96
- global $swp_user_options;
97
-
98
- if ( $array['network'] == 'total_shares' || $array['network'] == 'pinterest') :
99
- return $array;
100
- endif;
101
-
102
- $url = $array['url'];
103
- $network = $array['network'];
104
- $postID = $array['postID'];
105
-
106
- // Fetch the User's Options
107
- $options = $swp_user_options;
108
-
109
- // If Link shortening is activated....
110
- if ( $options['bitly_authentication'] == true ) :
111
-
112
- // If Bitly is activated and we have all the appropriate credentials....
113
- if ( isset( $options['bitly_access_token'] ) ) :
114
-
115
- // Collect our bitly login information
116
- $access_token = $options['bitly_access_token'];
117
-
118
- // If Google Analytics is Activated....
119
- if ( swp_get_option('google_analytics') == true ) :
120
-
121
- // If the link has already been shortened....
122
- $existingURL = get_post_meta( $postID,'bitly_link_' . $network,true );
123
-
124
- // If the Cache is still fresh or a previous API request failed....
125
- if ( ( true === $array['fresh_cache'] && $existingURL) || (isset( $_GLOBALS['bitly_status'] ) && $_GLOBALS['bitly_status'] == 'failure') ) :
126
-
127
- if ( $existingURL ) :
128
- if( true === _swp_is_debug('bitly') ){ echo 'Bitly: '. __LINE__; }
129
- $array['url'] = $existingURL;
130
- return $array;
131
-
132
- // If the link has NOT already been shortened
133
- else :
134
- if( true === _swp_is_debug('bitly') ){ echo 'Bitly: '. __LINE__; }
135
- // ....Return the normal URL
136
- return $array;
137
-
138
- endif;
139
-
140
- // If the Cache is NOT fresh....
141
- else :
142
-
143
- // If the API provides a shortened URL...
144
- $shortURL = $this->make_bitly_url( urldecode( $url ) , $network , $access_token );
145
- if ( $shortURL ) :
146
- if( true === _swp_is_debug('bitly') ){ echo 'Bitly: '. __LINE__; }
147
-
148
- // Store the link in the cache and return it to the buttons
149
- delete_post_meta( $postID,'bitly_link_' . $network );
150
- update_post_meta( $postID,'bitly_link_' . $network,$shortURL );
151
- $array['url'] = $shortURL;
152
- return $array;
153
-
154
- // If the API does not provide a shortened URL....
155
- else :
156
- if( true === _swp_is_debug('bitly') ){ echo 'Bitly: '. __LINE__; }
157
-
158
- // Set a variable we'll check to avoid multiple calls to bitly upon the first failure
159
- $_GLOBALS['sw']['bitly_status'] = 'failure';
160
-
161
- // Return the normal URL
162
- return $array;
163
-
164
- // End the check for a shortneing link from the API
165
- endif;
166
-
167
- // End the check for the cache being fresh
168
- endif;
169
-
170
- // If Google Analytics is NOT activated....
171
- else :
172
-
173
- $existingURL = get_post_meta( $postID,'bitly_link',true );
174
-
175
- // If the cache is fresh or if the API has failed already....
176
- if ( ( true === $array['fresh_cache'] && $existingURL) || (isset( $_GLOBALS['bitly_status'] ) && $_GLOBALS['bitly_status'] == 'failure') ) :
177
-
178
- // If we have a shortened URL in the cache....
179
- if ( $existingURL ) :
180
- if( true === _swp_is_debug('bitly') ){ echo 'Bitly: '. __LINE__; }
181
-
182
- // Save the link in a constant for use in other parts of the loops
183
- $_GLOBALS['sw']['links'][ $postID ] = $existingURL;
184
-
185
- // Return the shortened URL
186
- $array['url'] = $existingURL;
187
- return $array;
188
-
189
- // If we don't have a shortlink in the cache....
190
- else :
191
- if( true === _swp_is_debug('bitly') ){ echo 'Bitly: '. __LINE__; }
192
-
193
- // Return the normal URL
194
- return $array;
195
-
196
- endif;
197
-
198
- // If the cache is expired and needs to be rebuilt....
199
- else :
200
-
201
- // If we've already generated this link....
202
- if ( isset( $_GLOBALS['sw']['links'][ $postID ] ) ) :
203
- if( true === _swp_is_debug('bitly') ){ echo 'Bitly: '. __LINE__; }
204
-
205
- $array['url'] = $_GLOBALS['sw']['links'][ $postID ];
206
- return $array;
207
-
208
- // If we've don't already have a generated link....
209
- else :
210
-
211
- // Use the bitly function to construct a shortened link
212
- $shortURL = $this->make_bitly_url( urldecode( $url ) , $network , $access_token );
213
-
214
- // If we got a shortened URL from their API....
215
- if ( $shortURL ) :
216
-
217
- // Save the link in a global so we can skip this part next time
218
- $_GLOBALS['sw']['links'][ $postID ] = $shortURL;
219
-
220
- // Delete the meta fields and then update to keep the database clean and up to date.
221
- delete_post_meta( $postID,'bitly_link_' . $network );
222
- delete_post_meta( $postID,'bitly_link' );
223
- update_post_meta( $postID,'bitly_link',$shortURL );
224
- if( true === _swp_is_debug('bitly') ){ echo 'Bitly: '. __LINE__; }
225
-
226
- // Return the short URL
227
- $arr