Social Media Feather | social media sharing - Version 2.0.5

Version Description

  • Strengthen sanitization for inputs and outputs.
  • Fix warnings, remove unnecessary files.
  • Remove Google+ entirely.
Download this release

Release Info

Developer socialmediafeather
Plugin Icon 128x128 Social Media Feather | social media sharing
Version 2.0.5
Comparing to
See all releases

Code changes from version 2.0.4 to 2.0.5

Files changed (113) hide show
  1. readme.txt +18 -13
  2. screenshot-1.png +0 -0
  3. screenshot-2.png +0 -0
  4. screenshot-3.png +0 -0
  5. screenshot-4.png +0 -0
  6. screenshot-5.png +0 -0
  7. screenshot-6.png +0 -0
  8. screenshot-7.png +0 -0
  9. social-media-feather.php +11 -12
  10. synved-connect/synved-connect-addon.php +0 -2
  11. synved-connect/synved-connect-component.php +0 -21
  12. synved-connect/synved-connect-credit.php +0 -58
  13. synved-connect/synved-connect-key.php +3 -86
  14. synved-connect/synved-connect-sponsor.php +3 -10
  15. synved-connect/synved-connect-support.php +0 -13
  16. synved-connect/synved-connect.php +22 -75
  17. synved-option/addons/option-type-addon/addon-handle.php +0 -2
  18. synved-option/addons/option-type-addon/addon-render.php +0 -2
  19. synved-option/addons/option-type-addon/option-type-addon.php +184 -175
  20. synved-option/addons/option-type-addon/script/custom.js +178 -225
  21. synved-option/inc/SynvedOptionCallback.php +76 -0
  22. synved-option/script/custom.js +113 -116
  23. synved-option/synved-option-context.php +0 -6
  24. synved-option/synved-option-error.php +0 -2
  25. synved-option/synved-option-item.php +131 -136
  26. synved-option/synved-option-page.php +161 -148
  27. synved-option/synved-option-render.php +129 -213
  28. synved-option/synved-option-section.php +5 -11
  29. synved-option/synved-option-setting.php +75 -3
  30. synved-option/synved-option.php +239 -255
  31. synved-plugout/synved-plugout-core.php +67 -129
  32. synved-plugout/synved-plugout.php +4 -3
  33. synved-social/addons/extra-icons/extra-icons.php +77 -77
  34. synved-social/addons/extra-icons/image/social/balloon/128x128/google_plus.png +0 -0
  35. synved-social/addons/extra-icons/image/social/balloon/16x16/google_plus.png +0 -0
  36. synved-social/addons/extra-icons/image/social/balloon/24x24/google_plus.png +0 -0
  37. synved-social/addons/extra-icons/image/social/balloon/32x32/google_plus.png +0 -0
  38. synved-social/addons/extra-icons/image/social/balloon/48x48/google_plus.png +0 -0
  39. synved-social/addons/extra-icons/image/social/balloon/64x64/google_plus.png +0 -0
  40. synved-social/addons/extra-icons/image/social/balloon/96x96/google_plus.png +0 -0
  41. synved-social/addons/extra-icons/image/social/balloon/preview.png +0 -0
  42. synved-social/addons/extra-icons/image/social/circle/128x128/google_plus.png +0 -0
  43. synved-social/addons/extra-icons/image/social/circle/16x16/google_plus.png +0 -0
  44. synved-social/addons/extra-icons/image/social/circle/24x24/google_plus.png +0 -0
  45. synved-social/addons/extra-icons/image/social/circle/32x32/google_plus.png +0 -0
  46. synved-social/addons/extra-icons/image/social/circle/48x48/google_plus.png +0 -0
  47. synved-social/addons/extra-icons/image/social/circle/64x64/google_plus.png +0 -0
  48. synved-social/addons/extra-icons/image/social/circle/96x96/google_plus.png +0 -0
  49. synved-social/addons/extra-icons/image/social/circle/preview.png +0 -0
  50. synved-social/addons/extra-icons/image/social/clearslate/128x128/google_plus.png +0 -0
  51. synved-social/addons/extra-icons/image/social/clearslate/16x16/google_plus.png +0 -0
  52. synved-social/addons/extra-icons/image/social/clearslate/24x24/google_plus.png +0 -0
  53. synved-social/addons/extra-icons/image/social/clearslate/32x32/google_plus.png +0 -0
  54. synved-social/addons/extra-icons/image/social/clearslate/48x48/google_plus.png +0 -0
  55. synved-social/addons/extra-icons/image/social/clearslate/64x64/google_plus.png +0 -0
  56. synved-social/addons/extra-icons/image/social/clearslate/96x96/google_plus.png +0 -0
  57. synved-social/addons/extra-icons/image/social/clearslate/preview.png +0 -0
  58. synved-social/addons/extra-icons/image/social/darkslate/128x128/google_plus.png +0 -0
  59. synved-social/addons/extra-icons/image/social/darkslate/16x16/google_plus.png +0 -0
  60. synved-social/addons/extra-icons/image/social/darkslate/24x24/google_plus.png +0 -0
  61. synved-social/addons/extra-icons/image/social/darkslate/32x32/google_plus.png +0 -0
  62. synved-social/addons/extra-icons/image/social/darkslate/48x48/google_plus.png +0 -0
  63. synved-social/addons/extra-icons/image/social/darkslate/64x64/google_plus.png +0 -0
  64. synved-social/addons/extra-icons/image/social/darkslate/96x96/google_plus.png +0 -0
  65. synved-social/addons/extra-icons/image/social/darkslate/preview.png +0 -0
  66. synved-social/addons/extra-icons/image/social/flag/128x128/google_plus.png +0 -0
  67. synved-social/addons/extra-icons/image/social/flag/16x16/google_plus.png +0 -0
  68. synved-social/addons/extra-icons/image/social/flag/24x24/google_plus.png +0 -0
  69. synved-social/addons/extra-icons/image/social/flag/32x32/google_plus.png +0 -0
  70. synved-social/addons/extra-icons/image/social/flag/48x48/google_plus.png +0 -0
  71. synved-social/addons/extra-icons/image/social/flag/64x64/google_plus.png +0 -0
  72. synved-social/addons/extra-icons/image/social/flag/96x96/google_plus.png +0 -0
  73. synved-social/addons/extra-icons/image/social/flag/preview.png +0 -0
  74. synved-social/addons/extra-icons/image/social/medal/128x128/google_plus.png +0 -0
  75. synved-social/addons/extra-icons/image/social/medal/16x16/google_plus.png +0 -0
  76. synved-social/addons/extra-icons/image/social/medal/24x24/google_plus.png +0 -0
  77. synved-social/addons/extra-icons/image/social/medal/32x32/google_plus.png +0 -0
  78. synved-social/addons/extra-icons/image/social/medal/48x48/google_plus.png +0 -0
  79. synved-social/addons/extra-icons/image/social/medal/64x64/google_plus.png +0 -0
  80. synved-social/addons/extra-icons/image/social/medal/96x96/google_plus.png +0 -0
  81. synved-social/addons/extra-icons/image/social/medal/preview.png +0 -0
  82. synved-social/addons/extra-icons/image/social/shed/128x128/google_plus.png +0 -0
  83. synved-social/addons/extra-icons/image/social/shed/16x16/google_plus.png +0 -0
  84. synved-social/addons/extra-icons/image/social/shed/24x24/google_plus.png +0 -0
  85. synved-social/addons/extra-icons/image/social/shed/32x32/google_plus.png +0 -0
  86. synved-social/addons/extra-icons/image/social/shed/48x48/google_plus.png +0 -0
  87. synved-social/addons/extra-icons/image/social/shed/64x64/google_plus.png +0 -0
  88. synved-social/addons/extra-icons/image/social/shed/96x96/google_plus.png +0 -0
  89. synved-social/addons/extra-icons/image/social/shed/preview.png +0 -0
  90. synved-social/addons/extra-icons/image/social/wheel/128x128/google_plus.png +0 -0
  91. synved-social/addons/extra-icons/image/social/wheel/16x16/google_plus.png +0 -0
  92. synved-social/addons/extra-icons/image/social/wheel/24x24/google_plus.png +0 -0
  93. synved-social/addons/extra-icons/image/social/wheel/32x32/google_plus.png +0 -0
  94. synved-social/addons/extra-icons/image/social/wheel/48x48/google_plus.png +0 -0
  95. synved-social/addons/extra-icons/image/social/wheel/64x64/google_plus.png +0 -0
  96. synved-social/addons/extra-icons/image/social/wheel/96x96/google_plus.png +0 -0
  97. synved-social/addons/extra-icons/image/social/wheel/preview.png +0 -0
  98. synved-social/image/social-feather-extra-icons.png +0 -0
  99. synved-social/image/social-feather-grey-fade-demo.png +0 -0
  100. synved-social/image/social-feather-light-prompt-demo.png +0 -0
  101. synved-social/image/social/regular/128x128/google_plus.png +0 -0
  102. synved-social/image/social/regular/16x16/google_plus.png +0 -0
  103. synved-social/image/social/regular/24x24/google_plus.png +0 -0
  104. synved-social/image/social/regular/32x32/google_plus.png +0 -0
  105. synved-social/image/social/regular/48x48/google_plus.png +0 -0
  106. synved-social/image/social/regular/64x64/google_plus.png +0 -0
  107. synved-social/image/social/regular/96x96/google_plus.png +0 -0
  108. synved-social/image/social/regular/preview.png +0 -0
  109. synved-social/inc/SynvedSocialFollowWidget.php +34 -0
  110. synved-social/inc/SynvedSocialShareWidget.php +34 -0
  111. synved-social/inc/SynvedSocialWidget.php +144 -0
  112. synved-social/synved-social-setup.php +624 -832
  113. synved-social/synved-social.php +507 -724
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: socialmediafeather, scottstorebloom, scottmweaver
3
  Tags: social media, social sharing, social buttons, Facebook, Share, Like, twitter, google, Reddit, youtube, instagram, pinterest, social media buttons, button, shortcode, sidebar, sharing buttons, follow buttons
4
  Requires at least: 3.1
5
  Tested up to: 5.9
6
- Stable tag: 2.0.4
7
- Version: 2.0.4
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -22,11 +22,11 @@ What sets WordPress Social Media Feather aside from the plethora of other social
22
 
23
  Given the widespread focus on WordPress social media integration, your site will still provide social bookmarks and share buttons to improve visibility of your posts and content and improve your overall global reach on social platforms.
24
 
25
- The **WordPress social media sharing** offered by the plugin includes all major social sharing buttons providers like Facebook, Twitter, Google+, reddit, Pinterest, tumblr, Linkedin and even e-mail.
26
 
27
- It will show social buttons that your users can click to share to facebook or tweet your posts and pages on your site or submit it to reddit and google plus or publish it on tumblr and all other social sharing networks.
28
 
29
- The **WordPress social media following** offered by the plugin includes all major social network providers and tools like Facebook, Twitter, Google+, Pinterest, Linkedin, YouTube, tumblr, instagram, flickr, foursquare, vimeo or RSS.
30
 
31
  Our social media plugin also offers widgets for sharing and following buttons that you can place in any widgetized area in your site and the widgets also expose some settings and parameters to tweak the appearance of the social buttons. The plugin also provides shortcodes that can be used for the same purpose, creating both share and follow buttons and allowing selection of visibility of different social media networks or reordering how the various social networks appear (see example shortcodes at the bottom).
32
 
@@ -37,8 +37,8 @@ You can disable automatic rendering of social icons for specific posts by using
37
  * Full support for **Retina** and high resolution displays
38
  * WordPress social sharing and following widgets
39
  * Supports all major providers of social features
40
- * Sharing with Facebook, Twitter, Google+, reddit, Pinterest, tumblr, Linkedin and e-mail
41
- * Following on Facebook, Twitter, Google+, Pinterest, Linkedin, YouTube, tumblr, instagram, flickr, foursquare, vimeo or RSS Feed
42
  * Each social provider can be enabled or disabled
43
  * Ability to select what services each provider will be exposed for
44
  * Full customization for titles and URLs for each provider
@@ -46,18 +46,18 @@ You can disable automatic rendering of social icons for specific posts by using
46
  * Comes with a default modern icon set
47
  * For further customization more [social icons skins](http://socialmediafeather.com/products/extra-social-icons/ "Add 8 extra social icon skins to the Social Media Feather plugin!") are available. Free from the version 1.8.2!
48
  * Available skins can be customized with cool effects like [fading and greying out](http://socialmediafeather.com/products/grey-fade-effect/ "Customize any of the available social icon skins with 2 cool effects!") social icons
49
- * If you like them you can get [social sharing counters](http://socialmediafeather.com/products/light-prompt/ "Nice lightweight social sharing counters using the Light Prompt addon") that load dynamically, only when necessary, thus not weighing in on visitors who don't use them
50
 
51
  = Example Shortcodes =
52
 
53
  This shortcode will create a list of social sharing buttons to share content on your site:
54
  `[feather_share]`
55
 
56
- This shortcode will create a list of social media sharing buttons to share content on your site, only showing Google+, Twitter and Facebook, in that specific order:
57
- `[feather_share show="google_plus, twitter, facebook" hide="reddit, pinterest, linkedin, tumblr, mail"]`
58
 
59
  You can change the order of displayed buttons by changing the order of keywords:
60
- `[feather_share show="twitter, google_plus, facebook" hide="reddit, pinterest, linkedin, tumblr, mail"]`
61
 
62
  This shortcode will create a list of social sharing buttons to share content on your site using the "Wheel" icons skin:
63
  `[feather_share skin="wheel"]`
@@ -68,8 +68,8 @@ This shortcode will create a list of social media sharing buttons to share conte
68
  You can add a custom CSS class to your share buttons using the "class" attribute:
69
  `[feather_share class="myclass"]`
70
 
71
- You can combine all the parameters above to customize the look, for instance using the "Wheel" icon skin at a size of 64 pixels and only showing Google+, Twitter and Facebook, in that specific order:
72
- `[feather_share skin="wheel" size="64" show="google_plus, twitter, facebook" hide="reddit, pinterest, linkedin, tumblr, mail"]`
73
 
74
  The next shortcode will create a list of social following buttons that allow visitors to follow you:
75
  `[feather_follow]`
@@ -192,6 +192,11 @@ margin-left: 10px;
192
 
193
  == Changelog ==
194
 
 
 
 
 
 
195
  = 2.0.4 =
196
  * Test with WordPress 5.9.
197
  * Update media assets.
3
  Tags: social media, social sharing, social buttons, Facebook, Share, Like, twitter, google, Reddit, youtube, instagram, pinterest, social media buttons, button, shortcode, sidebar, sharing buttons, follow buttons
4
  Requires at least: 3.1
5
  Tested up to: 5.9
6
+ Stable tag: 2.0.5
7
+ Version: 2.0.5
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
22
 
23
  Given the widespread focus on WordPress social media integration, your site will still provide social bookmarks and share buttons to improve visibility of your posts and content and improve your overall global reach on social platforms.
24
 
25
+ The **WordPress social media sharing** offered by the plugin includes all major social sharing buttons providers like Facebook, Twitter, reddit, Pinterest, tumblr, Linkedin and even e-mail.
26
 
27
+ It will show social buttons that your users can click to share to facebook or tweet your posts and pages on your site or submit it to reddit or publish it on tumblr and all other social sharing networks.
28
 
29
+ The **WordPress social media following** offered by the plugin includes all major social network providers and tools like Facebook, Twitter, Pinterest, Linkedin, YouTube, tumblr, instagram, flickr, foursquare, vimeo or RSS.
30
 
31
  Our social media plugin also offers widgets for sharing and following buttons that you can place in any widgetized area in your site and the widgets also expose some settings and parameters to tweak the appearance of the social buttons. The plugin also provides shortcodes that can be used for the same purpose, creating both share and follow buttons and allowing selection of visibility of different social media networks or reordering how the various social networks appear (see example shortcodes at the bottom).
32
 
37
  * Full support for **Retina** and high resolution displays
38
  * WordPress social sharing and following widgets
39
  * Supports all major providers of social features
40
+ * Sharing with Facebook, Twitter, Reddit, Pinterest, Tumblr, Linkedin and E-mail
41
+ * Following on Facebook, Twitter, Pinterest, Linkedin, YouTube, Tumblr, Instagram, Flickr, Foursquare, Vimeo or RSS Feed
42
  * Each social provider can be enabled or disabled
43
  * Ability to select what services each provider will be exposed for
44
  * Full customization for titles and URLs for each provider
46
  * Comes with a default modern icon set
47
  * For further customization more [social icons skins](http://socialmediafeather.com/products/extra-social-icons/ "Add 8 extra social icon skins to the Social Media Feather plugin!") are available. Free from the version 1.8.2!
48
  * Available skins can be customized with cool effects like [fading and greying out](http://socialmediafeather.com/products/grey-fade-effect/ "Customize any of the available social icon skins with 2 cool effects!") social icons
49
+ * If you like them, you can get [social sharing counters](http://socialmediafeather.com/products/light-prompt/ "Nice lightweight social sharing counters using the Light Prompt addon") that load dynamically, only when necessary, thus not weighing in on visitors who don't use them
50
 
51
  = Example Shortcodes =
52
 
53
  This shortcode will create a list of social sharing buttons to share content on your site:
54
  `[feather_share]`
55
 
56
+ This shortcode will create a list of social media sharing buttons to share content on your site, only showing Twitter and Facebook, in that specific order:
57
+ `[feather_share show="twitter, facebook" hide="reddit, pinterest, linkedin, tumblr, mail"]`
58
 
59
  You can change the order of displayed buttons by changing the order of keywords:
60
+ `[feather_share show="twitter, facebook" hide="reddit, pinterest, linkedin, tumblr, mail"]`
61
 
62
  This shortcode will create a list of social sharing buttons to share content on your site using the "Wheel" icons skin:
63
  `[feather_share skin="wheel"]`
68
  You can add a custom CSS class to your share buttons using the "class" attribute:
69
  `[feather_share class="myclass"]`
70
 
71
+ You can combine all the parameters above to customize the look, for instance using the "Wheel" icon skin at a size of 64 pixels and only showing Twitter and Facebook, in that specific order:
72
+ `[feather_share skin="wheel" size="64" show="twitter, facebook" hide="reddit, pinterest, linkedin, tumblr, mail"]`
73
 
74
  The next shortcode will create a list of social following buttons that allow visitors to follow you:
75
  `[feather_follow]`
192
 
193
  == Changelog ==
194
 
195
+ = 2.0.5 =
196
+ * Strengthen sanitization for inputs and outputs.
197
+ * Fix warnings, remove unnecessary files.
198
+ * Remove Google+ entirely.
199
+
200
  = 2.0.4 =
201
  * Test with WordPress 5.9.
202
  * Update media assets.
screenshot-1.png DELETED
Binary file
screenshot-2.png DELETED
Binary file
screenshot-3.png DELETED
Binary file
screenshot-4.png DELETED
Binary file
screenshot-5.png DELETED
Binary file
screenshot-6.png DELETED
Binary file
screenshot-7.png DELETED
Binary file
social-media-feather.php CHANGED
@@ -1,16 +1,19 @@
1
  <?php
2
  /*
3
  Plugin Name: Social Media Feather
 
4
  Plugin URI: http://socialmediafeather.com/
5
- Description: Super lightweight social media plugin to add nice and effective social media sharing and following buttons and icons anywhere on your site quickly and easily
6
  Author: socialmediafeather
7
- Version: 2.0.4
8
  Author URI: http://socialmediafeather.com/
9
  */
10
 
11
- define('SYNVED_VERSION', '2.0.4');
12
 
13
- if (!function_exists('synved_wp_social_load'))
 
 
14
  {
15
  function synved_wp_social_load()
16
  {
@@ -18,24 +21,20 @@ if (!function_exists('synved_wp_social_load'))
18
 
19
  $path = __FILE__;
20
 
21
- if (defined('SYNVED_SOCIAL_INCLUDE_PATH'))
22
- {
23
  $path = SYNVED_SOCIAL_INCLUDE_PATH;
24
- }
25
- else if (isset($plugin))
26
- {
27
  /* This is mostly for symlink support */
28
  $real_plugin = realpath($plugin);
29
 
30
- if (strtolower($real_plugin) == strtolower(__FILE__))
31
- {
32
  $path = $plugin;
33
  }
34
  }
35
 
36
  $dir = dirname($path) . DIRECTORY_SEPARATOR;
37
 
38
- if (!function_exists('synved_plugout_module_import'))
39
  {
40
  include($dir . 'synved-plugout' . DIRECTORY_SEPARATOR . 'synved-plugout.php');
41
  }
1
  <?php
2
  /*
3
  Plugin Name: Social Media Feather
4
+ Contributors: scottstorebloom, scottmweaver, socialmediafeather
5
  Plugin URI: http://socialmediafeather.com/
6
+ Description: Super lightweight social media plugin to add nice and effective social media sharing and following buttons and icons anywhere on your site quickly and easily.
7
  Author: socialmediafeather
8
+ Version: 2.0.5
9
  Author URI: http://socialmediafeather.com/
10
  */
11
 
12
+ define( 'SOCIAL_MEDIA_FEATHER_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
13
 
14
+ const SYNVED_VERSION = '2.0.5';
15
+
16
+ if (false === function_exists('synved_wp_social_load'))
17
  {
18
  function synved_wp_social_load()
19
  {
21
 
22
  $path = __FILE__;
23
 
24
+ if (true === defined('SYNVED_SOCIAL_INCLUDE_PATH')) {
 
25
  $path = SYNVED_SOCIAL_INCLUDE_PATH;
26
+ } elseif (isset($plugin)) {
 
 
27
  /* This is mostly for symlink support */
28
  $real_plugin = realpath($plugin);
29
 
30
+ if (strtolower($real_plugin) == strtolower(__FILE__)) {
 
31
  $path = $plugin;
32
  }
33
  }
34
 
35
  $dir = dirname($path) . DIRECTORY_SEPARATOR;
36
 
37
+ if (false === function_exists('synved_plugout_module_import'))
38
  {
39
  include($dir . 'synved-plugout' . DIRECTORY_SEPARATOR . 'synved-plugout.php');
40
  }
synved-connect/synved-connect-addon.php DELETED
@@ -1,2 +0,0 @@
1
- <?php
2
- // Silence is golden.
 
 
synved-connect/synved-connect-component.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- function synved_connect_component_key($component)
4
- {
5
- return get_option('synved_connect_key_' . strtolower($component));
6
- }
7
-
8
- function synved_connect_component_validate($component, $online_check = false)
9
- {
10
- return synved_connect_key_component_validate(synved_connect_component_key($component), $component, $online_check);
11
- }
12
-
13
- function synved_connect_component_support($component)
14
- {
15
-
16
- }
17
-
18
- function synved_connect_component_sponsor($component)
19
- {
20
- $sponsor = get_option('synved_connect_sponsor');
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
synved-connect/synved-connect-credit.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
-
3
- function synved_connect_credit_filter_apply($filter)
4
- {
5
- if (!is_array($filter))
6
- {
7
- $filter = array();
8
- }
9
-
10
- $filter['type'] = 'credit';
11
-
12
- return $filter;
13
- }
14
-
15
- function synved_connect_credit_list($filter = null)
16
- {
17
- $filter = synved_connect_credit_filter_apply($filter);
18
-
19
- return synved_connect_sponsor_list($filter);
20
- }
21
-
22
- function synved_connect_credit_id_pick($filter = null)
23
- {
24
- $filter = synved_connect_credit_filter_apply($filter);
25
-
26
- return synved_connect_sponsor_id_pick($filter);
27
- }
28
-
29
- function synved_connect_credit_item_by_id($credit_id, $filter = null)
30
- {
31
- $filter = synved_connect_credit_filter_apply($filter);
32
-
33
- return synved_connect_sponsor_item_by_id($credit_id, $filter);
34
- }
35
-
36
- function synved_connect_credit_item_pick($filter = null)
37
- {
38
- $filter = synved_connect_credit_filter_apply($filter);
39
-
40
- return synved_connect_sponsor_item_pick($filter);
41
- }
42
-
43
- function synved_connect_credit_item($component = null, $filter = null)
44
- {
45
- $filter = synved_connect_credit_filter_apply($filter);
46
-
47
- return synved_connect_sponsor_item($component, $filter);
48
- }
49
-
50
- function synved_connect_credit_link(array $credit_item = null)
51
- {
52
- return synved_connect_sponsor_link($credit_item);
53
- }
54
-
55
- function synved_connect_credit_content(array $credit_item = null)
56
- {
57
- return synved_connect_sponsor_content($credit_item);
58
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
synved-connect/synved-connect-key.php CHANGED
@@ -1,106 +1,23 @@
1
  <?php
2
 
3
- class SynvedConnectKey
4
- {
5
- const STATE_OK = 0x01;
6
- const STATE_FAIL = 0x02;
7
- const STATE_MISMATCH = 0x03;
8
- const STATE_ONLINE_FAIL = 0x04;
9
- }
10
-
11
- function synved_connect_key_item_list($key)
12
- {
13
- // Note, this is just used to retrieve info from a textual key and is not used yet
14
- $key_clear = pack('H*', $key);
15
- $key_items = json_decode($key_clear, true);
16
-
17
- return $key_items;
18
- }
19
-
20
- function synved_connect_key_item($key, $item_id)
21
- {
22
- $key_items = synved_connect_key_item_list($key);
23
-
24
- if (isset($key_items[$item_id]))
25
- {
26
- return $key_items[$item_id];
27
- }
28
-
29
- return null;
30
- }
31
-
32
- function synved_connect_key_component($key)
33
- {
34
- return synved_connect_key_item($key, 'component');
35
- }
36
-
37
- function synved_connect_key_domain($key)
38
- {
39
- return synved_connect_key_item($key, 'domain');
40
- }
41
-
42
- function synved_connect_key_owner($key)
43
- {
44
- return synved_connect_key_item($key, 'owner');
45
- }
46
-
47
  function synved_connect_key_item_match($item, $item_list)
48
  {
49
  if (is_string($item_list))
50
  {
51
  $item_key = $item_list;
52
-
53
  if ($item == $item_key)
54
  {
55
  return true;
56
  }
57
-
58
  $item_key = '/' . $item_key . '/';
59
-
60
  if (preg_match($item_key, $item))
61
  {
62
  return true;
63
  }
64
  }
65
- else if (is_array($item_list))
66
- {
67
- // XXX TODO
68
- }
69
-
70
- return false;
71
- }
72
 
73
- function synved_connect_key_component_state($key, $component, $online_check = false)
74
- {
75
- $key_component = synved_connect_key_component($key);
76
- $key_domain = synved_connect_key_domain($key);
77
-
78
- if (synved_connect_key_item_match($component, $key_component))
79
- {
80
- if ($online_check)
81
- {
82
- // XXX perform online check
83
- }
84
-
85
- if (synved_connect_key_item_match($_SERVER['SERVER_NAME'], $key_domain))
86
- {
87
- return SynvedConnectKey::STATE_OK;
88
- }
89
-
90
- return SynvedConnectKey::STATE_MISMATCH;
91
- }
92
-
93
- return SynvedConnectKey::STATE_FAIL;
94
- }
95
-
96
- function synved_connect_key_component_validate($key, $component, $online_check = false)
97
- {
98
- $component_state = synved_connect_key_component_state($key, $component, $online_check);
99
-
100
- if ($component_state == SynvedConnectKey::STATE_OK)
101
- {
102
- return true;
103
- }
104
-
105
  return false;
106
  }
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  function synved_connect_key_item_match($item, $item_list)
4
  {
5
  if (is_string($item_list))
6
  {
7
  $item_key = $item_list;
8
+
9
  if ($item == $item_key)
10
  {
11
  return true;
12
  }
13
+
14
  $item_key = '/' . $item_key . '/';
15
+
16
  if (preg_match($item_key, $item))
17
  {
18
  return true;
19
  }
20
  }
 
 
 
 
 
 
 
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  return false;
23
  }
synved-connect/synved-connect-sponsor.php CHANGED
@@ -124,7 +124,7 @@ function synved_connect_sponsor_list($filter = null)
124
  {
125
  $sponsor_value = $sponsor_item[$filter_key];
126
 
127
- if (synved_connect_key_item_match($sponsor_value, $filter_value))
128
  {
129
  $final_list[$sponsor_key] = $sponsor_item;
130
  }
@@ -180,16 +180,9 @@ function synved_connect_sponsor_item_pick($filter = null)
180
 
181
  function synved_connect_sponsor_item($component = null, $filter = null)
182
  {
183
- $sponsor = null;
184
 
185
- // for now it is valid to have null $component
186
- //if ($component != null)
187
- {
188
- $sponsor_id = synved_connect_id_get($component);
189
- $sponsor = synved_connect_sponsor_item_by_id($sponsor_id, $filter);
190
- }
191
-
192
- return $sponsor;
193
  }
194
 
195
  function synved_connect_sponsor_link(array $sponsor_item = null)
124
  {
125
  $sponsor_value = $sponsor_item[$filter_key];
126
 
127
+ if (true === synved_connect_key_item_match($sponsor_value, $filter_value))
128
  {
129
  $final_list[$sponsor_key] = $sponsor_item;
130
  }
180
 
181
  function synved_connect_sponsor_item($component = null, $filter = null)
182
  {
183
+ $sponsor_id = synved_connect_id_get($component);
184
 
185
+ return synved_connect_sponsor_item_by_id($sponsor_id, $filter);
 
 
 
 
 
 
 
186
  }
187
 
188
  function synved_connect_sponsor_link(array $sponsor_item = null)
synved-connect/synved-connect-support.php CHANGED
@@ -29,16 +29,3 @@ function synved_connect_support_social_follow_render()
29
 
30
  return $out;
31
  }
32
-
33
- function synved_connect_support_social_follow_render_small()
34
- {
35
- $uri = synved_connect_path_uri();
36
-
37
- $out = null;
38
-
39
- $out .= '<span>';
40
- $out .= '<a target="_blank" href="https://twitter.com/synved" title="' . __('Follow Us on Twitter!', 'synved-connect') . '"><img alt="twitter" style="vertical-align:middle;" src="' . esc_url($uri . '/image/small/twitter.png') . '"></a></div>';
41
- $out .= '</span>';
42
-
43
- return $out;
44
- }
29
 
30
  return $out;
31
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
synved-connect/synved-connect.php CHANGED
@@ -16,57 +16,15 @@ NO LIABILITY
16
  In no event shall Synved Ltd. be liable to you or any third party for any direct or indirect, special, incidental, or consequential damages in connection with or arising from errors, omissions, delays or other cause of action that may be attributed to your use of any product, support, services, information or software provided, including, but not limited to, lost profits or lost data, even if Synved Ltd. had been advised of the possibility of such damages.
17
  */
18
 
19
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-connect-key.php');
20
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-connect-component.php');
21
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-connect-credit.php');
22
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-connect-support.php');
23
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-connect-sponsor.php');
24
 
 
25
 
26
- define('SYNVED_CONNECT_LOADED', true);
27
- define('SYNVED_CONNECT_VERSION', 100000004);
28
- define('SYNVED_CONNECT_VERSION_STRING', '1.0.4');
29
- define('SYNVED_WP_MODERN_VERSION', '4.1');
30
 
31
-
32
- $synved_connect = array();
33
-
34
-
35
- function synved_connect_version()
36
- {
37
- return SYNVED_CONNECT_VERSION;
38
- }
39
-
40
- function synved_connect_version_string()
41
- {
42
- return SYNVED_CONNECT_VERSION_STRING;
43
- }
44
-
45
- function synved_connect_object()
46
- {
47
- global $synved_connect;
48
-
49
- return $synved_connect;
50
- }
51
-
52
- function synved_connect_server_get()
53
- {
54
- global $synved_connect;
55
-
56
- if (isset($synved_connect['server']))
57
- {
58
- return $synved_connect['server'];
59
- }
60
-
61
- return null;
62
- }
63
-
64
- function synved_connect_server_set($server)
65
- {
66
- global $synved_connect;
67
-
68
- $synved_connect['server'] = $server;
69
- }
70
 
71
  function synved_connect_path_uri($path = null)
72
  {
@@ -97,50 +55,40 @@ function synved_connect_path_uri($path = null)
97
 
98
  function synved_connect_id_get($component = null, $part = null)
99
  {
100
- $option_key = null;
101
 
102
  if ($component != null)
103
  {
104
  $option_key = 'component_' . $component;
105
  }
106
- else
107
- {
108
- $option_key = 'default';
109
- }
110
 
111
  $id = get_option('synved_connect_id_' . $option_key);
112
 
113
  return $id;
114
  }
115
 
116
- function synved_connect_id_set($component = null, $sponsor_id)
117
- {
118
- $option_key = null;
119
-
120
- if ($component != null)
121
- {
122
- $option_key = 'component_' . $component;
123
- }
124
- else
125
- {
126
- $option_key = 'default';
127
- }
128
-
129
- return update_option('synved_connect_id_' . $option_key, $sponsor_id);
130
- }
131
-
132
-
133
  function synved_connect_enqueue_scripts()
134
  {
135
  $uri = synved_connect_path_uri();
 
136
 
137
- wp_register_style('synved-connect-admin', $uri . '/style/admin.css', false, '1.0');
 
 
 
 
 
138
 
139
  wp_enqueue_style('synved-connect-admin');
140
 
141
  if ( version_compare( get_bloginfo( 'version' ), SYNVED_WP_MODERN_VERSION, 'lt' ) ) {
142
- wp_register_style( 'synved-connect-old-wp-support-css', $uri . '/style/synved_old_wp_support.css', false,
143
- null, 'all' );
 
 
 
 
 
144
  wp_enqueue_style( 'synved-connect-old-wp-support-css' );
145
  }
146
  }
@@ -148,12 +96,11 @@ function synved_connect_enqueue_scripts()
148
  function synved_connect_init() {
149
  $install_date = get_option( 'synved_connect_install_date' );
150
 
151
- // Fresh install.
152
  if ( ! $install_date ) {
153
  update_option( 'synved_connect_install_date', time() );
154
  update_option( 'synved_version', SYNVED_VERSION );
155
  synved_option_set( 'synved_social', 'accepted_sharethis_terms', false );
156
-
157
  }
158
 
159
  $version = get_option( 'synved_version' );
16
  In no event shall Synved Ltd. be liable to you or any third party for any direct or indirect, special, incidental, or consequential damages in connection with or arising from errors, omissions, delays or other cause of action that may be attributed to your use of any product, support, services, information or software provided, including, but not limited to, lost profits or lost data, even if Synved Ltd. had been advised of the possibility of such damages.
17
  */
18
 
19
+ define( 'SYNVED_CONNECT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
 
 
 
 
20
 
21
+ const SYNVED_WP_MODERN_VERSION = '4.1';
22
 
23
+ include_once SYNVED_CONNECT_PLUGIN_PATH . 'synved-connect-key.php';
24
+ include_once SYNVED_CONNECT_PLUGIN_PATH . 'synved-connect-support.php';
25
+ include_once SYNVED_CONNECT_PLUGIN_PATH . 'synved-connect-sponsor.php';
 
26
 
27
+ $synved_connect = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  function synved_connect_path_uri($path = null)
30
  {
55
 
56
  function synved_connect_id_get($component = null, $part = null)
57
  {
58
+ $option_key = 'default';
59
 
60
  if ($component != null)
61
  {
62
  $option_key = 'component_' . $component;
63
  }
 
 
 
 
64
 
65
  $id = get_option('synved_connect_id_' . $option_key);
66
 
67
  return $id;
68
  }
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  function synved_connect_enqueue_scripts()
71
  {
72
  $uri = synved_connect_path_uri();
73
+ $dir = plugin_dir_path(__FILE__);
74
 
75
+ wp_register_style(
76
+ 'synved-connect-admin',
77
+ $uri . '/style/admin.css',
78
+ false,
79
+ filemtime($dir . '/style/admin.css')
80
+ );
81
 
82
  wp_enqueue_style('synved-connect-admin');
83
 
84
  if ( version_compare( get_bloginfo( 'version' ), SYNVED_WP_MODERN_VERSION, 'lt' ) ) {
85
+ wp_register_style(
86
+ 'synved-connect-old-wp-support-css',
87
+ $uri . '/style/synved_old_wp_support.css',
88
+ false,
89
+ filemtime( $dir . '/style/synved_old_wp_support.css' ),
90
+ 'all'
91
+ );
92
  wp_enqueue_style( 'synved-connect-old-wp-support-css' );
93
  }
94
  }
96
  function synved_connect_init() {
97
  $install_date = get_option( 'synved_connect_install_date' );
98
 
99
+ // Fresh installation.
100
  if ( ! $install_date ) {
101
  update_option( 'synved_connect_install_date', time() );
102
  update_option( 'synved_version', SYNVED_VERSION );
103
  synved_option_set( 'synved_social', 'accepted_sharethis_terms', false );
 
104
  }
105
 
106
  $version = get_option( 'synved_version' );
synved-option/addons/option-type-addon/addon-handle.php DELETED
@@ -1,2 +0,0 @@
1
- <?php
2
- // Silence is golden.
 
 
synved-option/addons/option-type-addon/addon-render.php DELETED
@@ -1,2 +0,0 @@
1
- <?php
2
- // Silence is golden.
 
 
synved-option/addons/option-type-addon/option-type-addon.php CHANGED
@@ -1,199 +1,208 @@
1
  <?php
2
 
3
- if (!function_exists('synved_option_render_type_addon'))
4
- {
5
- function synved_option_addon_type_addon_version()
6
- {
7
- return 100000003;
8
- }
9
 
10
- function synved_option_render_type_addon($id, $name, $item, $out_name, $extra = null)
11
- {
12
- $type = synved_option_item_type($item);
13
- $folder = synved_option_item_property($item, 'folder');
14
- $out_id = isset($extra['out_id']) ? $extra['out_id'] : null;
15
- $label = isset($extra['label']) ? $extra['label'] : null;
16
- $out = null;
17
-
18
- $out .= '<div class="synved-option-overlay-markup snvdopt" style="display:none;"><div class="overlay-ui"><div id="' . $out_id . '_overlay_container' . '" class="overlay-container">&nbsp;</div><div class="overlay-message">' . __('Click "Upload" and select the addon file, "' . $folder . '.zip". Only 1 file can be selected.', 'synved-option') . '</div>' . __('Progress', 'synved-option') . ': <div class="overlay-progress"></div></div><input id="' . $out_id . '_overlay_button' . '" type="button" class="overlay-button button-primary" value="' . __('Upload', 'synved-option') . '"/></div>';
19
- $out .= '<div class="synved-option-item-info" style="display:none;">' . "\n" . json_encode(array('id' => $id, 'name' => $name)) . "\n" . '</div>';
20
- $out .= '<input type="hidden" name="' . synved_option_render_field_name($id, $name . '_info_') . '" value="' . $type . '" />';
21
- $out .= '<input name="' . $out_name . '" id="' . $out_id . '" type="button" value="' . $label .'" class="button-secondary synved-option-overlay-button" />';
22
- $out .= '<input type="hidden" name="synved_option_addon_uploaded" value="0" />';
23
-
24
- return $out;
25
- }
 
26
 
27
- function synved_option_item_addon_install($id, $name, $item)
28
- {
29
- $return = null;
30
- $type = synved_option_item_type($item);
31
- $target = synved_option_item_property($item, 'target');
32
- $folder = synved_option_item_property($item, 'folder');
33
- $field_name = synved_option_name_default($id);
34
- $path = null;
35
-
36
- if (file_exists($target))
37
- {
38
- $path = $target;
39
- }
40
 
41
- if ($type != 'addon' || $path == null)
42
- {
43
- return false;
44
- }
45
-
46
- $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
47
-
48
- if (substr($path, -1) != DIRECTORY_SEPARATOR)
49
- {
50
- $path .= DIRECTORY_SEPARATOR;
51
  }
52
-
53
- if (isset($_FILES[$field_name]))
54
- {
55
- foreach ($_FILES[$field_name]["error"] as $key => $error)
56
- {
57
- if ($key == $name && $error == UPLOAD_ERR_OK)
58
- {
59
- $tmp_name = $_FILES[$field_name]["tmp_name"][$key];
60
- $name = $_FILES[$field_name]["name"][$key];
61
- $tmpfname = wp_tempnam($name . '.zip');
62
-
63
- if (move_uploaded_file($tmp_name, $tmpfname))
64
- {
65
- global $wp_filesystem;
66
-
67
- $unzip_path = realpath($path);
68
- $dirs = glob($path . '*', GLOB_ONLYDIR);
69
-
70
- if ($wp_filesystem != null)
71
- {
72
- $unzip_path = $wp_filesystem->find_folder($unzip_path);
73
- }
74
-
75
- wp_mkdir_p(realpath($path));
76
- $return = unzip_file($tmpfname, $unzip_path);
77
-
78
- if ($wp_filesystem != null)
79
- {
80
- $wp_filesystem->delete($tmpfname);
81
- }
82
-
83
- $dirs_new = glob($path . '*', GLOB_ONLYDIR);
84
- $dirs_diff = array_values(array_diff($dirs_new, $dirs));
85
- $addon_path = $path;
86
-
87
- if ($dirs_diff != null)
88
- {
89
- $folder_path = null;
90
-
91
- foreach ($dirs_diff as $dir)
92
- {
93
- if (basename($dir) == $folder)
94
- {
95
- $folder_path = $dir;
96
- }
 
 
97
  }
98
-
99
- // XXX no correct path, was unzip successful?
100
- if ($folder_path == null)
101
- {
102
- $folder_path = $dirs_diff[0];
 
103
  }
104
-
105
- $addon_path = $folder_path;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
-
108
- synved_option_set($id, $name, $addon_path);
109
  }
110
  }
111
  }
 
 
112
  }
113
-
114
- return $return;
115
- }
116
 
117
- function synved_option_ajax_type_addon($action, $params)
118
- {
119
- $response = null;
120
-
121
- if (current_user_can('upload_files') && current_user_can('install_plugins'))
122
- {
123
- $id = isset($params['id']) ? $params['id'] : null;
124
- $name = isset($params['name']) ? $params['name'] : null;
125
-
126
- if ($id != null && $name != null)
127
- {
128
- $item = synved_option_item_find($id, $name);
129
-
130
- if ($item != null)
131
- {
132
- $return = null;
133
- $error_list = array();
134
-
135
- try
136
- {
137
- $page_name = synved_option_item_page($id, $name);
138
- $page = synved_option_item($id, $page_name);
139
- $parent = synved_option_item_parent($page);
140
- $url = wp_nonce_url($parent . '?page=' . $page_name, 'synved-option');
141
-
142
- ob_start();
143
- $old_err = error_reporting(0);
144
- $credentials = request_filesystem_credentials($url);
145
- $form = ob_get_clean();
146
- error_reporting($old_err);
147
-
148
- ob_start();
149
- var_dump($_POST);
150
- $posted = ob_get_clean();
151
-
152
- if ($credentials === false)
153
- {
154
- $response['result'] = 'ERROR';
155
- $response['error'] = 'NO_CREDS';
156
- $response['creds_form'] = $form;
157
- $response['posted'] = $posted;
 
 
 
 
 
 
 
 
 
158
  }
159
- else if (WP_Filesystem($credentials))
160
- {
161
- $return = synved_option_item_addon_install($id, $name, $item);
162
  }
163
  }
164
- catch (Exception $ex)
165
- {
166
- $return = null;
167
- }
168
-
169
- if ($return != null)
170
- {
171
- $response['result'] = 'OK';
172
- }
173
  }
174
  }
 
 
175
  }
176
-
177
- return $response;
178
- }
179
 
180
- function synved_option_enqueue_scripts_type_addon()
181
- {
182
- $uri = synved_option_path_uri('addons/' . basename(dirname(__FILE__)));
183
-
184
- wp_register_style('synved-option-type-addon-admin', $uri . '/style/admin.css', array('jquery-ui', 'wp-jquery-ui-dialog'), '1.0');
185
-
186
- wp_register_script('synved-option-type-addon-script-custom', $uri . '/script/custom.js', array('jquery', 'thickbox', 'jquery-ui-core', 'jquery-ui-progressbar', 'jquery-ui-dialog'), '1.0.0');
187
-
188
- //wp_enqueue_style('synved-option-type-addon-admin');
189
-
190
- wp_enqueue_script('plupload-all');
191
- wp_enqueue_script('synved-option-type-addon-script-custom');
192
- }
193
 
194
- if (is_admin())
195
- {
196
- add_action('admin_enqueue_scripts', 'synved_option_enqueue_scripts_type_addon');
197
- }
 
 
 
 
 
 
 
 
 
 
198
 
199
  }
1
  <?php
2
 
3
+ if ( ! function_exists( 'synved_option_render_type_addon' ) ) {
 
 
 
 
 
4
 
5
+ /**
6
+ * Render type addon.
7
+ *
8
+ * @param $id
9
+ * @param $name
10
+ * @param $item
11
+ * @param $out_name
12
+ * @param $extra
13
+ *
14
+ * @return string
15
+ */
16
+ function synved_option_render_type_addon( $id, $name, $item, $out_name, $extra = null ) {
17
+ $type = synved_option_item_type( $item );
18
+ $folder = synved_option_item_property( $item, 'folder' );
19
+ $out_id = isset( $extra['out_id'] ) ? $extra['out_id'] : null;
20
+ $label = isset( $extra['label'] ) ? $extra['label'] : null;
21
+ $out = null;
22
 
23
+ $out .= '<div class="synved-option-overlay-markup snvdopt" style="display:none;"><div class="overlay-ui"><div id="' . $out_id . '_overlay_container' . '" class="overlay-container">&nbsp;</div><div class="overlay-message">' . __( 'Click "Upload" and select the addon file, "' . $folder . '.zip". Only 1 file can be selected.',
24
+ 'synved-option' ) . '</div>' . __( 'Progress',
25
+ 'synved-option' ) . ': <div class="overlay-progress"></div></div><input id="' . $out_id . '_overlay_button' . '" type="button" class="overlay-button button-primary" value="' . __( 'Upload',
26
+ 'synved-option' ) . '"/></div>';
27
+ $out .= '<div class="synved-option-item-info" style="display:none;">' . "\n" . json_encode( [ 'id' => $id,
28
+ 'name' => $name,
29
+ ] ) . "\n" . '</div>';
30
+ $out .= '<input type="hidden" name="' . synved_option_render_field_name( $id,
31
+ $name . '_info_' ) . '" value="' . $type . '" />';
32
+ $out .= '<input name="' . $out_name . '" id="' . $out_id . '" type="button" value="' . $label . '" class="button-secondary synved-option-overlay-button" />';
33
+ $out .= '<input type="hidden" name="synved_option_addon_uploaded" value="0" />';
 
 
34
 
35
+ return $out;
 
 
 
 
 
 
 
 
 
36
  }
37
+
38
+ /**
39
+ * Item addon install.
40
+ *
41
+ * @param $id
42
+ * @param $name
43
+ * @param $item
44
+ *
45
+ * @return bool|true|WP_Error|null
46
+ */
47
+ function synved_option_item_addon_install( $id, $name, $item ) {
48
+ $return = null;
49
+ $type = synved_option_item_type( $item );
50
+ $target = synved_option_item_property( $item, 'target' );
51
+ $folder = synved_option_item_property( $item, 'folder' );
52
+ $field_name = synved_option_name_default( $id );
53
+ $path = null;
54
+
55
+ if ( file_exists( $target ) ) {
56
+ $path = $target;
57
+ }
58
+
59
+ if ( $type != 'addon' || $path == null ) {
60
+ return false;
61
+ }
62
+
63
+ $path = str_replace( [ '/', '\\' ], DIRECTORY_SEPARATOR, $path );
64
+
65
+ if ( substr( $path, - 1 ) != DIRECTORY_SEPARATOR ) {
66
+ $path .= DIRECTORY_SEPARATOR;
67
+ }
68
+
69
+ if ( isset( $_FILES[ $field_name ] ) ) {
70
+ foreach ( $_FILES[ $field_name ]["error"] as $key => $error ) {
71
+ if ( $key == $name && $error == UPLOAD_ERR_OK ) {
72
+ $tmp_name = $_FILES[ $field_name ]["tmp_name"][ $key ];
73
+ $name = $_FILES[ $field_name ]["name"][ $key ];
74
+ $tmpfname = wp_tempnam( $name . '.zip' );
75
+
76
+ if ( move_uploaded_file( $tmp_name, $tmpfname ) ) {
77
+ global $wp_filesystem;
78
+
79
+ $unzip_path = realpath( $path );
80
+ $dirs = glob( $path . '*', GLOB_ONLYDIR );
81
+
82
+ if ( false === empty( $wp_filesystem ) ) {
83
+ $unzip_path = $wp_filesystem->find_folder( $unzip_path );
84
  }
85
+
86
+ wp_mkdir_p( realpath( $path ) );
87
+ $return = unzip_file( $tmpfname, $unzip_path );
88
+
89
+ if ( $wp_filesystem != null ) {
90
+ $wp_filesystem->delete( $tmpfname );
91
  }
92
+
93
+ $dirs_new = glob( $path . '*', GLOB_ONLYDIR );
94
+ $dirs_diff = array_values( array_diff( $dirs_new, $dirs ) );
95
+ $addon_path = $path;
96
+
97
+ if ( false === empty( $dirs_diff ) ) {
98
+ $folder_path = null;
99
+
100
+ foreach ( $dirs_diff as $dir ) {
101
+ if ( basename( $dir ) == $folder ) {
102
+ $folder_path = $dir;
103
+ }
104
+ }
105
+
106
+ if ( false === empty( $folder_path ) ) {
107
+ $folder_path = $dirs_diff[0];
108
+ }
109
+
110
+ $addon_path = $folder_path;
111
+ }
112
+
113
+ synved_option_set( $id, $name, $addon_path );
114
  }
 
 
115
  }
116
  }
117
  }
118
+
119
+ return $return;
120
  }
 
 
 
121
 
122
+ /**
123
+ * Ajax type addon.
124
+ *
125
+ * @param $action
126
+ * @param $params
127
+ *
128
+ * @return array
129
+ */
130
+ function synved_option_ajax_type_addon( $action, $params ) {
131
+ $response = null;
132
+
133
+ check_ajax_referer('synved-option-submit-nonce', 'synvedSecurity');
134
+
135
+ if ( current_user_can( 'upload_files' ) && current_user_can( 'install_plugins' ) ) {
136
+ $id = isset( $params['id'] ) ? $params['id'] : null;
137
+ $name = isset( $params['name'] ) ? $params['name'] : null;
138
+
139
+ if ( false === empty( $id ) && false === empty( $name ) ) {
140
+ $item = synved_option_item_find( $id, $name );
141
+
142
+ if ( $item != null ) {
143
+ $return = null;
144
+ $error_list = [];
145
+
146
+ try {
147
+ $page_name = synved_option_item_page( $id, $name );
148
+ $page = synved_option_item( $id, $page_name );
149
+ $parent = synved_option_item_parent( $page );
150
+ $url = wp_nonce_url( $parent . '?page=' . $page_name, 'synved-option' );
151
+
152
+ ob_start();
153
+ $old_err = error_reporting( 0 );
154
+ $credentials = request_filesystem_credentials( $url );
155
+ $form = ob_get_clean();
156
+ error_reporting( $old_err );
157
+
158
+ ob_start();
159
+ var_dump( $_POST );
160
+ $posted = ob_get_clean();
161
+
162
+ if ( $credentials === false ) {
163
+ $response['result'] = 'ERROR';
164
+ $response['error'] = 'NO_CREDS';
165
+ $response['creds_form'] = $form;
166
+ $response['posted'] = $posted;
167
+ } elseif ( WP_Filesystem( $credentials ) ) {
168
+ $return = synved_option_item_addon_install( $id, $name, $item );
169
+ }
170
+ } catch ( Exception $ex ) {
171
+ $return = null;
172
  }
173
+
174
+ if ( $return != null ) {
175
+ $response['result'] = 'OK';
176
  }
177
  }
 
 
 
 
 
 
 
 
 
178
  }
179
  }
180
+
181
+ return $response;
182
  }
 
 
 
183
 
184
+ /**
185
+ * Enqueue scripts.
186
+ *
187
+ * @return void
188
+ */
189
+ function synved_option_enqueue_scripts_type_addon() {
190
+ $uri = synved_option_path_uri( 'addons/' . basename( dirname( __FILE__ ) ) );
191
+ $dir = plugin_dir_path(__FILE__);
 
 
 
 
 
192
 
193
+ wp_register_script(
194
+ 'synved-option-type-addon-script-custom',
195
+ $uri . '/script/custom.js',
196
+ [ 'jquery', 'thickbox', 'jquery-ui-core', 'jquery-ui-progressbar', 'jquery-ui-dialog' ],
197
+ filemtime( $dir . 'script/custom.js' )
198
+ );
199
+
200
+ wp_enqueue_script( 'plupload-all' );
201
+ wp_enqueue_script( 'synved-option-type-addon-script-custom' );
202
+ }
203
+
204
+ if ( is_admin() ) {
205
+ add_action( 'admin_enqueue_scripts', 'synved_option_enqueue_scripts_type_addon' );
206
+ }
207
 
208
  }
synved-option/addons/option-type-addon/script/custom.js CHANGED
@@ -5,278 +5,231 @@
5
  // Copyright (c) 2011 Synved Ltd.
6
  // All rights reserved
7
 
8
- jQuery(document).ready(function() {
9
 
10
- jQuery('.synved-option-overlay-button').click(function() {
11
- tb_show(this.value, '#TB_inline');
12
- var tb = jQuery("#TB_window");
13
 
14
- if (tb)
15
- {
16
- var tbCont = tb.find('#TB_ajaxContent');
17
- tbCont.css({ width : tbCont.parent().width(), height : '100%' });
18
 
19
- if (!tbCont /*|| !tbCont.is(":visible")*/)
20
- {
21
- //tbCont = tb.find('#TB_iframeContent');
22
- }
23
-
24
- var jthis = jQuery(this);
25
- var info = jthis.prevAll('.synved-option-item-info:first').html();
26
-
27
- var infoObj = null;
28
-
29
- try
30
- {
31
- infoObj = jQuery.parseJSON(info);
32
- }
33
- catch (ex)
34
- {
35
- infoObj = jQuery.parseJSON(jQuery('<div/>').html(info).text());
36
  }
37
-
38
- var markup = jthis.prevAll('.synved-option-overlay-markup');
39
-
40
- if (markup)
41
- {
42
- markup = markup.clone();
43
- var progressBar = markup.find('.overlay-progress');
44
- var containerId = markup.find('.overlay-container').attr('id');
45
- var buttonId = markup.find('.overlay-button').attr('id');
46
- var fileField = jthis.attr('name');
47
-
48
- var counter = 0;
49
- containerId += '_tb';
50
- buttonId += '_tb';
51
-
52
- while (jQuery('#' + containerId + counter.toString()).size() > 0)
53
- {
54
- counter += 1;
55
- }
56
-
57
- containerId += counter.toString();
58
- buttonId += counter.toString();
59
-
60
- markup.find('.overlay-container').attr('id', containerId);
61
- markup.find('.overlay-button').attr('id', buttonId);
62
-
63
- markup.append(jQuery('<div class="overlay-message overlay-status" />'));
64
- markup.append(jQuery('<button class="button-primary overlay-close">Close and continue</button>').hide().click(function () {
65
- tb_remove();
66
- window.location = window.location;
67
- }));
68
-
69
- tbCont.html(markup);
70
- markup.show();
71
-
72
- // markup.append(containerId);
73
- // markup.append('<br/>');
74
- // markup.append(buttonId);
75
- // markup.append('<br/>');
76
- // markup.append(fileField);
77
-
78
- progressBar.progressbar();
79
-
80
- var finishInstall = function (message, error)
81
- {
82
- var status = markup.find('.overlay-status');
83
-
84
- if (status != null)
85
- {
86
- if (error != undefined && error == true)
87
- {
88
- status.css('color', '#b06066');
89
- }
90
- else
91
- {
92
- status.css('color', '#66b060');
93
- }
94
-
95
- status.html(message);
96
- }
97
-
98
- markup.find('#' + buttonId).hide();
99
- markup.find('.overlay-close').css('display', 'inline');
100
- };
101
-
102
- var params = infoObj;
103
- params = JSON.stringify(params);
104
-
105
- var uploader = new plupload.Uploader({
106
- runtimes: 'html5,flash,silverlight,html4',
107
- autostart : true,
108
- browse_button: buttonId,
109
- container: containerId,
110
- //drop_element: '',
111
- file_data_name: fileField,
112
- max_file_size: '8mb',
113
- max_file_count: 1,
114
  flash_swf_url: SynvedOptionVars.flash_swf_url,
115
  silverlight_xap_url: SynvedOptionVars.silverlight_xap_url,
116
- url: SynvedOptionVars.ajaxurl,
117
- multipart: true,
118
  urlstream_upload: true,
119
- multipart_params :
120
- {
121
- action : 'synved_option',
122
- synvedSecurity : SynvedOptionVars.synvedSecurity,
123
- synvedAction : 'install-addon',
124
- synvedParams : params
125
- },
126
- filters : [
127
- {title : "Zip files", extensions : "zip"}
128
  ],
129
  multiple_queues: true,
130
- debug: true
131
- });
132
-
133
- uploader.bind('Init', function(up) {
134
- up.bind('FilesAdded', function(up, files) {
135
-
136
- progressBar.progressbar('option', 'value', 0);
137
-
138
- if (files.length > 1)
139
- {
140
- up.splice(1);
141
- }
142
-
143
- plupload.each(files, function(file){
144
- });
145
 
146
  up.refresh();
147
  up.start();
148
- });
149
- });
150
-
151
- uploader.bind('UploadProgress', function(up, file) {
152
- progressBar.progressbar('option', 'value', file.percent);
153
- });
154
-
155
- uploader.bind('FileUploaded', function(up, file, info) {
156
  var response = info.response;
157
  var responseObj = null;
158
-
159
- try
160
- {
161
- responseObj = jQuery.parseJSON(response);
162
- }
163
- catch (ex)
164
- {
165
- responseObj = jQuery.parseJSON(jQuery('<div/>').html(response).text());
166
  }
167
-
168
- if (responseObj != null)
169
- {
170
- //tbCont.append('FileUploaded ' + JSON.stringify(file) + ' INFO: ' + jQuery('<div/>').text(JSON.stringify(info)).html());
171
-
172
  var result = responseObj['result'];
173
-
174
- if (result == 'ERROR')
175
- {
176
- progressBar.progressbar('option', 'value', 0);
177
-
178
  var error = null;
179
-
180
- if ('error' in responseObj)
181
- {
182
  error = responseObj['error'];
183
  }
184
-
185
- if (error == 'NO_CREDS')
186
- {
187
- var form = jQuery('<div>' + responseObj['creds_form'] + '</div>').find('form');
188
  var submitData = up.settings.multipart_params;
189
-
190
- if (submitData)
191
- {
192
- for (var i in submitData)
193
- {
194
- form.find('[name=' + i + ']').val(submitData[i]);
195
  }
196
  }
197
-
198
- form.data('submit-ok', false);
199
- form.submit(function () {
200
- form.data('submit-ok', true);
201
- form.dialog('close');
202
-
203
  return false;
204
- });
205
-
206
- form.find('.wrap .icon32').attr('id', 'icon-index');
207
-
208
- form.dialog({
209
- dialogClass : 'wp-dialog synved-option-creds-form',
210
  title: 'Connection Details',
211
  width: 550,
212
  modal: true,
213
  resizable: false,
214
  close: function() {
215
- if (form.data('submit-ok') == true)
216
- {
217
  var formData = form.serializeArray();
218
  var submitData = {};
219
-
220
- for (var i in formData)
221
- {
222
  submitData[formData[i].name] = formData[i].value;
223
  }
224
-
225
- for (var i in up.settings.multipart_params)
226
- {
227
  submitData[i] = up.settings.multipart_params[i];
228
  }
229
-
230
  up.settings.multipart_params = submitData;
231
-
232
- for (var f in up.files)
233
- {
234
  up.files[f].loaded = 0;
235
  up.files[f].percent = 0;
236
  up.files[f].status = plupload.STOPPED;
237
  }
238
-
239
  up.refresh();
240
  up.start();
 
 
241
  }
242
- else
243
- {
244
- finishInstall('Installation was canceled.', true);
245
- }
246
- }
247
- });
248
  }
249
- else
250
- {
251
- finishInstall('An error occurred.', true);
252
  }
253
- }
254
- else
255
- {
256
- if (result == 'OK')
257
- {
258
- finishInstall('Installation was successful.', false);
259
- }
260
-
261
- progressBar.progressbar('option', 'value', file.percent);
262
  }
263
  }
264
- });
265
-
266
- uploader.bind('Error', function(up, err) {
267
- console.log(err);
268
- finishInstall(err.message, true);
269
- });
270
-
271
- uploader.init();
272
- }
273
- else
274
- {
275
- tbCont.html('Error');
276
- }
277
  }
278
 
279
  return false;
280
- });
281
- });
282
 
5
  // Copyright (c) 2011 Synved Ltd.
6
  // All rights reserved
7
 
8
+ jQuery( document ).ready( function() {
9
 
10
+ jQuery( '.synved-option-overlay-button' ).click( function() {
11
+ tb_show( this.value, '#TB_inline' );
12
+ var tb = jQuery( "#TB_window" );
13
 
14
+ if ( tb ) {
15
+ var tbCont = tb.find( '#TB_ajaxContent' );
16
+ tbCont.css( { width: tbCont.parent().width(), height: '100%' } );
 
17
 
18
+ var jthis = jQuery( this );
19
+ var info = jthis.prevAll( '.synved-option-item-info:first' ).html();
20
+
21
+ var infoObj;
22
+
23
+ try {
24
+ infoObj = jQuery.parseJSON( info );
25
+ } catch ( ex ) {
26
+ infoObj = jQuery.parseJSON( jQuery( '<div/>' ).html( info ).text() );
 
 
 
 
 
 
 
 
27
  }
28
+
29
+ var markup = jthis.prevAll( '.synved-option-overlay-markup' );
30
+
31
+ if ( markup ) {
32
+ markup = markup.clone();
33
+ var progressBar = markup.find( '.overlay-progress' );
34
+ var containerId = markup.find( '.overlay-container' ).attr( 'id' );
35
+ var buttonId = markup.find( '.overlay-button' ).attr( 'id' );
36
+ var fileField = jthis.attr( 'name' );
37
+
38
+ var counter = 0;
39
+ containerId += '_tb';
40
+ buttonId += '_tb';
41
+
42
+ while ( jQuery( '#' + containerId + counter.toString() ).size() > 0 ) {
43
+ counter += 1;
44
+ }
45
+
46
+ containerId += counter.toString();
47
+ buttonId += counter.toString();
48
+
49
+ markup.find( '.overlay-container' ).attr( 'id', containerId );
50
+ markup.find( '.overlay-button' ).attr( 'id', buttonId );
51
+
52
+ markup.append( jQuery( '<div class="overlay-message overlay-status" />' ) );
53
+ markup.append( jQuery( '<button class="button-primary overlay-close">Close and continue</button>' ).hide().click( function() {
54
+ tb_remove();
55
+ window.location = window.location;
56
+ } ) );
57
+
58
+ tbCont.html( markup );
59
+ markup.show();
60
+
61
+ progressBar.progressbar();
62
+
63
+ var finishInstall = function( message, error ) {
64
+ var status = markup.find( '.overlay-status' );
65
+
66
+ if ( status != null ) {
67
+ if ( error != undefined && error == true ) {
68
+ status.css( 'color', '#b06066' );
69
+ } else {
70
+ status.css( 'color', '#66b060' );
71
+ }
72
+
73
+ status.html( message );
74
+ }
75
+
76
+ markup.find( '#' + buttonId ).hide();
77
+ markup.find( '.overlay-close' ).css( 'display', 'inline' );
78
+ };
79
+
80
+ var params = infoObj;
81
+ params = JSON.stringify( params );
82
+
83
+ var uploader = new plupload.Uploader( {
84
+ runtimes: 'html5,flash,silverlight,html4',
85
+ autostart: true,
86
+ browse_button: buttonId,
87
+ container: containerId,
88
+ file_data_name: fileField,
89
+ max_file_size: '8mb',
90
+ max_file_count: 1,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  flash_swf_url: SynvedOptionVars.flash_swf_url,
92
  silverlight_xap_url: SynvedOptionVars.silverlight_xap_url,
93
+ url: SynvedOptionVars.ajaxurl,
94
+ multipart: true,
95
  urlstream_upload: true,
96
+ multipart_params:
97
+ {
98
+ action: 'synved_option',
99
+ synvedSecurity: SynvedOptionVars.synvedSecurity,
100
+ synvedAction: 'install-addon',
101
+ synvedParams: params,
102
+ },
103
+ filters: [
104
+ { title: "Zip files", extensions: "zip" },
105
  ],
106
  multiple_queues: true,
107
+ debug: true,
108
+ } );
109
+
110
+ uploader.bind( 'Init', function( up ) {
111
+ up.bind( 'FilesAdded', function( up, files ) {
112
+
113
+ progressBar.progressbar( 'option', 'value', 0 );
114
+
115
+ if ( files.length > 1 ) {
116
+ up.splice( 1 );
117
+ }
118
+
119
+ plupload.each( files, function( file ) {
120
+ } );
 
121
 
122
  up.refresh();
123
  up.start();
124
+ } );
125
+ } );
126
+
127
+ uploader.bind( 'UploadProgress', function( up, file ) {
128
+ progressBar.progressbar( 'option', 'value', file.percent );
129
+ } );
130
+
131
+ uploader.bind( 'FileUploaded', function( up, file, info ) {
132
  var response = info.response;
133
  var responseObj = null;
134
+
135
+ try {
136
+ responseObj = jQuery.parseJSON( response );
137
+ } catch ( ex ) {
138
+ responseObj = jQuery.parseJSON( jQuery( '<div/>' ).html( response ).text() );
 
 
 
139
  }
140
+
141
+ if ( responseObj != null ) {
142
+
 
 
143
  var result = responseObj['result'];
144
+
145
+ if ( result == 'ERROR' ) {
146
+ progressBar.progressbar( 'option', 'value', 0 );
147
+
 
148
  var error = null;
149
+
150
+ if ( 'error' in responseObj ) {
 
151
  error = responseObj['error'];
152
  }
153
+
154
+ if ( error == 'NO_CREDS' ) {
155
+ var form = jQuery( '<div>' + responseObj['creds_form'] + '</div>' ).find( 'form' );
 
156
  var submitData = up.settings.multipart_params;
157
+
158
+ if ( submitData ) {
159
+ for ( var i in submitData ) {
160
+ form.find( '[name=' + i + ']' ).val( submitData[i] );
 
 
161
  }
162
  }
163
+
164
+ form.data( 'submit-ok', false );
165
+ form.submit( function() {
166
+ form.data( 'submit-ok', true );
167
+ form.dialog( 'close' );
168
+
169
  return false;
170
+ } );
171
+
172
+ form.find( '.wrap .icon32' ).attr( 'id', 'icon-index' );
173
+
174
+ form.dialog( {
175
+ dialogClass: 'wp-dialog synved-option-creds-form',
176
  title: 'Connection Details',
177
  width: 550,
178
  modal: true,
179
  resizable: false,
180
  close: function() {
181
+ if ( form.data( 'submit-ok' ) == true ) {
 
182
  var formData = form.serializeArray();
183
  var submitData = {};
184
+
185
+ for ( var i in formData ) {
 
186
  submitData[formData[i].name] = formData[i].value;
187
  }
188
+
189
+ for ( var i in up.settings.multipart_params ) {
 
190
  submitData[i] = up.settings.multipart_params[i];
191
  }
192
+
193
  up.settings.multipart_params = submitData;
194
+
195
+ for ( var f in up.files ) {
 
196
  up.files[f].loaded = 0;
197
  up.files[f].percent = 0;
198
  up.files[f].status = plupload.STOPPED;
199
  }
200
+
201
  up.refresh();
202
  up.start();
203
+ } else {
204
+ finishInstall( 'Installation was canceled.', true );
205
  }
206
+ },
207
+ } );
208
+ } else {
209
+ finishInstall( 'An error occurred.', true );
 
 
210
  }
211
+ } else {
212
+ if ( 'OK' === result ) {
213
+ finishInstall( 'Installation was successful.', false );
214
  }
215
+
216
+ progressBar.progressbar( 'option', 'value', file.percent );
 
 
 
 
 
 
 
217
  }
218
  }
219
+ } );
220
+
221
+ uploader.bind( 'Error', function( up, err ) {
222
+ console.log( err );
223
+ finishInstall( err.message, true );
224
+ } );
225
+
226
+ uploader.init();
227
+ } else {
228
+ tbCont.html( 'Error' );
229
+ }
 
 
230
  }
231
 
232
  return false;
233
+ } );
234
+ } );
235
 
synved-option/inc/SynvedOptionCallback.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Option callback class.
5
+ */
6
+ class SynvedOptionCallback {
7
+ private $_Object;
8
+ private $_Callback;
9
+ private $_Default;
10
+ private $_Params;
11
+
12
+ public function __construct( $callback, $object = null, $default = null, array $callback_parameters = null ) {
13
+ $this->_Object = $object;
14
+ $this->_Callback = $callback;
15
+ $this->_Default = $default;
16
+ $this->_Params = $callback_parameters;
17
+ }
18
+
19
+ public function __invoke( $arguments = null ) {
20
+ if ( ! is_array( $arguments ) || func_num_args() > 1 ) {
21
+ $arguments = func_get_args();
22
+ }
23
+
24
+ return $this->InvokeInternal( $arguments );
25
+ }
26
+
27
+ public function Invoke( $arguments = null ) {
28
+ if ( ! is_array( $arguments ) || func_num_args() > 1 ) {
29
+ $arguments = func_get_args();
30
+ }
31
+
32
+ return $this->InvokeInternal( $arguments );
33
+ }
34
+
35
+ protected function InvokeInternal( array $arguments = null ) {
36
+ $func = $this->_Callback;
37
+
38
+ if ( $this->_Object != null ) {
39
+ $func = [ $this->_Object, $func ];
40
+ }
41
+
42
+ $parameters = $this->_Params;
43
+
44
+ if ( $parameters != null ) {
45
+ $parameter_keys = array_keys( $parameters );
46
+ $count = count( $parameter_keys );
47
+ $argument_list = [];
48
+
49
+ for ( $i = 0; $i < $count; $i ++ ) {
50
+ $key = $parameter_keys[ $i ];
51
+ $parameter = $parameters[ $key ];
52
+ $value = isset( $parameter['default'] ) ? $parameter['default'] : null;
53
+
54
+ if ( isset( $arguments[ $key ] ) ) {
55
+ $value = $arguments[ $key ];
56
+ } elseif ( isset( $arguments[ $i ] ) ) {
57
+ $value = $arguments[ $i ];
58
+ }
59
+
60
+ $argument_list[ $i ] = $value;
61
+ }
62
+
63
+ $arguments = $argument_list;
64
+ }
65
+
66
+ if ( ! isset( $arguments[0] ) || $arguments[0] === null ) {
67
+ $arguments[0] = $this->_Default;
68
+ }
69
+
70
+ if ( is_callable( $func ) ) {
71
+ return call_user_func_array( $func, $arguments );
72
+ }
73
+
74
+ return $arguments[0];
75
+ }
76
+ }
synved-option/script/custom.js CHANGED
@@ -9,159 +9,156 @@ var synvedOptionmediaUploadInput = null;
9
 
10
  var SynvedOption = {
11
 
12
- performRequest: function (action, params)
13
- {
14
- if (params == undefined || params == null)
15
- {
16
- params = {}
17
  }
18
 
19
  jQuery.ajax(
20
  SynvedOptionVars.ajaxurl,
21
  {
22
- type : 'POST',
23
- data : {
24
- action : 'synved_option',
25
- synvedSecurity : SynvedOptionVars.synvedSecurity,
26
- synvedAction : action,
27
- synvedParams : params
28
  },
29
- success : function( response ) {
30
- SynvedOption.actionStarted(action, params, response, this);
31
  },
32
- error : function( jqXHR, textStatus, errorThrown ) {
33
- SynvedOption.actionFailed(action, params, errorThrown, this);
34
- }
35
- }
36
  );
37
  },
38
 
39
- actionStarted: function (action, params, response, request)
40
- {
41
 
42
  },
43
 
44
- actionFailed: function (action, params, error, request)
45
- {
46
 
47
  },
48
 
49
- handleOverlay: function (markup)
50
- {
51
 
52
- }
53
  };
54
 
55
- jQuery(document).ready(function() {
56
- jQuery('.synved-option-upload-button').click(function() {
57
- var formfield = jQuery(this).prevAll('input[type="text"]');
58
- var type = jQuery(this).prevAll('input[type="hidden"]').attr('value');
59
- synvedOptionmediaUploadInput = formfield;
60
- tb_show('', 'media-upload.php?type=' + type + '&amp;TB_iframe=true');
61
- return false;
62
- });
 
 
 
 
63
 
64
  var oldSendToEditor = null;
65
 
66
- if (window.send_to_editor)
67
- {
68
  oldSendToEditor = window.send_to_editor;
69
  }
70
 
71
- window.send_to_editor = function(html) {
72
- if (oldSendToEditor != null)
73
- {
74
- oldSendToEditor(html);
75
  }
76
 
77
- imgurl = jQuery('img',html).attr('src');
78
- jQuery(synvedOptionmediaUploadInput).val(imgurl);
79
- tb_remove();
80
- }
81
 
82
- jQuery('.synved-option-color-input-picker').each(function () {
83
- var it = jQuery(this);
84
- var input = it.prev('input.color-input');
85
- it.farbtastic(input);
86
 
87
- it.stop().css({opacity: 0, display: 'none'});
88
 
89
- input.focus(function (){
90
- jQuery(it).stop().css({display: 'block'}).animate({opacity: 1});
91
- })
92
- .blur(function () {
93
- jQuery(it).stop().animate({opacity: 0}).css({display: 'none'});
94
- });
95
- });
96
 
97
- jQuery('.synved-option-tag-selector').suggest(ajaxurl + '?action=ajax-tag-search&tax=post_tag', {multiple: true, multipleSep: ','});
 
 
 
98
 
99
- jQuery('.synved-option-reset-button').click(function (e) {
100
- var jthis = jQuery(this);
101
- var input = jthis.parentsUntil('tr').find('input, textarea');
102
 
103
- if (input.size() > 0)
104
- {
105
- var placeholder = input.attr('placeholder');
106
 
107
- if (placeholder != null)
108
- {
109
- input.val(placeholder);
110
  }
111
  }
112
 
113
  e.preventDefault();
114
 
115
  return false;
116
- });
117
- });
118
-
119
-
120
- (function ($, wp) {
121
-
122
- $(document).ready(function() {
123
- // Close review us.
124
- $( 'body' ).on( 'click', '#close-review-us', function () {
125
- wp.ajax.post( 'smf_ajax_hide_review', {
126
- nonce: ''
127
- } ).always( function ( results ) {
128
- $( '.smf-review-us' ).fadeOut();
129
- } );
130
- } );
131
- });
132
-
133
- /**
134
- * Handles "disable all features" switch button
135
- * @type {{init: synved_switcher.init}}
136
- */
137
- synved_switcher = {
138
- init: function (state) {
139
- var checkbox = $("#synved-disable");
140
-
141
- if (state) {
142
- checkbox.prop('checked', 'checked');
143
- } else {
144
- checkbox.removeProp('checked');
145
- }
146
-
147
- $("#synved-slider").on("click", function (e) {
148
-
149
- checkbox = $("#synved-disable");
150
- if (checkbox[0].checked) {
151
- if (confirm('This will decline ShareThis Terms of Service, please confirm.')) {
152
- window.location.href = SYNVED_DISABLE_FEATURE_URL;
153
- } else {
154
- var int = setInterval(function(){
155
- if (!checkbox[0].checked) {
156
- checkbox[0].checked = true;
157
- clearInterval(int);
158
- }
159
- }, 10);
160
- }
161
- } else { // disable
162
- window.location.href = SYNVED_ENABLE_FEATURE_URL;
163
- }
164
- });
165
- }
166
- };
167
- })( window.jQuery, window.wp );
9
 
10
  var SynvedOption = {
11
 
12
+ performRequest: function( action, params ) {
13
+ if ( params == undefined || params == null ) {
14
+ params = {};
 
 
15
  }
16
 
17
  jQuery.ajax(
18
  SynvedOptionVars.ajaxurl,
19
  {
20
+ type: 'POST',
21
+ data: {
22
+ action: 'synved_option',
23
+ synvedSecurity: SynvedOptionVars.synvedSecurity,
24
+ synvedAction: action,
25
+ synvedParams: params,
26
  },
27
+ success: function( response ) {
28
+ SynvedOption.actionStarted( action, params, response, this );
29
  },
30
+ error: function( jqXHR, textStatus, errorThrown ) {
31
+ SynvedOption.actionFailed( action, params, errorThrown, this );
32
+ },
33
+ },
34
  );
35
  },
36
 
37
+ actionStarted: function( action, params, response, request ) {
 
38
 
39
  },
40
 
41
+ actionFailed: function( action, params, error, request ) {
 
42
 
43
  },
44
 
45
+ handleOverlay: function( markup ) {
 
46
 
47
+ },
48
  };
49
 
50
+ jQuery( document ).ready( function() {
51
+ jQuery( '#sharethis_terms_notice' ).on( 'click', '.notice-dismiss', function( event ) {
52
+ jQuery.post( ajaxurl, { action: 'feather_hide_terms' } );
53
+ } );
54
+
55
+ jQuery( '.synved-option-upload-button' ).click( function() {
56
+ var formfield = jQuery( this ).prevAll( 'input[type="text"]' );
57
+ var type = jQuery( this ).prevAll( 'input[type="hidden"]' ).attr( 'value' );
58
+ synvedOptionmediaUploadInput = formfield;
59
+ tb_show( '', 'media-upload.php?type=' + type + '&amp;TB_iframe=true' );
60
+ return false;
61
+ } );
62
 
63
  var oldSendToEditor = null;
64
 
65
+ if ( window.send_to_editor ) {
 
66
  oldSendToEditor = window.send_to_editor;
67
  }
68
 
69
+ window.send_to_editor = function( html ) {
70
+ if ( oldSendToEditor != null ) {
71
+ oldSendToEditor( html );
 
72
  }
73
 
74
+ imgurl = jQuery( 'img', html ).attr( 'src' );
75
+ jQuery( synvedOptionmediaUploadInput ).val( imgurl );
76
+ tb_remove();
77
+ };
78
 
79
+ jQuery( '.synved-option-color-input-picker' ).each( function() {
80
+ var it = jQuery( this );
81
+ var input = it.prev( 'input.color-input' );
82
+ it.farbtastic( input );
83
 
84
+ it.stop().css( { opacity: 0, display: 'none' } );
85
 
86
+ input.focus( function() {
87
+ jQuery( it ).stop().css( { display: 'block' } ).animate( { opacity: 1 } );
88
+ } )
89
+ .blur( function() {
90
+ jQuery( it ).stop().animate( { opacity: 0 } ).css( { display: 'none' } );
91
+ } );
92
+ } );
93
 
94
+ jQuery( '.synved-option-tag-selector' ).suggest( ajaxurl + '?action=ajax-tag-search&tax=post_tag', {
95
+ multiple: true,
96
+ multipleSep: ',',
97
+ } );
98
 
99
+ jQuery( '.synved-option-reset-button' ).click( function( e ) {
100
+ var jthis = jQuery( this );
101
+ var input = jthis.parentsUntil( 'tr' ).find( 'input, textarea' );
102
 
103
+ if ( input.size() > 0 ) {
104
+ var placeholder = input.attr( 'placeholder' );
 
105
 
106
+ if ( placeholder != null ) {
107
+ input.val( placeholder );
 
108
  }
109
  }
110
 
111
  e.preventDefault();
112
 
113
  return false;
114
+ } );
115
+ } );
116
+
117
+ ( function( $, wp ) {
118
+
119
+ $( document ).ready( function() {
120
+ // Close review us.
121
+ $( 'body' ).on( 'click', '#close-review-us', function() {
122
+ wp.ajax.post( 'smf_ajax_hide_review', {
123
+ nonce: '',
124
+ } ).always( function( results ) {
125
+ $( '.smf-review-us' ).fadeOut();
126
+ } );
127
+ } );
128
+ } );
129
+
130
+ /**
131
+ * Handles "disable all features" switch button
132
+ * @type {{init: synved_switcher.init}}
133
+ */
134
+ synved_switcher = {
135
+ init: function( state ) {
136
+ var checkbox = $( "#synved-disable" );
137
+
138
+ if ( state ) {
139
+ checkbox.prop( 'checked', 'checked' );
140
+ } else {
141
+ checkbox.removeProp( 'checked' );
142
+ }
143
+
144
+ $( "#synved-slider" ).on( "click", function( e ) {
145
+
146
+ checkbox = $( "#synved-disable" );
147
+ if ( checkbox[0].checked ) {
148
+ if ( confirm( 'This will decline ShareThis Terms of Service, please confirm.' ) ) {
149
+ window.location.href = SYNVED_DISABLE_FEATURE_URL;
150
+ } else {
151
+ var int = setInterval( function() {
152
+ if ( ! checkbox[0].checked ) {
153
+ checkbox[0].checked = true;
154
+ clearInterval( int );
155
+ }
156
+ }, 10 );
157
+ }
158
+ } else { // disable
159
+ window.location.href = SYNVED_ENABLE_FEATURE_URL;
160
+ }
161
+ } );
162
+ },
163
+ };
164
+ } )( window.jQuery, window.wp );
 
synved-option/synved-option-context.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- function synved_option_context_post($post_id)
4
- {
5
- // XXX not implemented yet
6
- }
 
 
 
 
 
 
synved-option/synved-option-error.php DELETED
@@ -1,2 +0,0 @@
1
- <?php
2
- // Silence is golden.
 
 
synved-option/synved-option-item.php CHANGED
@@ -6,8 +6,8 @@ function synved_option_item_query_into($filter, $list)
6
  {
7
  return null;
8
  }
9
-
10
- foreach ($list as $item_name => $item)
11
  {
12
  if ($filter != null)
13
  {
@@ -15,18 +15,18 @@ function synved_option_item_query_into($filter, $list)
15
  $filter_keys = array_keys($filter);
16
  $filter_name = $filter_keys[0];
17
  $filter_value = $filter[$filter_keys[0]];
18
-
19
  if (is_string($filter_name) || !is_array($filter_value))
20
  {
21
  $filter = array($filter);
22
  }
23
-
24
  $found_item = true;
25
-
26
  foreach ($filter as $filter_index => $filter_list)
27
  {
28
  $pass = false;
29
-
30
  foreach ($filter_list as $filter_name => $filter_value)
31
  {
32
  if ($filter_name == 'name')
@@ -39,34 +39,34 @@ function synved_option_item_query_into($filter, $list)
39
  else
40
  {
41
  $property = synved_option_item_property($item, $filter_name);
42
-
43
  if ($property == $filter_value)
44
  {
45
  $pass = true;
46
  }
47
  }
48
  }
49
-
50
  $found_item = ($found_item && $pass);
51
-
52
  if (!$found_item)
53
  {
54
  break;
55
  }
56
  }
57
-
58
  if ($found_item)
59
  {
60
  return $item;
61
  }
62
  }
63
-
64
  $type = synved_option_item_type($item);
65
-
66
  if ($type == 'options-page' && isset($item['sections']) && $item['sections'] != null)
67
  {
68
  $ret = synved_option_item_query_into($filter, $item['sections']);
69
-
70
  if ($ret != null)
71
  {
72
  return $ret;
@@ -75,42 +75,37 @@ function synved_option_item_query_into($filter, $list)
75
  else if ($type == 'options-section' && isset($item['settings']) && $item['settings'] != null)
76
  {
77
  $ret = synved_option_item_query_into($filter, $item['settings']);
78
-
79
  if ($ret != null)
80
  {
81
  return $ret;
82
  }
83
  }
84
  }
85
-
86
  return null;
87
  }
88
 
89
  function synved_option_item_query($id, $filter)
90
  {
91
  global $synved_option_list;
92
-
93
  foreach ($synved_option_list as $list_id => $list)
94
  {
95
  if ($id == null || $list_id == $id)
96
  {
97
  $items = synved_option_item_list($list_id);
98
-
99
  $ret = synved_option_item_query_into($filter, $items);
100
-
101
  if ($ret != null || $id != null)
102
  {
103
  return $ret;
104
  }
105
  }
106
  }
107
-
108
- return null;
109
- }
110
 
111
- function synved_option_item_find_into($name, $list)
112
- {
113
- return synved_option_item_query_into(array('name' => $name), $list);
114
  }
115
 
116
  function synved_option_item_find($id, $name)
@@ -126,12 +121,12 @@ function synved_option_item($id, $name)
126
  function synved_option_item_property($item, $property, $default = null)
127
  {
128
  $prop = isset($item[$property]) ? $item[$property] : $default;
129
-
130
  if ($prop instanceof SynvedOptionCallback)
131
  {
132
  $prop = $prop->Invoke(array($default, $item));
133
  }
134
-
135
  return $prop;
136
  }
137
 
@@ -140,28 +135,28 @@ function synved_option_item_type(array $item)
140
  $type = isset($item['type']) ? $item['type'] : null;
141
  $default = synved_option_item_default($item);
142
  $callback = null;
143
-
144
  if ($type instanceof SynvedOptionCallback)
145
  {
146
  $callback = $type;
147
-
148
  $type = null;
149
  }
150
-
151
  if ($type == null && isset($item['sections']))
152
  {
153
  $type = 'options-page';
154
  }
155
-
156
  if ($type == null && isset($item['settings']))
157
  {
158
  $type = 'options-section';
159
  }
160
-
161
  if ($type == null)
162
  {
163
  $type = 'text';
164
-
165
  if ($default !== null)
166
  {
167
  if (is_bool($default))
@@ -182,241 +177,241 @@ function synved_option_item_type(array $item)
182
  }
183
  }
184
  }
185
-
186
  if ($callback != null)
187
  {
188
  return $callback->Invoke(array($type, $item));
189
  }
190
-
191
  return $type;
192
  }
193
 
194
  function synved_option_item_mode(array $item)
195
  {
196
  $mode = isset($item['mode']) ? $item['mode'] : null;
197
-
198
  if ($mode instanceof SynvedOptionCallback)
199
  {
200
  $mode = $mode->Invoke(array(null, $item));
201
  }
202
-
203
  if ($mode != null && is_string($mode))
204
  {
205
  $mode = explode(',', $mode);
206
  }
207
-
208
  if ($mode == null)
209
  {
210
  $mode = array();
211
  }
212
-
213
  return $mode;
214
  }
215
 
216
  function synved_option_item_style(array $item)
217
  {
218
  $style = isset($item['style']) ? $item['style'] : null;
219
-
220
  if ($style instanceof SynvedOptionCallback)
221
  {
222
  $style = $style->Invoke(array(null, $item));
223
  }
224
-
225
  if ($style != null && is_string($style))
226
  {
227
  $style = explode(',', $style);
228
  }
229
-
230
  if ($style == null)
231
  {
232
  $style = array();
233
  }
234
-
235
  return $style;
236
  }
237
 
238
  function synved_option_item_hidden(array $item)
239
  {
240
  $hidden = isset($item['hidden']) ? $item['hidden'] : null;
241
-
242
  if ($hidden instanceof SynvedOptionCallback)
243
  {
244
  $hidden = $hidden->Invoke(array(null, $item));
245
  }
246
-
247
  return $hidden;
248
  }
249
 
250
  function synved_option_item_label(array $item)
251
  {
252
  $label = isset($item['label']) ? $item['label'] : null;
253
-
254
  if ($label instanceof SynvedOptionCallback)
255
  {
256
  $label = $label->Invoke(array(null, $item));
257
  }
258
-
259
  return $label;
260
  }
261
 
262
  function synved_option_item_title(array $item)
263
  {
264
  $title = isset($item['title']) ? $item['title'] : null;
265
-
266
  if ($title instanceof SynvedOptionCallback)
267
  {
268
  $title = $title->Invoke(array(null, $item));
269
  }
270
-
271
  return $title;
272
  }
273
 
274
  function synved_option_item_tip(array $item)
275
  {
276
  $tip = isset($item['tip']) ? $item['tip'] : null;
277
-
278
  if ($tip instanceof SynvedOptionCallback)
279
  {
280
  $tip = $tip->Invoke(array(null, $item));
281
  }
282
-
283
  return $tip;
284
  }
285
 
286
  function synved_option_item_hint(array $item)
287
  {
288
  $hint = isset($item['hint']) ? $item['hint'] : null;
289
-
290
  if ($hint instanceof SynvedOptionCallback)
291
  {
292
  $hint = $hint->Invoke(array(null, $item));
293
  }
294
-
295
  return $hint;
296
  }
297
 
298
  function synved_option_item_default(array $item)
299
  {
300
  $default = isset($item['default']) ? $item['default'] : null;
301
-
302
  if ($default instanceof SynvedOptionCallback)
303
  {
304
  $default = $default->Invoke(array(null, $item));
305
  }
306
-
307
  return $default;
308
  }
309
 
310
  function synved_option_item_role(array $item)
311
  {
312
  $role = isset($item['role']) ? $item['role'] : null;
313
-
314
  if ($role instanceof SynvedOptionCallback)
315
  {
316
  $role = $role->Invoke(array(null, $item));
317
  }
318
-
319
  if ($role === null)
320
  {
321
  $role = 'manage_options';
322
  }
323
-
324
  return $role;
325
  }
326
 
327
  function synved_option_item_parent(array $item)
328
  {
329
  $parent = isset($item['parent']) ? $item['parent'] : null;
330
-
331
  if ($parent instanceof SynvedOptionCallback)
332
  {
333
  $parent = $parent->Invoke(array(null, $item));
334
  }
335
-
336
  switch ($parent)
337
  {
338
  case 'dashboard':
339
  {
340
  $parent = 'index.php';
341
-
342
  break;
343
  }
344
  case 'posts':
345
  {
346
  $parent = 'edit.php';
347
-
348
  break;
349
  }
350
  case 'media':
351
  {
352
  $parent = 'upload.php';
353
-
354
  break;
355
  }
356
  case 'links':
357
  {
358
  $parent = 'link-manager.php';
359
-
360
  break;
361
  }
362
  case 'pages':
363
  {
364
  $parent = 'edit.php?post_type=page';
365
-
366
  break;
367
  }
368
  case 'comments':
369
  {
370
  $parent = 'edit-comments.php';
371
-
372
  break;
373
  }
374
  case 'appearance':
375
  {
376
  $parent = 'themes.php';
377
-
378
  break;
379
  }
380
  case 'plugins':
381
  {
382
  $parent = 'plugins.php';
383
-
384
  break;
385
  }
386
  case 'users':
387
  {
388
  $parent = 'users.php';
389
-
390
  break;
391
  }
392
  case 'tools':
393
  {
394
  $parent = 'tools.php';
395
-
396
  break;
397
  }
398
  case null:
399
  case 'settings':
400
  {
401
  $parent = 'options-general.php';
402
-
403
  break;
404
  }
405
  }
406
-
407
  return $parent;
408
  }
409
 
410
  function synved_option_item_page($id, $name)
411
  {
412
  $items = synved_option_item_list($id);
413
-
414
  if ($items != null)
415
  {
416
  foreach ($items as $page_name => $page)
417
  {
418
  $sections = isset($page['sections']) ? $page['sections'] : array();
419
-
420
  foreach ($sections as $section_name => $section)
421
  {
422
  if ($section_name == $name || (isset($section['settings']) && array_key_exists($name, $section['settings'])))
@@ -426,19 +421,19 @@ function synved_option_item_page($id, $name)
426
  }
427
  }
428
  }
429
-
430
  return null;
431
  }
432
 
433
  function synved_option_item_page_link_url($id, $name)
434
  {
435
  $page_name = synved_option_item_page($id, $name);
436
-
437
  if ($page_name != null)
438
  {
439
  return synved_option_page_link_url($id, $page_name);
440
  }
441
-
442
  return null;
443
  }
444
 
@@ -446,85 +441,85 @@ function synved_option_item_set_parse(array $item, $set)
446
  {
447
  $type = synved_option_item_type($item);
448
  preg_match_all('/\\s*(?:(\\d+(?:(?:\\.|(?:\\s*-\\s*))\\d+)*)|([^=,]+))\s*(?:=\s*((?:[^,"]+)|(?:"(?:(?:[^"\\\\])|(?:\\.))*")))?(?:,|$)/', $set, $matches, PREG_SET_ORDER);
449
-
450
  $set = array();
451
-
452
  foreach ($matches as $match)
453
  {
454
  $number = isset($match[1]) ? $match[1] : null;
455
  $value = isset($match[2]) ? $match[2] : null;
456
  $label = isset($match[3]) ? $match[3] : null;
457
-
458
  if ($number != null && $value == null)
459
  {
460
  $value = $number;
461
  }
462
-
463
  $label = trim($label, '"');
464
  $value = array($value => $label);
465
-
466
  if ($number != null)
467
  {
468
  $range = explode('-', $number);
469
  $count = count($range);
470
-
471
  if ($count > 1)
472
  {
473
  $value_range = array();
474
-
475
  for ($i = 0; $i < $count; $i++)
476
  {
477
  $range_item = $range[$i];
478
  $range_value = synved_option_item_sanitize_value_basic($item, $range_item, 0);
479
-
480
  if ($range_value == 0)
481
  {
482
  $range_value = $range_item;
483
  }
484
-
485
  $value_range[$range_value] = $range_value;
486
  }
487
-
488
  $value = $value_range;
489
  }
490
  }
491
-
492
  $set[] = $value;
493
  }
494
-
495
  return $set;
496
  }
497
 
498
  function synved_option_item_set(array $item)
499
  {
500
  $set = isset($item['set']) ? $item['set'] : null;
501
-
502
  if ($set instanceof SynvedOptionCallback)
503
  {
504
  $set = $set->Invoke(array(null, $item));
505
  }
506
-
507
  if ($set != null && !is_array($set))
508
  {
509
  $set = synved_option_item_set_parse($item, $set);
510
  }
511
-
512
  return $set;
513
  }
514
 
515
  function synved_option_item_callback(array $item, $callback_id, $callback_parameters = null)
516
  {
517
  $callback = isset($item[$callback_id]) ? $item[$callback_id] : null;
518
-
519
  if ($callback != null)
520
  {
521
  $callback = trim($callback);
522
-
523
  if (is_string($callback) && !function_exists($callback))
524
  {
525
  $callback = synved_option_callback_create($callback_code, $callback_parameters);
526
  }
527
-
528
  if (!($callback instanceof SynvedOptionCallback))
529
  {
530
  if (is_callable($callback))
@@ -537,7 +532,7 @@ function synved_option_item_callback(array $item, $callback_id, $callback_parame
537
  }
538
  }
539
  }
540
-
541
  return $callback;
542
  }
543
 
@@ -572,16 +567,16 @@ function synved_option_item_set_check_value(array $item, $set, $value)
572
  {
573
  return true;
574
  }
575
-
576
  foreach ($set as $set_it)
577
  {
578
  if (!is_array($set_it))
579
  {
580
  $set_it = array($set_it);
581
  }
582
-
583
  $set_it_keys = array_keys($set_it);
584
-
585
  if (isset($set_it_keys[1]))
586
  {
587
  if ($value >= $set_it_keys[0] && $value <= $set_it_keys[1])
@@ -594,7 +589,7 @@ function synved_option_item_set_check_value(array $item, $set, $value)
594
  return true;
595
  }
596
  }
597
-
598
  return false;
599
  }
600
 
@@ -604,16 +599,16 @@ function synved_option_item_validate_value($id, $name, $value, &$new_value = nul
604
  {
605
  return null;
606
  }
607
-
608
  $validate = synved_option_item_validate($item);
609
  $is_valid = true;
610
  $error = null;
611
  $error_list = array();
612
-
613
  if ($validate != null)
614
  {
615
  $new_value = $value;
616
-
617
  try
618
  {
619
  $validate->Invoke(array($new_value, $name, $id, $item));
@@ -621,21 +616,21 @@ function synved_option_item_validate_value($id, $name, $value, &$new_value = nul
621
  catch (Exception $ex)
622
  {
623
  $is_valid = false;
624
-
625
  $error = $ex->getMessage();
626
  }
627
  }
628
-
629
  if (!$is_valid)
630
  {
631
  if ($error == null)
632
  {
633
  $error = __('Selected value is invalid', 'synved-option');
634
  }
635
-
636
  $error_list[] = array('code' => null, 'type' => null, 'message' => $error);
637
  }
638
-
639
  return $error_list;
640
  }
641
 
@@ -643,12 +638,12 @@ function synved_option_item_sanitize_value_basic(array $item, $value, $default =
643
  {
644
  $type = synved_option_item_type($item);
645
  $set = isset($item['set']) ? $item['set'] : null;
646
-
647
  if ($default === null)
648
  {
649
  $default = synved_option_item_default($item);
650
  }
651
-
652
  switch ($type)
653
  {
654
  case 'boolean':
@@ -657,9 +652,9 @@ function synved_option_item_sanitize_value_basic(array $item, $value, $default =
657
  {
658
  $value = $default;
659
  }
660
-
661
  $value = $value ? true : 0;
662
-
663
  break;
664
  }
665
  case 'integer':
@@ -668,9 +663,9 @@ function synved_option_item_sanitize_value_basic(array $item, $value, $default =
668
  {
669
  $value = $default;
670
  }
671
-
672
  $value = intval($value);
673
-
674
  break;
675
  }
676
  case 'decimal':
@@ -679,9 +674,9 @@ function synved_option_item_sanitize_value_basic(array $item, $value, $default =
679
  {
680
  $value = $default;
681
  }
682
-
683
  $value = floatval($value);
684
-
685
  break;
686
  }
687
  case 'text':
@@ -692,27 +687,27 @@ function synved_option_item_sanitize_value_basic(array $item, $value, $default =
692
  {
693
  $old_value = $value;
694
  $value = strval($value);
695
-
696
  if ($old_value === null || ($value == null && $set != null))
697
  {
698
  $value = $default;
699
  }
700
-
701
  break;
702
  }
703
  case 'color':
704
  {
705
  $value = strval($value);
706
-
707
  if ($value == null)
708
  {
709
  $value = $default;
710
  }
711
-
712
  break;
713
  }
714
  }
715
-
716
  return $value;
717
  }
718
 
@@ -727,18 +722,18 @@ function synved_option_item_sanitize_value($id, $name, $value, array $item = nul
727
  {
728
  return null;
729
  }
730
-
731
  $type = synved_option_item_type($item);
732
  $default = synved_option_item_default($item);
733
  $set = synved_option_item_set($item);
734
  $sanitize = synved_option_item_sanitize($item);
735
  $sanitize_raw = synved_option_item_sanitize_raw($item);
736
-
737
  if ($sanitize_raw != null)
738
  {
739
  return $sanitize_raw->Invoke(array($value, $name, $id, $item));
740
  }
741
-
742
  $value = synved_option_item_sanitize_value_basic($item, $value, $default);
743
  $is_valid = true;
744
 
@@ -748,7 +743,7 @@ function synved_option_item_sanitize_value($id, $name, $value, array $item = nul
748
  {
749
  $is_valid = false;
750
  $new_value = array();
751
-
752
  foreach ($value as $single_key => $single_value)
753
  {
754
  if (synved_option_item_set_check_value($item, $set, $single_value))
@@ -756,7 +751,7 @@ function synved_option_item_sanitize_value($id, $name, $value, array $item = nul
756
  $new_value[$single_key] = $single_value;
757
  }
758
  }
759
-
760
  if ($new_value != null)
761
  {
762
  $is_valid = true;
@@ -778,10 +773,10 @@ function synved_option_item_sanitize_value($id, $name, $value, array $item = nul
778
  {
779
  $value = $sanitize->Invoke(array($value, $name, $id, $item));
780
  }
781
-
782
  return $value;
783
  }
784
-
785
  return null;
786
  }
787
 
@@ -790,37 +785,37 @@ function synved_option_item_addon_is_installed(array $item)
790
  if ($item != null)
791
  {
792
  $type = synved_option_item_type($item);
793
-
794
  if ($type == 'addon')
795
  {
796
  $target = synved_option_item_property($item, 'target');
797
  $folder = synved_option_item_property($item, 'folder');
798
-
799
  $path = $target;
800
-
801
  if ($path != null)
802
  {
803
  $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
804
-
805
  if (substr($path, -1) != DIRECTORY_SEPARATOR)
806
  {
807
  $path .= DIRECTORY_SEPARATOR;
808
  }
809
-
810
  $path .= $folder;
811
-
812
  if (is_dir($path))
813
  {
814
  return true;
815
  }
816
  }
817
-
818
  $module = synved_option_item_property($item, 'module');
819
-
820
  if ($module != null)
821
  {
822
  $addon_list = synved_plugout_module_addon_list($module);
823
-
824
  if (isset($addon_list[$folder]))
825
  {
826
  return true;
@@ -828,6 +823,6 @@ function synved_option_item_addon_is_installed(array $item)
828
  }
829
  }
830
  }
831
-
832
  return false;
833
  }
6
  {
7
  return null;
8
  }
9
+
10
+ foreach ($list as $item_name => $item)
11
  {
12
  if ($filter != null)
13
  {
15
  $filter_keys = array_keys($filter);
16
  $filter_name = $filter_keys[0];
17
  $filter_value = $filter[$filter_keys[0]];
18
+
19
  if (is_string($filter_name) || !is_array($filter_value))
20
  {
21
  $filter = array($filter);
22
  }
23
+
24
  $found_item = true;
25
+
26
  foreach ($filter as $filter_index => $filter_list)
27
  {
28
  $pass = false;
29
+
30
  foreach ($filter_list as $filter_name => $filter_value)
31
  {
32
  if ($filter_name == 'name')
39
  else
40
  {
41
  $property = synved_option_item_property($item, $filter_name);
42
+
43
  if ($property == $filter_value)
44
  {
45
  $pass = true;
46
  }
47
  }
48
  }
49
+
50
  $found_item = ($found_item && $pass);
51
+
52
  if (!$found_item)
53
  {
54
  break;
55
  }
56
  }
57
+
58
  if ($found_item)
59
  {
60
  return $item;
61
  }
62
  }
63
+
64
  $type = synved_option_item_type($item);
65
+
66
  if ($type == 'options-page' && isset($item['sections']) && $item['sections'] != null)
67
  {
68
  $ret = synved_option_item_query_into($filter, $item['sections']);
69
+
70
  if ($ret != null)
71
  {
72
  return $ret;
75
  else if ($type == 'options-section' && isset($item['settings']) && $item['settings'] != null)
76
  {
77
  $ret = synved_option_item_query_into($filter, $item['settings']);
78
+
79
  if ($ret != null)
80
  {
81
  return $ret;
82
  }
83
  }
84
  }
85
+
86
  return null;
87
  }
88
 
89
  function synved_option_item_query($id, $filter)
90
  {
91
  global $synved_option_list;
92
+
93
  foreach ($synved_option_list as $list_id => $list)
94
  {
95
  if ($id == null || $list_id == $id)
96
  {
97
  $items = synved_option_item_list($list_id);
98
+
99
  $ret = synved_option_item_query_into($filter, $items);
100
+
101
  if ($ret != null || $id != null)
102
  {
103
  return $ret;
104
  }
105
  }
106
  }
 
 
 
107
 
108
+ return null;
 
 
109
  }
110
 
111
  function synved_option_item_find($id, $name)
121
  function synved_option_item_property($item, $property, $default = null)
122
  {
123
  $prop = isset($item[$property]) ? $item[$property] : $default;
124
+
125
  if ($prop instanceof SynvedOptionCallback)
126
  {
127
  $prop = $prop->Invoke(array($default, $item));
128
  }
129
+
130
  return $prop;
131
  }
132
 
135
  $type = isset($item['type']) ? $item['type'] : null;
136
  $default = synved_option_item_default($item);
137
  $callback = null;
138
+
139
  if ($type instanceof SynvedOptionCallback)
140
  {
141
  $callback = $type;
142
+
143
  $type = null;
144
  }
145
+
146
  if ($type == null && isset($item['sections']))
147
  {
148
  $type = 'options-page';
149
  }
150
+
151
  if ($type == null && isset($item['settings']))
152
  {
153
  $type = 'options-section';
154
  }
155
+
156
  if ($type == null)
157
  {
158
  $type = 'text';
159
+
160
  if ($default !== null)
161
  {
162
  if (is_bool($default))
177
  }
178
  }
179
  }
180
+
181
  if ($callback != null)
182
  {
183
  return $callback->Invoke(array($type, $item));
184
  }
185
+
186
  return $type;
187
  }
188
 
189
  function synved_option_item_mode(array $item)
190
  {
191
  $mode = isset($item['mode']) ? $item['mode'] : null;
192
+
193
  if ($mode instanceof SynvedOptionCallback)
194
  {
195
  $mode = $mode->Invoke(array(null, $item));
196
  }
197
+
198
  if ($mode != null && is_string($mode))
199
  {
200
  $mode = explode(',', $mode);
201
  }
202
+
203
  if ($mode == null)
204
  {
205
  $mode = array();
206
  }
207
+
208
  return $mode;
209
  }
210
 
211
  function synved_option_item_style(array $item)
212
  {
213
  $style = isset($item['style']) ? $item['style'] : null;
214
+
215
  if ($style instanceof SynvedOptionCallback)
216
  {
217
  $style = $style->Invoke(array(null, $item));
218
  }
219
+
220
  if ($style != null && is_string($style))
221
  {
222
  $style = explode(',', $style);
223
  }
224
+
225
  if ($style == null)
226
  {
227
  $style = array();
228
  }
229
+
230
  return $style;
231
  }
232
 
233
  function synved_option_item_hidden(array $item)
234
  {
235
  $hidden = isset($item['hidden']) ? $item['hidden'] : null;
236
+
237
  if ($hidden instanceof SynvedOptionCallback)
238
  {
239
  $hidden = $hidden->Invoke(array(null, $item));
240
  }
241
+
242
  return $hidden;
243
  }
244
 
245
  function synved_option_item_label(array $item)
246
  {
247
  $label = isset($item['label']) ? $item['label'] : null;
248
+
249
  if ($label instanceof SynvedOptionCallback)
250
  {
251
  $label = $label->Invoke(array(null, $item));
252
  }
253
+
254
  return $label;
255
  }
256
 
257
  function synved_option_item_title(array $item)
258
  {
259
  $title = isset($item['title']) ? $item['title'] : null;
260
+
261
  if ($title instanceof SynvedOptionCallback)
262
  {
263
  $title = $title->Invoke(array(null, $item));
264
  }
265
+
266
  return $title;
267
  }
268
 
269
  function synved_option_item_tip(array $item)
270
  {
271
  $tip = isset($item['tip']) ? $item['tip'] : null;
272
+
273
  if ($tip instanceof SynvedOptionCallback)
274
  {
275
  $tip = $tip->Invoke(array(null, $item));
276
  }
277
+
278
  return $tip;
279
  }
280
 
281
  function synved_option_item_hint(array $item)
282
  {
283
  $hint = isset($item['hint']) ? $item['hint'] : null;
284
+
285
  if ($hint instanceof SynvedOptionCallback)
286
  {
287
  $hint = $hint->Invoke(array(null, $item));
288
  }
289
+
290
  return $hint;
291
  }
292
 
293
  function synved_option_item_default(array $item)
294
  {
295
  $default = isset($item['default']) ? $item['default'] : null;
296
+
297
  if ($default instanceof SynvedOptionCallback)
298
  {
299
  $default = $default->Invoke(array(null, $item));
300
  }
301
+
302
  return $default;
303
  }
304
 
305
  function synved_option_item_role(array $item)
306
  {
307
  $role = isset($item['role']) ? $item['role'] : null;
308
+
309
  if ($role instanceof SynvedOptionCallback)
310
  {
311
  $role = $role->Invoke(array(null, $item));
312
  }
313
+
314
  if ($role === null)
315
  {
316
  $role = 'manage_options';
317
  }
318
+
319
  return $role;
320
  }
321
 
322
  function synved_option_item_parent(array $item)
323
  {
324
  $parent = isset($item['parent']) ? $item['parent'] : null;
325
+
326
  if ($parent instanceof SynvedOptionCallback)
327
  {
328
  $parent = $parent->Invoke(array(null, $item));
329
  }
330
+
331
  switch ($parent)
332
  {
333
  case 'dashboard':
334
  {
335
  $parent = 'index.php';
336
+
337
  break;
338
  }
339
  case 'posts':
340
  {
341
  $parent = 'edit.php';
342
+
343
  break;
344
  }
345
  case 'media':
346
  {
347
  $parent = 'upload.php';
348
+
349
  break;
350
  }
351
  case 'links':
352
  {
353
  $parent = 'link-manager.php';
354
+
355
  break;
356
  }
357
  case 'pages':
358
  {
359
  $parent = 'edit.php?post_type=page';
360
+
361
  break;
362
  }
363
  case 'comments':
364
  {
365
  $parent = 'edit-comments.php';
366
+
367
  break;
368
  }
369
  case 'appearance':
370
  {
371
  $parent = 'themes.php';
372
+
373
  break;
374
  }
375
  case 'plugins':
376
  {
377
  $parent = 'plugins.php';
378
+
379
  break;
380
  }
381
  case 'users':
382
  {
383
  $parent = 'users.php';
384
+
385
  break;
386
  }
387
  case 'tools':
388
  {
389
  $parent = 'tools.php';
390
+
391
  break;
392
  }
393
  case null:
394
  case 'settings':
395
  {
396
  $parent = 'options-general.php';
397
+
398
  break;
399
  }
400
  }
401
+
402
  return $parent;
403
  }
404
 
405
  function synved_option_item_page($id, $name)
406
  {
407
  $items = synved_option_item_list($id);
408
+
409
  if ($items != null)
410
  {
411
  foreach ($items as $page_name => $page)
412
  {
413
  $sections = isset($page['sections']) ? $page['sections'] : array();
414
+
415
  foreach ($sections as $section_name => $section)
416
  {
417
  if ($section_name == $name || (isset($section['settings']) && array_key_exists($name, $section['settings'])))
421
  }
422
  }
423
  }
424
+
425
  return null;
426
  }
427
 
428
  function synved_option_item_page_link_url($id, $name)
429
  {
430
  $page_name = synved_option_item_page($id, $name);
431
+
432
  if ($page_name != null)
433
  {
434
  return synved_option_page_link_url($id, $page_name);
435
  }
436
+
437
  return null;
438
  }
439
 
441
  {
442
  $type = synved_option_item_type($item);
443
  preg_match_all('/\\s*(?:(\\d+(?:(?:\\.|(?:\\s*-\\s*))\\d+)*)|([^=,]+))\s*(?:=\s*((?:[^,"]+)|(?:"(?:(?:[^"\\\\])|(?:\\.))*")))?(?:,|$)/', $set, $matches, PREG_SET_ORDER);
444
+
445
  $set = array();
446
+
447
  foreach ($matches as $match)
448
  {
449
  $number = isset($match[1]) ? $match[1] : null;
450
  $value = isset($match[2]) ? $match[2] : null;
451
  $label = isset($match[3]) ? $match[3] : null;
452
+
453
  if ($number != null && $value == null)
454
  {
455
  $value = $number;
456
  }
457
+
458
  $label = trim($label, '"');
459
  $value = array($value => $label);
460
+
461
  if ($number != null)
462
  {
463
  $range = explode('-', $number);
464
  $count = count($range);
465
+
466
  if ($count > 1)
467
  {
468
  $value_range = array();
469
+
470
  for ($i = 0; $i < $count; $i++)
471
  {
472
  $range_item = $range[$i];
473
  $range_value = synved_option_item_sanitize_value_basic($item, $range_item, 0);
474
+
475
  if ($range_value == 0)
476
  {
477
  $range_value = $range_item;
478
  }
479
+
480
  $value_range[$range_value] = $range_value;
481
  }
482
+
483
  $value = $value_range;
484
  }
485
  }
486
+
487
  $set[] = $value;
488
  }
489
+
490
  return $set;
491
  }
492
 
493
  function synved_option_item_set(array $item)
494
  {
495
  $set = isset($item['set']) ? $item['set'] : null;
496
+
497
  if ($set instanceof SynvedOptionCallback)
498
  {
499
  $set = $set->Invoke(array(null, $item));
500
  }
501
+
502
  if ($set != null && !is_array($set))
503
  {
504
  $set = synved_option_item_set_parse($item, $set);
505
  }
506
+
507
  return $set;
508
  }
509
 
510
  function synved_option_item_callback(array $item, $callback_id, $callback_parameters = null)
511
  {
512
  $callback = isset($item[$callback_id]) ? $item[$callback_id] : null;
513
+
514
  if ($callback != null)
515
  {
516
  $callback = trim($callback);
517
+
518
  if (is_string($callback) && !function_exists($callback))
519
  {
520
  $callback = synved_option_callback_create($callback_code, $callback_parameters);
521
  }
522
+
523
  if (!($callback instanceof SynvedOptionCallback))
524
  {
525
  if (is_callable($callback))
532
  }
533
  }
534
  }
535
+
536
  return $callback;
537
  }
538
 
567
  {
568
  return true;
569
  }
570
+
571
  foreach ($set as $set_it)
572
  {
573
  if (!is_array($set_it))
574
  {
575
  $set_it = array($set_it);
576
  }
577
+
578
  $set_it_keys = array_keys($set_it);
579
+
580
  if (isset($set_it_keys[1]))
581
  {
582
  if ($value >= $set_it_keys[0] && $value <= $set_it_keys[1])
589
  return true;
590
  }
591
  }
592
+
593
  return false;
594
  }
595
 
599
  {
600
  return null;
601
  }
602
+
603
  $validate = synved_option_item_validate($item);
604
  $is_valid = true;
605
  $error = null;
606
  $error_list = array();
607
+
608
  if ($validate != null)
609
  {
610
  $new_value = $value;
611
+
612
  try
613
  {
614
  $validate->Invoke(array($new_value, $name, $id, $item));
616
  catch (Exception $ex)
617
  {
618
  $is_valid = false;
619
+
620
  $error = $ex->getMessage();
621
  }
622
  }
623
+
624
  if (!$is_valid)
625
  {
626
  if ($error == null)
627
  {
628
  $error = __('Selected value is invalid', 'synved-option');
629
  }
630
+
631
  $error_list[] = array('code' => null, 'type' => null, 'message' => $error);
632
  }
633
+
634
  return $error_list;
635
  }
636
 
638
  {
639
  $type = synved_option_item_type($item);
640
  $set = isset($item['set']) ? $item['set'] : null;
641
+
642
  if ($default === null)
643
  {
644
  $default = synved_option_item_default($item);
645
  }
646
+
647
  switch ($type)
648
  {
649
  case 'boolean':
652
  {
653
  $value = $default;
654
  }
655
+
656
  $value = $value ? true : 0;
657
+
658
  break;
659
  }
660
  case 'integer':
663
  {
664
  $value = $default;
665
  }
666
+
667
  $value = intval($value);
668
+
669
  break;
670
  }
671
  case 'decimal':
674
  {
675
  $value = $default;
676
  }
677
+
678
  $value = floatval($value);
679
+
680
  break;
681
  }
682
  case 'text':
687
  {
688
  $old_value = $value;
689
  $value = strval($value);
690
+
691
  if ($old_value === null || ($value == null && $set != null))
692
  {
693
  $value = $default;
694
  }
695
+
696
  break;
697
  }
698
  case 'color':
699
  {
700
  $value = strval($value);
701
+
702
  if ($value == null)
703
  {
704
  $value = $default;
705
  }
706
+
707
  break;
708
  }
709
  }
710
+
711
  return $value;
712
  }
713
 
722
  {
723
  return null;
724
  }
725
+
726
  $type = synved_option_item_type($item);
727
  $default = synved_option_item_default($item);
728
  $set = synved_option_item_set($item);
729
  $sanitize = synved_option_item_sanitize($item);
730
  $sanitize_raw = synved_option_item_sanitize_raw($item);
731
+
732
  if ($sanitize_raw != null)
733
  {
734
  return $sanitize_raw->Invoke(array($value, $name, $id, $item));
735
  }
736
+
737
  $value = synved_option_item_sanitize_value_basic($item, $value, $default);
738
  $is_valid = true;
739
 
743
  {
744
  $is_valid = false;
745
  $new_value = array();
746
+
747
  foreach ($value as $single_key => $single_value)
748
  {
749
  if (synved_option_item_set_check_value($item, $set, $single_value))
751
  $new_value[$single_key] = $single_value;
752
  }
753
  }
754
+
755
  if ($new_value != null)
756
  {
757
  $is_valid = true;
773
  {
774
  $value = $sanitize->Invoke(array($value, $name, $id, $item));
775
  }
776
+
777
  return $value;
778
  }
779
+
780
  return null;
781
  }
782
 
785
  if ($item != null)
786
  {
787
  $type = synved_option_item_type($item);
788
+
789
  if ($type == 'addon')
790
  {
791
  $target = synved_option_item_property($item, 'target');
792
  $folder = synved_option_item_property($item, 'folder');
793
+
794
  $path = $target;
795
+
796
  if ($path != null)
797
  {
798
  $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
799
+
800
  if (substr($path, -1) != DIRECTORY_SEPARATOR)
801
  {
802
  $path .= DIRECTORY_SEPARATOR;
803
  }
804
+
805
  $path .= $folder;
806
+
807
  if (is_dir($path))
808
  {
809
  return true;
810
  }
811
  }
812
+
813
  $module = synved_option_item_property($item, 'module');
814
+
815
  if ($module != null)
816
  {
817
  $addon_list = synved_plugout_module_addon_list($module);
818
+
819
  if (isset($addon_list[$folder]))
820
  {
821
  return true;
823
  }
824
  }
825
  }
826
+
827
  return false;
828
  }
synved-option/synved-option-page.php CHANGED
@@ -1,169 +1,175 @@
1
  <?php
2
 
3
- function synved_option_page_default_name($id)
4
- {
5
- return 'page_settings';
 
 
 
 
 
 
6
  }
7
 
8
- function synved_option_page_default($id)
9
- {
10
- $page = synved_option_page_default_name($id);
11
-
12
- return array('name' => $page, 'type' => 'options-page', 'label' => synved_option_label_from_id($id));
13
- }
14
-
15
- function synved_option_page_slug($id, $name, $item = null)
16
- {
17
- if ($item == null)
18
- {
19
- $item = synved_option_item($id, $name);
20
  }
21
-
22
- $type = synved_option_item_type($item);
23
- $parent = synved_option_item_parent($item);
24
 
25
- if ($type == 'options-page')
26
- {
 
27
  global $synved_option_list;
28
-
29
- if (isset($synved_option_list[$id]['pages'][$name]['wp-page-slug']))
30
- {
31
- return $synved_option_list[$id]['pages'][$name]['wp-page-slug'];
32
  }
33
  }
34
-
35
  return null;
36
  }
37
-
38
- function synved_option_page_link_url($id, $name, $item = null)
39
- {
40
- if ($item == null)
41
- {
42
- $item = synved_option_item($id, $name);
 
 
 
 
 
 
 
43
  }
44
-
45
- $type = synved_option_item_type($item);
46
- $parent = synved_option_item_parent($item);
47
- $slug = synved_option_page_slug($id, $name, $item);
48
-
49
- if ($type == 'options-page')
50
- {
51
- if ($slug != null)
52
- {
53
- return $parent . '?page=' . $slug;
54
- }
55
  }
56
-
57
  return null;
58
  }
59
 
60
- function synved_option_page_cb($id, $name, $item)
61
- {
62
- $group = synved_option_group_default($id);
63
- $label = synved_option_item_label($item);
64
- $title = synved_option_item_title($item);
65
- $tip = synved_option_item_tip($item);
66
- $role = synved_option_item_role($item);
67
- $style = synved_option_item_style($item);
68
-
69
- if (!current_user_can($role))
70
- {
71
- wp_die(__('You do not have sufficient permissions to access this page.', 'synved-option'));
 
 
 
 
 
 
 
72
  }
73
-
74
- if ($title === null)
75
- {
76
  $title = $label;
77
  }
78
-
79
- $class = 'wrap';
80
-
81
- if ($style != null)
82
- {
83
- foreach ($style as $style_name)
84
- {
85
- $class .= ' ' . 'synved-option-style-' . $style_name;
86
  }
87
  }
88
- ?>
89
- <div class="<?php echo esc_attr($class); ?>">
90
- <div class="icon32" id="icon-options-general"><br/></div>
91
- <h2><?php echo $title; ?></h2>
92
- <p><?php echo $tip; ?></p>
93
- <form action="options.php" method="post">
94
- <?php settings_fields($group); ?>
95
- <?php
96
- $page_slug = synved_option_page_slug($id, $name, $item);
 
 
97
  do_settings_sections( $page_slug );
98
- ?>
99
- <p class="submit">
100
- <input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e('Save Changes'); ?>" />
101
- <?php
102
- $render_fragment = synved_option_item_render_fragment($item);
103
- $out = null;
104
-
105
- if ($render_fragment != null)
106
- {
107
- $error = null;
108
- $new_out = null;
109
-
110
- try
111
- {
112
- $params = array();
113
- $new_out = $render_fragment->Invoke(array('page-submit-tail', '', $params, $name, $id, $item));
114
- }
115
- catch (Exception $ex)
116
- {
117
- $new_out = null;
118
-
119
- $error = $ex->getMessage();
120
- }
121
-
122
- if ($new_out !== null)
123
- {
124
- $out = $new_out;
125
  }
126
- }
127
-
128
- echo $out;
129
- ?>
130
- </p>
131
- </form>
132
- </div>
133
 
134
  <script type="text/javascript">
135
- const SYNVED_DISABLE_FEATURE_URL = '<?php echo admin_url('options-general.php?page=synved_social_settings&accept-terms=no'); ?>';
136
- const SYNVED_ENABLE_FEATURE_URL = '<?php echo admin_url('options-general.php?page=synved_social_settings&accept-terms=yes'); ?>';
137
 
138
- jQuery(document).ready(function () {
139
- synved_switcher.init(<?php echo synved_option_get('synved_social', 'accepted_sharethis_terms'); ?>);
140
- });
141
  </script>
 
 
142
 
143
- <?php
144
  }
145
 
146
- function synved_option_page_add($id, $name, $item)
147
- {
 
 
 
 
 
 
 
 
148
  global $synved_option_list;
149
 
150
- define('SYNVEDOPTION', $id);
151
- define('SYNVEDNAME', $name);
152
 
153
- $type = synved_option_item_type($item);
154
 
155
- if ($type == 'options-page')
156
- {
157
- $label = synved_option_item_label($item);
158
- $tip = synved_option_item_tip($item);
159
- $parent = synved_option_item_parent($item);
160
- $role = synved_option_item_role($item);
161
 
162
- if ($label == null)
163
- {
164
- $label = $name;
165
- }
166
-
167
  $page_slug = $id . '_' . $name;
168
 
169
  $page = add_submenu_page(
@@ -172,31 +178,38 @@ function synved_option_page_add($id, $name, $item)
172
  $label,
173
  $role,
174
  $page_slug,
175
- function($name){ return synved_option_page_cb(SYNVEDOPTION, SYNVEDNAME, synved_option_item_find(SYNVEDOPTION, SYNVEDNAME) ); }
176
- );
177
-
178
- $synved_option_list[$id]['pages'][$name]['wp-page-slug'] = $page_slug;
179
- $synved_option_list[$id]['pages'][$name]['wp-page'] = $page;
 
 
 
 
 
 
180
 
181
  return $page;
182
  }
183
-
184
  return null;
185
  }
186
 
187
- function synved_option_page_add_cb()
188
- {
 
 
 
 
189
  global $synved_option_list;
190
-
191
- if ($synved_option_list != null)
192
- {
193
- foreach ($synved_option_list as $id => $list)
194
- {
195
  $pages = $list['pages'];
196
-
197
- foreach ($pages as $name => $item)
198
- {
199
- synved_option_page_add($id, $name, $item);
200
  }
201
  }
202
  }
1
  <?php
2
 
3
+ /**
4
+ * Option page default values.
5
+ *
6
+ * @param $id
7
+ *
8
+ * @return array
9
+ */
10
+ function synved_option_page_default( $id ) {
11
+ return [ 'name' => 'page_settings', 'type' => 'options-page', 'label' => synved_option_label_from_id( $id ) ];
12
  }
13
 
14
+ /**
15
+ * Option page slug.
16
+ *
17
+ * @param $id
18
+ * @param $name
19
+ * @param $item
20
+ *
21
+ * @return mixed|null
22
+ */
23
+ function synved_option_page_slug( $id, $name, $item = null ) {
24
+ if ( $item == null ) {
25
+ $item = synved_option_item( $id, $name );
26
  }
 
 
 
27
 
28
+ $type = synved_option_item_type( $item );
29
+
30
+ if ( 'options-page' === $type ) {
31
  global $synved_option_list;
32
+
33
+ if ( isset( $synved_option_list[ $id ]['pages'][ $name ]['wp-page-slug'] ) ) {
34
+ return $synved_option_list[ $id ]['pages'][ $name ]['wp-page-slug'];
 
35
  }
36
  }
37
+
38
  return null;
39
  }
40
+
41
+ /**
42
+ * Option page link.
43
+ *
44
+ * @param $id
45
+ * @param $name
46
+ * @param $item
47
+ *
48
+ * @return string|null
49
+ */
50
+ function synved_option_page_link_url( $id, $name, $item = null ) {
51
+ if ( $item == null ) {
52
+ $item = synved_option_item( $id, $name );
53
  }
54
+
55
+ $type = synved_option_item_type( $item );
56
+ $parent = synved_option_item_parent( $item );
57
+ $slug = synved_option_page_slug( $id, $name, $item );
58
+
59
+ if ( 'options-page' === $type && false === empty( $slug ) ) {
60
+ return $parent . '?page=' . $slug;
 
 
 
 
61
  }
62
+
63
  return null;
64
  }
65
 
66
+ /**
67
+ * Option page callback function.
68
+ *
69
+ * @param $id
70
+ * @param $name
71
+ * @param $item
72
+ *
73
+ * @return void
74
+ */
75
+ function synved_option_page_cb( $id, $name, $item ) {
76
+ $group = synved_option_group_default( $id );
77
+ $label = synved_option_item_label( $item );
78
+ $title = synved_option_item_title( $item );
79
+ $tip = synved_option_item_tip( $item );
80
+ $role = synved_option_item_role( $item );
81
+ $style = synved_option_item_style( $item );
82
+
83
+ if ( ! current_user_can( $role ) ) {
84
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'synved-option' ) );
85
  }
86
+
87
+ if ( $title === null ) {
 
88
  $title = $label;
89
  }
90
+
91
+ $class_list = [ 'wrap' ];
92
+
93
+ if ( false === empty( $style ) ) {
94
+ foreach ( $style as $style_name ) {
95
+ $class_list[] = 'synved-option-style-' . $style_name;
 
 
96
  }
97
  }
98
+
99
+ ob_start();
100
+ ?>
101
+ <div class="<?php echo esc_attr( implode( ' ', $class_list ) ); ?>">
102
+ <div class="icon32" id="icon-options-general"><br/></div>
103
+ <h2><?php echo esc_html( $title ); ?></h2>
104
+ <p><?php echo wp_kses_post( $tip ); ?></p>
105
+ <form action="options.php" method="post">
106
+ <?php settings_fields( $group ); ?>
107
+ <?php
108
+ $page_slug = synved_option_page_slug( $id, $name, $item );
109
  do_settings_sections( $page_slug );
110
+ ?>
111
+ <p class="submit">
112
+ <input name="Submit" type="submit" class="button-primary"
113
+ value="<?php esc_attr_e( 'Save Changes', 'synved-option' ); ?>"/>
114
+ <?php
115
+ $render_fragment = synved_option_item_render_fragment( $item );
116
+ $out = null;
117
+
118
+ if ( false === empty( $render_fragment ) ) {
119
+ try {
120
+ $params = [];
121
+ $new_out = $render_fragment->Invoke( [ 'page-submit-tail', '', $params, $name, $id, $item ] );
122
+ } catch ( Exception $ex ) {
123
+ $new_out = null;
124
+ }
125
+
126
+ if ( false === empty( $new_out ) ) {
127
+ $out = $new_out;
128
+ }
 
 
 
 
 
 
 
 
129
  }
130
+
131
+ echo $out;
132
+ ?>
133
+ </p>
134
+ </form>
135
+ </div>
 
136
 
137
  <script type="text/javascript">
138
+ const SYNVED_DISABLE_FEATURE_URL = '<?php echo esc_js( admin_url( 'options-general.php?page=synved_social_settings&accept-terms=no' ) ); ?>';
139
+ const SYNVED_ENABLE_FEATURE_URL = '<?php echo esc_js( admin_url( 'options-general.php?page=synved_social_settings&accept-terms=yes' ) ); ?>';
140
 
141
+ jQuery( document ).ready( function() {
142
+ synved_switcher.init(<?php echo synved_option_get( 'synved_social', 'accepted_sharethis_terms' ); ?>);
143
+ } );
144
  </script>
145
+ <?php
146
+ $html = ob_get_clean();
147
 
148
+ echo wp_kses( $html, synved_get_allowed_html_array() );
149
  }
150
 
151
+ /**
152
+ * Add option page.
153
+ *
154
+ * @param $id
155
+ * @param $name
156
+ * @param $item
157
+ *
158
+ * @return false|string|null
159
+ */
160
+ function synved_option_page_add( $id, $name, $item ) {
161
  global $synved_option_list;
162
 
163
+ define( 'SYNVEDOPTION', $id );
164
+ define( 'SYNVEDNAME', $name );
165
 
166
+ $type = synved_option_item_type( $item );
167
 
168
+ if ( $type == 'options-page' ) {
169
+ $label = synved_option_item_label( $item ) ?? $name;
170
+ $parent = synved_option_item_parent( $item );
171
+ $role = synved_option_item_role( $item );
 
 
172
 
 
 
 
 
 
173
  $page_slug = $id . '_' . $name;
174
 
175
  $page = add_submenu_page(
178
  $label,
179
  $role,
180
  $page_slug,
181
+ function () {
182
+ synved_option_page_cb(
183
+ SYNVEDOPTION,
184
+ SYNVEDNAME,
185
+ synved_option_item_find( SYNVEDOPTION, SYNVEDNAME )
186
+ );
187
+ }
188
+ );
189
+
190
+ $synved_option_list[ $id ]['pages'][ $name ]['wp-page-slug'] = $page_slug;
191
+ $synved_option_list[ $id ]['pages'][ $name ]['wp-page'] = $page;
192
 
193
  return $page;
194
  }
195
+
196
  return null;
197
  }
198
 
199
+ /**
200
+ * Page add callback function.
201
+ *
202
+ * @return void
203
+ */
204
+ function synved_option_page_add_cb() {
205
  global $synved_option_list;
206
+
207
+ if ( false === empty( $synved_option_list ) ) {
208
+ foreach ( $synved_option_list as $id => $list ) {
 
 
209
  $pages = $list['pages'];
210
+
211
+ foreach ( $pages as $name => $item ) {
212
+ synved_option_page_add( $id, $name, $item );
 
213
  }
214
  }
215
  }
synved-option/synved-option-render.php CHANGED
@@ -3,131 +3,15 @@
3
  function synved_option_render_field_name($id, $name)
4
  {
5
  $out_name = synved_option_name_default($id) . '[' . $name . ']';
6
-
7
  return $out_name;
8
  }
9
 
10
  function synved_option_render_field_id($id, $name)
11
  {
12
  $out_id = synved_option_name_default($id) . '_' . $name;
13
-
14
- return $out_id;
15
- }
16
-
17
- // XXX taken from WordPres, clean up...
18
- function synved_option_render_page($page)
19
- {
20
- global $wp_settings_sections, $wp_settings_fields;
21
-
22
- if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
23
- return;
24
-
25
- foreach ( (array) $wp_settings_sections[$page] as $section )
26
- {
27
- echo "<h3>{$section['title']}</h3>\n";
28
- call_user_func($section['callback'], $section);
29
- if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
30
- continue;
31
- echo '<table class="form-table">';
32
- synved_option_render_section($page, $section['id']);
33
- echo '</table>';
34
- }
35
- }
36
-
37
- // XXX taken from WordPres, clean up...
38
- function synved_option_render_section($page, $section)
39
- {
40
- global $wp_settings_fields;
41
-
42
- if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
43
- return;
44
-
45
- $index = 0;
46
-
47
- foreach ((array) $wp_settings_fields[$page][$section] as $field)
48
- {
49
- $callback = $field['callback'];
50
- $args = $field['args'];
51
- $id = null;
52
- $name = null;
53
- $item = null;
54
-
55
- if ($callback == 'synved_option_call_array' && $args[0] == 'synved_option_setting_cb')
56
- {
57
- $extra_args = $args[1];
58
- $id = $extra_args[0];
59
- $name = $extra_args[1];
60
- $item = $extra_args[2];
61
- }
62
-
63
- if ($item == null)
64
- continue;
65
-
66
- $type = synved_option_item_type($item);
67
- $hidden = synved_option_item_hidden($item);
68
- $style = synved_option_item_style($item);
69
-
70
- $class_list = array();
71
- $class_list[] = 'synved-option-type-' . $type;
72
-
73
- if ($style != null)
74
- {
75
- foreach ($style as $style_name)
76
- {
77
- $class_list[] = 'synved-option-style-' . $style_name;
78
 
79
- // XXX exception
80
- if ($style_name == 'addon-important')
81
- {
82
- if ($type == 'addon')
83
- {
84
- if (synved_option_item_addon_is_installed($item))
85
- {
86
- $class_list[] = 'synved-option-style-' . $style_name . '-installed';
87
- }
88
- }
89
- }
90
- else if ($style_name == 'group')
91
- {
92
- if ($index > 0)
93
- {
94
- $class_list[] = 'synved-option-style-' . $style_name . '-active';
95
- }
96
- }
97
- }
98
- }
99
-
100
- $class = null;
101
- $css = null;
102
-
103
- if ($class_list != null)
104
- {
105
- $class = ' class="' . implode(' ', $class_list) . '"';
106
- }
107
-
108
- if ($hidden)
109
- {
110
- $css = ' style="display: none;"';
111
- }
112
-
113
- echo '<tr valign="top"' . $class . $css . '>';
114
-
115
- if (!empty($field['args']['label_for']))
116
- echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
117
- else
118
- echo '<th scope="row">' . $field['title'] . '</th>';
119
- echo '<td>';
120
-
121
- if ($item != null)
122
- {
123
- synved_option_render_item($id, $name, $item, true);
124
- }
125
-
126
- echo '</td>';
127
- echo '</tr>';
128
-
129
- $index++;
130
- }
131
  }
132
 
133
  function synved_option_render_item($id, $name, $item = null, $render = false, $params = null, $context = null)
@@ -136,12 +20,12 @@ function synved_option_render_item($id, $name, $item = null, $render = false, $p
136
  {
137
  $item = synved_option_item($id, $name);
138
  }
139
-
140
  if ($item == null)
141
  {
142
  return null;
143
  }
144
-
145
  $value = synved_option_get($id, $name);
146
  $type = synved_option_item_type($item);
147
  $style = synved_option_item_style($item);
@@ -151,61 +35,61 @@ function synved_option_render_item($id, $name, $item = null, $render = false, $p
151
  $default = synved_option_item_default($item);
152
  $set = synved_option_item_set($item);
153
  $set_is_linear = false;
154
-
155
  if ($set != null)
156
  {
157
  $set_is_linear = true;
158
-
159
  foreach ($set as $set_it)
160
  {
161
  if (count($set_it) > 1)
162
  {
163
  $set_is_linear = false;
164
-
165
  break;
166
  }
167
  }
168
  }
169
-
170
  $out_name = synved_option_render_field_name($id, $name);
171
  $out_id = synved_option_render_field_id($id, $name);
172
  $out = null;
173
-
174
  if (isset($params['output_name']))
175
  {
176
  $out_name = $params['output_name'];
177
  }
178
-
179
  if (isset($params['output_id']))
180
  {
181
  $out_id = $params['output_id'];
182
  }
183
-
184
  if (isset($params['tip']))
185
  {
186
  $tip = $params['tip'];
187
  }
188
-
189
  if (isset($params['default']))
190
  {
191
  $default = $params['default'];
192
  }
193
-
194
  if (isset($params['value']))
195
  {
196
  $value = $params['value'];
197
  }
198
-
199
  $new_value = $value;
200
  $error_list = synved_option_item_validate_value($id, $name, $value, $new_value, $item);
201
 
202
  if ($new_value != $value && ($context == null || $context == 'settings'))
203
  {
204
  synved_option_set($id, $name, $new_value);
205
-
206
  $value = synved_option_get($id, $name);
207
  }
208
-
209
  if ($error_list != null)
210
  {
211
  foreach ($error_list as $error)
@@ -213,46 +97,62 @@ function synved_option_render_item($id, $name, $item = null, $render = false, $p
213
  $out .= '<div id="message" class="error"><p>For "<i>' . $label . '</i>": ' . $error['message'] . '</p></div>';
214
  }
215
  }
216
-
217
  if ($set_is_linear)
218
  {
219
  $out .= '<select name="' . $out_name . '" id="' . $out_id . '">';
220
-
221
  // XXX exception...remove at some point
222
  if (isset($params['set_before']))
223
  {
224
  $set_before = $params['set_before'];
225
-
226
  $set = array_merge($set_before, $set);
227
  }
228
-
229
  foreach ($set as $set_it)
230
  {
231
  $set_it_keys = array_keys($set_it);
232
  $selected = $set_it_keys[0] == $value ? ' selected="selected"' : null;
233
-
234
  $out .= '<option value="' . $set_it_keys[0] . '"' . $selected . '>' . $set_it[$set_it_keys[0]] . '</option>';
235
  }
236
-
237
  $out .= '</select>';
238
  }
239
  else
240
  {
241
  $placeholder = null;
242
-
243
  if ($hint != null)
244
  {
245
  $placeholder = ' placeholder="' . esc_attr($hint) . '"';
246
  }
247
-
248
  switch ($type)
249
  {
250
  case 'boolean':
251
  {
252
  $checked = $value == true ? ' checked="checked"' : null;
253
-
254
- $out .= '<fieldset><legend class="screen-reader-text"><span>' . $label . '</span></legend><label for="' . $out_id . '"><input type="hidden" name="' . $out_name . '" value="0" /><input name="' . $out_name . '" id="' . $out_id . '" type="checkbox" value="1" class="code" ' . $checked . $placeholder . ' /> ' . $label . '</label>&nbsp;&nbsp;<span class="description" style="vertical-align:middle;">' . $tip . '</span></fieldset>';
255
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  break;
257
  }
258
  case 'text':
@@ -267,71 +167,71 @@ function synved_option_render_item($id, $name, $item = null, $render = false, $p
267
  $content = null;
268
  $tag = 'input';
269
  $extended = false;
270
-
271
  if ($style != null)
272
  {
273
  if (in_array('wide', $style))
274
  {
275
  $atts['class'] = 'wide-text';
276
  }
277
-
278
  if (in_array('extend', $style))
279
  {
280
  $extended = true;
281
  }
282
  }
283
-
284
  if (in_array($type, array('style', 'script')))
285
  {
286
  $extended = true;
287
-
288
  $att_style['width'] = '450px';
289
  $att_style['height'] = '250px';
290
  }
291
-
292
  if ($extended)
293
  {
294
  $tag = 'textarea';
295
-
296
  if (isset($atts['value']))
297
  {
298
  $content = $atts['value'];
299
-
300
  unset($atts['value']);
301
  }
302
-
303
  if ($content == null)
304
  {
305
  $content = '';
306
  }
307
-
308
  unset($atts['type']);
309
  }
310
-
311
  if ($hint != null)
312
  {
313
  $atts['placeholder'] = $hint;
314
  }
315
-
316
  if ($att_style != null)
317
  {
318
  $att_css = null;
319
-
320
  foreach ($att_style as $style_name => $style_value)
321
  {
322
  $att_css .= $style_name . ':' . $style_value . ';';
323
  }
324
-
325
  $atts['style'] = $att_css;
326
  }
327
-
328
  $out .= '<' . $tag;
329
-
330
  foreach ($atts as $att_name => $att_value)
331
  {
332
  $out .= ' ' . $att_name . '="' . esc_attr($att_value) . '"';
333
  }
334
-
335
  if ($content !== null)
336
  {
337
  $out .= '>' . esc_html($content) . '</' . $tag . '>';
@@ -340,29 +240,43 @@ function synved_option_render_item($id, $name, $item = null, $render = false, $p
340
  {
341
  $out .= ' />';
342
  }
343
-
344
  if (in_array($type, array('image', 'video', 'media')))
345
  {
346
  $out .= '<input type="hidden" name="' . esc_attr(synved_option_render_field_name($id, $name . '_info_')) . '" value="' . esc_attr($type) . '" />';
347
  $out .= '&nbsp;&nbsp;<input type="button" class="synved-option-upload-button" value="' . esc_attr(__('Select File', 'synved-option')) . '"' . $placeholder . ' />';
348
  }
349
-
350
  break;
351
  }
352
  case 'color':
353
  {
354
  $out .= '<div style="position:relative; float: left;">';
355
- $out .= '<input name="' . $out_name . '" id="' . $out_id . '" type="text" value="' . esc_attr($value) . '" class="code medium-text color-input"' . $placeholder . ' />';
 
 
 
 
 
 
 
 
356
  $out .= '<div class="synved-option-color-input-picker" style="background:white;border:solid 1px #ccc;display:none;position:absolute;top:100%;left:0;z-index:10000;"></div>';
357
  $out .= '</div>';
358
-
359
  break;
360
  }
361
  case 'integer':
362
  case 'decimal':
363
  {
364
- $out .= '<input name="' . $out_name . '" id="' . $out_id . '" type="text" value="' . esc_attr($value) . '" class="code small-text"' . $placeholder . ' />';
365
-
 
 
 
 
 
 
366
  break;
367
  }
368
  case 'user':
@@ -374,9 +288,9 @@ function synved_option_render_item($id, $name, $item = null, $render = false, $p
374
  'echo' => false, 'name' => $out_name, 'id' => $name, 'selected' => $value,
375
  'show_option_all' => __('Every', 'synved-option') . ' ' . ucfirst($type)
376
  );
377
-
378
  $drop_out = null;
379
-
380
  switch ($type)
381
  {
382
  case 'author':
@@ -386,33 +300,41 @@ function synved_option_render_item($id, $name, $item = null, $render = false, $p
386
  case 'user':
387
  {
388
  $drop_out = wp_dropdown_users($args);
389
-
390
  break;
391
  }
392
  case 'category':
393
  {
394
  $drop_out = wp_dropdown_categories($args);
395
-
396
  break;
397
  }
398
  case 'page':
399
  {
400
  $args['show_option_no_change'] = $args['show_option_all'];
401
-
402
  $drop_out = wp_dropdown_pages($args);
403
-
404
  break;
405
  }
406
  }
407
-
408
  $out .= $drop_out;
409
-
410
  break;
411
  }
412
  case 'tag-list':
413
  {
414
- $out .= '<input name="' . $out_name . '" id="' . $out_id . '" type="text" value="' . esc_attr($value) . '" class="regular-text synved-option-tag-selector"' . $placeholder . ' />';
415
-
 
 
 
 
 
 
 
 
416
  break;
417
  }
418
  case 'addon':
@@ -421,59 +343,53 @@ function synved_option_render_item($id, $name, $item = null, $render = false, $p
421
  {
422
  $out .= synved_option_render_type_addon($id, $name, $item, $out_name, array('out_id' => $out_id, 'label' => $label));
423
  }
424
-
425
  break;
426
  }
427
  }
428
-
429
- if ($hint != null)
430
- {
431
- $out .= ' <span class="snvdopt"><a class="button synved-option-reset-button" title="' . __('Set value to default hinted background value', 'synved-option') . '" style="display: inline-block; padding: 0; vertical-align: middle; cursor: pointer;"><span class="ui-icon ui-icon-arrowrefresh-1-w"> </span></a></span>';
432
  }
433
  }
434
-
435
  $item_render = synved_option_item_render($item);
436
-
437
- if ($item_render != null)
438
- {
439
- $error = null;
440
- $new_out = null;
441
-
442
- try
443
- {
444
- $params = array('output_name' => $out_name, 'output_id' => $out_id, 'output' => $out, 'set' => $set, 'label' => $label);
445
- $new_out = $item_render->Invoke(array($value, $params, $name, $id, $item));
446
- }
447
- catch (Exception $ex)
448
- {
449
- $new_out = null;
450
-
451
- $error = $ex->getMessage();
452
  }
453
-
454
- if ($new_out !== null)
455
- {
456
  $out = $new_out;
457
  }
458
  }
459
-
460
- if ($out != null)
461
- {
462
- if ($tip != null && $type != 'boolean')
463
- {
464
  $tip_class = ' description-' . $type;
465
- $out .= '&nbsp;&nbsp;<span class="description' . $tip_class . '">' . $tip . '</span>';
466
  }
467
-
468
- if ($render)
469
- {
 
 
470
  echo $out;
471
- }
472
- else
473
- {
474
  return $out;
475
  }
476
  }
477
-
478
  return null;
479
  }
3
  function synved_option_render_field_name($id, $name)
4
  {
5
  $out_name = synved_option_name_default($id) . '[' . $name . ']';
6
+
7
  return $out_name;
8
  }
9
 
10
  function synved_option_render_field_id($id, $name)
11
  {
12
  $out_id = synved_option_name_default($id) . '_' . $name;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ return $out_id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
 
17
  function synved_option_render_item($id, $name, $item = null, $render = false, $params = null, $context = null)
20
  {
21
  $item = synved_option_item($id, $name);
22
  }
23
+
24
  if ($item == null)
25
  {
26
  return null;
27
  }
28
+
29
  $value = synved_option_get($id, $name);
30
  $type = synved_option_item_type($item);
31
  $style = synved_option_item_style($item);
35
  $default = synved_option_item_default($item);
36
  $set = synved_option_item_set($item);
37
  $set_is_linear = false;
38
+
39
  if ($set != null)
40
  {
41
  $set_is_linear = true;
42
+
43
  foreach ($set as $set_it)
44
  {
45
  if (count($set_it) > 1)
46
  {
47
  $set_is_linear = false;
48
+
49
  break;
50
  }
51
  }
52
  }
53
+
54
  $out_name = synved_option_render_field_name($id, $name);
55
  $out_id = synved_option_render_field_id($id, $name);
56
  $out = null;
57
+
58
  if (isset($params['output_name']))
59
  {
60
  $out_name = $params['output_name'];
61
  }
62
+
63
  if (isset($params['output_id']))
64
  {
65
  $out_id = $params['output_id'];
66
  }
67
+
68
  if (isset($params['tip']))
69
  {
70
  $tip = $params['tip'];
71
  }
72
+
73
  if (isset($params['default']))
74
  {
75
  $default = $params['default'];
76
  }
77
+
78
  if (isset($params['value']))
79
  {
80
  $value = $params['value'];
81
  }
82
+
83
  $new_value = $value;
84
  $error_list = synved_option_item_validate_value($id, $name, $value, $new_value, $item);
85
 
86
  if ($new_value != $value && ($context == null || $context == 'settings'))
87
  {
88
  synved_option_set($id, $name, $new_value);
89
+
90
  $value = synved_option_get($id, $name);
91
  }
92
+
93
  if ($error_list != null)
94
  {
95
  foreach ($error_list as $error)
97
  $out .= '<div id="message" class="error"><p>For "<i>' . $label . '</i>": ' . $error['message'] . '</p></div>';
98
  }
99
  }
100
+
101
  if ($set_is_linear)
102
  {
103
  $out .= '<select name="' . $out_name . '" id="' . $out_id . '">';
104
+
105
  // XXX exception...remove at some point
106
  if (isset($params['set_before']))
107
  {
108
  $set_before = $params['set_before'];
109
+
110
  $set = array_merge($set_before, $set);
111
  }
112
+
113
  foreach ($set as $set_it)
114
  {
115
  $set_it_keys = array_keys($set_it);
116
  $selected = $set_it_keys[0] == $value ? ' selected="selected"' : null;
117
+
118
  $out .= '<option value="' . $set_it_keys[0] . '"' . $selected . '>' . $set_it[$set_it_keys[0]] . '</option>';
119
  }
120
+
121
  $out .= '</select>';
122
  }
123
  else
124
  {
125
  $placeholder = null;
126
+
127
  if ($hint != null)
128
  {
129
  $placeholder = ' placeholder="' . esc_attr($hint) . '"';
130
  }
131
+
132
  switch ($type)
133
  {
134
  case 'boolean':
135
  {
136
  $checked = $value == true ? ' checked="checked"' : null;
137
+
138
+ $out .= '<fieldset><legend class="screen-reader-text"><span>'
139
+ . esc_attr($label)
140
+ . '</span></legend><label for="'
141
+ . esc_attr($out_id)
142
+ . '"><input type="hidden" name="'
143
+ . esc_attr($out_name)
144
+ . '" value="0" /><input name="'
145
+ . esc_attr($out_name)
146
+ . '" id="'
147
+ . esc_attr($out_id)
148
+ . '" type="checkbox" value="1" class="code" '
149
+ . $checked
150
+ . $placeholder
151
+ . ' /> '
152
+ . '</label>&nbsp;&nbsp;<span class="description" style="vertical-align:middle;">'
153
+ . esc_html($tip)
154
+ . '</span></fieldset>';
155
+
156
  break;
157
  }
158
  case 'text':
167
  $content = null;
168
  $tag = 'input';
169
  $extended = false;
170
+
171
  if ($style != null)
172
  {
173
  if (in_array('wide', $style))
174
  {
175
  $atts['class'] = 'wide-text';
176
  }
177
+
178
  if (in_array('extend', $style))
179
  {
180
  $extended = true;
181
  }
182
  }
183
+
184
  if (in_array($type, array('style', 'script')))
185
  {
186
  $extended = true;
187
+
188
  $att_style['width'] = '450px';
189
  $att_style['height'] = '250px';
190
  }
191
+
192
  if ($extended)
193
  {
194
  $tag = 'textarea';
195
+
196
  if (isset($atts['value']))
197
  {
198
  $content = $atts['value'];
199
+
200
  unset($atts['value']);
201
  }
202
+
203
  if ($content == null)
204
  {
205
  $content = '';
206
  }
207
+
208
  unset($atts['type']);
209
  }
210
+
211
  if ($hint != null)
212
  {
213
  $atts['placeholder'] = $hint;
214
  }
215
+
216
  if ($att_style != null)
217
  {
218
  $att_css = null;
219
+
220
  foreach ($att_style as $style_name => $style_value)
221
  {
222
  $att_css .= $style_name . ':' . $style_value . ';';
223
  }
224
+
225
  $atts['style'] = $att_css;
226
  }
227
+
228
  $out .= '<' . $tag;
229
+
230
  foreach ($atts as $att_name => $att_value)
231
  {
232
  $out .= ' ' . $att_name . '="' . esc_attr($att_value) . '"';
233
  }
234
+
235
  if ($content !== null)
236
  {
237
  $out .= '>' . esc_html($content) . '</' . $tag . '>';
240
  {
241
  $out .= ' />';
242
  }
243
+
244
  if (in_array($type, array('image', 'video', 'media')))
245
  {
246
  $out .= '<input type="hidden" name="' . esc_attr(synved_option_render_field_name($id, $name . '_info_')) . '" value="' . esc_attr($type) . '" />';
247
  $out .= '&nbsp;&nbsp;<input type="button" class="synved-option-upload-button" value="' . esc_attr(__('Select File', 'synved-option')) . '"' . $placeholder . ' />';
248
  }
249
+
250
  break;
251
  }
252
  case 'color':
253
  {
254
  $out .= '<div style="position:relative; float: left;">';
255
+ $out .= '<input name="'
256
+ . esc_attr( $out_name )
257
+ . '" id="'
258
+ . esc_attr( $out_id )
259
+ . '" type="text" value="'
260
+ . esc_attr( $value )
261
+ . '" class="code medium-text color-input"'
262
+ . $placeholder
263
+ . ' />';
264
  $out .= '<div class="synved-option-color-input-picker" style="background:white;border:solid 1px #ccc;display:none;position:absolute;top:100%;left:0;z-index:10000;"></div>';
265
  $out .= '</div>';
266
+
267
  break;
268
  }
269
  case 'integer':
270
  case 'decimal':
271
  {
272
+ $out .= '<input name="'
273
+ . esc_attr($out_name)
274
+ . '" id="'
275
+ . esc_attr($out_id)
276
+ . '" type="text" value="'
277
+ . esc_attr($value)
278
+ . '" class="code small-text"'
279
+ . $placeholder . ' />';
280
  break;
281
  }
282
  case 'user':
288
  'echo' => false, 'name' => $out_name, 'id' => $name, 'selected' => $value,
289
  'show_option_all' => __('Every', 'synved-option') . ' ' . ucfirst($type)
290
  );
291
+
292
  $drop_out = null;
293
+
294
  switch ($type)
295
  {
296
  case 'author':
300
  case 'user':
301
  {
302
  $drop_out = wp_dropdown_users($args);
303
+
304
  break;
305
  }
306
  case 'category':
307
  {
308
  $drop_out = wp_dropdown_categories($args);
309
+
310
  break;
311
  }
312
  case 'page':
313
  {
314
  $args['show_option_no_change'] = $args['show_option_all'];
315
+
316
  $drop_out = wp_dropdown_pages($args);
317
+
318
  break;
319
  }
320
  }
321
+
322
  $out .= $drop_out;
323
+
324
  break;
325
  }
326
  case 'tag-list':
327
  {
328
+ $out .= '<input name="'
329
+ . esc_attr($out_name)
330
+ . '" id="'
331
+ . esc_attr($out_id)
332
+ . '" type="text" value="'
333
+ . esc_attr($value)
334
+ . '" class="regular-text synved-option-tag-selector"'
335
+ . $placeholder
336
+ . ' />';
337
+
338
  break;
339
  }
340
  case 'addon':
343
  {
344
  $out .= synved_option_render_type_addon($id, $name, $item, $out_name, array('out_id' => $out_id, 'label' => $label));
345
  }
346
+
347
  break;
348
  }
349
  }
350
+
351
+ if ( $hint != null ) {
352
+ $out .= ' <span class="snvdopt"><a class="button synved-option-reset-button" title="' . __( 'Set value to default hinted background value',
353
+ 'synved-option' ) . '" style="display: inline-block; padding: 0; vertical-align: middle; cursor: pointer;"><span class="ui-icon ui-icon-arrowrefresh-1-w"> </span></a></span>';
354
  }
355
  }
356
+
357
  $item_render = synved_option_item_render($item);
358
+
359
+ if ( $item_render != null ) {
360
+ try {
361
+ $params = [
362
+ 'output_name' => $out_name,
363
+ 'output_id' => $out_id,
364
+ 'output' => $out,
365
+ 'set' => $set,
366
+ 'label' => $label,
367
+ ];
368
+ $new_out = $item_render->Invoke( [ $value, $params, $name, $id, $item ] );
369
+ } catch ( Exception $ex ) {
370
+ $new_out = '';
 
 
 
371
  }
372
+
373
+ if ( false === empty( $new_out ) ) {
 
374
  $out = $new_out;
375
  }
376
  }
377
+
378
+ if ( false === empty( $out ) ) {
379
+ if ( $tip != null && $type != 'boolean' ) {
 
 
380
  $tip_class = ' description-' . $type;
381
+ $out .= '&nbsp;&nbsp;<span class="description' . $tip_class . '">' . $tip . '</span>';
382
  }
383
+
384
+ // Escape our output.
385
+ $out = wp_kses( $out, synved_get_allowed_html_array() );
386
+
387
+ if ( $render ) {
388
  echo $out;
389
+ } else {
 
 
390
  return $out;
391
  }
392
  }
393
+
394
  return null;
395
  }
synved-option/synved-option-section.php CHANGED
@@ -8,16 +8,10 @@ function synved_option_section_default_name($id, $page)
8
  function synved_option_section_default($id, $page)
9
  {
10
  $section = synved_option_section_default_name($id, $page);
11
-
12
- return array('name' => $section, 'type' => 'options-section', 'label' => __('General Settings', 'synved-option'), 'tip' => __('General Settings for', 'synved-option') . ' ' . synved_option_label_from_id($id));
13
- }
14
 
15
- function synved_option_settings_section_cb($name, $item)
16
- {
17
- $tip = synved_option_item_tip($item);
18
-
19
- if ($tip != null)
20
- {
21
- echo '<p>' . $tip . '</p>';
22
- }
23
  }
8
  function synved_option_section_default($id, $page)
9
  {
10
  $section = synved_option_section_default_name($id, $page);
 
 
 
11
 
12
+ return ['name' => $section,
13
+ 'type' => 'options-section',
14
+ 'label' => __('General Settings', 'synved-option'),
15
+ 'tip' => __('General Settings for', 'synved-option') . ' ' . synved_option_label_from_id($id),
16
+ ];
 
 
 
17
  }
synved-option/synved-option-setting.php CHANGED
@@ -1,17 +1,89 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  function synved_option_setting_sanitize_cb($id, $values)
4
  {
5
  if ($values != null && is_array($values))
6
- {
7
  foreach ($values as $name => $value)
8
  {
9
  $values[$name] = synved_option_item_sanitize_value($id, $name, $values[$name]);
10
  }
11
-
12
  return $values;
13
  }
14
-
15
  return array();
16
  }
17
 
1
  <?php
2
 
3
+ /**
4
+ * @param $post
5
+ *
6
+ * @return array|mixed
7
+ */
8
+ function synved_option_setting_sanitize_item_callback($post) {
9
+ if (is_array($post)) {
10
+ foreach ($post as $item_key => &$item) {
11
+ switch ($item_key) {
12
+ case 'rss_follow_link':
13
+ case 'youtube_follow_link':
14
+ case 'vimeo_follow_link':
15
+ case 'instagram_follow_link':
16
+ case 'flickr_follow_link':
17
+ case 'foursquare_follow_link':
18
+ case 'facebook_follow_link':
19
+ case 'facebook_share_link':
20
+ case 'twitter_follow_link':
21
+ case 'twitter_share_link':
22
+ case 'reddit_share_link':
23
+ case 'pinterest_follow_link':
24
+ case 'pinterest_share_link':
25
+ case 'linkedin_follow_link':
26
+ case 'linkedin_share_link':
27
+ case 'tumblr_follow_link':
28
+ case 'tumblr_share_link':
29
+ $item = esc_url($item);
30
+ break;
31
+ case 'automatic_append_postfix':
32
+ case 'automatic_append_separator':
33
+ case 'automatic_append_prefix':
34
+ case 'automatic_follow_postfix':
35
+ case 'automatic_follow_prefix':
36
+ case 'automatic_share_postfix':
37
+ case 'automatic_share_prefix':
38
+ case 'custom_style':
39
+ case 'share_prefix_markup':
40
+ $item = str_replace('alert(', 'alert\(', $item);
41
+ $item = wp_kses_post($item);
42
+ break;
43
+ case 'automatic_share_position':
44
+ case 'automatic_follow_position':
45
+ case 'share_message_default':
46
+ $item = esc_html($item);
47
+ break;
48
+ case 'fb_app_id':
49
+ $item = preg_replace('/[^a-zA-Z0-9]+/', '', $item);
50
+ break;
51
+ case 'automatic_follow':
52
+ case 'automatic_follow_before_share':
53
+ case 'automatic_follow_single':
54
+ case 'automatic_share':
55
+ case 'automatic_share_single':
56
+ case 'show_credit':
57
+ case 'layout_rtl':
58
+ case 'accepted_sharethis_terms':
59
+ case 'hide_sharethis_terms':
60
+ case 'share_full_url':
61
+ case 'shortcode_widgets':
62
+ case 'use_shortlinks':
63
+ $item = filter_var($item, FILTER_SANITIZE_NUMBER_INT);
64
+ break;
65
+ default:
66
+ $item = filter_var($item, FILTER_SANITIZE_STRING);
67
+ break;
68
+ }
69
+ }
70
+ }
71
+
72
+ return $post;
73
+ }
74
+
75
  function synved_option_setting_sanitize_cb($id, $values)
76
  {
77
  if ($values != null && is_array($values))
78
+ {
79
  foreach ($values as $name => $value)
80
  {
81
  $values[$name] = synved_option_item_sanitize_value($id, $name, $values[$name]);
82
  }
83
+
84
  return $values;
85
  }
86
+
87
  return array();
88
  }
89
 
synved-option/synved-option.php CHANGED
@@ -16,119 +16,17 @@ NO LIABILITY
16
  In no event shall Synved Ltd. be liable to you or any third party for any direct or indirect, special, incidental, or consequential damages in connection with or arising from errors, omissions, delays or other cause of action that may be attributed to your use of any product, support, services, information or software provided, including, but not limited to, lost profits or lost data, even if Synved Ltd. had been advised of the possibility of such damages.
17
  */
18
 
 
19
 
20
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-option-item.php');
21
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-option-page.php');
22
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-option-section.php');
23
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-option-render.php');
24
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-option-setting.php');
 
25
 
26
-
27
- define('SYNVED_OPTION_LOADED', true);
28
- define('SYNVED_OPTION_VERSION', 100040008);
29
- define('SYNVED_OPTION_VERSION_STRING', '1.4.8');
30
-
31
-
32
- $synved_option = array();
33
- $synved_option_list = array();
34
-
35
-
36
- class SynvedOptionCallback
37
- {
38
- private $_Object;
39
- private $_Callback;
40
- private $_Default;
41
- private $_Params;
42
-
43
- public function __construct($callback, $object = null, $default = null, array $callback_parameters = null)
44
- {
45
- $this->_Object = $object;
46
- $this->_Callback = $callback;
47
- $this->_Default = $default;
48
- $this->_Params = $callback_parameters;
49
- }
50
-
51
- public function __invoke($arguments = null)
52
- {
53
- if (!is_array($arguments) || func_num_args() > 1)
54
- {
55
- $arguments = func_get_args();
56
- }
57
-
58
- return $this->InvokeInternal($arguments);
59
- }
60
-
61
- public function Invoke($arguments = null)
62
- {
63
- if (!is_array($arguments) || func_num_args() > 1)
64
- {
65
- $arguments = func_get_args();
66
- }
67
-
68
- return $this->InvokeInternal($arguments);
69
- }
70
-
71
- protected function InvokeInternal(array $arguments = null)
72
- {
73
- $func = $this->_Callback;
74
-
75
- if ($this->_Object != null)
76
- {
77
- $func = array($this->_Object, $func);
78
- }
79
-
80
- $parameters = $this->_Params;
81
-
82
- if ($parameters != null)
83
- {
84
- $parameter_keys = array_keys($parameters);
85
- $count = count($parameter_keys);
86
- $argument_list = array();
87
-
88
- for ($i = 0; $i < $count; $i++)
89
- {
90
- $key = $parameter_keys[$i];
91
- $parameter = $parameters[$key];
92
- $value = isset($parameter['default']) ? $parameter['default'] : null;
93
-
94
- if (isset($arguments[$key]))
95
- {
96
- $value = $arguments[$key];
97
- }
98
- else if (isset($arguments[$i]))
99
- {
100
- $value = $arguments[$i];
101
- }
102
-
103
- $argument_list[$i] = $value;
104
- }
105
-
106
- $arguments = $argument_list;
107
- }
108
-
109
- if (!isset($arguments[0]) || $arguments[0] === null)
110
- {
111
- $arguments[0] = $this->_Default;
112
- }
113
-
114
- if (is_callable($func))
115
- {
116
- return call_user_func_array($func, $arguments);
117
- }
118
-
119
- return $arguments[0];
120
- }
121
- }
122
-
123
- function synved_option_version()
124
- {
125
- return SYNVED_OPTION_VERSION;
126
- }
127
-
128
- function synved_option_version_string()
129
- {
130
- return SYNVED_OPTION_VERSION_STRING;
131
- }
132
 
133
  function synved_option_callback($callback, $default = null, $callback_parameters = null)
134
  {
@@ -570,46 +468,132 @@ function synved_option_group_default($id)
570
  return $group;
571
  }
572
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
573
  function synved_option_wp_handle_setting($id, $page, $section, $name, $item)
574
  {
575
- $type = synved_option_item_type($item);
576
- $label = synved_option_item_label($item);
577
  $sections = isset($item['sections']) ? $item['sections'] : null;
578
  $settings = isset($item['settings']) ? $item['settings'] : null;
579
 
580
- $GLOBALS['name'] = $name;
581
- $GLOBALS['id'] = $id;
582
-
583
- if ($type == 'options-page')
584
- {
585
- if ($sections != null)
586
- {
587
  $page_slug = synved_option_page_slug($id, $name, $item);
588
 
589
- foreach ($sections as $child_name => $child_item)
590
- {
591
  synved_option_wp_handle_setting($id, $page_slug, null, $child_name, $child_item);
592
  }
593
  }
594
- }
595
- else if ($type == 'options-section')
596
- {
597
- add_settings_section($name, $label, function() { return synved_option_settings_section_cb($GLOBALS['name'], synved_option_item_find($GLOBALS['id'], $GLOBALS['name'])); }, $page);
 
 
 
 
 
 
 
 
 
 
598
 
599
- if ($settings != null)
600
- {
601
- foreach ($settings as $child_name => $child_item)
602
- {
603
  synved_option_wp_handle_setting($id, $page, $name, $child_name, $child_item);
604
  }
605
  }
606
- }
607
- else
608
- {
609
- add_settings_field($name, $label,
610
  'synved_option_call_array',
611
  $page, $section,
612
- array('synved_option_setting_cb', array($id, $name, $item)));
 
613
  }
614
  }
615
 
@@ -625,22 +609,6 @@ function synved_option_addon_installed($id, $name, $item = null)
625
  return false;
626
  }
627
 
628
- function synved_option_include_addon_list($path, $filter = null)
629
- {
630
- $addon_list = synved_plugout_module_addon_scan_path($path, $filter);
631
-
632
- if ($addon_list != null)
633
- {
634
- foreach ($addon_list as $addon_name => $addon_file)
635
- {
636
- if (file_exists($addon_file))
637
- {
638
- include_once($addon_file);
639
- }
640
- }
641
- }
642
- }
643
-
644
  function synved_option_include_module_addon_list($module_id, $filter = null)
645
  {
646
  global $synved_option;
@@ -652,16 +620,15 @@ function synved_option_init()
652
  {
653
  global $synved_option_list;
654
 
655
- if ($synved_option_list != null)
656
- {
657
- foreach ($synved_option_list as $id => $list)
658
- {
659
  $items = synved_option_item_list($id);
660
  }
661
  }
662
 
663
- if ((isset($_POST['action']) && $_POST['action'] == 'synved_option'))
664
- {
 
665
  ob_start();
666
  }
667
  }
@@ -824,9 +791,10 @@ function synved_option_wp_admin_init()
824
  $dbname = synved_option_name_default($id);
825
  $group = synved_option_group_default($id);
826
 
827
- define( 'SYNVEDOPTIONID', $id );
 
828
 
829
- register_setting($group, $dbname, synved_option_setting_sanitize_cb($id, $list));
830
 
831
  $items = synved_option_item_list($id);
832
 
@@ -838,33 +806,29 @@ function synved_option_wp_admin_init()
838
  }
839
  }
840
 
841
- function synved_option_wp_upgrader_source_selection($source, $remote_source, $object = null)
842
- {
843
- if (is_wp_error($source))
844
- {
845
  return $source;
846
  }
847
 
848
- if ($object != null && $object instanceof Plugin_Upgrader && method_exists($object, 'check_package'))
849
- {
850
- $result = $object->check_package($source);
851
 
852
- if (is_wp_error($result))
853
- {
854
- $folder_name = basename($source);
855
- $addon_item = synved_option_item_query(null, array(array('type' => 'addon'), array('folder' => $folder_name)));
856
 
857
- if ($addon_item != null)
858
- {
859
- // XXX fix this $id/$name retrieval...ugly
860
- $id = $addon_item['_synved_option_id'];
861
- $name = $addon_item['_synved_option_name'];
862
- $addon_page = synved_option_item_page($id, $name);
863
- $page_item = synved_option_item($id, $addon_page);
864
- $page_label = synved_option_item_label($page_item);
865
- $page_url = synved_option_item_page_link_url($id, $name);
866
-
867
- $source = new WP_Error('synved_option_invalid_plugin_is_addon', sprintf(__('<b>This addon must be installed through the <a href="%s">%s settings page</a>.</b>'), $page_url, $page_label), '');
868
  }
869
  }
870
  }
@@ -872,89 +836,80 @@ function synved_option_wp_upgrader_source_selection($source, $remote_source, $ob
872
  return $source;
873
  }
874
 
875
- function synved_option_wp_upgrader_pre_install($perform, $extra)
876
- {
877
- if (!isset($extra['plugin']))
878
- {
879
  return $perform;
880
  }
881
 
882
- $upgrade_transfer = get_option('synved_option_wp_upgrade_addon_transfer');
883
 
884
- if ($upgrade_transfer != null)
885
- {
886
- $upgrade_transfer_time = get_option('synved_option_wp_upgrade_addon_transfer_time');
887
 
888
- if ($upgrade_transfer_time == null || (time() - $upgrade_transfer_time > (60 * 60 * 1)))
889
- {
890
  $upgrade_transfer = null;
891
 
892
- update_option('synved_option_wp_upgrade_addon_transfer', '');
893
  }
894
  }
895
 
896
- $module_list = array();
897
-
898
- if (function_exists('synved_plugout_get_module_list'))
899
- {
900
  $module_list = synved_plugout_get_module_list();
901
- }
902
- else
903
- {
904
  global $synved_plugout;
905
 
906
- $module_list = array_keys($synved_plugout['module-list']);
907
  }
908
 
909
  $plugins_dir = WP_PLUGIN_DIR;
910
- $plugins_dir = rtrim(str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, realpath($plugins_dir)), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
 
911
 
912
- $plugin = $extra['plugin'];
913
- $plugin_dir = rtrim(str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, realpath(dirname($plugins_dir . $plugin))), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
 
914
 
915
- $dir = get_temp_dir();
916
  $name = time();
917
- $dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . wp_unique_filename($dir, $name) . DIRECTORY_SEPARATOR;
918
- $list = array();
 
919
 
920
- foreach ($module_list as $module_id)
921
- {
922
- $addon_list = synved_plugout_module_addon_list($module_id);
923
 
924
- if ($addon_list != null)
925
- {
926
- foreach ($addon_list as $addon_name => $addon_file)
927
- {
928
- if (file_exists($addon_file))
929
- {
930
- $addon_dir = dirname($addon_file);
931
- $parent_dir = dirname($addon_dir);
932
 
933
  // clean names for comparison
934
- $addon_dir = rtrim(str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, realpath($addon_dir)), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
935
- $parent_dir = rtrim(str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, realpath($parent_dir)), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
 
 
936
 
937
- if (strtolower($parent_dir) != strtolower($plugins_dir) && strpos(strtolower($addon_dir), strtolower($plugin_dir)) !== false)
938
- {
939
  $path = $dir;
940
- $diff = substr($addon_dir, strlen($plugins_dir));
941
  $path .= $diff;
942
 
943
- wp_mkdir_p($path);
944
 
945
- copy_dir($addon_dir, $path);
946
 
947
- $list[] = array('original' => $addon_dir, 'temporary' => $path);
948
  }
949
  }
950
  }
951
  }
952
  }
953
 
954
- if ($list != null)
955
- {
956
- update_option('synved_option_wp_upgrade_addon_transfer', array('directory' => $dir, 'list' => $list));
957
- update_option('synved_option_wp_upgrade_addon_transfer_time', time());
958
  }
959
 
960
  return $perform;
@@ -1029,14 +984,41 @@ function synved_option_wp_plugin_action_links($links, $file)
1029
  function synved_option_admin_enqueue_scripts()
1030
  {
1031
  $uri = synved_option_path_uri();
 
1032
 
1033
  wp_register_style('synved-option-jquery-ui', $uri . '/jqueryUI/css/snvdopt/jquery-ui-1.9.2.custom.min.css', false, '1.9.2');
1034
- wp_register_style('synved-option-admin', $uri . '/style/admin.css', array('wp-jquery-ui-dialog', 'synved-option-jquery-ui'), '1.0');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1035
 
1036
- wp_register_script('synved-option-script-custom', $uri . '/script/custom.js', array('jquery', 'suggest', 'media-upload', 'thickbox', 'jquery-ui-core', 'jquery-ui-progressbar', 'jquery-ui-dialog', 'wp-util'), '1.0.1');
1037
- wp_localize_script('synved-option-script-custom', 'SynvedOptionVars', array('flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'ajaxurl' => admin_url('admin-ajax.php'), 'synvedSecurity' => wp_create_nonce('synved-option-submit-nonce')));
1038
-
1039
- $page = isset($_GET['page']) ? $_GET['page'] : null;
1040
  $enqueue = false;
1041
 
1042
  global $synved_option_list;
@@ -1083,35 +1065,34 @@ function synved_option_ajax()
1083
  {
1084
  check_ajax_referer('synved-option-submit-nonce', 'synvedSecurity');
1085
 
1086
- if (!isset($_POST['synvedAction']) || $_POST['synvedAction'] == null)
1087
- {
 
 
 
 
1088
  return;
1089
  }
1090
 
1091
- $action = $_POST['synvedAction'];
1092
- $params = isset($_POST['synvedParams']) ? $_POST['synvedParams'] : null;
1093
  $response = null;
1094
 
1095
- if (is_string($params))
1096
- {
1097
  $parms = json_decode($params, true);
1098
 
1099
- if ($parms == null)
1100
- {
1101
  $parms = json_decode(stripslashes($params), true);
1102
  }
1103
 
1104
  $params = $parms;
1105
  }
1106
 
1107
- switch ($action)
1108
- {
1109
  case 'install-addon':
1110
  {
1111
- if (current_user_can('upload_files') && current_user_can('install_plugins'))
1112
- {
1113
- if (function_exists('synved_option_ajax_type_addon'))
1114
- {
1115
  $response = synved_option_ajax_type_addon($action, $params);
1116
  }
1117
  }
@@ -1120,21 +1101,17 @@ function synved_option_ajax()
1120
  }
1121
  }
1122
 
1123
- while (ob_get_level() > 0)
1124
- {
1125
  ob_end_clean();
1126
  }
1127
 
1128
- if ($response != null)
1129
- {
1130
  $response = json_encode($response);
1131
 
1132
  header('Content-Type: application/json');
1133
 
1134
  echo $response;
1135
- }
1136
- else
1137
- {
1138
  header('HTTP/1.1 403 Forbidden');
1139
  }
1140
 
@@ -1148,6 +1125,13 @@ add_filter('upgrader_pre_install', 'synved_option_wp_upgrader_pre_install', 6, 2
1148
  add_filter('upgrader_post_install', 'synved_option_wp_upgrader_post_install', 10, 3);
1149
  add_filter('plugin_action_links', 'synved_option_wp_plugin_action_links', 10, 2);
1150
 
 
 
 
 
 
 
 
1151
  if (is_admin())
1152
  {
1153
  add_action('admin_init', 'synved_option_wp_admin_init');
16
  In no event shall Synved Ltd. be liable to you or any third party for any direct or indirect, special, incidental, or consequential damages in connection with or arising from errors, omissions, delays or other cause of action that may be attributed to your use of any product, support, services, information or software provided, including, but not limited to, lost profits or lost data, even if Synved Ltd. had been advised of the possibility of such damages.
17
  */
18
 
19
+ define( 'SYNVED_OPTION_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
20
 
21
+ require_once SYNVED_OPTION_PLUGIN_PATH . 'synved-option-item.php';
22
+ require_once SYNVED_OPTION_PLUGIN_PATH . 'synved-option-page.php';
23
+ require_once SYNVED_OPTION_PLUGIN_PATH . 'synved-option-section.php';
24
+ require_once SYNVED_OPTION_PLUGIN_PATH . 'synved-option-render.php';
25
+ require_once SYNVED_OPTION_PLUGIN_PATH . 'synved-option-setting.php';
26
+ require_once SYNVED_OPTION_PLUGIN_PATH . 'inc/SynvedOptionCallback.php';
27
 
28
+ $synved_option = [];
29
+ $synved_option_list = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  function synved_option_callback($callback, $default = null, $callback_parameters = null)
32
  {
468
  return $group;
469
  }
470
 
471
+ /**
472
+ * Get allowed HTML array for Synved forms.
473
+ *
474
+ * @return array
475
+ */
476
+ function synved_get_allowed_html_array() {
477
+ return [
478
+ 'a' => [
479
+ 'class' => [],
480
+ 'href' => [],
481
+ 'style' => [],
482
+ 'target' => [],
483
+ 'title' => [],
484
+ ],
485
+ 'b' => [],
486
+ 'br' => [],
487
+ 'div' => [
488
+ 'class' => [],
489
+ 'id' => [],
490
+ 'style' => [],
491
+ ],
492
+ 'fieldset' => [],
493
+ 'form' => [
494
+ 'action' => [],
495
+ 'method' => [],
496
+ ],
497
+ 'h1' => [],
498
+ 'h2' => [],
499
+ 'h3' => [],
500
+ 'img' => [
501
+ 'src' => [],
502
+ 'style' => [],
503
+ ],
504
+ 'input' => [
505
+ 'class' => [],
506
+ 'checked' => [],
507
+ 'id' => [],
508
+ 'name' => [],
509
+ 'size' => [],
510
+ 'placeholder' => [],
511
+ 'type' => [],
512
+ 'value' => [],
513
+ ],
514
+ 'label' => [
515
+ 'class' => [],
516
+ 'for' => [],
517
+ 'title' => [],
518
+ ],
519
+ 'legend' => [
520
+ 'class' => [],
521
+ ],
522
+ 'option' => [
523
+ 'selected' => [],
524
+ 'value' => [],
525
+ ],
526
+ 'p' => [
527
+ 'class' => [],
528
+ 'style' => [],
529
+ ],
530
+ 'script' => [
531
+ 'type' => [],
532
+ ],
533
+ 'select' => [
534
+ 'id' => [],
535
+ 'name' => [],
536
+ 'multiple' => [],
537
+ ],
538
+ 'span' => [
539
+ 'class' => [],
540
+ 'style' => [],
541
+ ],
542
+ 'table' => [
543
+ 'class' => [],
544
+ 'role' => [],
545
+ ],
546
+ 'td' => [],
547
+ 'tr' => [],
548
+ 'th' => [
549
+ 'scope' => [],
550
+ ],
551
+ ];
552
+ }
553
+
554
  function synved_option_wp_handle_setting($id, $page, $section, $name, $item)
555
  {
556
+ $type = synved_option_item_type($item);
557
+ $label = synved_option_item_label($item);
558
  $sections = isset($item['sections']) ? $item['sections'] : null;
559
  $settings = isset($item['settings']) ? $item['settings'] : null;
560
 
561
+ if ($type == 'options-page') {
562
+ if ($sections != null) {
 
 
 
 
 
563
  $page_slug = synved_option_page_slug($id, $name, $item);
564
 
565
+ foreach ($sections as $child_name => $child_item) {
 
566
  synved_option_wp_handle_setting($id, $page_slug, null, $child_name, $child_item);
567
  }
568
  }
569
+ } elseif ($type == 'options-section') {
570
+ add_settings_section(
571
+ $name,
572
+ $label,
573
+ function () use ($name, $id) {
574
+ $item = synved_option_item_find($id, $name);
575
+ $tip = synved_option_item_tip($item);
576
+
577
+ if ($tip != null) {
578
+ echo '<p>' . esc_html( $tip ) . '</p>';
579
+ }
580
+ },
581
+ $page
582
+ );
583
 
584
+ if ($settings != null) {
585
+ foreach ($settings as $child_name => $child_item) {
 
 
586
  synved_option_wp_handle_setting($id, $page, $name, $child_name, $child_item);
587
  }
588
  }
589
+ } else {
590
+ add_settings_field(
591
+ $name,
592
+ $label,
593
  'synved_option_call_array',
594
  $page, $section,
595
+ ['synved_option_setting_cb', [$id, $name, $item]]
596
+ );
597
  }
598
  }
599
 
609
  return false;
610
  }
611
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612
  function synved_option_include_module_addon_list($module_id, $filter = null)
613
  {
614
  global $synved_option;
620
  {
621
  global $synved_option_list;
622
 
623
+ if ($synved_option_list != null) {
624
+ foreach ($synved_option_list as $id => $list) {
 
 
625
  $items = synved_option_item_list($id);
626
  }
627
  }
628
 
629
+ $action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_STRING);
630
+
631
+ if (false === empty($action) && 'synved_option' === $action) {
632
  ob_start();
633
  }
634
  }
791
  $dbname = synved_option_name_default($id);
792
  $group = synved_option_group_default($id);
793
 
794
+ $option_setting_sanitize_cb = synved_option_setting_sanitize_cb($id, $list);
795
+ $option_setting_sanitize_cb['sanitize_callback'] = 'synved_option_setting_sanitize_item_callback';
796
 
797
+ register_setting($group, $dbname, $option_setting_sanitize_cb);
798
 
799
  $items = synved_option_item_list($id);
800
 
806
  }
807
  }
808
 
809
+ function synved_option_wp_upgrader_source_selection( $source, $remote_source, $object = null ) {
810
+ if ( is_wp_error( $source ) ) {
 
 
811
  return $source;
812
  }
813
 
814
+ if ( $object != null && $object instanceof Plugin_Upgrader && method_exists( $object, 'check_package' ) ) {
815
+ $result = $object->check_package( $source );
 
816
 
817
+ if ( is_wp_error( $result ) ) {
818
+ $folder_name = basename( $source );
819
+ $addon_item = synved_option_item_query( null, [ [ 'type' => 'addon' ], [ 'folder' => $folder_name ] ] );
 
820
 
821
+ if ( $addon_item != null ) {
822
+ $id = $addon_item['_synved_option_id'];
823
+ $name = $addon_item['_synved_option_name'];
824
+ $addon_page = synved_option_item_page( $id, $name );
825
+ $page_item = synved_option_item( $id, $addon_page );
826
+ $page_label = synved_option_item_label( $page_item );
827
+ $page_url = synved_option_item_page_link_url( $id, $name );
828
+
829
+ $source = new WP_Error( 'synved_option_invalid_plugin_is_addon',
830
+ sprintf( __( '<b>This addon must be installed through the <a href="%s">%s settings page</a>.</b>' ),
831
+ $page_url, $page_label ), '' );
832
  }
833
  }
834
  }
836
  return $source;
837
  }
838
 
839
+ function synved_option_wp_upgrader_pre_install( $perform, $extra ) {
840
+ if ( ! isset( $extra['plugin'] ) ) {
 
 
841
  return $perform;
842
  }
843
 
844
+ $upgrade_transfer = get_option( 'synved_option_wp_upgrade_addon_transfer' );
845
 
846
+ if ( $upgrade_transfer != null ) {
847
+ $upgrade_transfer_time = get_option( 'synved_option_wp_upgrade_addon_transfer_time' );
 
848
 
849
+ if ( $upgrade_transfer_time == null || ( time() - $upgrade_transfer_time > ( 60 * 60 * 1 ) ) ) {
 
850
  $upgrade_transfer = null;
851
 
852
+ update_option( 'synved_option_wp_upgrade_addon_transfer', '' );
853
  }
854
  }
855
 
856
+ if ( function_exists( 'synved_plugout_get_module_list' ) ) {
 
 
 
857
  $module_list = synved_plugout_get_module_list();
858
+ } else {
 
 
859
  global $synved_plugout;
860
 
861
+ $module_list = array_keys( $synved_plugout['module-list'] );
862
  }
863
 
864
  $plugins_dir = WP_PLUGIN_DIR;
865
+ $plugins_dir = rtrim( str_replace( [ '\\', '/' ], DIRECTORY_SEPARATOR, realpath( $plugins_dir ) ),
866
+ DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR;
867
 
868
+ $plugin = $extra['plugin'];
869
+ $plugin_dir = rtrim( str_replace( [ '\\', '/' ], DIRECTORY_SEPARATOR,
870
+ realpath( dirname( $plugins_dir . $plugin ) ) ), DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR;
871
 
872
+ $dir = get_temp_dir();
873
  $name = time();
874
+ $dir = rtrim( $dir, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . wp_unique_filename( $dir,
875
+ $name ) . DIRECTORY_SEPARATOR;
876
+ $list = [];
877
 
878
+ foreach ( $module_list as $module_id ) {
879
+ $addon_list = synved_plugout_module_addon_list( $module_id );
 
880
 
881
+ if ( $addon_list != null ) {
882
+ foreach ( $addon_list as $addon_name => $addon_file ) {
883
+ if ( file_exists( $addon_file ) ) {
884
+ $addon_dir = dirname( $addon_file );
885
+ $parent_dir = dirname( $addon_dir );
 
 
 
886
 
887
  // clean names for comparison
888
+ $addon_dir = rtrim( str_replace( [ '\\', '/' ], DIRECTORY_SEPARATOR, realpath( $addon_dir ) ),
889
+ DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR;
890
+ $parent_dir = rtrim( str_replace( [ '\\', '/' ], DIRECTORY_SEPARATOR, realpath( $parent_dir ) ),
891
+ DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR;
892
 
893
+ if ( strtolower( $parent_dir ) != strtolower( $plugins_dir ) && strpos( strtolower( $addon_dir ),
894
+ strtolower( $plugin_dir ) ) !== false ) {
895
  $path = $dir;
896
+ $diff = substr( $addon_dir, strlen( $plugins_dir ) );
897
  $path .= $diff;
898
 
899
+ wp_mkdir_p( $path );
900
 
901
+ copy_dir( $addon_dir, $path );
902
 
903
+ $list[] = [ 'original' => $addon_dir, 'temporary' => $path ];
904
  }
905
  }
906
  }
907
  }
908
  }
909
 
910
+ if ( $list != null ) {
911
+ update_option( 'synved_option_wp_upgrade_addon_transfer', [ 'directory' => $dir, 'list' => $list ] );
912
+ update_option( 'synved_option_wp_upgrade_addon_transfer_time', time() );
 
913
  }
914
 
915
  return $perform;
984
  function synved_option_admin_enqueue_scripts()
985
  {
986
  $uri = synved_option_path_uri();
987
+ $dir = plugin_dir_path(__FILE__);
988
 
989
  wp_register_style('synved-option-jquery-ui', $uri . '/jqueryUI/css/snvdopt/jquery-ui-1.9.2.custom.min.css', false, '1.9.2');
990
+ wp_register_style(
991
+ 'synved-option-admin',
992
+ $uri . '/style/admin.css',
993
+ [ 'wp-jquery-ui-dialog', 'synved-option-jquery-ui' ],
994
+ filemtime( $dir . '/style/admin.css' )
995
+ );
996
+
997
+ wp_register_script(
998
+ 'synved-option-script-custom',
999
+ $uri . '/script/custom.js',
1000
+ [
1001
+ 'jquery',
1002
+ 'suggest',
1003
+ 'media-upload',
1004
+ 'thickbox',
1005
+ 'jquery-ui-core',
1006
+ 'jquery-ui-progressbar',
1007
+ 'jquery-ui-dialog',
1008
+ 'wp-util',
1009
+ ],
1010
+ filemtime($dir . '/script/custom.js')
1011
+ );
1012
+
1013
+ wp_localize_script( 'synved-option-script-custom', 'SynvedOptionVars', [
1014
+ 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
1015
+ 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
1016
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1017
+ 'synvedSecurity' => wp_create_nonce( 'synved-option-submit-nonce' ),
1018
+ ] );
1019
+
1020
+ $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_STRING);
1021
 
 
 
 
 
1022
  $enqueue = false;
1023
 
1024
  global $synved_option_list;
1065
  {
1066
  check_ajax_referer('synved-option-submit-nonce', 'synvedSecurity');
1067
 
1068
+ $post = filter_input_array(INPUT_POST, [
1069
+ 'synvedAction' => FILTER_SANITIZE_STRING,
1070
+ 'synvedParams' => FILTER_SANITIZE_STRING,
1071
+ ]);
1072
+
1073
+ if (true === empty($post['synvedAction'])) {
1074
  return;
1075
  }
1076
 
1077
+ $action = $post['synvedAction'];
1078
+ $params = false === empty($post['synvedParams']) ? $post['synvedParams'] : null;
1079
  $response = null;
1080
 
1081
+ if (is_string($params)) {
 
1082
  $parms = json_decode($params, true);
1083
 
1084
+ if ($parms == null) {
 
1085
  $parms = json_decode(stripslashes($params), true);
1086
  }
1087
 
1088
  $params = $parms;
1089
  }
1090
 
1091
+ switch ($action) {
 
1092
  case 'install-addon':
1093
  {
1094
+ if (current_user_can('upload_files') && current_user_can('install_plugins')) {
1095
+ if (function_exists('synved_option_ajax_type_addon')) {
 
 
1096
  $response = synved_option_ajax_type_addon($action, $params);
1097
  }
1098
  }
1101
  }
1102
  }
1103
 
1104
+ while (ob_get_level() > 0) {
 
1105
  ob_end_clean();
1106
  }
1107
 
1108
+ if ($response != null) {
 
1109
  $response = json_encode($response);
1110
 
1111
  header('Content-Type: application/json');
1112
 
1113
  echo $response;
1114
+ } else {
 
 
1115
  header('HTTP/1.1 403 Forbidden');
1116
  }
1117
 
1125
  add_filter('upgrader_post_install', 'synved_option_wp_upgrader_post_install', 10, 3);
1126
  add_filter('plugin_action_links', 'synved_option_wp_plugin_action_links', 10, 2);
1127
 
1128
+ // Add 'display' to safe style list.
1129
+ add_filter( 'safe_style_css', function( $styles ) {
1130
+ $styles[] = 'display';
1131
+ return $styles;
1132
+ } );
1133
+
1134
+
1135
  if (is_admin())
1136
  {
1137
  add_action('admin_init', 'synved_option_wp_admin_init');
synved-plugout/synved-plugout-core.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
 
3
- define('SYNVED_PLUGOUT_LOADED', true);
4
- define('SYNVED_PLUGOUT_VERSION', 100000002);
5
- define('SYNVED_PLUGOUT_VERSION_STRING', '1.0.2');
6
 
7
 
8
  $synved_plugout = array();
@@ -13,11 +13,6 @@ function synved_plugout_version()
13
  return SYNVED_PLUGOUT_VERSION;
14
  }
15
 
16
- function synved_plugout_version_string()
17
- {
18
- return SYNVED_PLUGOUT_VERSION_STRING;
19
- }
20
-
21
  function synved_plugout_path_default($path_id)
22
  {
23
  switch ($path_id)
@@ -27,40 +22,33 @@ function synved_plugout_path_default($path_id)
27
  return dirname(dirname(__FILE__));
28
  }
29
  }
30
-
31
  return null;
32
  }
33
 
34
  function synved_plugout_path_get($path_id)
35
  {
36
  global $synved_plugout;
37
-
38
  if (isset($synved_plugout['path'][$path_id]))
39
  {
40
  return $synved_plugout['path'][$path_id];
41
  }
42
-
43
- return synved_plugout_path_default($path_id);
44
- }
45
 
46
- function synved_plugout_path_set($path_id, $path)
47
- {
48
- global $synved_plugout;
49
-
50
- $synved_plugout['path'][$path_id] = $path;
51
  }
52
 
53
  function synved_plugout_get_module_list()
54
  {
55
  global $synved_plugout;
56
-
57
  return array_keys($synved_plugout['module-list']);
58
  }
59
 
60
  function synved_plugout_module_register($module_id, $module_prefix = null, $module_name = null)
61
  {
62
  global $synved_plugout;
63
-
64
  if (!isset($synved_plugout['module-list'][$module_id]))
65
  {
66
  $synved_plugout['module-list'][$module_id] = array(
@@ -70,56 +58,56 @@ function synved_plugout_module_register($module_id, $module_prefix = null, $modu
70
  'location' => null,
71
  'callback-list' => array()
72
  );
73
-
74
  return true;
75
  }
76
-
77
  return false;
78
  }
79
 
80
  function synved_plugout_module_path_add($module_id, $type, $path, $meta = null)
81
  {
82
  global $synved_plugout;
83
-
84
  if (isset($synved_plugout['module-list'][$module_id]))
85
  {
86
  $path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $path);
87
-
88
  $path_object = $meta ? $meta : array();
89
  $path_object['path'] = $path;
90
-
91
  $synved_plugout['module-list'][$module_id]['path-list'][$type][] = $path_object;
92
-
93
  return true;
94
  }
95
-
96
  return false;
97
  }
98
 
99
  function synved_plugout_module_path_get($module_id, $type)
100
  {
101
  $path_list = synved_plugout_module_path_list_get($module_id, $type, 'first');
102
-
103
  if ($path_list != null)
104
  {
105
  return $path_list[0]['path'];
106
  }
107
-
108
  return null;
109
  }
110
 
111
  function synved_plugout_module_path_list_get($module_id, $type, $criteria = null)
112
  {
113
  global $synved_plugout;
114
-
115
  if (isset($synved_plugout['module-list'][$module_id]))
116
  {
117
  $path_list = $synved_plugout['module-list'][$module_id]['path-list'];
118
-
119
  if ($path_list != null)
120
  {
121
  $return_list = array();
122
-
123
  foreach ($path_list as $path_type => $path_type_list)
124
  {
125
  if ($type == null || $type == $path_type)
@@ -127,74 +115,62 @@ function synved_plugout_module_path_list_get($module_id, $type, $criteria = null
127
  foreach ($path_type_list as $path_object)
128
  {
129
  $return_item = array();
130
-
131
  $return_item['type'] = $path_type;
132
  $return_item['path'] = $path_object['path'];
133
  $return_item['meta'] = $path_object;
134
-
135
  $return_list[] = $return_item;
136
  }
137
  }
138
  }
139
-
140
  return $return_list;
141
  }
142
  }
143
-
144
  return null;
145
  }
146
 
147
  function synved_plugout_module_get($module_id)
148
  {
149
  global $synved_plugout;
150
-
151
  if (isset($synved_plugout['module-list'][$module_id]))
152
  {
153
  return $synved_plugout['module-list'][$module_id];
154
  }
155
-
156
- return null;
157
- }
158
 
159
- function synved_plugout_module_exists($module_id)
160
- {
161
- $module = synved_plugout_module_get($module_id);
162
-
163
- if ($module !== null)
164
- {
165
- return true;
166
- }
167
-
168
- return false;
169
  }
170
 
171
  function synved_plugout_module_version($module_id)
172
  {
173
  $module = synved_plugout_module_get($module_id);
174
-
175
  if ($module !== null)
176
  {
177
  $module_cb = isset($module['callback-list']) ? $module['callback-list'] : null;
178
  $version_cb = str_replace('-', '_', $module_id) . '_version';
179
-
180
  if (isset($module_cb['version']))
181
  {
182
  $version_cb = $module_cb['version'];
183
  }
184
-
185
  if (is_callable($version_cb))
186
  {
187
  return $version_cb();
188
  }
189
  }
190
-
191
  return false;
192
  }
193
 
194
  function synved_plugout_module_location_get($module_id)
195
  {
196
  $module = synved_plugout_module_get($module_id);
197
-
198
  if ($module != null)
199
  {
200
  if (isset($module['location']))
@@ -202,7 +178,7 @@ function synved_plugout_module_location_get($module_id)
202
  return $module['location'];
203
  }
204
  }
205
-
206
  return null;
207
  }
208
 
@@ -214,7 +190,7 @@ function synved_plugout_module_directory_get($module_id)
214
  {
215
  return dirname($location);
216
  }
217
-
218
  return null;
219
  }
220
 
@@ -227,61 +203,56 @@ function synved_plugout_module_uri_get($module_id)
227
  $directory = strtolower(str_replace(array('\\', '/'), '/', $directory));
228
  $content_dir = strtolower(str_replace(array('\\', '/'), '/', WP_CONTENT_DIR));
229
  $base_len = strlen($content_dir);
230
-
231
  if (substr($directory, 0, $base_len) == $content_dir)
232
  {
233
  return content_url(substr($directory, $base_len));
234
  }
235
  }
236
-
237
- return null;
238
- }
239
-
240
- function synved_plugout_module_callback_set($module_id, $callback_id, $callback)
241
- {
242
 
 
243
  }
244
 
245
  function synved_plugout_module_import($module_id)
246
  {
247
- // XXX better way to check if the plugin/module is being activated?
248
- // This is needed because on activation the plugin's code is included *after* the theme code
249
- if (strpos($_SERVER['REQUEST_URI'], '/plugins.php?') !== false &&
250
- isset($_GET['action']) && $_GET['action'] == 'activate')
251
- {
252
  return false;
253
  }
254
-
255
  global $synved_plugout;
256
-
257
  if (isset($synved_plugout['module-list'][$module_id]))
258
  {
259
  $lib_path = synved_plugout_module_path_get($module_id, 'library');
260
  $core_path = synved_plugout_module_path_get($module_id, 'core');
261
-
262
  if ($lib_path == null)
263
  {
264
  if ($core_path == null)
265
  {
266
  $module_path = synved_plugout_path_get('module');
267
-
268
  if (substr($module_path, -1) != DIRECTORY_SEPARATOR)
269
  {
270
  $module_path .= DIRECTORY_SEPARATOR;
271
  }
272
-
273
  $core_path = $module_path . $module_id;
274
  }
275
-
276
  if (is_dir($core_path))
277
  {
278
  if (substr($core_path, -1) != DIRECTORY_SEPARATOR)
279
  {
280
  $core_path .= DIRECTORY_SEPARATOR;
281
  }
282
-
283
  $lib_path = $core_path . $module_id;
284
-
285
  if (file_exists($lib_path . '.php'))
286
  {
287
  $lib_path .= '.php';
@@ -296,26 +267,22 @@ function synved_plugout_module_import($module_id)
296
  }
297
  }
298
  }
299
-
300
  if ($lib_path != null && file_exists($lib_path))
301
  {
302
  $version = synved_plugout_module_version($module_id);
303
-
304
  if ($version === false)
305
  {
306
  $synved_plugout['module-list'][$module_id]['location'] = $lib_path;
307
-
308
  include_once($lib_path);
309
  }
310
- else
311
- {
312
- // XXX undefine old module, include new one
313
- }
314
-
315
  return true;
316
  }
317
  }
318
-
319
  return false;
320
  }
321
 
@@ -325,20 +292,20 @@ function synved_plugout_module_addon_scan_path($path, $filter = null)
325
  {
326
  $filter = '*';
327
  }
328
-
329
  $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
330
-
331
  if (substr($path, -1) != DIRECTORY_SEPARATOR)
332
  {
333
  $path .= DIRECTORY_SEPARATOR;
334
  }
335
-
336
  if (is_dir($path))
337
  {
338
  $list = glob($path . '*', GLOB_ONLYDIR);
339
  $addon_list = array();
340
  $filter_regex = '/' . str_replace(array('*'), array('.*'), $filter) . '/';
341
-
342
  if ($list != null)
343
  {
344
  foreach ($list as $addon_dir)
@@ -346,11 +313,11 @@ function synved_plugout_module_addon_scan_path($path, $filter = null)
346
  $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $addon_dir);
347
  $path = rtrim($path, DIRECTORY_SEPARATOR);
348
  $base = basename($addon_dir);
349
-
350
  if (preg_match($filter_regex, $base))
351
  {
352
  $filename = $addon_dir . DIRECTORY_SEPARATOR . $base . '.php';
353
-
354
  if (file_exists($filename))
355
  {
356
  $addon_list[$base] = $filename;
@@ -358,7 +325,7 @@ function synved_plugout_module_addon_scan_path($path, $filter = null)
358
  }
359
  }
360
  }
361
-
362
  return $addon_list;
363
  }
364
  }
@@ -367,71 +334,42 @@ function synved_plugout_module_addon_list($module_id, $filter = null)
367
  {
368
  $addon_list = array();
369
  $path_list = synved_plugout_module_path_list_get($module_id, 'addon');
370
-
371
  if ($path_list != null)
372
  {
373
  foreach ($path_list as $path_item)
374
  {
375
  $path = $path_item['path'];
376
  $extra_list = synved_plugout_module_addon_scan_path($path, $filter);
377
-
378
  if ($extra_list != null)
379
  {
380
  $addon_list = array_merge($addon_list, $extra_list);
381
  }
382
  }
383
  }
384
- #
385
- # $path_list = synved_plugout_module_path_list_get($module_id, 'addon-plugin');
386
- #
387
- # if ($path_list != null)
388
- # {
389
- # foreach ($path_list as $path_item)
390
- # {
391
- # $path = $path_item['path'];
392
- # $addon_plugin = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'addon-plugin.php';
393
- # $extra_list = null;
394
- #
395
- # if (file_exists($addon_plugin))
396
- # {
397
- # $content = file_get_contents($addon_plugin);
398
- # $match = null;
399
- #
400
- # if (preg_match('/\\/(?:\\*)+\\s*(?:synved-)?addon-plugin\\s*\\{\\s*Name\\s*:\\s*(?P<name>[\\w_-]+)(?:\\s*,\\s*\\w+\\s*:\\s*(?:[\\w_-]+))*\\s*\\}/m', $content, $match) > 0)
401
- # {
402
- # $addon_name = $match['name'];
403
- # $extra_list = array($addon_name => $addon_plugin);
404
- # }
405
- # }
406
- #
407
- # if ($extra_list != null)
408
- # {
409
- # $addon_list = array_merge($addon_list, $extra_list);
410
- # }
411
- # }
412
- # }
413
- #
414
  $path_list = synved_plugout_module_path_list_get($module_id, 'addon-file');
415
-
416
  if ($path_list != null)
417
  {
418
  foreach ($path_list as $path_item)
419
  {
420
  $path = $path_item['path'];
421
  $extra_list = null;
422
-
423
  if (file_exists($path) && strtolower(substr($path, -4)) == '.php')
424
  {
425
  $addon_name = isset($path_item['path']['meta']['addon-name']) ? $path_item['path']['meta']['addon-name'] : basename($path, '.php');
426
  $extra_list = array($addon_name => $path);
427
  }
428
-
429
  if ($extra_list != null)
430
  {
431
  $addon_list = array_merge($addon_list, $extra_list);
432
  }
433
  }
434
  }
435
-
436
  return $addon_list;
437
  }
1
  <?php
2
 
3
+ const SYNVED_PLUGOUT_LOADED = true;
4
+ const SYNVED_PLUGOUT_VERSION = 100000002;
5
+ const SYNVED_PLUGOUT_VERSION_STRING = '1.0.2';
6
 
7
 
8
  $synved_plugout = array();
13
  return SYNVED_PLUGOUT_VERSION;
14
  }
15
 
 
 
 
 
 
16
  function synved_plugout_path_default($path_id)
17
  {
18
  switch ($path_id)
22
  return dirname(dirname(__FILE__));
23
  }
24
  }
25
+
26
  return null;
27
  }
28
 
29
  function synved_plugout_path_get($path_id)
30
  {
31
  global $synved_plugout;
32
+
33
  if (isset($synved_plugout['path'][$path_id]))
34
  {
35
  return $synved_plugout['path'][$path_id];
36
  }
 
 
 
37
 
38
+ return synved_plugout_path_default($path_id);
 
 
 
 
39
  }
40
 
41
  function synved_plugout_get_module_list()
42
  {
43
  global $synved_plugout;
44
+
45
  return array_keys($synved_plugout['module-list']);
46
  }
47
 
48
  function synved_plugout_module_register($module_id, $module_prefix = null, $module_name = null)
49
  {
50
  global $synved_plugout;
51
+
52
  if (!isset($synved_plugout['module-list'][$module_id]))
53
  {
54
  $synved_plugout['module-list'][$module_id] = array(
58
  'location' => null,
59
  'callback-list' => array()
60
  );
61
+
62
  return true;
63
  }
64
+
65
  return false;
66
  }
67
 
68
  function synved_plugout_module_path_add($module_id, $type, $path, $meta = null)
69
  {
70
  global $synved_plugout;
71
+
72
  if (isset($synved_plugout['module-list'][$module_id]))
73
  {
74
  $path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $path);
75
+
76
  $path_object = $meta ? $meta : array();
77
  $path_object['path'] = $path;
78
+
79
  $synved_plugout['module-list'][$module_id]['path-list'][$type][] = $path_object;
80
+
81
  return true;
82
  }
83
+
84
  return false;
85
  }
86
 
87
  function synved_plugout_module_path_get($module_id, $type)
88
  {
89
  $path_list = synved_plugout_module_path_list_get($module_id, $type, 'first');
90
+
91
  if ($path_list != null)
92
  {
93
  return $path_list[0]['path'];
94
  }
95
+
96
  return null;
97
  }
98
 
99
  function synved_plugout_module_path_list_get($module_id, $type, $criteria = null)
100
  {
101
  global $synved_plugout;
102
+
103
  if (isset($synved_plugout['module-list'][$module_id]))
104
  {
105
  $path_list = $synved_plugout['module-list'][$module_id]['path-list'];
106
+
107
  if ($path_list != null)
108
  {
109
  $return_list = array();
110
+
111
  foreach ($path_list as $path_type => $path_type_list)
112
  {
113
  if ($type == null || $type == $path_type)
115
  foreach ($path_type_list as $path_object)
116
  {
117
  $return_item = array();
118
+
119
  $return_item['type'] = $path_type;
120
  $return_item['path'] = $path_object['path'];
121
  $return_item['meta'] = $path_object;
122
+
123
  $return_list[] = $return_item;
124
  }
125
  }
126
  }
127
+
128
  return $return_list;
129
  }
130
  }
131
+
132
  return null;
133
  }
134
 
135
  function synved_plugout_module_get($module_id)
136
  {
137
  global $synved_plugout;
138
+
139
  if (isset($synved_plugout['module-list'][$module_id]))
140
  {
141
  return $synved_plugout['module-list'][$module_id];
142
  }
 
 
 
143
 
144
+ return null;
 
 
 
 
 
 
 
 
 
145
  }
146
 
147
  function synved_plugout_module_version($module_id)
148
  {
149
  $module = synved_plugout_module_get($module_id);
150
+
151
  if ($module !== null)
152
  {
153
  $module_cb = isset($module['callback-list']) ? $module['callback-list'] : null;
154
  $version_cb = str_replace('-', '_', $module_id) . '_version';
155
+
156
  if (isset($module_cb['version']))
157
  {
158
  $version_cb = $module_cb['version'];
159
  }
160
+
161
  if (is_callable($version_cb))
162
  {
163
  return $version_cb();
164
  }
165
  }
166
+
167
  return false;
168
  }
169
 
170
  function synved_plugout_module_location_get($module_id)
171
  {
172
  $module = synved_plugout_module_get($module_id);
173
+
174
  if ($module != null)
175
  {
176
  if (isset($module['location']))
178
  return $module['location'];
179
  }
180
  }
181
+
182
  return null;
183
  }
184
 
190
  {
191
  return dirname($location);
192
  }
193
+
194
  return null;
195
  }
196
 
203
  $directory = strtolower(str_replace(array('\\', '/'), '/', $directory));
204
  $content_dir = strtolower(str_replace(array('\\', '/'), '/', WP_CONTENT_DIR));
205
  $base_len = strlen($content_dir);
206
+
207
  if (substr($directory, 0, $base_len) == $content_dir)
208
  {
209
  return content_url(substr($directory, $base_len));
210
  }
211
  }
 
 
 
 
 
 
212
 
213
+ return null;
214
  }
215
 
216
  function synved_plugout_module_import($module_id)
217
  {
218
+ // This is needed because on activation the plugin's code is included *after* the theme code.
219
+ $request_uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING);
220
+ $action = filter_input(INPUT_GET, 'action', FILTER_SANITIZE_STRING);
221
+
222
+ if (false !== strpos($request_uri, '/plugins.php?') && 'activate' === $action) {
223
  return false;
224
  }
225
+
226
  global $synved_plugout;
227
+
228
  if (isset($synved_plugout['module-list'][$module_id]))
229
  {
230
  $lib_path = synved_plugout_module_path_get($module_id, 'library');
231
  $core_path = synved_plugout_module_path_get($module_id, 'core');
232
+
233
  if ($lib_path == null)
234
  {
235
  if ($core_path == null)
236
  {
237
  $module_path = synved_plugout_path_get('module');
238
+
239
  if (substr($module_path, -1) != DIRECTORY_SEPARATOR)
240
  {
241
  $module_path .= DIRECTORY_SEPARATOR;
242
  }
243
+
244
  $core_path = $module_path . $module_id;
245
  }
246
+
247
  if (is_dir($core_path))
248
  {
249
  if (substr($core_path, -1) != DIRECTORY_SEPARATOR)
250
  {
251
  $core_path .= DIRECTORY_SEPARATOR;
252
  }
253
+
254
  $lib_path = $core_path . $module_id;
255
+
256
  if (file_exists($lib_path . '.php'))
257
  {
258
  $lib_path .= '.php';
267
  }
268
  }
269
  }
270
+
271
  if ($lib_path != null && file_exists($lib_path))
272
  {
273
  $version = synved_plugout_module_version($module_id);
274
+
275
  if ($version === false)
276
  {
277
  $synved_plugout['module-list'][$module_id]['location'] = $lib_path;
278
+
279
  include_once($lib_path);
280
  }
281
+
 
 
 
 
282
  return true;
283
  }
284
  }
285
+
286
  return false;
287
  }
288
 
292
  {
293
  $filter = '*';
294
  }
295
+
296
  $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
297
+
298
  if (substr($path, -1) != DIRECTORY_SEPARATOR)
299
  {
300
  $path .= DIRECTORY_SEPARATOR;
301
  }
302
+
303
  if (is_dir($path))
304
  {
305
  $list = glob($path . '*', GLOB_ONLYDIR);
306
  $addon_list = array();
307
  $filter_regex = '/' . str_replace(array('*'), array('.*'), $filter) . '/';
308
+
309
  if ($list != null)
310
  {
311
  foreach ($list as $addon_dir)
313
  $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $addon_dir);
314
  $path = rtrim($path, DIRECTORY_SEPARATOR);
315
  $base = basename($addon_dir);
316
+
317
  if (preg_match($filter_regex, $base))
318
  {
319
  $filename = $addon_dir . DIRECTORY_SEPARATOR . $base . '.php';
320
+
321
  if (file_exists($filename))
322
  {
323
  $addon_list[$base] = $filename;
325
  }
326
  }
327
  }
328
+
329
  return $addon_list;
330
  }
331
  }
334
  {
335
  $addon_list = array();
336
  $path_list = synved_plugout_module_path_list_get($module_id, 'addon');
337
+
338
  if ($path_list != null)
339
  {
340
  foreach ($path_list as $path_item)
341
  {
342
  $path = $path_item['path'];
343
  $extra_list = synved_plugout_module_addon_scan_path($path, $filter);
344
+
345
  if ($extra_list != null)
346
  {
347
  $addon_list = array_merge($addon_list, $extra_list);
348
  }
349
  }
350
  }
351
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  $path_list = synved_plugout_module_path_list_get($module_id, 'addon-file');
353
+
354
  if ($path_list != null)
355
  {
356
  foreach ($path_list as $path_item)
357
  {
358
  $path = $path_item['path'];
359
  $extra_list = null;
360
+
361
  if (file_exists($path) && strtolower(substr($path, -4)) == '.php')
362
  {
363
  $addon_name = isset($path_item['path']['meta']['addon-name']) ? $path_item['path']['meta']['addon-name'] : basename($path, '.php');
364
  $extra_list = array($addon_name => $path);
365
  }
366
+
367
  if ($extra_list != null)
368
  {
369
  $addon_list = array_merge($addon_list, $extra_list);
370
  }
371
  }
372
  }
373
+
374
  return $addon_list;
375
  }
synved-plugout/synved-plugout.php CHANGED
@@ -20,7 +20,8 @@ NO LIABILITY
20
  In no event shall Synved Ltd. be liable to you or any third party for any direct or indirect, special, incidental, or consequential damages in connection with or arising from errors, omissions, delays or other cause of action that may be attributed to your use of any product, support, services, information or software provided, including, but not limited to, lost profits or lost data, even if Synved Ltd. had been advised of the possibility of such damages.
21
  */
22
 
23
- if (!function_exists('synved_plugout_version'))
24
- {
25
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-plugout-core.php');
 
26
  }
20
  In no event shall Synved Ltd. be liable to you or any third party for any direct or indirect, special, incidental, or consequential damages in connection with or arising from errors, omissions, delays or other cause of action that may be attributed to your use of any product, support, services, information or software provided, including, but not limited to, lost profits or lost data, even if Synved Ltd. had been advised of the possibility of such damages.
21
  */
22
 
23
+ define( 'SYNVED_PLUGOUT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
24
+
25
+ if (!function_exists('synved_plugout_version')) {
26
+ include_once SYNVED_PLUGOUT_PLUGIN_PATH . 'synved-plugout-core.php';
27
  }
synved-social/addons/extra-icons/extra-icons.php CHANGED
@@ -1,84 +1,84 @@
1
  <?php
2
 
3
  if (!function_exists('synved_social_addon_extra_icons_get')) {
4
- function synved_social_addon_extra_icons_version()
5
- {
6
- return 100020002;
7
- }
8
 
9
- function synved_social_addon_extra_icons_get()
10
- {
11
- $addon_dir = '/addons/' . basename(dirname(__FILE__));
12
- $path = synved_social_path($addon_dir);
13
- $uri = synved_social_path_uri($addon_dir);
14
 
15
- $icons = [
16
- 'clearslate' => [
17
- 'label' => __('Clear Slate', 'social-media-feather'),
18
- 'image' => $uri . '/image/social/clearslate/preview.png',
19
- 'folder' => $addon_dir . '/image/social/clearslate/',
20
- 'path' => $path . '/image/social/clearslate/',
21
- 'uri' => $uri . '/image/social/clearslate/',
22
- 'extra' => true,
23
- ],
24
- 'darkslate' => [
25
- 'label' => __('Dark Slate', 'social-media-feather'),
26
- 'image' => $uri . '/image/social/darkslate/preview.png',
27
- 'folder' => $addon_dir . '/image/social/darkslate/',
28
- 'path' => $path . '/image/social/darkslate/',
29
- 'uri' => $uri . '/image/social/darkslate/',
30
- 'extra' => true,
31
- ],
32
- 'circle' => [
33
- 'label' => __('Circle', 'social-media-feather'),
34
- 'image' => $uri . '/image/social/circle/preview.png',
35
- 'folder' => $addon_dir . '/image/social/circle/',
36
- 'path' => $path . '/image/social/circle/',
37
- 'uri' => $uri . '/image/social/circle/',
38
- 'extra' => true,
39
- ],
40
- 'wheel' => [
41
- 'label' => __('Wheel', 'social-media-feather'),
42
- 'image' => $uri . '/image/social/wheel/preview.png',
43
- 'folder' => $addon_dir . '/image/social/wheel/',
44
- 'path' => $path . '/image/social/wheel/',
45
- 'uri' => $uri . '/image/social/wheel/',
46
- 'extra' => true,
47
- ],
48
- 'flag' => [
49
- 'label' => __('Flag', 'social-media-feather'),
50
- 'image' => $uri . '/image/social/flag/preview.png',
51
- 'folder' => $addon_dir . '/image/social/flag/',
52
- 'path' => $path . '/image/social/flag/',
53
- 'uri' => $uri . '/image/social/flag/',
54
- 'extra' => true,
55
- ],
56
- 'medal' => [
57
- 'label' => __('Medal', 'social-media-feather'),
58
- 'image' => $uri . '/image/social/medal/preview.png',
59
- 'folder' => $addon_dir . '/image/social/medal/',
60
- 'path' => $path . '/image/social/medal/',
61
- 'uri' => $uri . '/image/social/medal/',
62
- 'extra' => true,
63
- ],
64
- 'shed' => [
65
- 'label' => __('Shed', 'social-media-feather'),
66
- 'image' => $uri . '/image/social/shed/preview.png',
67
- 'folder' => $addon_dir . '/image/social/shed/',
68
- 'path' => $path . '/image/social/shed/',
69
- 'uri' => $uri . '/image/social/shed/',
70
- 'extra' => true,
71
- ],
72
- 'balloon' => [
73
- 'label' => __('Balloon', 'social-media-feather'),
74
- 'image' => $uri . '/image/social/balloon/preview.png',
75
- 'folder' => $addon_dir . '/image/social/balloon/',
76
- 'path' => $path . '/image/social/balloon/',
77
- 'uri' => $uri . '/image/social/balloon/',
78
- 'extra' => true,
79
- ],
80
- ];
81
 
82
- return apply_filters('synved_social_addon_extra_icons_get', $icons);
83
- }
84
  }
1
  <?php
2
 
3
  if (!function_exists('synved_social_addon_extra_icons_get')) {
4
+ function synved_social_addon_extra_icons_version()
5
+ {
6
+ return 100020002;
7
+ }
8
 
9
+ function synved_social_addon_extra_icons_get()
10
+ {
11
+ $addon_dir = '/addons/' . basename(dirname(__FILE__));
12
+ $path = synved_social_path($addon_dir);
13
+ $uri = synved_social_path_uri($addon_dir);
14
 
15
+ $icons = [
16
+ 'clearslate' => [
17
+ 'label' => __('Clear Slate', 'social-media-feather'),
18
+ 'image' => $uri . '/image/social/clearslate/preview.png',
19
+ 'folder' => $addon_dir . '/image/social/clearslate/',
20
+ 'path' => $path . '/image/social/clearslate/',
21
+ 'uri' => $uri . '/image/social/clearslate/',
22
+ 'extra' => true,
23
+ ],
24
+ 'darkslate' => [
25
+ 'label' => __('Dark Slate', 'social-media-feather'),
26
+ 'image' => $uri . '/image/social/darkslate/preview.png',
27
+ 'folder' => $addon_dir . '/image/social/darkslate/',
28
+ 'path' => $path . '/image/social/darkslate/',
29
+ 'uri' => $uri . '/image/social/darkslate/',
30
+ 'extra' => true,
31
+ ],
32
+ 'circle' => [
33
+ 'label' => __('Circle', 'social-media-feather'),
34
+ 'image' => $uri . '/image/social/circle/preview.png',
35
+ 'folder' => $addon_dir . '/image/social/circle/',
36
+ 'path' => $path . '/image/social/circle/',
37
+ 'uri' => $uri . '/image/social/circle/',
38
+ 'extra' => true,
39
+ ],
40
+ 'wheel' => [
41
+ 'label' => __('Wheel', 'social-media-feather'),
42
+ 'image' => $uri . '/image/social/wheel/preview.png',
43
+ 'folder' => $addon_dir . '/image/social/wheel/',
44
+ 'path' => $path . '/image/social/wheel/',
45
+ 'uri' => $uri . '/image/social/wheel/',
46
+ 'extra' => true,
47
+ ],
48
+ 'flag' => [
49
+ 'label' => __('Flag', 'social-media-feather'),
50
+ 'image' => $uri . '/image/social/flag/preview.png',
51
+ 'folder' => $addon_dir . '/image/social/flag/',
52
+ 'path' => $path . '/image/social/flag/',
53
+ 'uri' => $uri . '/image/social/flag/',
54
+ 'extra' => true,
55
+ ],
56
+ 'medal' => [
57
+ 'label' => __('Medal', 'social-media-feather'),
58
+ 'image' => $uri . '/image/social/medal/preview.png',
59
+ 'folder' => $addon_dir . '/image/social/medal/',
60
+ 'path' => $path . '/image/social/medal/',
61
+ 'uri' => $uri . '/image/social/medal/',
62
+ 'extra' => true,
63
+ ],
64
+ 'shed' => [
65
+ 'label' => __('Shed', 'social-media-feather'),
66
+ 'image' => $uri . '/image/social/shed/preview.png',
67
+ 'folder' => $addon_dir . '/image/social/shed/',
68
+ 'path' => $path . '/image/social/shed/',
69
+ 'uri' => $uri . '/image/social/shed/',
70
+ 'extra' => true,
71
+ ],
72
+ 'balloon' => [
73
+ 'label' => __('Balloon', 'social-media-feather'),
74
+ 'image' => $uri . '/image/social/balloon/preview.png',
75
+ 'folder' => $addon_dir . '/image/social/balloon/',
76
+ 'path' => $path . '/image/social/balloon/',
77
+ 'uri' => $uri . '/image/social/balloon/',
78
+ 'extra' => true,
79
+ ],
80
+ ];
81
 
82
+ return apply_filters('synved_social_addon_extra_icons_get', $icons);
83
+ }
84
  }
synved-social/addons/extra-icons/image/social/balloon/128x128/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/balloon/16x16/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/balloon/24x24/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/balloon/32x32/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/balloon/48x48/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/balloon/64x64/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/balloon/96x96/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/balloon/preview.png CHANGED
Binary file
synved-social/addons/extra-icons/image/social/circle/128x128/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/circle/16x16/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/circle/24x24/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/circle/32x32/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/circle/48x48/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/circle/64x64/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/circle/96x96/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/circle/preview.png CHANGED
Binary file
synved-social/addons/extra-icons/image/social/clearslate/128x128/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/clearslate/16x16/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/clearslate/24x24/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/clearslate/32x32/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/clearslate/48x48/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/clearslate/64x64/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/clearslate/96x96/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/clearslate/preview.png CHANGED
Binary file
synved-social/addons/extra-icons/image/social/darkslate/128x128/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/darkslate/16x16/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/darkslate/24x24/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/darkslate/32x32/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/darkslate/48x48/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/darkslate/64x64/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/darkslate/96x96/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/darkslate/preview.png CHANGED
Binary file
synved-social/addons/extra-icons/image/social/flag/128x128/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/flag/16x16/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/flag/24x24/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/flag/32x32/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/flag/48x48/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/flag/64x64/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/flag/96x96/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/flag/preview.png CHANGED
Binary file
synved-social/addons/extra-icons/image/social/medal/128x128/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/medal/16x16/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/medal/24x24/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/medal/32x32/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/medal/48x48/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/medal/64x64/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/medal/96x96/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/medal/preview.png CHANGED
Binary file
synved-social/addons/extra-icons/image/social/shed/128x128/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/shed/16x16/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/shed/24x24/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/shed/32x32/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/shed/48x48/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/shed/64x64/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/shed/96x96/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/shed/preview.png CHANGED
Binary file
synved-social/addons/extra-icons/image/social/wheel/128x128/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/wheel/16x16/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/wheel/24x24/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/wheel/32x32/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/wheel/48x48/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/wheel/64x64/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/wheel/96x96/google_plus.png DELETED
Binary file
synved-social/addons/extra-icons/image/social/wheel/preview.png CHANGED
Binary file
synved-social/image/social-feather-extra-icons.png DELETED
Binary file
synved-social/image/social-feather-grey-fade-demo.png DELETED
Binary file
synved-social/image/social-feather-light-prompt-demo.png DELETED
Binary file
synved-social/image/social/regular/128x128/google_plus.png DELETED
Binary file
synved-social/image/social/regular/16x16/google_plus.png DELETED
Binary file
synved-social/image/social/regular/24x24/google_plus.png DELETED
Binary file
synved-social/image/social/regular/32x32/google_plus.png DELETED
Binary file
synved-social/image/social/regular/48x48/google_plus.png DELETED
Binary file
synved-social/image/social/regular/64x64/google_plus.png DELETED
Binary file
synved-social/image/social/regular/96x96/google_plus.png DELETED
Binary file
synved-social/image/social/regular/preview.png CHANGED
Binary file
synved-social/inc/SynvedSocialFollowWidget.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Social Follow Widget.
5
+ */
6
+ class SynvedSocialFollowWidget extends SynvedSocialWidget {
7
+ function __construct() {
8
+ parent::__construct( 'synved_social_follow', __( 'Social Media Feather: Follow Us', 'social-media-feather' ) );
9
+ }
10
+
11
+ /**
12
+ * Override defaults.
13
+ *
14
+ * @return string[]
15
+ */
16
+ function get_defaults() {
17
+ $defaults = parent::get_defaults();
18
+
19
+ return array_merge( $defaults, [ 'title' => __( 'Follow Us', 'social-media-feather' ) ] );
20
+ }
21
+
22
+ /**
23
+ * Render social markup.
24
+ *
25
+ * NOTE: Escaped via wp_kses_post().
26
+ *
27
+ * @param $params
28
+ *
29
+ * @return void
30
+ */
31
+ function render_social_markup( $params = null ) {
32
+ echo synved_social_follow_markup( null, null, $params ); // Escaped using wp_kses_post.
33
+ }
34
+ }
synved-social/inc/SynvedSocialShareWidget.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Social Share Widget.
5
+ */
6
+ class SynvedSocialShareWidget extends SynvedSocialWidget {
7
+ function __construct() {
8
+ parent::__construct( 'synved_social_share', __( 'Social Media Feather: Sharing', 'social-media-feather' ) );
9
+ }
10
+
11
+ /**
12
+ * Override defaults.
13
+ *
14
+ * @return string[]
15
+ */
16
+ function get_defaults() {
17
+ $defaults = parent::get_defaults();
18
+
19
+ return array_merge( $defaults, [ 'title' => __( 'Sharing', 'social-media-feather' ) ] );
20
+ }
21
+
22
+ /**
23
+ * Render social markup.
24
+ *
25
+ * NOTE: Escaped via wp_kses_post().
26
+ *
27
+ * @param $params
28
+ *
29
+ * @return void
30
+ */
31
+ function render_social_markup( $params = null ) {
32
+ echo synved_social_share_markup( null, null, $params ); // Escaped using wp_kses_post.
33
+ }
34
+ }
synved-social/inc/SynvedSocialWidget.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Social Widget.
5
+ */
6
+ class SynvedSocialWidget extends WP_Widget {
7
+ function __construct( $id_base = false, $name = null, $widget_options = [], $control_options = [] ) {
8
+ if ( $name == null ) {
9
+ $name = 'Social Media Feather';
10
+ }
11
+
12
+ parent::__construct( $id_base, $name, $widget_options, $control_options );
13
+ }
14
+
15
+ function widget( $args, $instance ) {
16
+ extract( $args ); /* before/after widget, before/after title (defined by themes). */
17
+ extract( $instance );
18
+
19
+ ob_start();
20
+ echo $before_widget;
21
+
22
+ if ( $title != null ) {
23
+ echo $before_title . $title . $after_title;
24
+ }
25
+
26
+ echo '<div>';
27
+
28
+ $params = [];
29
+ $params['alignment'] = 'none';
30
+
31
+ if ( $icon_skin != 'default' ) {
32
+ $params['skin'] = $icon_skin;
33
+ }
34
+
35
+ if ( $icon_size != 'default' ) {
36
+ $params['size'] = $icon_size;
37
+ }
38
+
39
+ if ( $icon_spacing !== null && $icon_spacing !== '' ) {
40
+ $params['spacing'] = $icon_spacing;
41
+ }
42
+
43
+ $this->render_social_markup( $params );
44
+
45
+ echo '</div>';
46
+ echo $after_widget;
47
+
48
+ $html = ob_get_clean();
49
+
50
+ echo wp_kses_post( $html );
51
+ }
52
+
53
+ function get_defaults() {
54
+ return [ 'icon_skin' => 'default', 'icon_size' => 'default', 'icon_spacing' => '' ];
55
+ }
56
+
57
+ function render_social_markup( $params = null ) {
58
+ }
59
+
60
+ function update( $new_instance, $old_instance ) {
61
+ $instance = $old_instance;
62
+ $instance['title'] = strip_tags( $new_instance['title'] );
63
+ $instance['icon_skin'] = strip_tags( $new_instance['icon_skin'] );
64
+ $instance['icon_size'] = strip_tags( $new_instance['icon_size'] );
65
+ $instance['icon_spacing'] = strip_tags( $new_instance['icon_spacing'] );
66
+
67
+ return $instance;
68
+ }
69
+
70
+ /**
71
+ * Form render.
72
+ *
73
+ * NOTE: Escaped via wp_kses_post().
74
+ *
75
+ * @param $instance
76
+ *
77
+ * @return string|void
78
+ */
79
+ function form( $instance ) {
80
+ $instance = wp_parse_args( (array) $instance, $this->get_defaults() );
81
+
82
+ ob_start();
83
+ ?>
84
+ <p>
85
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
86
+ <?php echo esc_html__( 'Title', 'social-media-feather' ) ?>:
87
+ </label>
88
+ <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
89
+ name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
90
+ value="<?php echo esc_attr( $instance['title'] ); ?>"/>
91
+ </p>
92
+ <p>
93
+ <label for="<?php echo esc_attr( $this->get_field_id( 'icon_skin' ) ); ?>">
94
+ <?php echo esc_html__( 'Icon Skin', 'social-media-feather' ); ?>:
95
+ </label>
96
+ <?php
97
+ $params = [
98
+ 'tip' => '',
99
+ 'output_name' => $this->get_field_name( 'icon_skin' ),
100
+ 'value' => $instance['icon_skin'],
101
+ 'set_before' => [ [ 'default' => __( 'Use Default' ) ] ],
102
+ ];
103
+
104
+ $item = synved_option_item( 'synved_social', 'icon_skin' );
105
+
106
+ if ( false === empty( $item ) ) {
107
+ if ( true === is_object( $item ) ) {
108
+ $item = clone $item;
109
+ }
110
+
111
+ unset( $item['render'] );
112
+
113
+ synved_option_render_item( 'synved_social', 'icon_skin', $item, true, $params, 'widget' );
114
+ }
115
+ ?>
116
+ <br/>
117
+ <label for="<?php echo esc_attr( $this->get_field_id( 'icon_size' ) ); ?>">
118
+ <?php echo esc_html__( 'Icon Size', 'social-media-feather' ); ?>:
119
+ </label>
120
+ <?php
121
+ $params = [
122
+ 'tip' => '',
123
+ 'output_name' => $this->get_field_name( 'icon_size' ),
124
+ 'value' => $instance['icon_size'],
125
+ 'set_before' => [ [ 'default' => __( 'Use Default' ) ] ],
126
+ ];
127
+
128
+ synved_option_render_item( 'synved_social', 'icon_size', null, true, $params, 'widget' );
129
+ ?>
130
+ <br/>
131
+ <label for="<?php echo esc_attr( $this->get_field_id( 'icon_spacing' ) ); ?>">
132
+ <?php echo esc_html__( 'Icon Spacing', 'social-media-feather' ); ?>:
133
+ </label>
134
+ <input type="text" size="3" class="" id="<?php echo esc_attr( $this->get_field_id( 'icon_spacing' ) ); ?>"
135
+ name="<?php echo esc_attr( $this->get_field_name( 'icon_spacing' ) ); ?>"
136
+ value="<?php echo esc_attr( $instance['icon_spacing'] ); ?>"/>
137
+ </p>
138
+ <?php
139
+
140
+ $form = ob_get_clean();
141
+
142
+ echo wp_kses( $form, synved_get_allowed_html_array() );
143
+ }
144
+ }
synved-social/synved-social-setup.php CHANGED
@@ -1,104 +1,96 @@
1
  <?php
2
 
3
- function synved_social_provider_settings()
4
- {
5
- $share_providers = synved_social_service_provider_list('share', true);
6
- $follow_providers = synved_social_service_provider_list('follow', true);
7
- $provider_list = array_merge($share_providers, $follow_providers);
8
- $providers_settings = array();
9
-
10
- foreach ($provider_list as $provider_name => $provider_item)
11
- {
12
- $provider_label = ucwords(str_replace(array('-', '_'), ' ', $provider_name));
13
- $display_set = 'none=None';
14
  $display_default = 'none';
15
 
16
- if (isset($provider_item['label']))
17
- {
18
  $provider_label = $provider_item['label'];
19
  }
20
 
21
- if (isset($share_providers[$provider_name]))
22
- {
23
  $display_set .= ',share=Share';
24
 
25
- if (!isset($share_providers[$provider_name]['default-display']) || $share_providers[$provider_name]['default-display'])
26
- {
27
  $display_default = 'share';
28
  }
29
  }
30
 
31
- if (isset($follow_providers[$provider_name]))
32
- {
33
  $display_set .= ',follow=Follow';
34
 
35
- if (isset($share_providers[$provider_name]))
36
- {
37
  $display_set .= ',both=Share & Follow';
38
  }
39
 
40
- if (!isset($follow_providers[$provider_name]['default-display']) || $follow_providers[$provider_name]['default-display'])
41
- {
42
- if ($display_default == 'share')
43
- {
44
  $display_default = 'both';
45
- }
46
- else
47
- {
48
  $display_default = 'follow';
49
  }
50
  }
51
  }
52
 
53
- $providers_settings = array_merge($providers_settings,
54
- array(
55
- $provider_name . '_display' => array(
56
  'default' => $display_default,
57
- 'style' => 'group',
58
- 'set' => $display_set,
59
- 'label' => __($provider_label . ' Service', 'social-media-feather'),
60
- 'tip' => __('Decides for what types of services ' . $provider_label . ' will be used by default', 'social-media-feather')
61
- ),
62
- )
 
63
  );
64
 
65
- if (isset($share_providers[$provider_name]))
66
- {
67
- $share_item = $share_providers[$provider_name];
68
-
69
- $providers_settings = array_merge($providers_settings,
70
- array(
71
- $provider_name . '_share_link' => array(
72
- 'label' => __($provider_label . ' Share Link', 'social-media-feather'),
73
- 'tip' => __('The link used by default for sharing content on ' . $provider_label . '. <b>Note: this generally doesn\'t need to be changed, only change it if you know what you\'re doing.</b>', 'social-media-feather'),
74
- 'hint' => $share_item['link']
75
- ),
76
- $provider_name . '_share_title' => array(
77
- 'label' => __($provider_label . ' Share Title', 'social-media-feather'),
78
- 'tip' => __('The title used by default for the ' . $provider_label . ' share button (a standard one will be used if left empty)', 'social-media-feather'),
79
- 'hint' => $share_item['title']
80
- ),
81
- )
 
82
  );
83
  }
84
 
85
- if (isset($follow_providers[$provider_name]))
86
- {
87
- $follow_item = $follow_providers[$provider_name];
88
-
89
- $providers_settings = array_merge($providers_settings,
90
- array(
91
- $provider_name . '_follow_link' => array(
92
- 'label' => __($provider_label . ' Follow Link', 'social-media-feather'),
93
- 'tip' => __('The link used by default for following you on ' . $provider_label . '. Change this to point to your own social profile page on ' . $provider_label . '.', 'social-media-feather'),
94
- 'hint' => $follow_item['link']
95
- ),
96
- $provider_name . '_follow_title' => array(
97
- 'label' => __($provider_label . ' Follow Title', 'social-media-feather'),
98
- 'tip' => __('The title used by default for the ' . $provider_label . ' follow button (a standard one will be used if left empty)', 'social-media-feather'),
99
- 'hint' => $follow_item['title']
100
- ),
101
- )
 
102
  );
103
  }
104
  }
@@ -106,368 +98,362 @@ function synved_social_provider_settings()
106
  return $providers_settings;
107
  }
108
 
109
- $terms_accepted = synved_option_get('synved_social', 'accepted_sharethis_terms');
110
-
111
- $synved_social_options = array(
112
- 'settings' => array(
113
- 'label' => 'Social Media',
114
- 'title' => 'Social Media Feather',
115
- 'tip' => synved_option_callback('synved_social_page_settings_tip'),
116
- 'link-target' => plugin_basename(synved_plugout_module_path_get('synved-social', 'provider')),
117
- 'render-fragment' => 'synved_social_page_render_fragment',
118
- 'sections' => array(
119
- 'section_general' => array(
120
- 'label' => __('General Settings', 'social-media-feather'),
121
- 'tip' => __('Settings affecting the general behaviour of the plugin', 'social-media-feather'),
122
- 'settings' => array(
123
- 'use_shortlinks' => array(
124
- 'default' => false, 'label' => __('Use Shortlinks', 'social-media-feather'),
125
- 'tip' => __('Allows for shortened URLs to be used when sharing content if a shortening plugin is installed', 'social-media-feather')
126
- ),
127
- 'share_full_url' => array(
128
- 'default' => false, 'label' => __('Share Full URL', 'social-media-feather'),
129
- 'tip' => __('Determines whether to always share the full URL or just the post permalink. You can override this for individual posts by setting the "synved_social_share_full_url" custom field to either "yes" or "no", case sensitive', 'social-media-feather')
130
- ),
131
- 'layout_rtl' => array(
132
- 'default' => false, 'label' => __('Right To Left Layout', 'social-media-feather'),
133
- 'tip' => __('Check this option if you have a right-to-left site layout and icons show spacing issues', 'social-media-feather')
134
- ),
135
- 'shortcode_widgets' => array(
136
- 'default' => true, 'label' => __('Shortcodes In Widgets', 'social-media-feather'),
137
- 'tip' => __('Allow shortcodes in Text widgets', 'social-media-feather')
138
- ),
139
- 'show_credit' => array(
140
- 'default' => false, 'label' => __('Show Credit', 'social-media-feather'),
141
- 'tip' => __('Display a small icon with a link to the Social Media Feather page', 'social-media-feather')
142
- ),
143
- 'share_message_default' => array(
144
- 'default' => __('Hey check this out', 'social-media-feather'), 'label' => __('Default Message', 'social-media-feather'),
145
- 'tip' => __('Specify the default message to use when sharing content, this is what gets replaced into the %%message%% variable', 'social-media-feather')
146
- ),
147
- 'hide_sharethis_terms' => array(
148
- 'default' => false, 'label' => __('Hide Extra Features Prompt', 'social-media-feather'),
149
- 'tip' => __('Don\'t prompt for extra features.', 'social-media-feather'),
150
- 'hidden' => true
151
- ),
152
- 'fb_app_id' => array(
153
- 'default' => '',
154
- 'label' => __( 'Facebook App ID', 'social-media-feather' ),
155
- ),
156
- 'accepted_sharethis_terms' => array(
157
- 'type' => 'custom',
158
- 'label' => __( 'Terms of Service', 'social-media-feather' ),
159
- 'tip' => __( 'Accept or decline <a target="_blank" href="https://www.sharethis.com/terms/">ShareThis Terms of Service</a> and <a target="_blank" href="https://www.sharethis.com/privacy/">Privacy Notice</a>', 'social-media-feather' ),
160
- 'render' => 'synved_social_accept_terms_switch'
161
- ),
162
- )
163
- ),
164
-
165
- 'section_automatic_display' => array(
166
- 'label' => __('Automatic Display', 'social-media-feather'),
167
- 'tip' => __('Settings affecting automating appending of social buttons to post contents', 'social-media-feather'),
168
- 'settings' => array(
169
- 'automatic_share' => array(
170
- 'default' => false, 'label' => __('Display Sharing Buttons', 'social-media-feather'),
171
- 'tip' => __('Tries to automatically append sharing buttons to your posts (disable for specific posts by setting custom field synved_social_exclude or synved_social_exclude_share to "yes", case sensitive)', 'social-media-feather')
172
- ),
173
- 'automatic_share_position' => array(
174
- 'default' => 'after_post',
175
- 'set' => 'after_post=After Post,before_post=Before Post,after_before_post=After and Before Post',
176
- 'label' => __('Share Buttons Position', 'social-media-feather'),
177
- 'tip' => __('Select where the sharing buttons should be placed. Note: placing buttons Before Post might not work in all themes.', 'social-media-feather')
178
- ),
179
- 'automatic_share_single' => array(
180
- 'default' => false, 'label' => __('Sharing Single Posts', 'social-media-feather'),
181
- 'tip' => __('Sharing buttons are only displayed on single posts/pages and not on archive pages like blog/category/tag/author pages', 'social-media-feather')
182
- ),
183
- 'automatic_share_post_types' => array(
184
- 'type' => 'custom',
185
- 'default' => 'post',
186
- 'set' => synved_option_callback('synved_social_automatic_append_post_types_set', array('post', 'page')),
187
- 'label' => __('Share Post Types', 'social-media-feather'),
188
- 'tip' => __('Post types for which automatic appending for share buttons should be attempted (CTRL + click to select multiple ones)', 'social-media-feather'),
189
- 'render' => 'synved_social_automatic_append_post_types_render'
190
- ),
191
- 'automatic_share_prefix' => array(
192
- 'default' => '', 'label' => __('Share Prefix Markup', 'social-media-feather'),
193
- 'tip' => __('When automatically appending, place this markup before the share buttons markup', 'social-media-feather')
194
- ),
195
- 'automatic_share_postfix' => array(
196
- 'default' => '', 'label' => __('Share Postfix Markup', 'social-media-feather'),
197
- 'tip' => __('When automatically appending, place this markup after all of the share buttons markup', 'social-media-feather')
198
- ),
199
- 'automatic_follow' => array(
200
- 'default' => false, 'label' => __('Display Follow Buttons', 'social-media-feather'),
201
- 'tip' => __('Tries to automatically append follow buttons to your posts (disable for specific posts by setting custom field synved_social_exclude or synved_social_exclude_follow to "yes", case sensitive)', 'social-media-feather')
202
- ),
203
- 'automatic_follow_position' => array(
204
- 'default' => 'after_post',
205
- 'set' => 'after_post=After Post,before_post=Before Post,after_before_post=After and Before Post',
206
- 'label' => __('Follow Buttons Position', 'social-media-feather'),
207
- 'tip' => __('Select where the follow buttons should be placed. Note: placing buttons Before Post might not work in all themes.', 'social-media-feather')
208
- ),
209
- 'automatic_follow_single' => array(
210
- 'default' => false, 'label' => __('Follow Single Posts', 'social-media-feather'),
211
- 'tip' => __('Follow buttons are only displayed on single posts/pages and not on archive pages like blog/category/tag/author pages', 'social-media-feather')
212
- ),
213
- 'automatic_follow_post_types' => array(
214
- 'type' => 'custom',
215
- 'default' => 'post',
216
- 'set' => synved_option_callback('synved_social_automatic_append_post_types_set', array('post', 'page')),
217
- 'label' => __('Follow Post Types', 'social-media-feather'),
218
- 'tip' => __('Post types for which automatic appending for follow buttons should be attempted (CTRL + click to select multiple ones)', 'social-media-feather'),
219
- 'render' => 'synved_social_automatic_append_post_types_render'
220
- ),
221
- 'automatic_follow_before_share' => array(
222
- 'default' => false, 'label' => __('Follow Before Share', 'social-media-feather'),
223
- 'tip' => __('When automatically appending, place follow buttons before share buttons. Only valid when share and follow buttons positions are the same.', 'social-media-feather')
224
- ),
225
- 'automatic_follow_prefix' => array(
226
- 'default' => '', 'label' => __('Follow Prefix Markup', 'social-media-feather'),
227
- 'tip' => __('When automatically appending, place this markup before the follow buttons markup', 'social-media-feather')
228
- ),
229
- 'automatic_follow_postfix' => array(
230
- 'default' => '', 'label' => __('Follow Postfix Markup', 'social-media-feather'),
231
- 'tip' => __('When automatically appending, place this markup after all of the follow buttons markup', 'social-media-feather')
232
- ),
233
- 'automatic_append_prefix' => array(
234
- 'default' => '', 'label' => __('Prefix Markup', 'social-media-feather'),
235
- 'tip' => __('When automatically appending, place this markup before the buttons markup', 'social-media-feather')
236
- ),
237
- 'automatic_append_separator' => array(
238
- 'default' => '<br/>', 'label' => __('Separator Markup', 'social-media-feather'),
239
- 'tip' => __('When automatically appending both, use this markup as separator between the set of share buttons and the set of follow buttons. Only valid when share and follow buttons positions are the same.', 'social-media-feather')
240
- ),
241
- 'automatic_append_postfix' => array(
242
- 'default' => '', 'label' => __('Postfix Markup', 'social-media-feather'),
243
- 'tip' => __('When automatically appending, place this markup after all of the buttons markup', 'social-media-feather')
244
- ),
245
- )
246
- ),
247
- 'section_customize_look' => array(
248
- 'label' => __('Customize Look', 'social-media-feather'),
249
- 'tip' => synved_option_callback('synved_social_section_customize_look_tip', __('Customize the look & feel of Social Media Feather', 'social-media-feather')),
250
- 'settings' => array(
251
- 'icon_skin' => array(
252
- 'default' => 'regular',
253
- 'set' => synved_option_callback('synved_social_cb_icon_skin_set', 'regular=Regular'),
254
- 'label' => __('Icon Skin', 'social-media-feather'),
255
- 'tip' => synved_option_callback('synved_social_setting_icon_skin_tip',__('Select the default skin to use for the icons', 'social-media-feather')),
256
- 'render' => 'synved_social_icon_skin_render'
257
- ),
258
- 'addon_extra_icons' => array(
259
- 'type' => 'addon',
260
- 'target' => SYNVED_SOCIAL_ADDON_PATH,
261
- 'folder' => 'extra-icons',
262
- 'module' => 'synved-social',
263
- 'style' => 'addon-important',
264
- 'label' => __('Extra Icon Skins', 'social-media-feather'),
265
- 'tip' => synved_option_callback('synved_social_option_addon_extra_icons_tip', __('Click the button to install the "Extra Social Icons" addon, get it <a target="_blank" href="http://socialmediafeather.com/products/extra-social-icons/">here</a>.', 'social-media-feather'))
266
- ),
267
- 'addon_grey_fade' => array(
268
- 'type' => 'addon',
269
- 'target' => SYNVED_SOCIAL_ADDON_PATH,
270
- 'folder' => 'grey-fade',
271
- 'module' => 'synved-social',
272
- 'style' => 'addon-important',
273
- 'label' => __('Grey Fade Effect', 'social-media-feather'),
274
- 'tip' => synved_option_callback('synved_social_option_addon_grey_fade_tip', __('Click the button to install the "Grey Fade" addon, get it <a target="_blank" href="http://socialmediafeather.com/products/grey-fade-effect/">here</a>.', 'social-media-feather'))
275
- ),
276
- 'addon_light_prompt' => array(
277
- 'type' => 'addon',
278
- 'target' => SYNVED_SOCIAL_ADDON_PATH,
279
- 'folder' => 'light-prompt',
280
- 'module' => 'synved-social',
281
- 'style' => 'addon-important',
282
- 'label' => __('Light Prompt Overlay', 'social-media-feather'),
283
- 'tip' => synved_option_callback('synved_social_option_addon_light_prompt_tip', __('Click the button to install the "Light Prompt" addon, get it <a target="_blank" href="http://socialmediafeather.com/products/light-prompt/">here</a>.', 'social-media-feather'))
284
- ),
285
- 'icon_size' => array(
286
- 'default' => 48,
287
- 'set' => '16=16x16,24=24x24,32=32x32,48=48x48,64=64x64,96=96x96',
288
- 'label' => __('Icon Size', 'social-media-feather'),
289
- 'tip' => __('Select the size in pixels for the icons. Note: for high resolution displays like Retina the maximum size is 64x64.', 'social-media-feather')
290
- ),
291
- 'icon_resolution' => array(
292
- 'default' => 'single',
293
- 'set' => 'single=Single,double=Double',
294
- 'label' => __('Icon Resolution', 'social-media-feather'),
295
- 'tip' => __('Select what icon resolutions will be used. Single might make the icons slightly blurry on low resolution displays. Double will always look the best but will consume more bandwidth.', 'social-media-feather')
296
- ),
297
- 'icon_spacing' => array(
298
- 'default' => 5,
299
- 'label' => __('Icon Spacing', 'social-media-feather'),
300
- 'tip' => __('Select the spacing in pixels between the icons', 'social-media-feather')
301
- ),
302
- 'buttons_container' => array(
303
- 'default' => 'none',
304
- 'set' => 'none=None,share=Sharing Buttons,follow=Following Buttons,both=Both',
305
- 'label' => __('Buttons in Container', 'social-media-feather'),
306
- 'tip' => __('Determines whether or not to wrap the buttons in a container, which will affect how the buttons are rendered, based on the "Buttons Container Type" setting.', 'social-media-feather')
307
- ),
308
- 'buttons_container_type' => array(
309
- 'default' => 'basic',
310
- 'set' => 'basic=Basic,block=Block',
311
- 'label' => __('Buttons Container Type', 'social-media-feather'),
312
- 'tip' => __('"Basic" should not affect rendering, while "Block" should display the buttons in their own row. <b>Note</b>: selecting "Block" might not look the way you want if you\'re using Prefix or Postfix markup.', 'social-media-feather')
313
- ),
314
- 'buttons_alignment_share' => array(
315
- 'default' => 'none',
316
- 'set' => 'none=Theme Default,left=Align Left,right=Align Right,center=Align Center',
317
- 'label' => __('Share Buttons Alignment', 'social-media-feather'),
318
- 'tip' => __('Will attempt at aligning the share buttons accordingly. <strong>Note:</strong> this will enforce "Buttons Container Type" of "Block" and might not work reliably on all themes', 'social-media-feather')
319
- ),
320
- 'buttons_alignment_follow' => array(
321
- 'default' => 'none',
322
- 'set' => 'none=Theme Default,left=Align Left,right=Align Right,center=Align Center',
323
- 'label' => __('Follow Buttons Alignment', 'social-media-feather'),
324
- 'tip' => __('Will attempt at aligning the follow buttons accordingly. <strong>Note:</strong> this will enforce "Buttons Container Type" of "Block" and might not work reliably on all themes', 'social-media-feather')
325
- ),
326
- 'custom_style' => array(
327
- 'type' => 'style',
328
- 'label' => __('Extra Styles', 'social-media-feather'),
329
- 'tip' => __('Any CSS styling code you type in here will be loaded after all of the Social Media Feather styles.', 'social-media-feather')
330
- ),
331
- )
332
- ),
333
- 'section_service_providers' => array(
334
- 'label' => __('Service Providers', 'social-media-feather'),
335
- 'tip' => __('Customize social sharing and following providers', 'social-media-feather'),
336
- 'settings' => synved_social_provider_settings()
337
- )
338
- )
339
- )
340
- );
341
-
342
-
343
- synved_option_register('synved_social', $synved_social_options);
344
-
345
- synved_option_include_module_addon_list('synved-social');
346
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
 
348
  function synved_social_accept_terms_switch() {
349
 
350
  $out = '<label class="synved-switch">
351
  <input id="synved-disable" name="synved_social_settings[accepted_sharethis_terms]"
352
- type="checkbox" value="'.(synved_social_are_terms_accepted()?1:0).'">
353
  <div id="synved-slider" class="synved-slider round"></div>
354
  </label>';
355
 
356
- return $out;
357
- }
358
-
359
- function synved_social_provider_option_value_sanitize($value, $name, $id, $item)
360
- {
361
- $default = synved_option_item_default($item);
362
-
363
- if ($value == $default)
364
- {
365
-
366
- }
367
  }
368
 
369
- function synved_social_page_settings_tip($tip, $item)
370
- {
 
 
 
 
 
 
 
371
  $tip = '';
372
 
373
- if (preg_match( '/page=synved_social_settings/i', $_SERVER[ 'REQUEST_URI' ] )) {
374
 
375
- // if terms have just been accepted
376
- if ( isset( $_GET['accept-terms'] ) && $_GET['accept-terms'] == "yes" ) {
377
- $tip .= '<div class="alert alert-success text-center">
378
- <p>Thank you, the update has been enabled!</p>
379
- </div>';
380
- } elseif ( ! synved_option_get( 'synved_social',
381
- 'accepted_sharethis_terms' )
382
- ) {
383
  $tip .= synved_social_sharethis_terms_notice( false, false );
384
  }
385
 
386
- // if (!function_exists('synved_shortcode_version'))
387
- // {
388
- // $tip .= ' <div style="background:#f2f2f2;font-size:110%;color:#444;margin-right:270px;padding:10px 15px;"><b>' . __('Note', 'social-media-feather') . '</b>: ' . sprintf(__('The Social Media Feather plugin is fully compatible with the free <a target="_blank" href="%1$s">WordPress Shortcodes</a> plugin! WordPress Shortcodes will simplify adding Social Media shortcodes to your posts and pages. You can install it using your <a href="%2$s">plugin installer</a>.', 'social-media-feather'), 'http://synved.com/wordpress-shortcodes/', add_query_arg(array('tab' => 'search', 's' => 'synved shortcodes'), admin_url('plugin-install.php'))) . '</div>';
389
- // }
390
-
391
- if ( function_exists( 'synved_connect_support_social_follow_render' ) ) {
392
  $tip .= synved_connect_support_social_follow_render();
393
  }
394
  }
 
395
  return $tip;
396
  }
397
 
398
- function synved_social_page_render_fragment($fragment, $out, $params)
399
- {
400
- if ($fragment == 'page-submit-tail')
401
- {
402
  $out .= '<div style="clear:both; margin-top: -12px;"><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/social-media-feather?rate=5#postform" style="font-size:120%"><b>We need your help!</b> If you like the plugin, you can help us by leaving a 5-stars review! It only takes a minute and it\'s free!</a></div>';
403
- $out .= '<p>By using this plugin you are agreeing to the <a href="http://socialmediafeather.com/privacy/">Terms of service and Privacy Policy</a>.</p>';
404
  }
405
 
406
  return $out;
407
  }
408
 
409
- function synved_social_section_customize_look_tip($tip, $item)
410
- {
411
  return $tip;
412
  }
413
 
414
- function synved_social_cb_icon_skin_set($set, $item)
415
- {
416
- if ($set != null && !is_array($set))
417
- {
418
- $set = synved_option_item_set_parse($item, $set);
419
  }
420
 
421
- $set = array();
422
  $icons = synved_social_icon_skin_list();
423
 
424
- foreach ($icons as $icon_name => $icon_meta)
425
- {
426
- $set[][$icon_name] = $icon_meta['label'];
427
  }
428
 
429
  return $set;
430
  }
431
 
432
- function synved_social_setting_icon_skin_tip($tip, $item)
433
- {
434
- $uri = synved_social_path_uri();
435
-
436
- if (!synved_option_addon_installed('synved_social', 'addon_extra_icons'))
437
- {
438
- $tip .= '<div style="clear:both"><p style="font-size:120%;"><b>Get all 8 extra icon skins you see below with the <a target="_blank" href="http://socialmediafeather.com/products/extra-social-icons/">Extra Social Icons addon</a></b>:</p> <a target="_blank" href="http://socialmediafeather.com/products/extra-social-icons/"><img src="' . $uri . '/image/social-feather-extra-icons.png" /></a></div>';
439
- }
440
-
441
- return $tip;
442
- }
443
-
444
- function synved_social_icon_skin_render($value, $params, $id, $name, $item)
445
- {
446
- $uri = synved_social_path_uri();
447
  $icons = synved_social_icon_skin_list();
448
 
449
- $out = null;
450
  $out_name = $params['output_name'];
451
- $set = $params['set'];
452
 
453
  $out .= '<div>';
454
 
455
  $sharethis_terms_agree = synved_option_get( 'synved_social', 'accepted_sharethis_terms' );
456
 
457
- foreach ($set as $set_it)
458
- {
459
- $set_it_keys = array_keys($set_it);
460
- $selected = $set_it_keys[0] == $value ? ' checked="checked"' : null;
461
- $img_src = '';
462
 
463
- if (isset($icons[$set_it_keys[0]]))
464
- {
465
- $img_src = $icons[$set_it_keys[0]]['image'];
466
  }
467
 
468
  $disabled = disabled( ! $sharethis_terms_agree && ! empty( $icons[ $set_it_keys[0] ]['extra'] ), true, false );
469
 
470
- $out .= '<div style="text-align:center; width:260px; float:left; margin-right:20px; margin-bottom: 15px;"><label title="Use skin=&quot;' . esc_attr($set_it_keys[0]) . '&quot; in shortcodes"><img src="' . esc_url($img_src) . '" style="border:solid 1px #bbb" /><p><input type="radio" name="' . esc_attr($out_name) . '" value="' . esc_attr($set_it_keys[0]) . '"' . $selected . ' ' . $disabled . '/> ' . $set_it[$set_it_keys[0]] . '</p></label></div>';
471
  }
472
 
473
  $out .= '</div>';
@@ -476,53 +462,44 @@ function synved_social_icon_skin_render($value, $params, $id, $name, $item)
476
  }
477
 
478
 
479
- function synved_social_automatic_append_post_types_set($set, $item)
480
- {
481
- if ($set != null && !is_array($set))
482
- {
483
- $set = synved_option_item_set_parse($item, $set);
484
  }
485
 
486
- $set = array();
487
- $types = get_post_types(array('public' => true));
488
 
489
- foreach ($types as $type_name)
490
- {
491
- $set[][$type_name] = $type_name;
492
  }
493
 
494
  return $set;
495
  }
496
 
497
- function synved_social_automatic_append_post_types_render($value, $params, $id, $name, $item)
498
- {
499
- $uri = synved_social_path_uri();
500
  $icons = synved_social_icon_skin_list();
501
 
502
- if (!is_array($value))
503
- {
504
- if ($value != null)
505
- {
506
- $value = array($value);
507
- }
508
- else
509
- {
510
- $value = array();
511
  }
512
  }
513
 
514
- $out = null;
515
  $out_name = $params['output_name'];
516
- $set = $params['set'];
517
 
518
- $out .= '<select multiple="multiple" name="' . esc_attr($out_name . '[]') . '">';
519
 
520
- foreach ($set as $set_it)
521
- {
522
- $set_it_keys = array_keys($set_it);
523
- $selected = in_array($set_it_keys[0], $value) ? ' selected="selected"' : null;
524
 
525
- $out .= '<option value="' . esc_attr($set_it_keys[0]) . '"' . $selected . '>' . $set_it[$set_it_keys[0]] . '</option>';
526
  }
527
 
528
  $out .= '</select>';
@@ -530,93 +507,35 @@ function synved_social_automatic_append_post_types_render($value, $params, $id,
530
  return $out;
531
  }
532
 
533
- function synved_social_option_addon_extra_icons_tip($tip, $item)
534
- {
535
- if (synved_option_addon_installed('synved_social', 'addon_extra_icons'))
536
- {
537
- // missing icons for installed extra-icons addon
538
- if (!function_exists('synved_social_addon_extra_icons_version'))
539
- {
540
- $tip .= ' <span style="background:#ecc;padding:5px 8px;">' . __('The "Extra Social Icons" addon is already installed but requires an update for recently added providers, please use your download link or <a href="http://socialmediafeather.com/products/extra-social-icons/">Extra Social Icons addon</a>', 'social-media-feather') . '</span>';
541
- }
542
- else
543
- {
544
- $tip .= ' <span style="background:#eee;padding:5px 8px;">' . __('The "Extra Social Icons" addon is already installed! You can use the button to re-install it.', 'social-media-feather') . '</span>';
545
- }
546
- }
547
-
548
- return $tip;
549
- }
550
-
551
- function synved_social_option_addon_grey_fade_tip($tip, $item)
552
- {
553
- $uri = synved_social_path_uri();
554
-
555
- if (synved_option_addon_installed('synved_social', 'addon_grey_fade'))
556
- {
557
- $tip .= ' <span style="background:#eee;padding:5px 8px;">' . __('The "Grey Fade" addon is already installed! You can use the button to re-install it.', 'social-media-feather') . '</span>';
558
- }
559
- else
560
- {
561
- $tip .= '<div style="clear:both"><p style="font-size:120%;"><b>The <a target="_blank" href="http://socialmediafeather.com/products/grey-fade-effect/">Grey Fade addon</a> allows you to achieve the effect below, <a target="_blank" href="http://socialmediafeather.com/products/grey-fade-effect/">get it now</a>!</b></p> <a target="_blank" href="http://socialmediafeather.com/products/grey-fade-effect/"><img src="' . $uri . '/image/social-feather-grey-fade-demo.png" /></a></div>';
562
- }
563
-
564
- return $tip;
565
- }
566
-
567
- function synved_social_option_addon_light_prompt_tip($tip, $item)
568
- {
569
- $uri = synved_social_path_uri();
570
 
571
- if (synved_option_addon_installed('synved_social', 'addon_light_prompt'))
572
- {
573
- $tip .= ' <span style="background:#eee;padding:5px 8px;">' . __('The "Light Prompt" addon is already installed! You can use the button to re-install it.', 'social-media-feather') . '</span>';
574
- }
575
- else
576
- {
577
- $tip .= '<div style="clear:both"><p style="font-size:120%;"><b>The <a target="_blank" href="http://socialmediafeather.com/products/light-prompt/">Light Prompt addon</a> allows you to achieve the nice overlay below when users click on a share button, <a target="_blank" href="http://socialmediafeather.com/products/light-prompt/">get it now</a>!</b></p> <a target="_blank" href="http://socialmediafeather.com/products/light-prompt/"><img src="' . $uri . '/image/social-feather-light-prompt-demo.png" /></a></div>';
578
- }
579
-
580
- return $tip;
581
- }
582
-
583
- function synved_social_path($path = null)
584
- {
585
- $root = dirname(__FILE__);
586
-
587
- if ($root != null)
588
- {
589
- if (substr($root, -1) != '/' && isset($path) && $path[0] != '/')
590
- {
591
  $root .= '/';
592
  }
593
 
594
  $root .= $path;
595
  }
596
 
597
- $root = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $root);
598
 
599
  return $root;
600
  }
601
 
602
- function synved_social_path_uri($path = null)
603
- {
604
- $uri = plugins_url('/social-media-feather') . '/synved-social';
605
 
606
- if (function_exists('synved_plugout_module_uri_get'))
607
- {
608
- $mod_uri = synved_plugout_module_uri_get('synved-social');
609
 
610
- if ($mod_uri != null)
611
- {
612
  $uri = $mod_uri;
613
  }
614
  }
615
 
616
- if ($path != null)
617
- {
618
- if (substr($uri, -1) != '/' && $path[0] != '/')
619
- {
620
  $uri .= '/';
621
  }
622
 
@@ -626,64 +545,53 @@ function synved_social_path_uri($path = null)
626
  return $uri;
627
  }
628
 
629
- function synved_social_wp_register_common_scripts()
630
- {
631
- $uri = synved_social_path_uri();
632
-
633
- //wp_register_style('synved-social-style', $uri . '/style/style.css', false, '1.0');
634
- }
635
-
636
- function synved_social_wp_script_loader_tag($tag, $handle)
637
- {
638
- if ('feather-sharethis' === $handle)
639
- {
640
  return str_replace( '<script', '<script id=\'st_insights_js\'', $tag );
641
  }
642
 
643
  return $tag;
644
  }
645
 
646
- function synved_social_enqueue_scripts()
647
- {
648
- $uri = synved_social_path_uri();
649
-
650
- synved_social_wp_register_common_scripts();
651
-
652
- //wp_enqueue_style('synved-social-style');
653
-
654
- if ( synved_social_are_terms_accepted() )
655
- {
656
-
657
- if (is_ssl()) {
658
- $st_insights = 'https://ws.sharethis.com/button/st_insights.js';
659
- } else {
660
- $st_insights = 'http://w.sharethis.com/button/st_insights.js';
661
- }
662
 
663
  $url = add_query_arg(
664
- array(
665
  'publisher' => 'eba0f3ba-f9ab-408c-bc68-c28af5afe749',
666
  'product' => 'feather',
667
- ), $st_insights );
668
 
669
- wp_enqueue_script('feather-sharethis', $url, null, null);
670
 
671
- add_filter('script_loader_tag', 'synved_social_wp_script_loader_tag', 10, 2);
672
  }
673
  }
674
 
675
  /**
 
 
676
  * @return bool
677
  */
678
  function synved_social_are_terms_accepted() {
679
- return synved_option_get( 'synved_social', 'accepted_sharethis_terms' );
680
  }
681
 
682
- function synved_social_print_styles()
683
- {
684
- echo "\r\n" . '<style type="text/css">';
 
 
 
 
685
 
686
- echo '
 
687
  .synved-social-resolution-single {
688
  display: inline-block;
689
  }
@@ -707,190 +615,106 @@ only screen and (min-resolution: 192dpi) {
707
  display: inline-block;
708
  }
709
  }
710
- ';
711
-
712
- echo '</style>' . "\r\n";
713
- }
714
-
715
- function synved_social_admin_enqueue_scripts()
716
- {
717
- $uri = synved_social_path_uri();
718
 
719
- synved_social_wp_register_common_scripts();
720
- }
721
 
722
- function synved_social_admin_print_styles()
723
- {
 
724
  }
725
 
726
- function synved_social_wp_tinymce_plugin($plugin_array)
727
- {
728
- $plugin_array['synved_social'] = synved_social_path_uri() . '/script/tinymce_plugin.js';
729
-
730
- return $plugin_array;
731
- }
732
-
733
- function synved_social_wp_tinymce_button($buttons)
734
- {
735
- array_push($buttons, '|', 'synved_social');
736
-
737
- return $buttons;
738
- }
739
-
740
- function synved_social_ajax_callback()
741
- {
742
- check_ajax_referer('synved-social-submit-nonce', 'synvedSecurity');
743
-
744
- if (!isset($_POST['synvedAction']) || $_POST['synvedAction'] == null)
745
- {
746
- return;
747
- }
748
-
749
- $action = $_POST['synvedAction'];
750
- $params = isset($_POST['synvedParams']) ? $_POST['synvedParams'] : null;
751
- $response = null;
752
- $response_html = null;
753
-
754
- if (is_string($params))
755
- {
756
- $parms = json_decode($params, true);
757
-
758
- if ($parms == null)
759
- {
760
- $parms = json_decode(stripslashes($params), true);
761
- }
762
-
763
- $params = $parms;
764
- }
765
-
766
- switch ($action)
767
- {
768
- case 'load-ui':
769
- {
770
- $uri = synved_social_path_uri();
771
-
772
- if (current_user_can('edit_posts') || current_user_can('edit_pages'))
773
- {
774
- }
775
-
776
- break;
777
- }
778
- case 'preview-code':
779
- {
780
- if (current_user_can('edit_posts') || current_user_can('edit_pages'))
781
- {
782
- }
783
-
784
- break;
785
- }
786
- }
787
-
788
- while (ob_get_level() > 0)
789
- {
790
- ob_end_clean();
791
- }
792
-
793
- if ($response != null)
794
- {
795
- $response = json_encode($response);
796
-
797
- header('Content-Type: application/json');
798
-
799
- echo $response;
800
- }
801
- else if ($response_html != null)
802
- {
803
- header('Content-Type: text/html');
804
-
805
- echo $response_html;
806
- }
807
- else
808
- {
809
- header('HTTP/1.1 403 Forbidden');
810
- }
811
 
812
- exit();
 
 
 
 
 
 
 
813
  }
814
 
815
- function synved_social_register_widgets()
816
- {
817
- register_widget('SynvedSocialShareWidget');
818
- register_widget('SynvedSocialFollowWidget');
819
  }
820
 
821
- function synved_social_wp_the_content($content, $id = null)
822
- {
823
- $exclude = false;
824
- $exclude_share = false;
825
  $exclude_follow = false;
826
 
827
- $extra_after = null;
828
- $extra_before = null;
829
- $separator_after = null;
830
  $separator_before = null;
831
 
832
- if ($id == null)
833
- {
834
  $id = get_the_ID();
835
 
836
- if ($id == null)
837
- {
838
  global $post;
839
 
840
  $id = $post->ID;
841
  }
842
  }
843
 
844
- if ($id != null)
845
- {
846
- $exclude = get_post_meta($id, 'synved_social_exclude', true) == 'yes' ? true : false;
847
- $exclude_share = get_post_meta($id, 'synved_social_exclude_share', true) == 'yes' ? true : false;
848
- $exclude_follow = get_post_meta($id, 'synved_social_exclude_follow', true) == 'yes' ? true : false;
849
 
850
- if (!$exclude_share && synved_option_get('synved_social', 'automatic_share_single'))
851
- {
852
- $exclude_share = !(is_singular(synved_option_get('synved_social', 'automatic_share_post_types')) && (is_single($id) || is_page($id)));
853
  }
854
 
855
- if (!$exclude_follow && synved_option_get('synved_social', 'automatic_follow_single'))
856
- {
857
- $exclude_follow = !(is_singular(synved_option_get('synved_social', 'automatic_follow_post_types')) && (is_single($id) || is_page($id)));
858
  }
859
  }
860
 
861
- if ($exclude == false)
862
- {
863
- if ($exclude_share == false && synved_option_get('synved_social', 'automatic_share'))
864
- {
865
  $post_type = get_post_type();
866
- $type_list = synved_option_get('synved_social', 'automatic_share_post_types');
867
-
868
- if (in_array($post_type, $type_list))
869
- {
870
- $position = synved_option_get('synved_social', 'automatic_share_position');
871
- $position_before = in_array($position, array('before_post', 'after_before_post'));
872
- $position_after = in_array($position, array('after_post', 'after_before_post'));
873
- $prefix = synved_option_get('synved_social', 'automatic_share_prefix');
874
- $postfix = synved_option_get('synved_social', 'automatic_share_postfix');
875
-
876
- if ($position_after)
877
- {
 
 
878
  $markup = synved_social_share_markup();
879
 
880
- if (trim($markup) != null)
881
- {
882
  $markup = $prefix . $markup . $postfix;
883
 
884
  $extra_after .= $markup;
885
  }
886
  }
887
 
888
- if ($position_before)
889
- {
890
  $markup = synved_social_share_markup();
891
 
892
- if (trim($markup) != null)
893
- {
894
  $markup = $prefix . $markup . $postfix;
895
 
896
  $extra_before .= $markup;
@@ -899,64 +723,50 @@ function synved_social_wp_the_content($content, $id = null)
899
  }
900
  }
901
 
902
- $separator = synved_option_get('synved_social', 'automatic_append_separator');
903
 
904
- if ($extra_after != null)
905
- {
906
  $separator_after = $separator;
907
  }
908
 
909
- if ($extra_before != null)
910
- {
911
  $separator_before = $separator;
912
  }
913
 
914
- if ($exclude_follow == false && synved_option_get('synved_social', 'automatic_follow'))
915
- {
916
  $post_type = get_post_type();
917
- $type_list = synved_option_get('synved_social', 'automatic_follow_post_types');
918
-
919
- if (in_array($post_type, $type_list))
920
- {
921
- $position = synved_option_get('synved_social', 'automatic_follow_position');
922
- $position_before = in_array($position, array('before_post', 'after_before_post'));
923
- $position_after = in_array($position, array('after_post', 'after_before_post'));
924
- $prefix = synved_option_get('synved_social', 'automatic_follow_prefix');
925
- $postfix = synved_option_get('synved_social', 'automatic_follow_postfix');
926
-
927
- if ($position_after)
928
- {
929
  $markup = synved_social_follow_markup();
930
 
931
- if (trim($markup) != null)
932
- {
933
  $markup = $prefix . $markup . $postfix;
934
 
935
- if (synved_option_get('synved_social', 'automatic_follow_before_share'))
936
- {
937
  $extra_after = $markup . $separator_after . $extra_after;
938
- }
939
- else
940
- {
941
  $extra_after .= $separator_after . $markup;
942
  }
943
  }
944
  }
945
 
946
- if ($position_before)
947
- {
948
  $markup = synved_social_follow_markup();
949
 
950
- if (trim($markup) != null)
951
- {
952
  $markup = $prefix . $markup . $postfix;
953
 
954
- if (synved_option_get('synved_social', 'automatic_follow_before_share'))
955
- {
956
  $extra_before = $markup . $separator_before . $extra_before;
957
- }
958
- else
959
- {
960
  $extra_before .= $separator_before . $markup;
961
  }
962
  }
@@ -964,16 +774,14 @@ function synved_social_wp_the_content($content, $id = null)
964
  }
965
  }
966
 
967
- $prefix = synved_option_get('synved_social', 'automatic_append_prefix');
968
- $postfix = synved_option_get('synved_social', 'automatic_append_postfix');
969
 
970
- if ($extra_after != null)
971
- {
972
  $content .= $prefix . $extra_after . $postfix;
973
  }
974
 
975
- if ($extra_before != null)
976
- {
977
  $content = $prefix . $extra_before . $postfix . $content;
978
  }
979
  }
@@ -989,27 +797,21 @@ function synved_social_wp_the_content($content, $id = null)
989
  *
990
  * @return string
991
  */
992
- function synved_social_sharethis_terms_notice($render_html = true, $isDismissible = true)
993
- {
994
- $out = '<div id="sharethis_terms_notice" class="notice-warning notice '.(!empty($isDismissible)?'is-dismissible':'').'">
995
  <p>
996
  To get the most out of Social Media Feather and to help enable its continued development,
997
  please read the <a href="//sharethis.com/terms" target="_blank">ShareThis Terms of Service</a> and <a href="//sharethis.com/privacy" target="_blank">Privacy Notice</a>,
998
- then <a href="'.admin_url('options-general.php?page=synved_social_settings&accept-terms=yes').'">click here to accept the terms</a>.
999
  </p>
1000
  </div>
1001
- <script language="JavaScript">
1002
- jQuery(\'#sharethis_terms_notice\').on( \'click\', \'.notice-dismiss\', function( event ) {
1003
- jQuery.post( ajaxurl, { action: \'feather_hide_terms\' } );
1004
- });
1005
- </script>
1006
  ';
1007
 
1008
- if ($render_html){
1009
- echo $out;
1010
- } else {
1011
- return $out;
1012
- }
1013
 
1014
  }
1015
 
@@ -1017,152 +819,142 @@ function synved_social_sharethis_terms_notice($render_html = true, $isDismissibl
1017
  * Wrapper to be able to call this method within parameters by add_action
1018
  */
1019
  function synved_social_sharethis_terms_notice_callback_admin_notice_wrapper() {
1020
- synved_social_sharethis_terms_notice(true, true);
1021
  }
1022
 
1023
  // Hides the terms agreement at user's request.
1024
- function synved_social_admin_hide_callback()
1025
- {
1026
- synved_option_set('synved_social', 'hide_sharethis_terms', true);
1027
  }
1028
 
1029
- function synved_social_init()
1030
- {
1031
- if (current_user_can('edit_posts') || current_user_can('edit_pages'))
1032
- {
1033
- if (get_user_option('rich_editing') == 'true')
1034
- {
1035
- //add_filter('mce_external_plugins', 'synved_social_wp_tinymce_plugin');
1036
- //add_filter('mce_buttons', 'synved_social_wp_tinymce_button');
1037
- }
1038
- }
1039
-
1040
- $priority = defined('SHORTCODE_PRIORITY') ? SHORTCODE_PRIORITY : 11;
1041
 
1042
- if (synved_option_get('synved_social', 'shortcode_widgets'))
1043
- {
1044
- remove_filter('widget_text', 'do_shortcode', $priority);
1045
- add_filter('widget_text', 'do_shortcode', $priority);
1046
  }
1047
 
1048
- if (function_exists('synved_shortcode_add'))
1049
- {
1050
- synved_shortcode_add('feather_share', 'synved_social_share_shortcode');
1051
- synved_shortcode_add('feather_follow', 'synved_social_follow_shortcode');
1052
-
1053
- $size_set = '16,24,32,48,64,96';
1054
- $size_item = synved_option_item('synved_social', 'icon_size');
1055
-
1056
- if ($size_item != null)
1057
- {
1058
- $item_set = synved_option_item_set($size_item);
1059
-
1060
- if ($item_set != null)
1061
- {
1062
- $set_items = array();
1063
 
1064
- foreach ($item_set as $set_item)
1065
- {
1066
- $item_keys = array_keys($set_item);
1067
 
1068
- $set_items[] = $item_keys[0];
1069
- }
1070
 
1071
- $size_set = implode(',', $set_items);
1072
- }
1073
- }
1074
 
1075
- $providers_share = array_keys(synved_social_service_provider_list('share'));
1076
- $providers_follow = array_keys(synved_social_service_provider_list('follow'));
1077
 
1078
- $providers_params = array(
1079
- 'show' => __('Specify a comma-separated list of %1$s providers to show and their order, possible values are %2$s', 'social-media-feather'),
1080
- 'hide' => __('Specify a comma-separated list of %1$s providers to hide, possible values are %2$s', 'social-media-feather'),
1081
- );
1082
-
1083
- $common_params = array(
1084
- 'skin' => __('Specify which skin to use for the icons', 'social-media-feather'),
1085
- 'size' => sprintf(__('Specify the size for the icons, possible values are %s', 'social-media-feather'), $size_set),
1086
- 'spacing' => __('Determines how much blank space there will be between the buttons, in pixels', 'social-media-feather'),
1087
- 'container' => __('Determines whether to wrap the buttons in a container', 'social-media-feather'),
1088
- 'container_type' => sprintf(__('Determines what type of container to use, possible values are %1$s', 'social-media-feather'), 'basic, block'),
1089
- 'class' => __('Select additional CSS classes for the buttons, separated by spaces', 'social-media-feather'),
1090
- );
1091
-
1092
- $share_params = array(
1093
- 'url' => __('URL to use for the sharing buttons, default is the current post URL', 'social-media-feather'),
1094
- 'title' => __('Title to use for the sharing buttons, default is the current post title', 'social-media-feather'),
1095
- 'message' => __('Message to use when sharing content, replaced into the %%message%% variable', 'social-media-feather'),
1096
- );
1097
-
1098
- $follow_params = array(
1099
- );
1100
 
1101
- $share_params = array_merge($common_params, $share_params);
1102
- $follow_params = array_merge($common_params, $follow_params);
 
1103
 
1104
- foreach ($providers_params as $param_name => $param_value)
1105
- {
1106
- $share_params[$param_name] = sprintf($param_value, 'share', implode(', ', $providers_share));
1107
- $follow_params[$param_name] = sprintf($param_value, 'follow', implode(', ', $providers_follow));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1108
  }
1109
 
1110
- synved_shortcode_item_help_set('feather_share', array(
1111
- 'tip' => __('Creates a list of buttons for social sharing as selected in the Social Media options', 'social-media-feather'),
1112
- 'parameters' => $share_params
1113
- ));
1114
- synved_shortcode_item_help_set('feather_follow', array(
1115
- 'tip' => __('Creates a list of buttons for social following as selected in the Social Media options', 'social-media-feather'),
1116
- 'parameters' => $follow_params
1117
- ));
 
 
 
 
 
 
 
1118
  }
1119
- else
1120
- {
1121
- add_shortcode('feather_share', 'synved_social_share_shortcode');
1122
- add_shortcode('synved_feather_share', 'synved_social_share_shortcode');
1123
- add_shortcode('feather_follow', 'synved_social_follow_shortcode');
1124
- add_shortcode('synved_feather_follow', 'synved_social_follow_shortcode');
1125
- }
1126
-
1127
- //add_action('wp_ajax_synved_social', 'synved_social_ajax_callback');
1128
- //add_action('wp_ajax_nopriv_synved_social', 'synved_social_ajax_callback');
1129
 
1130
- if (!is_admin())
1131
- {
1132
- add_action('wp_enqueue_scripts', 'synved_social_enqueue_scripts');
1133
- add_action('wp_head', 'synved_social_print_styles');
1134
  }
1135
 
1136
- if (synved_option_get('synved_social', 'automatic_share') || synved_option_get('synved_social', 'automatic_follow'))
1137
- {
1138
- add_filter('the_content', 'synved_social_wp_the_content', 10, 2);
1139
  }
1140
 
1141
- if (is_admin())
1142
- {
1143
- if (current_user_can('manage_options'))
1144
- {
1145
- if (isset($_GET['accept-terms'])) {
1146
- synved_option_set( 'synved_social', 'accepted_sharethis_terms',
1147
- ($_GET['accept-terms'] == "yes" ? true : false) );
1148
- wp_redirect(admin_url('options-general.php?page=synved_social_settings'));
1149
  }
1150
  }
1151
 
 
 
1152
  $canShowShareThisAlert = ! synved_option_get( 'synved_social',
1153
  'accepted_sharethis_terms' ) &&
1154
  ! synved_option_get( 'synved_social', 'hide_sharethis_terms' ) &&
1155
- ! preg_match( '/page=synved_social_settings/i', $_SERVER['REQUEST_URI'] );
1156
- if ( $canShowShareThisAlert )
1157
- {
1158
- add_action('admin_notices', 'synved_social_sharethis_terms_notice_callback_admin_notice_wrapper');
1159
- add_action('wp_ajax_feather_hide_terms', 'synved_social_admin_hide_callback');
1160
  }
1161
  }
1162
  }
1163
 
1164
- add_action('init', 'synved_social_init');
1165
- add_action('admin_enqueue_scripts', 'synved_social_admin_enqueue_scripts');
1166
- add_action('admin_print_styles', 'synved_social_admin_print_styles', 1);
1167
 
1168
- add_action('widgets_init', 'synved_social_register_widgets');
 
 
 
 
1
  <?php
2
 
3
+ function synved_social_provider_settings() {
4
+ $share_providers = synved_social_service_provider_list( 'share', true );
5
+ $follow_providers = synved_social_service_provider_list( 'follow', true );
6
+ $provider_list = array_merge( $share_providers, $follow_providers );
7
+ $providers_settings = [];
8
+
9
+ foreach ( $provider_list as $provider_name => $provider_item ) {
10
+ $provider_label = ucwords( str_replace( [ '-', '_' ], ' ', $provider_name ) );
11
+ $display_set = 'none=None';
 
 
12
  $display_default = 'none';
13
 
14
+ if ( true === isset( $provider_item['label'] ) ) {
 
15
  $provider_label = $provider_item['label'];
16
  }
17
 
18
+ if ( true === isset( $share_providers[ $provider_name ] ) ) {
 
19
  $display_set .= ',share=Share';
20
 
21
+ if ( false === isset( $share_providers[ $provider_name ]['default-display'] ) || $share_providers[ $provider_name ]['default-display'] ) {
 
22
  $display_default = 'share';
23
  }
24
  }
25
 
26
+ if ( true === isset( $follow_providers[ $provider_name ] ) ) {
 
27
  $display_set .= ',follow=Follow';
28
 
29
+ if ( true === isset( $share_providers[ $provider_name ] ) ) {
 
30
  $display_set .= ',both=Share & Follow';
31
  }
32
 
33
+ if ( false === isset( $follow_providers[ $provider_name ]['default-display'] ) || $follow_providers[ $provider_name ]['default-display'] ) {
34
+ if ( 'share' === $display_default ) {
 
 
35
  $display_default = 'both';
36
+ } else {
 
 
37
  $display_default = 'follow';
38
  }
39
  }
40
  }
41
 
42
+ $providers_settings = array_merge( $providers_settings,
43
+ [
44
+ $provider_name . '_display' => [
45
  'default' => $display_default,
46
+ 'style' => 'group',
47
+ 'set' => $display_set,
48
+ 'label' => __( $provider_label . ' Service', 'social-media-feather' ),
49
+ 'tip' => __( 'Decides for what types of services ' . $provider_label . ' will be used by default',
50
+ 'social-media-feather' ),
51
+ ],
52
+ ]
53
  );
54
 
55
+ if ( true === isset( $share_providers[ $provider_name ] ) ) {
56
+ $share_item = $share_providers[ $provider_name ];
57
+
58
+ $providers_settings = array_merge( $providers_settings,
59
+ [
60
+ $provider_name . '_share_link' => [
61
+ 'label' => __( $provider_label . ' Share Link', 'social-media-feather' ),
62
+ 'tip' => __( 'The link used by default for sharing content on ' . $provider_label . '. <b>Note: this generally doesn\'t need to be changed, only change it if you know what you\'re doing.</b>',
63
+ 'social-media-feather' ),
64
+ 'hint' => $share_item['link'],
65
+ ],
66
+ $provider_name . '_share_title' => [
67
+ 'label' => __( $provider_label . ' Share Title', 'social-media-feather' ),
68
+ 'tip' => __( 'The title used by default for the ' . $provider_label . ' share button (a standard one will be used if left empty)',
69
+ 'social-media-feather' ),
70
+ 'hint' => $share_item['title'],
71
+ ],
72
+ ]
73
  );
74
  }
75
 
76
+ if ( true === isset( $follow_providers[ $provider_name ] ) ) {
77
+ $follow_item = $follow_providers[ $provider_name ];
78
+
79
+ $providers_settings = array_merge( $providers_settings,
80
+ [
81
+ $provider_name . '_follow_link' => [
82
+ 'label' => __( $provider_label . ' Follow Link', 'social-media-feather' ),
83
+ 'tip' => __( 'The link used by default for following you on ' . $provider_label . '. Change this to point to your own social profile page on ' . $provider_label . '.',
84
+ 'social-media-feather' ),
85
+ 'hint' => $follow_item['link'],
86
+ ],
87
+ $provider_name . '_follow_title' => [
88
+ 'label' => __( $provider_label . ' Follow Title', 'social-media-feather' ),
89
+ 'tip' => __( 'The title used by default for the ' . $provider_label . ' follow button (a standard one will be used if left empty)',
90
+ 'social-media-feather' ),
91
+ 'hint' => $follow_item['title'],
92
+ ],
93
+ ]
94
  );
95
  }
96
  }
98
  return $providers_settings;
99
  }
100
 
101
+ $terms_accepted = synved_option_get( 'synved_social', 'accepted_sharethis_terms' );
102
+
103
+ $synved_social_options = [
104
+ 'settings' => [
105
+ 'label' => 'Social Media',
106
+ 'title' => 'Social Media Feather',
107
+ 'tip' => synved_option_callback( 'synved_social_page_settings_tip' ),
108
+ 'link-target' => plugin_basename( synved_plugout_module_path_get( 'synved-social', 'provider' ) ),
109
+ 'render-fragment' => 'synved_social_page_render_fragment',
110
+ 'sections' => [
111
+ 'section_general' => [
112
+ 'label' => __( 'General Settings', 'social-media-feather' ),
113
+ 'tip' => __( 'Settings affecting the general behaviour of the plugin', 'social-media-feather' ),
114
+ 'settings' => [
115
+ 'use_shortlinks' => [
116
+ 'default' => false,
117
+ 'label' => __( 'Use Shortlinks', 'social-media-feather' ),
118
+ 'tip' => __( 'Allows for shortened URLs to be used when sharing content if a shortening plugin is installed',
119
+ 'social-media-feather' ),
120
+ ],
121
+ 'share_full_url' => [
122
+ 'default' => false,
123
+ 'label' => __( 'Share Full URL', 'social-media-feather' ),
124
+ 'tip' => __( 'Determines whether to always share the full URL or just the post permalink. You can override this for individual posts by setting the "synved_social_share_full_url" custom field to either "yes" or "no", case sensitive',
125
+ 'social-media-feather' ),
126
+ ],
127
+ 'layout_rtl' => [
128
+ 'default' => false,
129
+ 'label' => __( 'Right To Left Layout', 'social-media-feather' ),
130
+ 'tip' => __( 'Check this option if you have a right-to-left site layout and icons show spacing issues',
131
+ 'social-media-feather' ),
132
+ ],
133
+ 'shortcode_widgets' => [
134
+ 'default' => true,
135
+ 'label' => __( 'Shortcodes In Widgets', 'social-media-feather' ),
136
+ 'tip' => __( 'Allow shortcodes in Text widgets', 'social-media-feather' ),
137
+ ],
138
+ 'show_credit' => [
139
+ 'default' => false,
140
+ 'label' => __( 'Show Credit', 'social-media-feather' ),
141
+ 'tip' => __( 'Display a small icon with a link to the Social Media Feather page',
142
+ 'social-media-feather' ),
143
+ ],
144
+ 'share_message_default' => [
145
+ 'default' => __( 'Hey check this out', 'social-media-feather' ),
146
+ 'label' => __( 'Default Message', 'social-media-feather' ),
147
+ 'tip' => __( 'Specify the default message to use when sharing content, this is what gets replaced into the %%message%% variable',
148
+ 'social-media-feather' ),
149
+ ],
150
+ 'hide_sharethis_terms' => [
151
+ 'default' => false,
152
+ 'label' => __( 'Hide Extra Features Prompt', 'social-media-feather' ),
153
+ 'tip' => __( 'Don\'t prompt for extra features.', 'social-media-feather' ),
154
+ 'hidden' => true,
155
+ ],
156
+ 'fb_app_id' => [
157
+ 'default' => '',
158
+ 'label' => __( 'Facebook App ID', 'social-media-feather' ),
159
+ ],
160
+ 'accepted_sharethis_terms' => [
161
+ 'type' => 'custom',
162
+ 'label' => __( 'Terms of Service', 'social-media-feather' ),
163
+ 'tip' => __( 'Accept or decline <a target="_blank" href="https://www.sharethis.com/terms/">ShareThis Terms of Service</a> and <a target="_blank" href="https://www.sharethis.com/privacy/">Privacy Notice</a>',
164
+ 'social-media-feather' ),
165
+ 'render' => 'synved_social_accept_terms_switch',
166
+ ],
167
+ ],
168
+ ],
169
+
170
+ 'section_automatic_display' => [
171
+ 'label' => __( 'Automatic Display', 'social-media-feather' ),
172
+ 'tip' => __( 'Settings affecting automating appending of social buttons to post contents',
173
+ 'social-media-feather' ),
174
+ 'settings' => [
175
+ 'automatic_share' => [
176
+ 'default' => false,
177
+ 'label' => __( 'Display Sharing Buttons', 'social-media-feather' ),
178
+ 'tip' => __( 'Tries to automatically append sharing buttons to your posts (disable for specific posts by setting custom field synved_social_exclude or synved_social_exclude_share to "yes", case sensitive)',
179
+ 'social-media-feather' ),
180
+ ],
181
+ 'automatic_share_position' => [
182
+ 'default' => 'after_post',
183
+ 'set' => 'after_post=After Post,before_post=Before Post,after_before_post=After and Before Post',
184
+ 'label' => __( 'Share Buttons Position', 'social-media-feather' ),
185
+ 'tip' => __( 'Select where the sharing buttons should be placed. Note: placing buttons Before Post might not work in all themes.',
186
+ 'social-media-feather' ),
187
+ ],
188
+ 'automatic_share_single' => [
189
+ 'default' => false,
190
+ 'label' => __( 'Sharing Single Posts', 'social-media-feather' ),
191
+ 'tip' => __( 'Sharing buttons are only displayed on single posts/pages and not on archive pages like blog/category/tag/author pages',
192
+ 'social-media-feather' ),
193
+ ],
194
+ 'automatic_share_post_types' => [
195
+ 'type' => 'custom',
196
+ 'default' => 'post',
197
+ 'set' => synved_option_callback( 'synved_social_automatic_append_post_types_set',
198
+ [ 'post', 'page' ] ),
199
+ 'label' => __( 'Share Post Types', 'social-media-feather' ),
200
+ 'tip' => __( 'Post types for which automatic appending for share buttons should be attempted (CTRL + click to select multiple ones)',
201
+ 'social-media-feather' ),
202
+ 'render' => 'synved_social_automatic_append_post_types_render',
203
+ ],
204
+ 'automatic_share_prefix' => [
205
+ 'default' => '',
206
+ 'label' => __( 'Share Prefix Markup', 'social-media-feather' ),
207
+ 'tip' => __( 'When automatically appending, place this markup before the share buttons markup',
208
+ 'social-media-feather' ),
209
+ ],
210
+ 'automatic_share_postfix' => [
211
+ 'default' => '',
212
+ 'label' => __( 'Share Postfix Markup', 'social-media-feather' ),
213
+ 'tip' => __( 'When automatically appending, place this markup after all of the share buttons markup',
214
+ 'social-media-feather' ),
215
+ ],
216
+ 'automatic_follow' => [
217
+ 'default' => false,
218
+ 'label' => __( 'Display Follow Buttons', 'social-media-feather' ),
219
+ 'tip' => __( 'Tries to automatically append follow buttons to your posts (disable for specific posts by setting custom field synved_social_exclude or synved_social_exclude_follow to "yes", case sensitive)',
220
+ 'social-media-feather' ),
221
+ ],
222
+ 'automatic_follow_position' => [
223
+ 'default' => 'after_post',
224
+ 'set' => 'after_post=After Post,before_post=Before Post,after_before_post=After and Before Post',
225
+ 'label' => __( 'Follow Buttons Position', 'social-media-feather' ),
226
+ 'tip' => __( 'Select where the follow buttons should be placed. Note: placing buttons Before Post might not work in all themes.',
227
+ 'social-media-feather' ),
228
+ ],
229
+ 'automatic_follow_single' => [
230
+ 'default' => false,
231
+ 'label' => __( 'Follow Single Posts', 'social-media-feather' ),
232
+ 'tip' => __( 'Follow buttons are only displayed on single posts/pages and not on archive pages like blog/category/tag/author pages',
233
+ 'social-media-feather' ),
234
+ ],
235
+ 'automatic_follow_post_types' => [
236
+ 'type' => 'custom',
237
+ 'default' => 'post',
238
+ 'set' => synved_option_callback( 'synved_social_automatic_append_post_types_set',
239
+ [ 'post', 'page' ] ),
240
+ 'label' => __( 'Follow Post Types', 'social-media-feather' ),
241
+ 'tip' => __( 'Post types for which automatic appending for follow buttons should be attempted (CTRL + click to select multiple ones)',
242
+ 'social-media-feather' ),
243
+ 'render' => 'synved_social_automatic_append_post_types_render',
244
+ ],
245
+ 'automatic_follow_before_share' => [
246
+ 'default' => false,
247
+ 'label' => __( 'Follow Before Share', 'social-media-feather' ),
248
+ 'tip' => __( 'When automatically appending, place follow buttons before share buttons. Only valid when share and follow buttons positions are the same.',
249
+ 'social-media-feather' ),
250
+ ],
251
+ 'automatic_follow_prefix' => [
252
+ 'default' => '',
253
+ 'label' => __( 'Follow Prefix Markup', 'social-media-feather' ),
254
+ 'tip' => __( 'When automatically appending, place this markup before the follow buttons markup',
255
+ 'social-media-feather' ),
256
+ ],
257
+ 'automatic_follow_postfix' => [
258
+ 'default' => '',
259
+ 'label' => __( 'Follow Postfix Markup', 'social-media-feather' ),
260
+ 'tip' => __( 'When automatically appending, place this markup after all of the follow buttons markup',
261
+ 'social-media-feather' ),
262
+ ],
263
+ 'automatic_append_prefix' => [
264
+ 'default' => '',
265
+ 'label' => __( 'Prefix Markup', 'social-media-feather' ),
266
+ 'tip' => __( 'When automatically appending, place this markup before the buttons markup',
267
+ 'social-media-feather' ),
268
+ ],
269
+ 'automatic_append_separator' => [
270
+ 'default' => '<br/>',
271
+ 'label' => __( 'Separator Markup', 'social-media-feather' ),
272
+ 'tip' => __( 'When automatically appending both, use this markup as separator between the set of share buttons and the set of follow buttons. Only valid when share and follow buttons positions are the same.',
273
+ 'social-media-feather' ),
274
+ ],
275
+ 'automatic_append_postfix' => [
276
+ 'default' => '',
277
+ 'label' => __( 'Postfix Markup', 'social-media-feather' ),
278
+ 'tip' => __( 'When automatically appending, place this markup after all of the buttons markup',
279
+ 'social-media-feather' ),
280
+ ],
281
+ ],
282
+ ],
283
+ 'section_customize_look' => [
284
+ 'label' => __( 'Customize Look', 'social-media-feather' ),
285
+ 'tip' => synved_option_callback( 'synved_social_section_customize_look_tip',
286
+ __( 'Customize the look & feel of Social Media Feather', 'social-media-feather' ) ),
287
+ 'settings' => [
288
+ 'icon_skin' => [
289
+ 'default' => 'regular',
290
+ 'set' => synved_option_callback( 'synved_social_cb_icon_skin_set', 'regular=Regular' ),
291
+ 'label' => __( 'Icon Skin', 'social-media-feather' ),
292
+ 'tip' => '',
293
+ 'render' => 'synved_social_icon_skin_render',
294
+ ],
295
+ 'icon_size' => [
296
+ 'default' => 48,
297
+ 'set' => '16=16x16,24=24x24,32=32x32,48=48x48,64=64x64,96=96x96',
298
+ 'label' => __( 'Icon Size', 'social-media-feather' ),
299
+ 'tip' => __( 'Select the size in pixels for the icons. Note: for high resolution displays like Retina the maximum size is 64x64.',
300
+ 'social-media-feather' ),
301
+ ],
302
+ 'icon_resolution' => [
303
+ 'default' => 'single',
304
+ 'set' => 'single=Single,double=Double',
305
+ 'label' => __( 'Icon Resolution', 'social-media-feather' ),
306
+ 'tip' => __( 'Select what icon resolutions will be used. Single might make the icons slightly blurry on low resolution displays. Double will always look the best but will consume more bandwidth.',
307
+ 'social-media-feather' ),
308
+ ],
309
+ 'icon_spacing' => [
310
+ 'default' => 5,
311
+ 'label' => __( 'Icon Spacing', 'social-media-feather' ),
312
+ 'tip' => __( 'Select the spacing in pixels between the icons', 'social-media-feather' ),
313
+ ],
314
+ 'buttons_container' => [
315
+ 'default' => 'none',
316
+ 'set' => 'none=None,share=Sharing Buttons,follow=Following Buttons,both=Both',
317
+ 'label' => __( 'Buttons in Container', 'social-media-feather' ),
318
+ 'tip' => __( 'Determines whether or not to wrap the buttons in a container, which will affect how the buttons are rendered, based on the "Buttons Container Type" setting.',
319
+ 'social-media-feather' ),
320
+ ],
321
+ 'buttons_container_type' => [
322
+ 'default' => 'basic',
323
+ 'set' => 'basic=Basic,block=Block',
324
+ 'label' => __( 'Buttons Container Type', 'social-media-feather' ),
325
+ 'tip' => __( '"Basic" should not affect rendering, while "Block" should display the buttons in their own row. <b>Note</b>: selecting "Block" might not look the way you want if you\'re using Prefix or Postfix markup.',
326
+ 'social-media-feather' ),
327
+ ],
328
+ 'buttons_alignment_share' => [
329
+ 'default' => 'none',
330
+ 'set' => 'none=Theme Default,left=Align Left,right=Align Right,center=Align Center',
331
+ 'label' => __( 'Share Buttons Alignment', 'social-media-feather' ),
332
+ 'tip' => __( 'Will attempt at aligning the share buttons accordingly. <strong>Note:</strong> this will enforce "Buttons Container Type" of "Block" and might not work reliably on all themes',
333
+ 'social-media-feather' ),
334
+ ],
335
+ 'buttons_alignment_follow' => [
336
+ 'default' => 'none',
337
+ 'set' => 'none=Theme Default,left=Align Left,right=Align Right,center=Align Center',
338
+ 'label' => __( 'Follow Buttons Alignment', 'social-media-feather' ),
339
+ 'tip' => __( 'Will attempt at aligning the follow buttons accordingly. <strong>Note:</strong> this will enforce "Buttons Container Type" of "Block" and might not work reliably on all themes',
340
+ 'social-media-feather' ),
341
+ ],
342
+ 'custom_style' => [
343
+ 'type' => 'style',
344
+ 'label' => __( 'Extra Styles', 'social-media-feather' ),
345
+ 'tip' => __( 'Any CSS styling code you type in here will be loaded after all of the Social Media Feather styles.',
346
+ 'social-media-feather' ),
347
+ ],
348
+ ],
349
+ ],
350
+ 'section_service_providers' => [
351
+ 'label' => __( 'Service Providers', 'social-media-feather' ),
352
+ 'tip' => __( 'Customize social sharing and following providers', 'social-media-feather' ),
353
+ 'settings' => synved_social_provider_settings(),
354
+ ],
355
+ ],
356
+ ],
357
+ ];
358
+
359
+ synved_option_register( 'synved_social', $synved_social_options );
360
+
361
+ synved_option_include_module_addon_list( 'synved-social' );
362
 
363
  function synved_social_accept_terms_switch() {
364
 
365
  $out = '<label class="synved-switch">
366
  <input id="synved-disable" name="synved_social_settings[accepted_sharethis_terms]"
367
+ type="checkbox" value="' . ( synved_social_are_terms_accepted() ? 1 : 0 ) . '">
368
  <div id="synved-slider" class="synved-slider round"></div>
369
  </label>';
370
 
371
+ return $out;
 
 
 
 
 
 
 
 
 
 
372
  }
373
 
374
+ /**
375
+ * Synved Social Page Settings tip.
376
+ *
377
+ * @param $tip
378
+ * @param $item
379
+ *
380
+ * @return string
381
+ */
382
+ function synved_social_page_settings_tip( $tip, $item ) {
383
  $tip = '';
384
 
385
+ $request_uri = filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING );
386
 
387
+ if ( preg_match( '/page=synved_social_settings/i', $request_uri ) ) {
388
+ $accept_terms = filter_input( INPUT_GET, 'accept-terms', FILTER_SANITIZE_STRING );
389
+
390
+ // If terms have just been accepted.
391
+ if ( 'yes' === $accept_terms ) {
392
+ $tip .= '<div class="alert alert-success text-center"><p>Thank you, the update has been enabled!</p></div>';
393
+ } elseif ( false === synved_option_get( 'synved_social', 'accepted_sharethis_terms', false ) ) {
 
394
  $tip .= synved_social_sharethis_terms_notice( false, false );
395
  }
396
 
397
+ if ( true === function_exists( 'synved_connect_support_social_follow_render' ) ) {
 
 
 
 
 
398
  $tip .= synved_connect_support_social_follow_render();
399
  }
400
  }
401
+
402
  return $tip;
403
  }
404
 
405
+ function synved_social_page_render_fragment( $fragment, $out, $params ) {
406
+ if ( $fragment == 'page-submit-tail' ) {
 
 
407
  $out .= '<div style="clear:both; margin-top: -12px;"><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/social-media-feather?rate=5#postform" style="font-size:120%"><b>We need your help!</b> If you like the plugin, you can help us by leaving a 5-stars review! It only takes a minute and it\'s free!</a></div>';
408
+ $out .= '<p>By using this plugin you are agreeing to the <a href="https://sharethis.com/terms/" target="_blank">Terms of service</a> and <a href="https://sharethis.com/privacy/" target="_blank">Privacy Policy</a>.</p>';
409
  }
410
 
411
  return $out;
412
  }
413
 
414
+ function synved_social_section_customize_look_tip( $tip, $item ) {
 
415
  return $tip;
416
  }
417
 
418
+ function synved_social_cb_icon_skin_set( $set, $item ) {
419
+ if ( $set != null && ! is_array( $set ) ) {
420
+ $set = synved_option_item_set_parse( $item, $set );
 
 
421
  }
422
 
423
+ $set = [];
424
  $icons = synved_social_icon_skin_list();
425
 
426
+ foreach ( $icons as $icon_name => $icon_meta ) {
427
+ $set[][ $icon_name ] = $icon_meta['label'];
 
428
  }
429
 
430
  return $set;
431
  }
432
 
433
+ function synved_social_icon_skin_render( $value, $params, $id, $name, $item ) {
434
+ $uri = synved_social_path_uri();
 
 
 
 
 
 
 
 
 
 
 
 
 
435
  $icons = synved_social_icon_skin_list();
436
 
437
+ $out = null;
438
  $out_name = $params['output_name'];
439
+ $set = $params['set'];
440
 
441
  $out .= '<div>';
442
 
443
  $sharethis_terms_agree = synved_option_get( 'synved_social', 'accepted_sharethis_terms' );
444
 
445
+ foreach ( $set as $set_it ) {
446
+ $set_it_keys = array_keys( $set_it );
447
+ $selected = $set_it_keys[0] == $value ? ' checked="checked"' : null;
448
+ $img_src = '';
 
449
 
450
+ if ( isset( $icons[ $set_it_keys[0] ] ) ) {
451
+ $img_src = $icons[ $set_it_keys[0] ]['image'];
 
452
  }
453
 
454
  $disabled = disabled( ! $sharethis_terms_agree && ! empty( $icons[ $set_it_keys[0] ]['extra'] ), true, false );
455
 
456
+ $out .= '<div style="text-align:center; width:260px; float:left; margin-right:20px; margin-bottom: 15px;"><label title="Use skin=&quot;' . esc_attr( $set_it_keys[0] ) . '&quot; in shortcodes"><img src="' . esc_url( $img_src ) . '" style="border:solid 1px #bbb" /><p><input type="radio" name="' . esc_attr( $out_name ) . '" value="' . esc_attr( $set_it_keys[0] ) . '"' . $selected . ' ' . $disabled . '/> ' . $set_it[ $set_it_keys[0] ] . '</p></label></div>';
457
  }
458
 
459
  $out .= '</div>';
462
  }
463
 
464
 
465
+ function synved_social_automatic_append_post_types_set( $set, $item ) {
466
+ if ( $set != null && ! is_array( $set ) ) {
467
+ $set = synved_option_item_set_parse( $item, $set );
 
 
468
  }
469
 
470
+ $set = [];
471
+ $types = get_post_types( [ 'public' => true ] );
472
 
473
+ foreach ( $types as $type_name ) {
474
+ $set[][ $type_name ] = $type_name;
 
475
  }
476
 
477
  return $set;
478
  }
479
 
480
+ function synved_social_automatic_append_post_types_render( $value, $params, $id, $name, $item ) {
481
+ $uri = synved_social_path_uri();
 
482
  $icons = synved_social_icon_skin_list();
483
 
484
+ if ( ! is_array( $value ) ) {
485
+ if ( $value != null ) {
486
+ $value = [ $value ];
487
+ } else {
488
+ $value = [];
 
 
 
 
489
  }
490
  }
491
 
492
+ $out = null;
493
  $out_name = $params['output_name'];
494
+ $set = $params['set'];
495
 
496
+ $out .= '<select multiple="multiple" name="' . esc_attr( $out_name . '[]' ) . '">';
497
 
498
+ foreach ( $set as $set_it ) {
499
+ $set_it_keys = array_keys( $set_it );
500
+ $selected = in_array( $set_it_keys[0], $value ) ? ' selected="selected"' : null;
 
501
 
502
+ $out .= '<option value="' . esc_attr( $set_it_keys[0] ) . '"' . $selected . '>' . $set_it[ $set_it_keys[0] ] . '</option>';
503
  }
504
 
505
  $out .= '</select>';
507
  return $out;
508
  }
509
 
510
+ function synved_social_path( $path = null ) {
511
+ $root = dirname( __FILE__ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
 
513
+ if ( $root != null ) {
514
+ if ( substr( $root, - 1 ) != '/' && isset( $path ) && $path[0] != '/' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
  $root .= '/';
516
  }
517
 
518
  $root .= $path;
519
  }
520
 
521
+ $root = str_replace( [ '\\', '/' ], DIRECTORY_SEPARATOR, $root );
522
 
523
  return $root;
524
  }
525
 
526
+ function synved_social_path_uri( $path = null ) {
527
+ $uri = plugins_url( '/social-media-feather' ) . '/synved-social';
 
528
 
529
+ if ( function_exists( 'synved_plugout_module_uri_get' ) ) {
530
+ $mod_uri = synved_plugout_module_uri_get( 'synved-social' );
 
531
 
532
+ if ( $mod_uri != null ) {
 
533
  $uri = $mod_uri;
534
  }
535
  }
536
 
537
+ if ( $path != null ) {
538
+ if ( substr( $uri, - 1 ) != '/' && $path[0] != '/' ) {
 
 
539
  $uri .= '/';
540
  }
541
 
545
  return $uri;
546
  }
547
 
548
+ function synved_social_wp_script_loader_tag( $tag, $handle ) {
549
+ if ( 'feather-sharethis' === $handle ) {
 
 
 
 
 
 
 
 
 
550
  return str_replace( '<script', '<script id=\'st_insights_js\'', $tag );
551
  }
552
 
553
  return $tag;
554
  }
555
 
556
+ function synved_social_enqueue_scripts() {
557
+ if ( true === synved_social_are_terms_accepted() ) {
558
+ if ( true === is_ssl() ) {
559
+ $st_insights = 'https://ws.sharethis.com/button/st_insights.js';
560
+ } else {
561
+ $st_insights = 'http://w.sharethis.com/button/st_insights.js';
562
+ }
 
 
 
 
 
 
 
 
 
563
 
564
  $url = add_query_arg(
565
+ [
566
  'publisher' => 'eba0f3ba-f9ab-408c-bc68-c28af5afe749',
567
  'product' => 'feather',
568
+ ], $st_insights );
569
 
570
+ wp_enqueue_script( 'feather-sharethis', $url, null, null );
571
 
572
+ add_filter( 'script_loader_tag', 'synved_social_wp_script_loader_tag', 10, 2 );
573
  }
574
  }
575
 
576
  /**
577
+ * Are terms accepted?
578
+ *
579
  * @return bool
580
  */
581
  function synved_social_are_terms_accepted() {
582
+ return synved_option_get( 'synved_social', 'accepted_sharethis_terms', false );
583
  }
584
 
585
+ /**
586
+ * Print Styles.
587
+ *
588
+ * @return void
589
+ */
590
+ function synved_social_print_styles() {
591
+ ob_start();
592
 
593
+ echo <<<HEAD_STYLE
594
+ <style>
595
  .synved-social-resolution-single {
596
  display: inline-block;
597
  }
615
  display: inline-block;
616
  }
617
  }
618
+ </style>
619
+ HEAD_STYLE;
 
 
 
 
 
 
620
 
621
+ $styles = ob_get_clean();
 
622
 
623
+ echo wp_kses( $styles, [
624
+ 'style' => [],
625
+ ] );
626
  }
627
 
628
+ /**
629
+ * Admin enqueue scripts for Social.
630
+ *
631
+ * @return void
632
+ */
633
+ function synved_social_admin_enqueue_scripts() {
634
+ $uri = synved_social_path_uri();
635
+ $dir = plugin_dir_path( __FILE__ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
 
637
+ wp_enqueue_script(
638
+ 'synved-option-script-custom',
639
+ $uri . '/script/custom.js',
640
+ [
641
+ 'jquery',
642
+ ],
643
+ filemtime( $dir . '/script/custom.js' )
644
+ );
645
  }
646
 
647
+ function synved_social_register_widgets() {
648
+ register_widget( 'SynvedSocialShareWidget' );
649
+ register_widget( 'SynvedSocialFollowWidget' );
 
650
  }
651
 
652
+ function synved_social_wp_the_content( $content, $id = null ) {
653
+ $exclude = false;
654
+ $exclude_share = false;
 
655
  $exclude_follow = false;
656
 
657
+ $extra_after = null;
658
+ $extra_before = null;
659
+ $separator_after = null;
660
  $separator_before = null;
661
 
662
+ if ( $id == null ) {
 
663
  $id = get_the_ID();
664
 
665
+ if ( $id == null ) {
 
666
  global $post;
667
 
668
  $id = $post->ID;
669
  }
670
  }
671
 
672
+ if ( $id != null ) {
673
+ $exclude = get_post_meta( $id, 'synved_social_exclude', true ) == 'yes' ? true : false;
674
+ $exclude_share = get_post_meta( $id, 'synved_social_exclude_share', true ) == 'yes' ? true : false;
675
+ $exclude_follow = get_post_meta( $id, 'synved_social_exclude_follow', true ) == 'yes' ? true : false;
 
676
 
677
+ if ( ! $exclude_share && synved_option_get( 'synved_social', 'automatic_share_single' ) ) {
678
+ $exclude_share = ! ( is_singular( synved_option_get( 'synved_social',
679
+ 'automatic_share_post_types' ) ) && ( is_single( $id ) || is_page( $id ) ) );
680
  }
681
 
682
+ if ( ! $exclude_follow && synved_option_get( 'synved_social', 'automatic_follow_single' ) ) {
683
+ $exclude_follow = ! ( is_singular( synved_option_get( 'synved_social',
684
+ 'automatic_follow_post_types' ) ) && ( is_single( $id ) || is_page( $id ) ) );
685
  }
686
  }
687
 
688
+ if ( $exclude == false ) {
689
+ if ( $exclude_share == false && synved_option_get( 'synved_social', 'automatic_share' ) ) {
 
 
690
  $post_type = get_post_type();
691
+ $type_list = synved_option_get( 'synved_social', 'automatic_share_post_types' );
692
+
693
+ if ( true === is_string( $type_list ) ) {
694
+ $type_list = [ $type_list ];
695
+ }
696
+
697
+ if ( in_array( $post_type, $type_list ) ) {
698
+ $position = synved_option_get( 'synved_social', 'automatic_share_position' );
699
+ $position_before = in_array( $position, [ 'before_post', 'after_before_post' ] );
700
+ $position_after = in_array( $position, [ 'after_post', 'after_before_post' ] );
701
+ $prefix = synved_option_get( 'synved_social', 'automatic_share_prefix' );
702
+ $postfix = synved_option_get( 'synved_social', 'automatic_share_postfix' );
703
+
704
+ if ( $position_after ) {
705
  $markup = synved_social_share_markup();
706
 
707
+ if ( trim( $markup ) != null ) {
 
708
  $markup = $prefix . $markup . $postfix;
709
 
710
  $extra_after .= $markup;
711
  }
712
  }
713
 
714
+ if ( $position_before ) {
 
715
  $markup = synved_social_share_markup();
716
 
717
+ if ( trim( $markup ) != null ) {
 
718
  $markup = $prefix . $markup . $postfix;
719
 
720
  $extra_before .= $markup;
723
  }
724
  }
725
 
726
+ $separator = synved_option_get( 'synved_social', 'automatic_append_separator' );
727
 
728
+ if ( $extra_after != null ) {
 
729
  $separator_after = $separator;
730
  }
731
 
732
+ if ( $extra_before != null ) {
 
733
  $separator_before = $separator;
734
  }
735
 
736
+ if ( $exclude_follow == false && synved_option_get( 'synved_social', 'automatic_follow' ) ) {
 
737
  $post_type = get_post_type();
738
+ $type_list = synved_option_get( 'synved_social', 'automatic_follow_post_types' );
739
+
740
+ if ( in_array( $post_type, $type_list ) ) {
741
+ $position = synved_option_get( 'synved_social', 'automatic_follow_position' );
742
+ $position_before = in_array( $position, [ 'before_post', 'after_before_post' ] );
743
+ $position_after = in_array( $position, [ 'after_post', 'after_before_post' ] );
744
+ $prefix = synved_option_get( 'synved_social', 'automatic_follow_prefix' );
745
+ $postfix = synved_option_get( 'synved_social', 'automatic_follow_postfix' );
746
+
747
+ if ( $position_after ) {
 
 
748
  $markup = synved_social_follow_markup();
749
 
750
+ if ( trim( $markup ) != null ) {
 
751
  $markup = $prefix . $markup . $postfix;
752
 
753
+ if ( synved_option_get( 'synved_social', 'automatic_follow_before_share' ) ) {
 
754
  $extra_after = $markup . $separator_after . $extra_after;
755
+ } else {
 
 
756
  $extra_after .= $separator_after . $markup;
757
  }
758
  }
759
  }
760
 
761
+ if ( $position_before ) {
 
762
  $markup = synved_social_follow_markup();
763
 
764
+ if ( trim( $markup ) != null ) {
 
765
  $markup = $prefix . $markup . $postfix;
766
 
767
+ if ( synved_option_get( 'synved_social', 'automatic_follow_before_share' ) ) {
 
768
  $extra_before = $markup . $separator_before . $extra_before;
769
+ } else {
 
 
770
  $extra_before .= $separator_before . $markup;
771
  }
772
  }
774
  }
775
  }
776
 
777
+ $prefix = synved_option_get( 'synved_social', 'automatic_append_prefix' );
778
+ $postfix = synved_option_get( 'synved_social', 'automatic_append_postfix' );
779
 
780
+ if ( $extra_after != null ) {
 
781
  $content .= $prefix . $extra_after . $postfix;
782
  }
783
 
784
+ if ( $extra_before != null ) {
 
785
  $content = $prefix . $extra_before . $postfix . $content;
786
  }
787
  }
797
  *
798
  * @return string
799
  */
800
+ function synved_social_sharethis_terms_notice( $render_html = true, $isDismissible = true ) {
801
+ $out = '<div id="sharethis_terms_notice" class="notice-warning notice ' . ( ! empty( $isDismissible ) ? 'is-dismissible' : '' ) . '">
 
802
  <p>
803
  To get the most out of Social Media Feather and to help enable its continued development,
804
  please read the <a href="//sharethis.com/terms" target="_blank">ShareThis Terms of Service</a> and <a href="//sharethis.com/privacy" target="_blank">Privacy Notice</a>,
805
+ then <a href="' . admin_url( 'options-general.php?page=synved_social_settings&accept-terms=yes' ) . '">click here to accept the terms</a>.
806
  </p>
807
  </div>
 
 
 
 
 
808
  ';
809
 
810
+ if ( $render_html ) {
811
+ echo $out;
812
+ } else {
813
+ return $out;
814
+ }
815
 
816
  }
817
 
819
  * Wrapper to be able to call this method within parameters by add_action
820
  */
821
  function synved_social_sharethis_terms_notice_callback_admin_notice_wrapper() {
822
+ synved_social_sharethis_terms_notice( true, true );
823
  }
824
 
825
  // Hides the terms agreement at user's request.
826
+ function synved_social_admin_hide_callback() {
827
+ synved_option_set( 'synved_social', 'hide_sharethis_terms', true );
 
828
  }
829
 
830
+ function synved_social_init() {
831
+ $priority = defined( 'SHORTCODE_PRIORITY' ) ? SHORTCODE_PRIORITY : 11;
 
 
 
 
 
 
 
 
 
 
832
 
833
+ if ( synved_option_get( 'synved_social', 'shortcode_widgets' ) ) {
834
+ remove_filter( 'widget_text', 'do_shortcode', $priority );
835
+ add_filter( 'widget_text', 'do_shortcode', $priority );
 
836
  }
837
 
838
+ if ( function_exists( 'synved_shortcode_add' ) ) {
839
+ synved_shortcode_add( 'feather_share', 'synved_social_share_shortcode' );
840
+ synved_shortcode_add( 'feather_follow', 'synved_social_follow_shortcode' );
 
 
 
 
 
 
 
 
 
 
 
 
841
 
842
+ $size_set = '16,24,32,48,64,96';
843
+ $size_item = synved_option_item( 'synved_social', 'icon_size' );
 
844
 
845
+ if ( $size_item != null ) {
846
+ $item_set = synved_option_item_set( $size_item );
847
 
848
+ if ( $item_set != null ) {
849
+ $set_items = [];
 
850
 
851
+ foreach ( $item_set as $set_item ) {
852
+ $item_keys = array_keys( $set_item );
853
 
854
+ $set_items[] = $item_keys[0];
855
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
856
 
857
+ $size_set = implode( ',', $set_items );
858
+ }
859
+ }
860
 
861
+ $providers_share = array_keys( synved_social_service_provider_list( 'share' ) );
862
+ $providers_follow = array_keys( synved_social_service_provider_list( 'follow' ) );
863
+
864
+ $providers_params = [
865
+ 'show' => __( 'Specify a comma-separated list of %1$s providers to show and their order, possible values are %2$s',
866
+ 'social-media-feather' ),
867
+ 'hide' => __( 'Specify a comma-separated list of %1$s providers to hide, possible values are %2$s',
868
+ 'social-media-feather' ),
869
+ ];
870
+
871
+ $common_params = [
872
+ 'skin' => __( 'Specify which skin to use for the icons', 'social-media-feather' ),
873
+ 'size' => sprintf( __( 'Specify the size for the icons, possible values are %s',
874
+ 'social-media-feather' ), $size_set ),
875
+ 'spacing' => __( 'Determines how much blank space there will be between the buttons, in pixels',
876
+ 'social-media-feather' ),
877
+ 'container' => __( 'Determines whether to wrap the buttons in a container', 'social-media-feather' ),
878
+ 'container_type' => sprintf( __( 'Determines what type of container to use, possible values are %1$s',
879
+ 'social-media-feather' ), 'basic, block' ),
880
+ 'class' => __( 'Select additional CSS classes for the buttons, separated by spaces',
881
+ 'social-media-feather' ),
882
+ ];
883
+
884
+ $share_params = [
885
+ 'url' => __( 'URL to use for the sharing buttons, default is the current post URL',
886
+ 'social-media-feather' ),
887
+ 'title' => __( 'Title to use for the sharing buttons, default is the current post title',
888
+ 'social-media-feather' ),
889
+ 'message' => __( 'Message to use when sharing content, replaced into the %%message%% variable',
890
+ 'social-media-feather' ),
891
+ ];
892
+
893
+ $follow_params = [
894
+ ];
895
+
896
+ $share_params = array_merge( $common_params, $share_params );
897
+ $follow_params = array_merge( $common_params, $follow_params );
898
+
899
+ foreach ( $providers_params as $param_name => $param_value ) {
900
+ $share_params[ $param_name ] = sprintf( $param_value, 'share', implode( ', ', $providers_share ) );
901
+ $follow_params[ $param_name ] = sprintf( $param_value, 'follow', implode( ', ', $providers_follow ) );
902
  }
903
 
904
+ synved_shortcode_item_help_set( 'feather_share', [
905
+ 'tip' => __( 'Creates a list of buttons for social sharing as selected in the Social Media options',
906
+ 'social-media-feather' ),
907
+ 'parameters' => $share_params,
908
+ ] );
909
+ synved_shortcode_item_help_set( 'feather_follow', [
910
+ 'tip' => __( 'Creates a list of buttons for social following as selected in the Social Media options',
911
+ 'social-media-feather' ),
912
+ 'parameters' => $follow_params,
913
+ ] );
914
+ } else {
915
+ add_shortcode( 'feather_share', 'synved_social_share_shortcode' );
916
+ add_shortcode( 'synved_feather_share', 'synved_social_share_shortcode' );
917
+ add_shortcode( 'feather_follow', 'synved_social_follow_shortcode' );
918
+ add_shortcode( 'synved_feather_follow', 'synved_social_follow_shortcode' );
919
  }
 
 
 
 
 
 
 
 
 
 
920
 
921
+ if ( ! is_admin() ) {
922
+ add_action( 'wp_enqueue_scripts', 'synved_social_enqueue_scripts' );
923
+ add_action( 'wp_head', 'synved_social_print_styles' );
 
924
  }
925
 
926
+ if ( synved_option_get( 'synved_social', 'automatic_share' ) || synved_option_get( 'synved_social',
927
+ 'automatic_follow' ) ) {
928
+ add_filter( 'the_content', 'synved_social_wp_the_content', 10, 2 );
929
  }
930
 
931
+ if ( is_admin() ) {
932
+ if ( current_user_can( 'manage_options' ) ) {
933
+ $accept_terms = filter_input( INPUT_GET, 'accept-terms', FILTER_SANITIZE_STRING );
934
+
935
+ if ( false === empty( $accept_terms ) ) {
936
+ synved_option_set( 'synved_social', 'accepted_sharethis_terms', ( 'yes' === $accept_terms ) );
937
+ wp_redirect( admin_url( 'options-general.php?page=synved_social_settings' ) );
 
938
  }
939
  }
940
 
941
+ $request_uri = filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING );
942
+
943
  $canShowShareThisAlert = ! synved_option_get( 'synved_social',
944
  'accepted_sharethis_terms' ) &&
945
  ! synved_option_get( 'synved_social', 'hide_sharethis_terms' ) &&
946
+ ! preg_match( '/page=synved_social_settings/i', $request_uri );
947
+ if ( $canShowShareThisAlert ) {
948
+ add_action( 'admin_notices', 'synved_social_sharethis_terms_notice_callback_admin_notice_wrapper' );
949
+ add_action( 'wp_ajax_feather_hide_terms', 'synved_social_admin_hide_callback' );
 
950
  }
951
  }
952
  }
953
 
954
+ add_action( 'init', 'synved_social_init' );
 
 
955
 
956
+ add_action( 'widgets_init', 'synved_social_register_widgets' );
957
+
958
+ if ( is_admin() ) {
959
+ add_action( 'admin_enqueue_scripts', 'synved_social_admin_enqueue_scripts' );
960
+ }
synved-social/synved-social.php CHANGED
@@ -16,321 +16,145 @@ NO LIABILITY
16
  In no event shall Synved Ltd. be liable to you or any third party for any direct or indirect, special, incidental, or consequential damages in connection with or arising from errors, omissions, delays or other cause of action that may be attributed to your use of any product, support, services, information or software provided, including, but not limited to, lost profits or lost data, even if Synved Ltd. had been advised of the possibility of such damages.
17
  */
18
 
19
-
20
- define('SYNVED_SOCIAL_LOADED', true);
21
- define('SYNVED_SOCIAL_VERSION', 100070016);
22
- define('SYNVED_SOCIAL_VERSION_STRING', '1.7.16');
23
-
24
  define('SYNVED_SOCIAL_ADDON_PATH', str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, dirname(__FILE__) . '/addons'));
25
 
26
- include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'synved-social-setup.php');
27
-
28
-
29
- $synved_social = array();
30
-
31
-
32
- function synved_social_version()
33
- {
34
- return SYNVED_SOCIAL_VERSION;
35
- }
36
-
37
- function synved_social_version_string()
38
- {
39
- return SYNVED_SOCIAL_VERSION_STRING;
40
- }
41
-
42
- class SynvedSocialWidget extends WP_Widget
43
- {
44
- function __construct($id_base = false, $name = null, $widget_options = array(), $control_options = array() )
45
- {
46
- if ($name == null)
47
- {
48
- $name = 'Social Media Feather';
49
- }
50
-
51
- parent::__construct($id_base, $name, $widget_options, $control_options);
52
- }
53
-
54
- function widget($args, $instance)
55
- {
56
- extract($args); /* before/after widget, before/after title (defined by themes). */
57
- extract($instance);
58
-
59
- echo $before_widget;
60
-
61
- if ($title != null)
62
- {
63
- echo $before_title . $title . $after_title;
64
- }
65
-
66
- echo '<div>';
67
-
68
- $params = array();
69
- $params['alignment'] = 'none';
70
-
71
- if ($icon_skin != 'default')
72
- {
73
- $params['skin'] = $icon_skin;
74
- }
75
-
76
- if ($icon_size != 'default')
77
- {
78
- $params['size'] = $icon_size;
79
- }
80
-
81
- if ($icon_spacing !== null && $icon_spacing !== '')
82
- {
83
- $params['spacing'] = $icon_spacing;
84
- }
85
-
86
- $this->render_social_markup($params);
87
-
88
- echo '</div>';
89
- echo $after_widget;
90
- }
91
-
92
- function get_defaults()
93
- {
94
- return array('icon_skin' => 'default', 'icon_size' => 'default', 'icon_spacing' => '');
95
- }
96
-
97
- function render_social_markup($params = null)
98
- {
99
- }
100
-
101
- function update($new_instance, $old_instance)
102
- {
103
- $instance = $old_instance;
104
- $instance['title'] = strip_tags($new_instance['title']);
105
- $instance['icon_skin'] = strip_tags($new_instance['icon_skin']);
106
- $instance['icon_size'] = strip_tags($new_instance['icon_size']);
107
- $instance['icon_spacing'] = strip_tags($new_instance['icon_spacing']);
108
-
109
- return $instance;
110
- }
111
-
112
- function form($instance)
113
- {
114
- $defaults = $this->get_defaults();
115
- $instance = wp_parse_args((array) $instance, $defaults);
116
- ?>
117
- <p>
118
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php echo(__('Title', 'social-media-feather')) ?>:</label>
119
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" />
120
- </p>
121
- <p>
122
- <label for="<?php echo $this->get_field_id('icon_skin'); ?>"><?php echo(__('Icon Skin', 'social-media-feather')) ?>:</label>
123
- <?php
124
- $params = array(
125
- 'tip' => '',
126
- 'output_name' => $this->get_field_name('icon_skin'),
127
- 'value' => $instance['icon_skin'],
128
- 'set_before' => array(array('default' => __('Use Default'))),
129
- );
130
-
131
- $item = synved_option_item('synved_social', 'icon_skin');
132
-
133
- if ($item != null)
134
- {
135
- // XXX a bit unorthodox...
136
- if (is_object($item))
137
- {
138
- $item = clone $item;
139
- }
140
-
141
- unset($item['render']);
142
-
143
- synved_option_render_item('synved_social', 'icon_skin', $item, true, $params, 'widget');
144
- }
145
- ?>
146
- <br/>
147
- <label for="<?php echo $this->get_field_id('icon_size'); ?>"><?php echo(__('Icon Size', 'social-media-feather')) ?>:</label>
148
- <?php
149
- $params = array(
150
- 'tip' => '',
151
- 'output_name' => $this->get_field_name('icon_size'),
152
- 'value' => $instance['icon_size'],
153
- 'set_before' => array(array('default' => __('Use Default'))),
154
- );
155
-
156
- synved_option_render_item('synved_social', 'icon_size', null, true, $params, 'widget');
157
- ?>
158
- <br/>
159
- <label for="<?php echo $this->get_field_id('icon_spacing'); ?>"><?php echo(__('Icon Spacing', 'social-media-feather')) ?>:</label>
160
- <input type="text" size="3" class="" id="<?php echo $this->get_field_id('icon_spacing'); ?>" name="<?php echo $this->get_field_name('icon_spacing'); ?>" value="<?php echo $instance['icon_spacing']; ?>" />
161
- </p>
162
- <?php
163
- }
164
- }
165
-
166
- class SynvedSocialShareWidget extends SynvedSocialWidget
167
- {
168
- function __construct()
169
- {
170
- parent::__construct('synved_social_share', __('Social Media Feather: Sharing', 'social-media-feather'));
171
- }
172
-
173
- function get_defaults()
174
- {
175
- $defaults = parent::get_defaults();
176
-
177
- return array_merge($defaults, array('title' => __('Sharing', 'social-media-feather')));
178
- }
179
-
180
- function render_social_markup($params = null)
181
- {
182
- echo synved_social_share_markup(null, null, $params);
183
- }
184
- }
185
-
186
- class SynvedSocialFollowWidget extends SynvedSocialWidget
187
- {
188
- function __construct()
189
- {
190
- parent::__construct('synved_social_follow', __('Social Media Feather: Follow Us', 'social-media-feather'));
191
- }
192
-
193
- function get_defaults()
194
- {
195
- $defaults = parent::get_defaults();
196
-
197
- return array_merge($defaults, array('title' => __('Follow Us', 'social-media-feather')));
198
- }
199
-
200
- function render_social_markup($params = null)
201
- {
202
- echo synved_social_follow_markup(null, null, $params);
203
- }
204
- }
205
-
206
-
207
  function synved_social_service_provider_list($context, $raw = false)
208
  {
209
- $provider_list = array();
210
-
211
- if ($context == 'share')
212
- {
213
- $provider_list = array(
214
- 'facebook' => array(
215
- 'link' => 'https://www.facebook.com/sharer.php?u=%%url%%&t=%%title%%&s=100&p[url]=%%url%%&p[images][0]=%%image%%&p[title]=%%title%%',
216
- 'title' => __('Share on Facebook')
217
- ),
218
- 'twitter' => array(
219
- 'link' => 'https://twitter.com/intent/tweet?url=%%url%%&text=%%message%%',
220
  'title' => __('Share on Twitter'),
221
- ),
222
- 'reddit' => array(
223
- 'link' => 'https://www.reddit.com/submit?url=%%url%%&title=%%title%%',
224
  'title' => __('Share on Reddit'),
225
- ),
226
- 'pinterest' => array(
227
- 'link' => 'https://pinterest.com/pin/create/button/?url=%%url%%&media=%%image%%&description=%%title%%',
228
  'title' => __('Pin it with Pinterest'),
229
- ),
230
- 'linkedin' => array(
231
- 'link' => 'https://www.linkedin.com/shareArticle?mini=true&url=%%url%%&title=%%title%%',
232
  'title' => __('Share on Linkedin'),
233
- ),
234
- 'tumblr' => array(
235
- 'link' => 'https://tumblr.com/share?s=&v=3&t=%%title%%&u=%%url%%',
236
- 'title' => __('Share on tumblr'),
237
  'default-display' => false,
238
- ),
239
- 'mail' => array(
240
- 'link' => 'mailto:?subject=%%title%%&body=%%message%%:%20%%url%%',
241
  'title' => __('Share by email'),
242
- ),
243
- );
244
- }
245
- else if ($context == 'follow')
246
- {
247
- $provider_list = array(
248
- 'facebook' => array(
249
- 'link' => 'https://www.facebook.com/facebook',
250
  'title' => __('Follow us on Facebook'),
251
- ),
252
- 'twitter' => array(
253
- 'link' => 'https://twitter.com/twitter',
254
  'title' => __('Follow us on Twitter'),
255
- ),
256
- 'pinterest' => array(
257
- 'link' => 'https://pinterest.com/MyUserName/',
258
- 'title' => __('Our board on Pinterest'),
259
  'default-display' => false,
260
- ),
261
- 'linkedin' => array(
262
- 'link' => 'https://www.linkedin.com/in/yourid',
263
  'title' => __('Find us on Linkedin'),
264
- ),
265
- 'rss' => array(
266
  'label' => 'RSS',
267
- 'link' => 'https://feeds.feedburner.com/MyFeedName',
268
  'title' => __('Subscribe to our RSS Feed'),
269
- ),
270
- 'youtube' => array(
271
- 'link' => 'https://www.youtube.com/MyYouTubeName',
272
  'title' => __('Find us on YouTube'),
273
- ),
274
- 'vimeo' => array(
275
- 'link' => 'https://vimeo.com/MyVimeoName',
276
- 'title' => __('Find us on vimeo'),
277
  'default-display' => false,
278
- ),
279
- 'tumblr' => array(
280
- 'link' => 'https://myname.tumblr.com',
281
- 'title' => __('Find us on tumblr'),
282
  'default-display' => false,
283
- ),
284
- 'instagram' => array(
285
- 'link' => 'https://instagram.com/myusername',
286
- 'title' => __('Check out our instagram feed'),
287
  'default-display' => false,
288
- ),
289
- 'flickr' => array(
290
- 'link' => 'https://www.flickr.com/photos/myusername/',
291
- 'title' => __('Check out our flickr feed'),
292
  'default-display' => false,
293
- ),
294
- 'foursquare' => array(
295
- 'link' => 'https://foursquare.com/myusername',
296
- 'title' => __('Check out our foursquare feed'),
297
  'default-display' => false,
298
- ),
299
- 'mail' => array(
300
- 'link' => 'mailto:mail@example.com?subject=Contact%20Request',
301
- 'title' => __('Contact Us'),
302
  'default-display' => false,
303
- ),
304
- );
305
  }
306
 
307
  $return_list = $provider_list;
308
 
309
- if ($raw == false)
310
- {
311
  global $synved_social;
312
 
313
  $list_name = 'provider_list' . '_' . $context;
314
 
315
- if (!isset($synved_social[$list_name]) || $synved_social[$list_name] == null)
316
- {
317
- $return_list = array();
318
 
319
- foreach ($provider_list as $provider_name => $provider_item)
320
- {
321
  $display = synved_option_get('synved_social', $provider_name . '_display');
322
- $link = synved_option_get('synved_social', $provider_name . '_' . $context . '_link');
323
- $title = synved_option_get('synved_social', $provider_name . '_' . $context . '_title');
324
 
325
- if ($display === null || in_array($display, array($context, 'both')))
326
- {
327
- if ($link != null)
328
- {
329
  $provider_item['link'] = $link;
330
  }
331
 
332
- if ($title != null)
333
- {
334
  $provider_item['title'] = $title;
335
  }
336
 
@@ -339,9 +163,7 @@ function synved_social_service_provider_list($context, $raw = false)
339
  }
340
 
341
  $synved_social[$list_name] = $return_list;
342
- }
343
- else
344
- {
345
  $return_list = $synved_social[$list_name];
346
  }
347
  }
@@ -349,37 +171,37 @@ function synved_social_service_provider_list($context, $raw = false)
349
  return apply_filters('synved_social_service_provider_list', $return_list, $context, $raw);
350
  }
351
 
 
 
 
 
 
352
  function synved_social_icon_skin_list()
353
  {
354
  global $synved_social;
355
 
356
- if (!isset($synved_social['skin_list']) || $synved_social['skin_list'] == null)
357
- {
358
  $path = synved_social_path();
359
- $uri = synved_social_path_uri();
360
 
361
- $icons = array(
362
- 'regular' => array(
363
- 'label' => __('Regular'),
364
- 'image' => $uri . '/image/social/regular/preview.png',
365
  'folder' => '/image/social/regular/',
366
- 'path' => $path . '/image/social/regular/',
367
- 'uri' => $uri . '/image/social/regular/'
368
- )
369
- );
370
-
371
- $icons_extra = null;
372
 
373
- if (function_exists('synved_social_addon_extra_icons_get'))
374
- {
375
  $icons_extra = synved_social_addon_extra_icons_get();
376
- $icons = array_merge($icons, $icons_extra);
377
  }
378
 
379
  $icons = apply_filters('synved_social_icon_skin_list', $icons);
380
 
381
- foreach ($icons as $skin_name => $skin)
382
- {
383
  $icons[$skin_name]['name'] = $skin_name;
384
  }
385
 
@@ -389,16 +211,20 @@ function synved_social_icon_skin_list()
389
  return $synved_social['skin_list'];
390
  }
391
 
 
 
 
 
 
 
 
392
  function synved_social_icon_skin_get($name = null)
393
  {
394
  $icons = synved_social_icon_skin_list();
395
 
396
- if ($name != null && !isset($icons[$name]))
397
- {
398
- foreach ($icons as $skin_name => $skin)
399
- {
400
- if (strtolower($name) == strtolower($skin['label']))
401
- {
402
  $name = $skin_name;
403
 
404
  break;
@@ -406,180 +232,165 @@ function synved_social_icon_skin_get($name = null)
406
  }
407
  }
408
 
409
- if ($name == null || !isset($icons[$name]))
410
- {
411
  $selected = synved_option_get('synved_social', 'icon_skin');
412
 
413
  $name = $selected;
414
  }
415
 
416
- if (isset($icons[$name]))
417
- {
418
  return $icons[$name];
419
  }
420
 
421
- if (isset($icons['regular']))
422
- {
423
  return $icons['regular'];
424
  }
425
 
426
  return null;
427
  }
428
 
429
- function synved_social_icon_skin_current()
430
- {
431
- return synved_social_icon_skin_get();
432
- }
433
-
434
- // XXX internal, don't use
435
- function synved_social_icon_skin_set($name, $skin)
436
- {
437
- global $synved_social;
438
-
439
- // ensure the global is set
440
- synved_social_icon_skin_list();
441
-
442
- if (isset($synved_social['skin_list']) && $synved_social['skin_list'] != null)
443
- {
444
- if (!isset($synved_social['skin_list'][$name]))
445
- {
446
- $synved_social['skin_list'][$name] = array();
447
- }
448
-
449
- foreach ($skin as $key => $value)
450
- {
451
- $synved_social['skin_list'][$name][$key] = $value;
452
- }
453
- }
454
- }
455
-
456
  function synved_social_icon_skin_get_size_list($skin)
457
  {
458
- if (isset($skin['size-list']))
459
- {
460
  return $skin['size-list'];
461
  }
462
 
463
- if (isset($skin['name']))
464
- {
465
  $skin_fresh = synved_social_icon_skin_get($skin['name']);
466
 
467
- if (isset($skin['path']) && isset($skin_fresh['path']) && $skin['path'] == $skin_fresh['path'])
468
- {
469
- if (isset($skin_fresh['size-list']))
470
- {
471
  return $skin_fresh['size-list'];
472
  }
473
  }
474
  }
475
 
476
- $path = synved_social_path();
477
  $skin_path = isset($skin['path']) ? $skin['path'] : ($path . '/image/social/regular/');
478
 
479
- $sizes = glob($skin_path . '*', GLOB_ONLYDIR);
480
- $sizes = array_map('basename', $sizes);
481
- $size_list = array();
482
 
483
- foreach ($sizes as $size_dir)
484
- {
485
  $size_parts = explode('x', $size_dir);
486
- $size_width = (int) $size_parts[0];
487
 
488
- if ($size_width != null)
489
- {
490
  $size_list[] = $size_width;
491
  }
492
  }
493
 
494
  sort($size_list, SORT_NUMERIC);
495
 
496
- if (isset($skin['name']))
497
- {
498
- synved_social_icon_skin_set($skin['name'], array('size-list' => $size_list));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  }
500
 
501
  return $size_list;
502
  }
503
 
 
 
 
 
 
 
 
 
 
504
  function synved_social_icon_skin_get_image_list_raw($skin, $name_list, $forced_size = null)
505
  {
506
- $path = synved_social_path();
507
- $uri = synved_social_path_uri();
508
  $skin_default = synved_social_icon_skin_get('regular');
509
 
510
  $skin_default_path = isset($skin_default['path']) ? $skin_default['path'] : ($path . '/image/social/regular/');
511
- $skin_default_uri = isset($skin_default['uri']) ? $skin_default['uri'] : ($uri . '/image/social/regular/');
512
- $skin_sel_path = isset($skin['path']) ? $skin['path'] : ($path . '/image/social/regular/');
513
- $skin_sel_uri = isset($skin['uri']) ? $skin['uri'] : ($uri . '/image/social/regular/');
514
 
515
  $default_size_list = synved_social_icon_skin_get_size_list($skin_default);
516
- $sel_size_list = synved_social_icon_skin_get_size_list($skin);
517
 
518
- $skin_list = array(
519
- array(
520
  'path' => $skin_sel_path,
521
- 'uri' => $skin_sel_uri,
522
  'list' => $sel_size_list,
523
- ),
524
- array(
525
  'path' => $skin_default_path,
526
- 'uri' => $skin_default_uri,
527
  'list' => $default_size_list,
528
- ),
529
- );
530
-
531
- $image_list = array();
532
-
533
- foreach ($name_list as $name)
534
- {
535
- foreach ($skin_list as $skin)
536
- {
537
- $skin_path = $skin['path'];
538
- $skin_uri = $skin['uri'];
539
- $size_list = $skin['list'];
540
  $size_count = count($size_list);
541
 
542
- $image_size_list = array();
543
- $image_size_list_skipped = array();
544
 
545
- for ($i = 0; $i < $size_count; $i++)
546
- {
547
  $image_size = $size_list[$i];
548
- $image_sub = '/' . $name . '.png';
549
- $size_name = $image_size . 'x' . $image_size;
550
  $image_path = $skin_path . $size_name . $image_sub;
551
- $image_uri = $skin_uri . $size_name . $image_sub;
552
 
553
- if (file_exists($image_path))
554
- {
555
- $image_size_meta = array(
556
  'name' => $size_name,
557
- 'sub' => $image_sub,
558
  'path' => $image_path,
559
- 'uri' => $image_uri,
560
- );
561
 
562
- foreach ($image_size_list_skipped as $image_size_skipped)
563
- {
564
  $image_size_list[$image_size_skipped] = $image_size_meta;
565
  }
566
 
567
- $image_size_skipped = array();
568
  $image_size_list[$image_size] = $image_size_meta;
569
 
570
- if ($forced_size != null && ($image_size > $forced_size || $i == $size_count - 1) && !isset($image_size_list[$forced_size]))
571
- {
572
  $image_size_list[$forced_size] = $image_size_meta;
573
  }
574
- }
575
- else
576
- {
577
  $image_size_skipped[] = $image_size;
578
  }
579
  }
580
 
581
- if ($image_size_list != null)
582
- {
583
  break;
584
  }
585
  }
@@ -590,6 +401,15 @@ function synved_social_icon_skin_get_image_list_raw($skin, $name_list, $forced_s
590
  return $image_list;
591
  }
592
 
 
 
 
 
 
 
 
 
 
593
  function synved_social_icon_skin_get_image_list($skin, $name_list, $forced_size = null)
594
  {
595
  $image_list = synved_social_icon_skin_get_image_list_raw($skin, $name_list, $forced_size);
@@ -598,66 +418,107 @@ function synved_social_icon_skin_get_image_list($skin, $name_list, $forced_size
598
  return $image_list;
599
  }
600
 
 
 
 
 
 
 
 
 
 
 
601
  function synved_social_button_list_shortcode($atts, $content = null, $code = '', $context = null)
602
  {
603
- $vars_def = array('url' => null, 'image' => null, 'title' => null, 'message' => null);
604
- $params_def = array('skin' => null, 'size' => null, 'spacing' => null, 'container' => null, 'container_type' => null, 'class' => null, 'show' => null, 'hide' => null, 'prompt' => null, 'custom1' => null, 'custom2' => null, 'custom3' => null);
605
- $vars = shortcode_atts($vars_def, $atts, 'feather_' . $context);
606
- $params = shortcode_atts($params_def, $atts, 'feather_' . $context);
607
- $vars = array_filter($vars);
608
- $params = array_filter($params);
609
-
610
- $vars = apply_filters('synved_social_shortcode_variable_list', $vars, $context, $atts);
 
 
 
 
 
 
 
 
 
 
 
 
 
611
  $params = apply_filters('synved_social_shortcode_parameter_list', $params, $context, $atts);
612
 
613
- if ($context == 'share')
614
- {
615
  return synved_social_share_markup($vars, null, $params);
616
- }
617
- else if ($context == 'follow')
618
- {
619
  return synved_social_follow_markup($vars, null, $params);
620
  }
621
 
622
- return null;
623
  }
624
 
 
 
 
 
 
 
 
 
 
625
  function synved_social_share_shortcode($atts, $content = null, $code = '')
626
  {
627
  return synved_social_button_list_shortcode($atts, $content, $code, 'share');
628
  }
629
 
 
 
 
 
 
 
 
 
 
630
  function synved_social_follow_shortcode($atts, $content = null, $code = '')
631
  {
632
  return synved_social_button_list_shortcode($atts, $content, $code, 'follow');
633
  }
634
 
 
 
 
 
 
 
 
 
 
635
  function synved_social_button_list_markup_item_out($out_item)
636
  {
637
- $out = null;
638
- $tag = isset($out_item['tag']) ? $out_item['tag'] : null;
639
  $content = isset($out_item['content']) ? $out_item['content'] : null;
640
- $list = isset($out_item['child-list']) ? $out_item['child-list'] : null;
641
 
642
  unset($out_item['tag']);
643
  unset($out_item['content']);
644
  unset($out_item['child-list']);
645
 
646
- if ($tag != null)
647
- {
648
  $out .= '<' . $tag;
649
 
650
- foreach ($out_item as $attr_name => $attr_value)
651
- {
652
- if ($attr_name != null && $attr_value !== null)
653
- {
654
- if (in_array($attr_name, array('href', 'src')))
655
- {
656
- $attr_value = str_ireplace(array('[', ']'), array('&#91;', '&#93;'), $attr_value);
657
  $attr_value = esc_url($attr_value);
658
- }
659
- else
660
- {
661
  $attr_value = esc_attr($attr_value);
662
  }
663
 
@@ -665,53 +526,53 @@ function synved_social_button_list_markup_item_out($out_item)
665
  }
666
  }
667
 
668
- if ($list != null || $content != null)
669
- {
670
  $out .= '>';
671
- }
672
- else
673
- {
674
  $out .= ' />';
675
  }
676
  }
677
 
678
- if ($list != null)
679
- {
680
- foreach ($list as $child)
681
- {
682
  $out .= synved_social_button_list_markup_item_out($child);
683
  }
684
  }
685
 
686
- if ($content != null)
687
- {
688
  $out .= $content;
689
  }
690
 
691
- if ($tag != null && ($list != null || $content != null))
692
- {
693
  $out .= '</' . $tag . '>';
694
  }
695
 
696
- return $out;
697
  }
698
 
 
 
 
 
 
 
 
 
 
 
 
 
699
  function synved_social_button_list_markup($context, $vars = null, $buttons = null, $params = null)
700
  {
701
  $buttons_default = synved_social_service_provider_list($context);
702
 
703
- if ($buttons == null)
704
- {
705
  $buttons = $buttons_default;
706
- }
707
- else
708
- {
709
  $keys = array_keys($buttons);
710
 
711
- foreach ($keys as $key)
712
- {
713
- if ($buttons[$key] == null && isset($buttons_default[$key]))
714
- {
715
  $buttons[$key] = $buttons_default[$key];
716
  }
717
  }
@@ -719,107 +580,67 @@ function synved_social_button_list_markup($context, $vars = null, $buttons = nul
719
 
720
  $id = get_the_ID();
721
 
722
- if ($id == null)
723
- {
724
  global $post;
725
 
726
- if ($post != null)
727
- {
728
  $id = $post->ID;
729
  }
730
  }
731
 
732
- if (!isset($vars['url']) || !isset($vars['short_url']))
733
- {
734
- $full_url = synved_option_get('synved_social', 'share_full_url');
735
  $home_url = home_url();
736
- $req_uri = $_SERVER['REQUEST_URI'];
737
 
738
- $path = parse_url($home_url, PHP_URL_PATH);
739
  $path_len = strlen($path);
740
 
741
- if (strtolower(substr($req_uri, 0, $path_len)) == strtolower($path))
742
- {
743
  $req_uri = substr($req_uri, $path_len);
744
  }
745
 
746
- $url = home_url($req_uri);
747
  $short_url = $url;
748
 
749
- if ($id != null && in_the_loop())
750
- {
751
- $post_full_url = strtolower(get_post_meta($id, 'synved_social_share_full_url', true));
 
752
 
753
- if ($post_full_url != null)
754
- {
755
- if ($post_full_url == 'yes')
756
- {
757
- $full_url = true;
758
- }
759
- else if ($post_full_url == 'no')
760
- {
761
- $full_url = false;
762
  }
 
 
763
  }
 
 
764
  }
765
 
766
- //if (!$full_url)
767
- {
768
- if ($id != null && in_the_loop())
769
- {
770
- $use_shortlinks = synved_option_get('synved_social', 'use_shortlinks');
771
- $url = get_permalink($id);
772
- $short_url = wp_get_shortlink($id);
773
-
774
- if ($short_url != null)
775
- {
776
- if ($use_shortlinks && function_exists('wp_get_shortlink'))
777
- {
778
- $url = $short_url;
779
- }
780
- }
781
- else
782
- {
783
- $short_url = $url;
784
- }
785
- }
786
- else if (is_front_page())
787
- {
788
- $url = $home_url;
789
- }
790
- }
791
-
792
- if (!isset($vars['url']))
793
- {
794
  $vars['url'] = $url;
795
  }
796
 
797
- if (!isset($vars['short_url']))
798
- {
799
  $vars['short_url'] = $short_url;
800
  }
801
  }
802
 
803
- if (!isset($vars['image']))
804
- {
805
  $image_src = null;
806
 
807
- if ($id != null)
808
- {
809
  $image_id = get_post_thumbnail_id($id);
810
 
811
- if ($image_id != null)
812
- {
813
- $src = wp_get_attachment_image_src($image_id, 'full');
814
  $image_src = $src[0];
815
- }
816
- else
817
- {
818
- $post = get_post($id);
819
  $match = null;
820
 
821
- if (preg_match('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $match) > 0)
822
- {
823
  $image_src = $match[1];
824
  }
825
  }
@@ -828,311 +649,265 @@ function synved_social_button_list_markup($context, $vars = null, $buttons = nul
828
  $vars['image'] = $image_src;
829
  }
830
 
831
- if (!isset($vars['title']))
832
- {
833
  $title = get_the_title();
834
  // do this encoding to prevent non-tags things, like emoticons, from being stripped, i.e. <8
835
- $title = preg_replace('/\\<\\s*([^[:alpha:]\\/])/', '&lt;$1', $title);
836
  $vars['title'] = html_entity_decode(wp_strip_all_tags($title));
837
  }
838
 
839
- if (!isset($vars['message']))
840
- {
841
  $message = synved_option_get('synved_social', 'share_message_default');
842
 
843
- if ($message == null)
844
- {
845
  $message = __('Hey check this out', 'social-media-feather');
846
  }
847
 
848
  $vars['message'] = $message;
849
  }
850
 
851
- if (!isset($vars['author_wp']))
852
- {
853
- if ($id != null && in_the_loop())
854
- {
855
  $author = get_the_author();
856
 
857
- if ($author != null)
858
- {
859
  $vars['author_wp'] = $author;
860
  }
861
  }
862
  }
863
 
864
- if (!isset($vars['author']))
865
- {
866
- if ($id != null && in_the_loop())
867
- {
868
  $author = get_the_author_meta('_synved_twitter_handle');
869
 
870
- if ($author == null)
871
- {
872
  $author = get_the_author_meta('twitter');
873
  }
874
 
875
- if ($author == null)
876
- {
877
  $author = get_the_author();
878
  }
879
 
880
- if ($author != null)
881
- {
882
  $vars['author'] = $author;
883
  }
884
  }
885
  }
886
 
887
- if (!isset($vars['date']))
888
- {
889
- if ($id != null && in_the_loop())
890
- {
891
  $date = get_the_date('', $id);
892
 
893
- if ($date != null)
894
- {
895
  $vars['date'] = $date;
896
  }
897
  }
898
  }
899
 
900
- if (isset($vars['url']) && !isset($vars['url_trimmed']))
901
- {
902
  $url_trimmed = trim($vars['url']);
903
 
904
- while (substr($url_trimmed, -1) == '/')
905
- {
906
  $url_trimmed = substr($url_trimmed, 0, -1);
907
  }
908
 
909
- while (strtolower(substr($url_trimmed, -3)) == '%2f')
910
- {
911
  $url_trimmed = substr($url_trimmed, 0, -3);
912
  }
913
 
914
  $vars['url_trimmed'] = $url_trimmed;
915
  }
916
 
917
- if (isset($params['class']) && !is_array($params['class']))
918
- {
919
- $class = explode(' ', $params['class']);
920
  $params['class'] = array_map('trim', $class);
921
  }
922
 
923
- if (isset($params['show']) && !is_array($params['show']))
924
- {
925
- $show = explode(',', $params['show']);
926
  $params['show'] = array_map('trim', $show);
927
  }
928
 
929
- if (isset($params['hide']) && !is_array($params['hide']))
930
- {
931
- $hide = explode(',', $params['hide']);
932
  $params['hide'] = array_map('trim', $hide);
933
  }
934
 
935
- $vars = apply_filters('synved_social_markup_variable_list', $vars, $context, $params);
936
  $params = apply_filters('synved_social_markup_parameter_list', $params, $context, $vars);
937
 
938
- if ($vars != null)
939
- {
940
  $vars = array_map('wp_kses_decode_entities', $vars);
941
  $vars = urlencode_deep($vars);
942
 
943
  // urlencode_deep converts space characters to + rather than %20 which messes things up
944
  $vars['message'] = str_ireplace('+', '%20', $vars['message']);
945
- $vars['title'] = str_ireplace('+', '%20', $vars['title']);
946
 
947
  // urlencode_deep tries to be smart and apostrophes (') to %19 not %27 and double quotes (") to their equivalent open/closed counterparts which doesn't work on most social networks sharings
948
  $vars['message'] = str_ireplace('%18', '%27', $vars['message']);
949
- $vars['title'] = str_ireplace('%18', '%27', $vars['title']);
950
  $vars['message'] = str_ireplace('%19', '%27', $vars['message']);
951
- $vars['title'] = str_ireplace('%19', '%27', $vars['title']);
952
  $vars['message'] = str_ireplace('%1c', '%22', $vars['message']);
953
- $vars['title'] = str_ireplace('%1c', '%22', $vars['title']);
954
  $vars['message'] = str_ireplace('%1d', '%22', $vars['message']);
955
- $vars['title'] = str_ireplace('%1d', '%22', $vars['title']);
956
  }
957
 
958
  $path = synved_social_path();
959
- $uri = synved_social_path_uri();
960
- $skin = synved_social_icon_skin_current();
961
 
962
- if (isset($params['skin']))
963
- {
964
  $skin = synved_social_icon_skin_get($params['skin']);
965
  }
966
 
967
  $skin_path = isset($skin['path']) ? $skin['path'] : ($path . '/image/social/regular/');
968
- $skin_uri = isset($skin['uri']) ? $skin['uri'] : ($uri . '/image/social/regular/');
969
 
970
  $icon_size = synved_option_get('synved_social', 'icon_size');
971
- $size = 48;
972
 
973
- if ($icon_size != null)
974
- {
975
  $size = $icon_size;
976
  }
977
 
978
- if (isset($params['size']))
979
- {
980
  $size = $params['size'];
981
 
982
- if (is_string($size))
983
- {
984
- $size = strtolower($size);
985
  $size_parts = explode('x', $size);
986
- $size = (int) $size_parts[0];
987
  }
988
  }
989
 
990
- $icon_spacing = synved_option_get('synved_social', 'icon_spacing');
991
- $buttons_container = synved_option_get('synved_social', 'buttons_container');
992
  $buttons_container_type = synved_option_get('synved_social', 'buttons_container_type');
993
- $buttons_alignment = synved_option_get('synved_social', 'buttons_alignment_' . $context);
994
- $layout_rtl = synved_option_get('synved_social', 'layout_rtl');
995
- $spacing = 5;
996
- $container = 'none';
997
- $container_type = 'basic';
998
- $alignment = 'none';
999
-
1000
- if ($icon_spacing != null)
1001
- {
1002
  $spacing = $icon_spacing;
1003
  }
1004
 
1005
- if (isset($params['spacing']))
1006
- {
1007
  $spacing = $params['spacing'];
1008
  }
1009
 
1010
- if ($buttons_container != null)
1011
- {
1012
  $container = $buttons_container;
1013
  }
1014
 
1015
- if ($buttons_container_type != null)
1016
- {
1017
  $container_type = $buttons_container_type;
1018
  }
1019
 
1020
- if ($buttons_alignment != null)
1021
- {
1022
  $alignment = $buttons_alignment;
1023
  }
1024
 
1025
- if (isset($params['alignment']))
1026
- {
1027
  $alignment = $params['alignment'];
1028
  }
1029
 
1030
- if ($alignment != 'none')
1031
- {
1032
- if ($container == 'none')
1033
- {
1034
  $container = $context;
1035
- }
1036
- else if ($container != 'both' && $container != $context)
1037
- {
1038
  $container = 'both';
1039
  }
1040
  }
1041
 
1042
  // Allow parameters to override container after we decide a default based on selected alignment
1043
- if (isset($params['container']))
1044
- {
1045
  $container = $params['container'];
1046
  }
1047
 
1048
- if ($alignment != 'none')
1049
- {
1050
  $container_type = 'block';
1051
  }
1052
 
1053
  // Allow parameters to override container after we decide a default based on selected alignment
1054
- if (isset($params['container_type']))
1055
- {
1056
  $container_type = $params['container_type'];
1057
  }
1058
 
1059
  $class = isset($params['class']) ? $params['class'] : null;
1060
- $show = isset($params['show']) ? $params['show'] : null;
1061
- $hide = isset($params['hide']) ? $params['hide'] : null;
1062
 
1063
- if ($show != null)
1064
- {
1065
- $button_list = array();
1066
 
1067
- foreach ($show as $button_key)
1068
- {
1069
- if (isset($buttons[$button_key]))
1070
- {
1071
  $button_list[$button_key] = $buttons[$button_key];
1072
 
1073
  unset($buttons[$button_key]);
1074
  }
1075
  }
1076
 
1077
- foreach ($buttons as $button_key => $button_item)
1078
- {
1079
  $button_list[$button_key] = $button_item;
1080
  }
1081
 
1082
  $buttons = $button_list;
1083
  }
1084
 
1085
- if ($hide != null)
1086
- {
1087
- foreach ($hide as $button_key)
1088
- {
1089
- if (isset($buttons[$button_key]))
1090
- {
1091
  unset($buttons[$button_key]);
1092
  }
1093
  }
1094
  }
1095
 
1096
- $out_list = array();
1097
- $out_params = array();
1098
- $image_list = array();
1099
  $icon_resolution = synved_option_get('synved_social', 'icon_resolution');
1100
- $resolutions = array('normal' => $size, 'hidef' => $size * 2);
1101
 
1102
- if (is_feed())
1103
- {
1104
  $icon_resolution = 'single';
1105
  }
1106
 
1107
- if ($icon_resolution == 'single')
1108
- {
1109
- $resolutions = array('single' => $size * 2);
1110
  }
1111
 
1112
- foreach ($resolutions as $resolution_name => $resolution_size)
1113
- {
1114
- $image_list[$resolution_name] = synved_social_icon_skin_get_image_list($skin, array_keys($buttons), $resolution_size);
 
 
 
 
 
1115
  }
1116
 
1117
  $index = 0;
1118
  $count = count($buttons);
1119
 
1120
- foreach ($buttons as $button_key => $button_item)
1121
- {
1122
- $href = $button_item['link'];
1123
  $title = $button_item['title'];
1124
 
1125
  $matches = null;
1126
 
1127
- if (preg_match_all('/%%(\\w+)%%/', $href, $matches, PREG_SET_ORDER) > 0)
1128
- {
1129
- foreach ($matches as $match)
1130
- {
1131
  $var_key = $match[1];
1132
  $replace = null;
1133
 
1134
- if (isset($vars[$var_key]))
1135
- {
1136
  $replace = $vars[$var_key];
1137
  }
1138
 
@@ -1142,68 +917,65 @@ function synved_social_button_list_markup($context, $vars = null, $buttons = nul
1142
 
1143
  $icon_sizes = $resolutions;
1144
 
1145
- foreach ($icon_sizes as $icon_def => $icon_size)
1146
- {
1147
- $image = $image_list[$icon_def][$button_key];
1148
  $image_size = $image[$icon_size];
1149
- $image_sub = $image_size['sub'];
1150
  $image_path = $image_size['path'];
1151
- $image_uri = $image_size['uri'];
1152
-
1153
- if (!file_exists($image_path))
1154
- {
1155
- $size_list = array_keys($image);
1156
- $image_path = apply_filters('synved_social_button_image_path', $image_path, $image_uri, $icon_size, $image_sub, $skin_path, $skin_uri, $size_list);
1157
- $image_uri = apply_filters('synved_social_button_image_uri', $image_uri, $image_path, $icon_size, $image_sub, $skin_path, $skin_uri, $size_list);
 
1158
  }
1159
 
1160
  $style = 'margin:0;';
1161
 
1162
- if (true)
1163
- {
1164
  $style .= 'margin-bottom:' . $spacing . 'px;';
1165
  }
1166
 
1167
- if ($index < $count - 1 || $layout_rtl)
1168
- {
1169
  $style .= 'margin-right:' . $spacing . 'px;';
1170
  }
1171
 
1172
  $class_extra = null;
1173
 
1174
- if ($class != null)
1175
- {
1176
  $class_extra = ' ' . implode(' ', $class);
1177
  }
1178
 
1179
  // don't use "nofancybox" because some plugins/themes interpret it as enabling fancybox
1180
  $class_extra .= ' nolightbox';
1181
 
1182
- $out_button = array(
1183
- 'tag' => 'a',
1184
- 'class' => 'synved-social-button synved-social-button-' . $context . ' synved-social-size-' . $size . ' synved-social-resolution-' . $icon_def . ' synved-social-provider-' . $button_key . $class_extra,
1185
  'data-provider' => $button_key,
1186
- 'target' => $button_key != 'mail' ? '_blank' : null,
1187
- 'rel' => 'nofollow',
1188
- 'title' => $title,
1189
- 'href' => $href,
1190
- 'style' => 'font-size: 0px; width:' . $size . 'px;' . 'height:' . $size . 'px;' . $style,
1191
- 'child-list' => array(
1192
- array(
1193
- 'tag' => 'img',
1194
- 'alt' => $button_key == 'facebook' ? 'Facebook' : $button_key,
1195
- 'title' => $title,
1196
- 'class' => 'synved-share-image synved-social-image synved-social-image-' . $context,
1197
- 'width' => $size,
1198
  'height' => $size,
1199
- 'style' => 'display: inline; width:' . $size . 'px;' . 'height:' . $size . 'px; margin: 0; padding: 0; border: none; box-shadow: none;',
1200
- 'src' => $image_uri,
1201
- )
1202
- )
1203
- );
1204
-
1205
- $out_list[$icon_def][$button_key] = $out_button;
1206
- $out_params[$icon_def][$button_key] = array('icon-resolution' => $icon_def);
1207
  }
1208
 
1209
  $index++;
@@ -1211,59 +983,70 @@ function synved_social_button_list_markup($context, $vars = null, $buttons = nul
1211
 
1212
  $out = null;
1213
 
1214
- if ($out_list != null)
1215
- {
1216
- foreach ($out_list as $def_key => $def_list)
1217
- {
1218
- $out_list[$def_key] = apply_filters('synved_social_button_list_markup', $def_list, $out_params[$def_key], $context, $vars, $params);
1219
  }
1220
  }
1221
 
1222
- if ($out_list != null)
1223
- {
1224
  $container_tag = 'span';
1225
 
1226
- if ($container_type == 'block')
1227
- {
1228
  $container_tag = 'div';
1229
  }
1230
 
1231
- if ($container != 'none' && ($container == 'both' || $container == $context))
1232
- {
1233
  $container_style = $alignment != 'none' ? ' style="text-align: ' . $alignment . '"' : null;
1234
 
1235
  $out .= '<' . $container_tag . ' class="synved-social-container synved-social-container-' . $context . '"' . $container_style . '>';
1236
  }
1237
 
1238
- foreach ($out_list as $def_key => $def_list)
1239
- {
1240
- foreach ($def_list as $button_key => $out_item)
1241
- {
1242
  $out .= synved_social_button_list_markup_item_out($out_item);
1243
  }
1244
  }
1245
 
1246
- if (synved_option_get('synved_social', 'show_credit'))
1247
- {
1248
- $out .= '<a class="synved-social-credit" target="_blank" rel="nofollow" title="' . __('WordPress Social Media Feather', 'social-media-feather') . '" href="http://synved.com/wordpress-social-media-feather/" style="color:#444; text-decoration:none; font-size:8px; margin-left:5px;vertical-align:10px;white-space:nowrap;"><span>' . __('by ', 'social-media-feather') . '</span><img style="display: inline;margin:0;padding:0;width:16px;height:16px;" width="16" height="16" alt="feather" src="' . $uri . '/image/icon.png" /></a>';
 
1249
  }
1250
 
1251
- if ($container != 'none' && ($container == 'both' || $container == $context))
1252
- {
1253
  $out .= '</' . $container_tag . '>';
1254
  }
1255
  }
1256
 
1257
- return $out;
1258
  }
1259
 
 
 
 
 
 
 
 
 
 
1260
  function synved_social_share_markup($vars = null, $buttons = null, $params = null)
1261
  {
1262
  return synved_social_button_list_markup('share', $vars, $buttons, $params);
1263
  }
1264
 
 
 
 
 
 
 
 
 
 
1265
  function synved_social_follow_markup($vars = null, $buttons = null, $params = null)
1266
  {
1267
  return synved_social_button_list_markup('follow', $vars, $buttons, $params);
1268
  }
1269
-
16
  In no event shall Synved Ltd. be liable to you or any third party for any direct or indirect, special, incidental, or consequential damages in connection with or arising from errors, omissions, delays or other cause of action that may be attributed to your use of any product, support, services, information or software provided, including, but not limited to, lost profits or lost data, even if Synved Ltd. had been advised of the possibility of such damages.
17
  */
18
 
19
+ define( 'SYNVED_SOCIAL_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
20
+ define( 'SYNVED_SOCIAL_LOADED', true );
21
+ define( 'SYNVED_SOCIAL_VERSION', 100070016 );
22
+ define( 'SYNVED_SOCIAL_VERSION_STRING', '1.7.16' );
 
23
  define('SYNVED_SOCIAL_ADDON_PATH', str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, dirname(__FILE__) . '/addons'));
24
 
25
+ $synved_social = [];
26
+
27
+ include_once SYNVED_SOCIAL_PLUGIN_PATH . 'synved-social-setup.php';
28
+ require_once SYNVED_SOCIAL_PLUGIN_PATH . 'inc/SynvedSocialWidget.php';
29
+ require_once SYNVED_SOCIAL_PLUGIN_PATH . 'inc/SynvedSocialShareWidget.php';
30
+ require_once SYNVED_SOCIAL_PLUGIN_PATH . 'inc/SynvedSocialFollowWidget.php';
31
+
32
+ /**
33
+ * Get service provider list array.
34
+ *
35
+ * @param $context
36
+ * @param $raw
37
+ *
38
+ * @return array
39
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  function synved_social_service_provider_list($context, $raw = false)
41
  {
42
+ $provider_list = [];
43
+
44
+ if ($context == 'share') {
45
+ $provider_list = [
46
+ 'facebook' => [
47
+ 'link' => 'https://www.facebook.com/sharer.php?u=%%url%%&t=%%title%%&s=100&p[url]=%%url%%&p[images][0]=%%image%%&p[title]=%%title%%',
48
+ 'title' => __('Share on Facebook'),
49
+ ],
50
+ 'twitter' => [
51
+ 'link' => 'https://twitter.com/intent/tweet?url=%%url%%&text=%%message%%',
 
52
  'title' => __('Share on Twitter'),
53
+ ],
54
+ 'reddit' => [
55
+ 'link' => 'https://www.reddit.com/submit?url=%%url%%&title=%%title%%',
56
  'title' => __('Share on Reddit'),
57
+ ],
58
+ 'pinterest' => [
59
+ 'link' => 'https://pinterest.com/pin/create/button/?url=%%url%%&media=%%image%%&description=%%title%%',
60
  'title' => __('Pin it with Pinterest'),
61
+ ],
62
+ 'linkedin' => [
63
+ 'link' => 'https://www.linkedin.com/shareArticle?mini=true&url=%%url%%&title=%%title%%',
64
  'title' => __('Share on Linkedin'),
65
+ ],
66
+ 'tumblr' => [
67
+ 'link' => 'https://tumblr.com/share?s=&v=3&t=%%title%%&u=%%url%%',
68
+ 'title' => __('Share on tumblr'),
69
  'default-display' => false,
70
+ ],
71
+ 'mail' => [
72
+ 'link' => 'mailto:?subject=%%title%%&body=%%message%%:%20%%url%%',
73
  'title' => __('Share by email'),
74
+ ],
75
+ ];
76
+ } elseif ($context == 'follow') {
77
+ $provider_list = [
78
+ 'facebook' => [
79
+ 'link' => 'https://www.facebook.com/facebook',
 
 
80
  'title' => __('Follow us on Facebook'),
81
+ ],
82
+ 'twitter' => [
83
+ 'link' => 'https://twitter.com/twitter',
84
  'title' => __('Follow us on Twitter'),
85
+ ],
86
+ 'pinterest' => [
87
+ 'link' => 'https://pinterest.com/MyUserName/',
88
+ 'title' => __('Our board on Pinterest'),
89
  'default-display' => false,
90
+ ],
91
+ 'linkedin' => [
92
+ 'link' => 'https://www.linkedin.com/in/yourid',
93
  'title' => __('Find us on Linkedin'),
94
+ ],
95
+ 'rss' => [
96
  'label' => 'RSS',
97
+ 'link' => 'https://feeds.feedburner.com/MyFeedName',
98
  'title' => __('Subscribe to our RSS Feed'),
99
+ ],
100
+ 'youtube' => [
101
+ 'link' => 'https://www.youtube.com/MyYouTubeName',
102
  'title' => __('Find us on YouTube'),
103
+ ],
104
+ 'vimeo' => [
105
+ 'link' => 'https://vimeo.com/MyVimeoName',
106
+ 'title' => __('Find us on vimeo'),
107
  'default-display' => false,
108
+ ],
109
+ 'tumblr' => [
110
+ 'link' => 'https://myname.tumblr.com',
111
+ 'title' => __('Find us on tumblr'),
112
  'default-display' => false,
113
+ ],
114
+ 'instagram' => [
115
+ 'link' => 'https://instagram.com/myusername',
116
+ 'title' => __('Check out our instagram feed'),
117
  'default-display' => false,
118
+ ],
119
+ 'flickr' => [
120
+ 'link' => 'https://www.flickr.com/photos/myusername/',
121
+ 'title' => __('Check out our flickr feed'),
122
  'default-display' => false,
123
+ ],
124
+ 'foursquare' => [
125
+ 'link' => 'https://foursquare.com/myusername',
126
+ 'title' => __('Check out our foursquare feed'),
127
  'default-display' => false,
128
+ ],
129
+ 'mail' => [
130
+ 'link' => 'mailto:mail@example.com?subject=Contact%20Request',
131
+ 'title' => __('Contact Us'),
132
  'default-display' => false,
133
+ ],
134
+ ];
135
  }
136
 
137
  $return_list = $provider_list;
138
 
139
+ if ($raw == false) {
 
140
  global $synved_social;
141
 
142
  $list_name = 'provider_list' . '_' . $context;
143
 
144
+ if (!isset($synved_social[$list_name]) || $synved_social[$list_name] == null) {
145
+ $return_list = [];
 
146
 
147
+ foreach ($provider_list as $provider_name => $provider_item) {
 
148
  $display = synved_option_get('synved_social', $provider_name . '_display');
149
+ $link = synved_option_get('synved_social', $provider_name . '_' . $context . '_link');
150
+ $title = synved_option_get('synved_social', $provider_name . '_' . $context . '_title');
151
 
152
+ if ($display === null || in_array($display, [$context, 'both'])) {
153
+ if ($link != null) {
 
 
154
  $provider_item['link'] = $link;
155
  }
156
 
157
+ if ($title != null) {
 
158
  $provider_item['title'] = $title;
159
  }
160
 
163
  }
164
 
165
  $synved_social[$list_name] = $return_list;
166
+ } else {
 
 
167
  $return_list = $synved_social[$list_name];
168
  }
169
  }
171
  return apply_filters('synved_social_service_provider_list', $return_list, $context, $raw);
172
  }
173
 
174
+ /**
175
+ * Get icon skin list array.
176
+ *
177
+ * @return array
178
+ */
179
  function synved_social_icon_skin_list()
180
  {
181
  global $synved_social;
182
 
183
+ if (!isset($synved_social['skin_list']) || $synved_social['skin_list'] == null) {
 
184
  $path = synved_social_path();
185
+ $uri = synved_social_path_uri();
186
 
187
+ $icons = [
188
+ 'regular' => [
189
+ 'label' => __('Regular'),
190
+ 'image' => $uri . '/image/social/regular/preview.png',
191
  'folder' => '/image/social/regular/',
192
+ 'path' => $path . '/image/social/regular/',
193
+ 'uri' => $uri . '/image/social/regular/',
194
+ ],
195
+ ];
 
 
196
 
197
+ if (function_exists('synved_social_addon_extra_icons_get')) {
 
198
  $icons_extra = synved_social_addon_extra_icons_get();
199
+ $icons = array_merge($icons, $icons_extra);
200
  }
201
 
202
  $icons = apply_filters('synved_social_icon_skin_list', $icons);
203
 
204
+ foreach ($icons as $skin_name => $skin) {
 
205
  $icons[$skin_name]['name'] = $skin_name;
206
  }
207
 
211
  return $synved_social['skin_list'];
212
  }
213
 
214
+ /**
215
+ * Get icon skin.
216
+ *
217
+ * @param $name
218
+ *
219
+ * @return mixed|null
220
+ */
221
  function synved_social_icon_skin_get($name = null)
222
  {
223
  $icons = synved_social_icon_skin_list();
224
 
225
+ if ($name != null && !isset($icons[$name])) {
226
+ foreach ($icons as $skin_name => $skin) {
227
+ if (strtolower($name) == strtolower($skin['label'])) {
 
 
 
228
  $name = $skin_name;
229
 
230
  break;
232
  }
233
  }
234
 
235
+ if ($name == null || !isset($icons[$name])) {
 
236
  $selected = synved_option_get('synved_social', 'icon_skin');
237
 
238
  $name = $selected;
239
  }
240
 
241
+ if (isset($icons[$name])) {
 
242
  return $icons[$name];
243
  }
244
 
245
+ if (isset($icons['regular'])) {
 
246
  return $icons['regular'];
247
  }
248
 
249
  return null;
250
  }
251
 
252
+ /**
253
+ * Get icon skin size list array.
254
+ *
255
+ * @param $skin
256
+ *
257
+ * @return array
258
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  function synved_social_icon_skin_get_size_list($skin)
260
  {
261
+ if (isset($skin['size-list'])) {
 
262
  return $skin['size-list'];
263
  }
264
 
265
+ if (isset($skin['name'])) {
 
266
  $skin_fresh = synved_social_icon_skin_get($skin['name']);
267
 
268
+ if (isset($skin['path']) && isset($skin_fresh['path']) && $skin['path'] == $skin_fresh['path']) {
269
+ if (isset($skin_fresh['size-list'])) {
 
 
270
  return $skin_fresh['size-list'];
271
  }
272
  }
273
  }
274
 
275
+ $path = synved_social_path();
276
  $skin_path = isset($skin['path']) ? $skin['path'] : ($path . '/image/social/regular/');
277
 
278
+ $sizes = glob($skin_path . '*', GLOB_ONLYDIR);
279
+ $sizes = array_map('basename', $sizes);
280
+ $size_list = [];
281
 
282
+ foreach ($sizes as $size_dir) {
 
283
  $size_parts = explode('x', $size_dir);
284
+ $size_width = (int)$size_parts[0];
285
 
286
+ if ($size_width != null) {
 
287
  $size_list[] = $size_width;
288
  }
289
  }
290
 
291
  sort($size_list, SORT_NUMERIC);
292
 
293
+ if (isset($skin['name'])) {
294
+ global $synved_social;
295
+
296
+ $name = $skin['name'];
297
+
298
+ // ensure the global is set
299
+ synved_social_icon_skin_list();
300
+
301
+ if (isset($synved_social['skin_list']) && $synved_social['skin_list'] != null) {
302
+ if (!isset($synved_social['skin_list'][$name])) {
303
+ $synved_social['skin_list'][$name] = [];
304
+ }
305
+
306
+ foreach ($skin as $key => $value) {
307
+ $synved_social['skin_list'][$name][$key] = $value;
308
+ }
309
+ }
310
  }
311
 
312
  return $size_list;
313
  }
314
 
315
+ /**
316
+ * Get Icon Skin Image List array.
317
+ *
318
+ * @param $skin
319
+ * @param $name_list
320
+ * @param $forced_size
321
+ *
322
+ * @return array
323
+ */
324
  function synved_social_icon_skin_get_image_list_raw($skin, $name_list, $forced_size = null)
325
  {
326
+ $path = synved_social_path();
327
+ $uri = synved_social_path_uri();
328
  $skin_default = synved_social_icon_skin_get('regular');
329
 
330
  $skin_default_path = isset($skin_default['path']) ? $skin_default['path'] : ($path . '/image/social/regular/');
331
+ $skin_default_uri = isset($skin_default['uri']) ? $skin_default['uri'] : ($uri . '/image/social/regular/');
332
+ $skin_sel_path = isset($skin['path']) ? $skin['path'] : ($path . '/image/social/regular/');
333
+ $skin_sel_uri = isset($skin['uri']) ? $skin['uri'] : ($uri . '/image/social/regular/');
334
 
335
  $default_size_list = synved_social_icon_skin_get_size_list($skin_default);
336
+ $sel_size_list = synved_social_icon_skin_get_size_list($skin);
337
 
338
+ $skin_list = [
339
+ [
340
  'path' => $skin_sel_path,
341
+ 'uri' => $skin_sel_uri,
342
  'list' => $sel_size_list,
343
+ ],
344
+ [
345
  'path' => $skin_default_path,
346
+ 'uri' => $skin_default_uri,
347
  'list' => $default_size_list,
348
+ ],
349
+ ];
350
+
351
+ $image_list = [];
352
+
353
+ foreach ($name_list as $name) {
354
+ foreach ($skin_list as $skin) {
355
+ $skin_path = $skin['path'];
356
+ $skin_uri = $skin['uri'];
357
+ $size_list = $skin['list'];
 
 
358
  $size_count = count($size_list);
359
 
360
+ $image_size_list = [];
361
+ $image_size_list_skipped = [];
362
 
363
+ for ($i = 0; $i < $size_count; $i++) {
 
364
  $image_size = $size_list[$i];
365
+ $image_sub = '/' . $name . '.png';
366
+ $size_name = $image_size . 'x' . $image_size;
367
  $image_path = $skin_path . $size_name . $image_sub;
368
+ $image_uri = $skin_uri . $size_name . $image_sub;
369
 
370
+ if (true === file_exists($image_path)) {
371
+ $image_size_meta = [
 
372
  'name' => $size_name,
373
+ 'sub' => $image_sub,
374
  'path' => $image_path,
375
+ 'uri' => $image_uri,
376
+ ];
377
 
378
+ foreach ($image_size_list_skipped as $image_size_skipped) {
 
379
  $image_size_list[$image_size_skipped] = $image_size_meta;
380
  }
381
 
382
+ $image_size_skipped = [];
383
  $image_size_list[$image_size] = $image_size_meta;
384
 
385
+ if ($forced_size != null && ($image_size > $forced_size || $i == $size_count - 1) && !isset($image_size_list[$forced_size])) {
 
386
  $image_size_list[$forced_size] = $image_size_meta;
387
  }
388
+ } else {
 
 
389
  $image_size_skipped[] = $image_size;
390
  }
391
  }
392
 
393
+ if ($image_size_list != null) {
 
394
  break;
395
  }
396
  }
401
  return $image_list;
402
  }
403
 
404
+ /**
405
+ * Get filtered Icon skin image list array.
406
+ *
407
+ * @param $skin
408
+ * @param $name_list
409
+ * @param $forced_size
410
+ *
411
+ * @return array
412
+ */
413
  function synved_social_icon_skin_get_image_list($skin, $name_list, $forced_size = null)
414
  {
415
  $image_list = synved_social_icon_skin_get_image_list_raw($skin, $name_list, $forced_size);
418
  return $image_list;
419
  }
420
 
421
+ /**
422
+ * Get Button list shortcode HTML.
423
+ *
424
+ * @param $atts
425
+ * @param $content
426
+ * @param $code
427
+ * @param $context
428
+ *
429
+ * @return string
430
+ */
431
  function synved_social_button_list_shortcode($atts, $content = null, $code = '', $context = null)
432
  {
433
+ $vars_def = ['url' => null, 'image' => null, 'title' => null, 'message' => null];
434
+ $params_def = [
435
+ 'skin' => null,
436
+ 'size' => null,
437
+ 'spacing' => null,
438
+ 'container' => null,
439
+ 'container_type' => null,
440
+ 'class' => null,
441
+ 'show' => null,
442
+ 'hide' => null,
443
+ 'prompt' => null,
444
+ 'custom1' => null,
445
+ 'custom2' => null,
446
+ 'custom3' => null,
447
+ ];
448
+ $vars = shortcode_atts($vars_def, $atts, 'feather_' . $context);
449
+ $params = shortcode_atts($params_def, $atts, 'feather_' . $context);
450
+ $vars = array_filter($vars);
451
+ $params = array_filter($params);
452
+
453
+ $vars = apply_filters('synved_social_shortcode_variable_list', $vars, $context, $atts);
454
  $params = apply_filters('synved_social_shortcode_parameter_list', $params, $context, $atts);
455
 
456
+ if ('share' === $context) {
 
457
  return synved_social_share_markup($vars, null, $params);
458
+ } elseif ('follow' === $context) {
 
 
459
  return synved_social_follow_markup($vars, null, $params);
460
  }
461
 
462
+ return '';
463
  }
464
 
465
+ /**
466
+ * Get Share shortcode HTML output.
467
+ *
468
+ * @param $atts
469
+ * @param $content
470
+ * @param $code
471
+ *
472
+ * @return string
473
+ */
474
  function synved_social_share_shortcode($atts, $content = null, $code = '')
475
  {
476
  return synved_social_button_list_shortcode($atts, $content, $code, 'share');
477
  }
478
 
479
+ /**
480
+ * Get Follow shortcode HTML output.
481
+ *
482
+ * @param $atts
483
+ * @param $content
484
+ * @param $code
485
+ *
486
+ * @return string
487
+ */
488
  function synved_social_follow_shortcode($atts, $content = null, $code = '')
489
  {
490
  return synved_social_button_list_shortcode($atts, $content, $code, 'follow');
491
  }
492
 
493
+ /**
494
+ * Button list markup item.
495
+ *
496
+ * Escaped via wp_kses_post.
497
+ *
498
+ * @param $out_item
499
+ *
500
+ * @return string
501
+ */
502
  function synved_social_button_list_markup_item_out($out_item)
503
  {
504
+ $out = null;
505
+ $tag = isset($out_item['tag']) ? $out_item['tag'] : null;
506
  $content = isset($out_item['content']) ? $out_item['content'] : null;
507
+ $list = isset($out_item['child-list']) ? $out_item['child-list'] : null;
508
 
509
  unset($out_item['tag']);
510
  unset($out_item['content']);
511
  unset($out_item['child-list']);
512
 
513
+ if ($tag != null) {
 
514
  $out .= '<' . $tag;
515
 
516
+ foreach ($out_item as $attr_name => $attr_value) {
517
+ if ($attr_name != null && $attr_value !== null) {
518
+ if (in_array($attr_name, ['href', 'src'])) {
519
+ $attr_value = str_ireplace(['[', ']'], ['&#91;', '&#93;'], $attr_value);
 
 
 
520
  $attr_value = esc_url($attr_value);
521
+ } else {
 
 
522
  $attr_value = esc_attr($attr_value);
523
  }
524
 
526
  }
527
  }
528
 
529
+ if ($list != null || $content != null) {
 
530
  $out .= '>';
531
+ } else {
 
 
532
  $out .= ' />';
533
  }
534
  }
535
 
536
+ if ($list != null) {
537
+ foreach ($list as $child) {
 
 
538
  $out .= synved_social_button_list_markup_item_out($child);
539
  }
540
  }
541
 
542
+ if ($content != null) {
 
543
  $out .= $content;
544
  }
545
 
546
+ if ($tag != null && ($list != null || $content != null)) {
 
547
  $out .= '</' . $tag . '>';
548
  }
549
 
550
+ return wp_kses_post($out);
551
  }
552
 
553
+ /**
554
+ * Button list markup.
555
+ *
556
+ * Escaped via wp_kses_post.
557
+ *
558
+ * @param $context
559
+ * @param $vars
560
+ * @param $buttons
561
+ * @param $params
562
+ *
563
+ * @return string
564
+ */
565
  function synved_social_button_list_markup($context, $vars = null, $buttons = null, $params = null)
566
  {
567
  $buttons_default = synved_social_service_provider_list($context);
568
 
569
+ if ($buttons == null) {
 
570
  $buttons = $buttons_default;
571
+ } else {
 
 
572
  $keys = array_keys($buttons);
573
 
574
+ foreach ($keys as $key) {
575
+ if ($buttons[$key] == null && isset($buttons_default[$key])) {
 
 
576
  $buttons[$key] = $buttons_default[$key];
577
  }
578
  }
580
 
581
  $id = get_the_ID();
582
 
583
+ if ($id == null) {
 
584
  global $post;
585
 
586
+ if ($post != null) {
 
587
  $id = $post->ID;
588
  }
589
  }
590
 
591
+ if (!isset($vars['url']) || !isset($vars['short_url'])) {
 
 
592
  $home_url = home_url();
593
+ $req_uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING);
594
 
595
+ $path = parse_url($home_url, PHP_URL_PATH);
596
  $path_len = strlen($path);
597
 
598
+ if (strtolower(substr($req_uri, 0, $path_len)) == strtolower($path)) {
 
599
  $req_uri = substr($req_uri, $path_len);
600
  }
601
 
602
+ $url = home_url($req_uri);
603
  $short_url = $url;
604
 
605
+ if ($id != null && in_the_loop()) {
606
+ $use_shortlinks = synved_option_get('synved_social', 'use_shortlinks');
607
+ $url = get_permalink($id);
608
+ $short_url = wp_get_shortlink($id);
609
 
610
+ if ($short_url != null) {
611
+ if ($use_shortlinks && function_exists('wp_get_shortlink')) {
612
+ $url = $short_url;
 
 
 
 
 
 
613
  }
614
+ } else {
615
+ $short_url = $url;
616
  }
617
+ } elseif (is_front_page()) {
618
+ $url = $home_url;
619
  }
620
 
621
+ if (!isset($vars['url'])) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
622
  $vars['url'] = $url;
623
  }
624
 
625
+ if (!isset($vars['short_url'])) {
 
626
  $vars['short_url'] = $short_url;
627
  }
628
  }
629
 
630
+ if (!isset($vars['image'])) {
 
631
  $image_src = null;
632
 
633
+ if ($id != null) {
 
634
  $image_id = get_post_thumbnail_id($id);
635
 
636
+ if ($image_id != null) {
637
+ $src = wp_get_attachment_image_src($image_id, 'full');
 
638
  $image_src = $src[0];
639
+ } else {
640
+ $post = get_post($id);
 
 
641
  $match = null;
642
 
643
+ if (preg_match('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $match) > 0) {
 
644
  $image_src = $match[1];
645
  }
646
  }
649
  $vars['image'] = $image_src;
650
  }
651
 
652
+ if (!isset($vars['title'])) {
 
653
  $title = get_the_title();
654
  // do this encoding to prevent non-tags things, like emoticons, from being stripped, i.e. <8
655
+ $title = preg_replace('/\\<\\s*([^[:alpha:]\\/])/', '&lt;$1', $title);
656
  $vars['title'] = html_entity_decode(wp_strip_all_tags($title));
657
  }
658
 
659
+ if (!isset($vars['message'])) {
 
660
  $message = synved_option_get('synved_social', 'share_message_default');
661
 
662
+ if ($message == null) {
 
663
  $message = __('Hey check this out', 'social-media-feather');
664
  }
665
 
666
  $vars['message'] = $message;
667
  }
668
 
669
+ if (!isset($vars['author_wp'])) {
670
+ if ($id != null && in_the_loop()) {
 
 
671
  $author = get_the_author();
672
 
673
+ if ($author != null) {
 
674
  $vars['author_wp'] = $author;
675
  }
676
  }
677
  }
678
 
679
+ if (!isset($vars['author'])) {
680
+ if ($id != null && in_the_loop()) {
 
 
681
  $author = get_the_author_meta('_synved_twitter_handle');
682
 
683
+ if ($author == null) {
 
684
  $author = get_the_author_meta('twitter');
685
  }
686
 
687
+ if ($author == null) {
 
688
  $author = get_the_author();
689
  }
690
 
691
+ if ($author != null) {
 
692
  $vars['author'] = $author;
693
  }
694
  }
695
  }
696
 
697
+ if (!isset($vars['date'])) {
698
+ if ($id != null && in_the_loop()) {
 
 
699
  $date = get_the_date('', $id);
700
 
701
+ if ($date != null) {
 
702
  $vars['date'] = $date;
703
  }
704
  }
705
  }
706
 
707
+ if (isset($vars['url']) && !isset($vars['url_trimmed'])) {
 
708
  $url_trimmed = trim($vars['url']);
709
 
710
+ while (substr($url_trimmed, -1) == '/') {
 
711
  $url_trimmed = substr($url_trimmed, 0, -1);
712
  }
713
 
714
+ while (strtolower(substr($url_trimmed, -3)) == '%2f') {
 
715
  $url_trimmed = substr($url_trimmed, 0, -3);
716
  }
717
 
718
  $vars['url_trimmed'] = $url_trimmed;
719
  }
720
 
721
+ if (isset($params['class']) && !is_array($params['class'])) {
722
+ $class = explode(' ', $params['class']);
 
723
  $params['class'] = array_map('trim', $class);
724
  }
725
 
726
+ if (isset($params['show']) && !is_array($params['show'])) {
727
+ $show = explode(',', $params['show']);
 
728
  $params['show'] = array_map('trim', $show);
729
  }
730
 
731
+ if (isset($params['hide']) && !is_array($params['hide'])) {
732
+ $hide = explode(',', $params['hide']);
 
733
  $params['hide'] = array_map('trim', $hide);
734
  }
735
 
736
+ $vars = apply_filters('synved_social_markup_variable_list', $vars, $context, $params);
737
  $params = apply_filters('synved_social_markup_parameter_list', $params, $context, $vars);
738
 
739
+ if ($vars != null) {
 
740
  $vars = array_map('wp_kses_decode_entities', $vars);
741
  $vars = urlencode_deep($vars);
742
 
743
  // urlencode_deep converts space characters to + rather than %20 which messes things up
744
  $vars['message'] = str_ireplace('+', '%20', $vars['message']);
745
+ $vars['title'] = str_ireplace('+', '%20', $vars['title']);
746
 
747
  // urlencode_deep tries to be smart and apostrophes (') to %19 not %27 and double quotes (") to their equivalent open/closed counterparts which doesn't work on most social networks sharings
748
  $vars['message'] = str_ireplace('%18', '%27', $vars['message']);
749
+ $vars['title'] = str_ireplace('%18', '%27', $vars['title']);
750
  $vars['message'] = str_ireplace('%19', '%27', $vars['message']);
751
+ $vars['title'] = str_ireplace('%19', '%27', $vars['title']);
752
  $vars['message'] = str_ireplace('%1c', '%22', $vars['message']);
753
+ $vars['title'] = str_ireplace('%1c', '%22', $vars['title']);
754
  $vars['message'] = str_ireplace('%1d', '%22', $vars['message']);
755
+ $vars['title'] = str_ireplace('%1d', '%22', $vars['title']);
756
  }
757
 
758
  $path = synved_social_path();
759
+ $uri = synved_social_path_uri();
760
+ $skin = synved_social_icon_skin_get();
761
 
762
+ if (isset($params['skin'])) {
 
763
  $skin = synved_social_icon_skin_get($params['skin']);
764
  }
765
 
766
  $skin_path = isset($skin['path']) ? $skin['path'] : ($path . '/image/social/regular/');
767
+ $skin_uri = isset($skin['uri']) ? $skin['uri'] : ($uri . '/image/social/regular/');
768
 
769
  $icon_size = synved_option_get('synved_social', 'icon_size');
770
+ $size = 48;
771
 
772
+ if ($icon_size != null) {
 
773
  $size = $icon_size;
774
  }
775
 
776
+ if (isset($params['size'])) {
 
777
  $size = $params['size'];
778
 
779
+ if (is_string($size)) {
780
+ $size = strtolower($size);
 
781
  $size_parts = explode('x', $size);
782
+ $size = (int)$size_parts[0];
783
  }
784
  }
785
 
786
+ $icon_spacing = synved_option_get('synved_social', 'icon_spacing');
787
+ $buttons_container = synved_option_get('synved_social', 'buttons_container');
788
  $buttons_container_type = synved_option_get('synved_social', 'buttons_container_type');
789
+ $buttons_alignment = synved_option_get('synved_social', 'buttons_alignment_' . $context);
790
+ $layout_rtl = synved_option_get('synved_social', 'layout_rtl');
791
+ $spacing = 5;
792
+ $container = 'none';
793
+ $container_type = 'basic';
794
+ $alignment = 'none';
795
+
796
+ if ($icon_spacing != null) {
 
797
  $spacing = $icon_spacing;
798
  }
799
 
800
+ if (isset($params['spacing'])) {
 
801
  $spacing = $params['spacing'];
802
  }
803
 
804
+ if ($buttons_container != null) {
 
805
  $container = $buttons_container;
806
  }
807
 
808
+ if ($buttons_container_type != null) {
 
809
  $container_type = $buttons_container_type;
810
  }
811
 
812
+ if ($buttons_alignment != null) {
 
813
  $alignment = $buttons_alignment;
814
  }
815
 
816
+ if (isset($params['alignment'])) {
 
817
  $alignment = $params['alignment'];
818
  }
819
 
820
+ if ($alignment != 'none') {
821
+ if ($container == 'none') {
 
 
822
  $container = $context;
823
+ } elseif ($container != 'both' && $container != $context) {
 
 
824
  $container = 'both';
825
  }
826
  }
827
 
828
  // Allow parameters to override container after we decide a default based on selected alignment
829
+ if (isset($params['container'])) {
 
830
  $container = $params['container'];
831
  }
832
 
833
+ if ($alignment != 'none') {
 
834
  $container_type = 'block';
835
  }
836
 
837
  // Allow parameters to override container after we decide a default based on selected alignment
838
+ if (isset($params['container_type'])) {
 
839
  $container_type = $params['container_type'];
840
  }
841
 
842
  $class = isset($params['class']) ? $params['class'] : null;
843
+ $show = isset($params['show']) ? $params['show'] : null;
844
+ $hide = isset($params['hide']) ? $params['hide'] : null;
845
 
846
+ if ($show != null) {
847
+ $button_list = [];
 
848
 
849
+ foreach ($show as $button_key) {
850
+ if (isset($buttons[$button_key])) {
 
 
851
  $button_list[$button_key] = $buttons[$button_key];
852
 
853
  unset($buttons[$button_key]);
854
  }
855
  }
856
 
857
+ foreach ($buttons as $button_key => $button_item) {
 
858
  $button_list[$button_key] = $button_item;
859
  }
860
 
861
  $buttons = $button_list;
862
  }
863
 
864
+ if ($hide != null) {
865
+ foreach ($hide as $button_key) {
866
+ if (isset($buttons[$button_key])) {
 
 
 
867
  unset($buttons[$button_key]);
868
  }
869
  }
870
  }
871
 
872
+ $out_list = [];
873
+ $out_params = [];
874
+ $image_list = [];
875
  $icon_resolution = synved_option_get('synved_social', 'icon_resolution');
876
+ $resolutions = ['normal' => $size, 'hidef' => $size * 2];
877
 
878
+ if (true === is_feed()) {
 
879
  $icon_resolution = 'single';
880
  }
881
 
882
+ if ($icon_resolution == 'single') {
883
+ $resolutions = ['single' => $size * 2];
 
884
  }
885
 
886
+ $button_keys = array_keys($buttons);
887
+
888
+ foreach ($resolutions as $resolution_name => $resolution_size) {
889
+ $image_list[$resolution_name] = synved_social_icon_skin_get_image_list(
890
+ $skin,
891
+ $button_keys,
892
+ $resolution_size
893
+ );
894
  }
895
 
896
  $index = 0;
897
  $count = count($buttons);
898
 
899
+ foreach ($buttons as $button_key => $button_item) {
900
+ $href = $button_item['link'];
 
901
  $title = $button_item['title'];
902
 
903
  $matches = null;
904
 
905
+ if (preg_match_all('/%%(\\w+)%%/', $href, $matches, PREG_SET_ORDER) > 0) {
906
+ foreach ($matches as $match) {
 
 
907
  $var_key = $match[1];
908
  $replace = null;
909
 
910
+ if (isset($vars[$var_key])) {
 
911
  $replace = $vars[$var_key];
912
  }
913
 
917
 
918
  $icon_sizes = $resolutions;
919
 
920
+ foreach ($icon_sizes as $icon_def => $icon_size) {
921
+ $image = $image_list[$icon_def][$button_key];
 
922
  $image_size = $image[$icon_size];
923
+ $image_sub = $image_size['sub'];
924
  $image_path = $image_size['path'];
925
+ $image_uri = $image_size['uri'];
926
+
927
+ if (!file_exists($image_path)) {
928
+ $size_list = array_keys($image);
929
+ $image_path = apply_filters('synved_social_button_image_path', $image_path, $image_uri, $icon_size,
930
+ $image_sub, $skin_path, $skin_uri, $size_list);
931
+ $image_uri = apply_filters('synved_social_button_image_uri', $image_uri, $image_path, $icon_size,
932
+ $image_sub, $skin_path, $skin_uri, $size_list);
933
  }
934
 
935
  $style = 'margin:0;';
936
 
937
+ if (true) {
 
938
  $style .= 'margin-bottom:' . $spacing . 'px;';
939
  }
940
 
941
+ if ($index < $count - 1 || $layout_rtl) {
 
942
  $style .= 'margin-right:' . $spacing . 'px;';
943
  }
944
 
945
  $class_extra = null;
946
 
947
+ if ($class != null) {
 
948
  $class_extra = ' ' . implode(' ', $class);
949
  }
950
 
951
  // don't use "nofancybox" because some plugins/themes interpret it as enabling fancybox
952
  $class_extra .= ' nolightbox';
953
 
954
+ $out_button = [
955
+ 'tag' => 'a',
956
+ 'class' => 'synved-social-button synved-social-button-' . $context . ' synved-social-size-' . $size . ' synved-social-resolution-' . $icon_def . ' synved-social-provider-' . $button_key . $class_extra,
957
  'data-provider' => $button_key,
958
+ 'target' => $button_key != 'mail' ? '_blank' : null,
959
+ 'rel' => 'nofollow',
960
+ 'title' => $title,
961
+ 'href' => $href,
962
+ 'style' => 'font-size: 0px; width:' . $size . 'px;' . 'height:' . $size . 'px;' . $style,
963
+ 'child-list' => [
964
+ [
965
+ 'tag' => 'img',
966
+ 'alt' => $button_key == 'facebook' ? 'Facebook' : $button_key,
967
+ 'title' => $title,
968
+ 'class' => 'synved-share-image synved-social-image synved-social-image-' . $context,
969
+ 'width' => $size,
970
  'height' => $size,
971
+ 'style' => 'display: inline; width:' . $size . 'px;' . 'height:' . $size . 'px; margin: 0; padding: 0; border: none; box-shadow: none;',
972
+ 'src' => $image_uri,
973
+ ],
974
+ ],
975
+ ];
976
+
977
+ $out_list[$icon_def][$button_key] = $out_button;
978
+ $out_params[$icon_def][$button_key] = ['icon-resolution' => $icon_def];
979
  }
980
 
981
  $index++;
983
 
984
  $out = null;
985
 
986
+ if ($out_list != null) {
987
+ foreach ($out_list as $def_key => $def_list) {
988
+ $out_list[$def_key] = apply_filters('synved_social_button_list_markup', $def_list, $out_params[$def_key],
989
+ $context, $vars, $params);
 
990
  }
991
  }
992
 
993
+ if ($out_list != null) {
 
994
  $container_tag = 'span';
995
 
996
+ if ($container_type == 'block') {
 
997
  $container_tag = 'div';
998
  }
999
 
1000
+ if ($container != 'none' && ($container == 'both' || $container == $context)) {
 
1001
  $container_style = $alignment != 'none' ? ' style="text-align: ' . $alignment . '"' : null;
1002
 
1003
  $out .= '<' . $container_tag . ' class="synved-social-container synved-social-container-' . $context . '"' . $container_style . '>';
1004
  }
1005
 
1006
+ foreach ($out_list as $def_list) {
1007
+ foreach ($def_list as $out_item) {
 
 
1008
  $out .= synved_social_button_list_markup_item_out($out_item);
1009
  }
1010
  }
1011
 
1012
+ if (synved_option_get('synved_social', 'show_credit')) {
1013
+ $out .= '<a class="synved-social-credit" target="_blank" rel="nofollow" title="' . __('WordPress Social Media Feather',
1014
+ 'social-media-feather') . '" href="http://synved.com/wordpress-social-media-feather/" style="color:#444; text-decoration:none; font-size:8px; margin-left:5px;vertical-align:10px;white-space:nowrap;"><span>' . __('by ',
1015
+ 'social-media-feather') . '</span><img style="display: inline;margin:0;padding:0;width:16px;height:16px;" width="16" height="16" alt="feather" src="' . $uri . '/image/icon.png" /></a>';
1016
  }
1017
 
1018
+ if ($container != 'none' && ($container == 'both' || $container == $context)) {
 
1019
  $out .= '</' . $container_tag . '>';
1020
  }
1021
  }
1022
 
1023
+ return wp_kses_post($out);
1024
  }
1025
 
1026
+ /**
1027
+ * Share markup.
1028
+ *
1029
+ * @param $vars
1030
+ * @param $buttons
1031
+ * @param $params
1032
+ *
1033
+ * @return string
1034
+ */
1035
  function synved_social_share_markup($vars = null, $buttons = null, $params = null)
1036
  {
1037
  return synved_social_button_list_markup('share', $vars, $buttons, $params);
1038
  }
1039
 
1040
+ /**
1041
+ * Follow markup.
1042
+ *
1043
+ * @param $vars
1044
+ * @param $buttons
1045
+ * @param $params
1046
+ *
1047
+ * @return string
1048
+ */
1049
  function synved_social_follow_markup($vars = null, $buttons = null, $params = null)
1050
  {
1051
  return synved_social_button_list_markup('follow', $vars, $buttons, $params);
1052
  }